-
Notifications
You must be signed in to change notification settings - Fork 0
/
lattice_orbit-fragments_generator.f90
129 lines (98 loc) · 3.57 KB
/
lattice_orbit-fragments_generator.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
!---------------------------------------------------------------------
!lattice orbit-fragments generator - used by lammps and ovito for generate .data file and .xyz file
!---------------------------------------------------------------------
!compilation: gfortran -o lattice_orbit-fragments_generator lattice_orbit-fragments_generator.f90
!usage: ./lattice_orbit-fragments_generator
!---------------------------------------------------------------------
! 1.1 version
! Bruno Morini
! jun 2021
!---------------------------------------------------------------------
Implicit none
real*8 m, d, a, q, pi, gr, ga, lat, lon, x, y, z, de, df
integer cnt, j, i, k, n, l
print*, 'Particle masses ? q=m'
read*, m
print*, 'Particle Diameter?'
read*, d
print*, 'Distance of Fragments ? < d*1E5'
read*, a
print*, 'Layers of Fragments ?'
read*, l
print*, 'Density of Fragments ? (area/density)'
read*, df
!q=m*(sqrt((6.67408E-11)/(8.98755E9))) !Converting mass to charge
q=m
open(1, file='fragments.data')
open(2, file='fragments.xyz')
cnt=0 !counter
pi=4*(atan(1.0_8)) !4 * atan (1.0_8)=pi
de=m/((4.0/3.0)*pi*((d/2.0)**3.0)) !particle density
call id(a, j, i, cnt, l, n, pi, d, df) !counter subroutne
Write(1,*) '#LAMMPS data file via lattice_orbit-fragments_generator.f90, version 1.1 Jun 2021, by Bruno Morini'
Write(1,*) cnt, 'atoms'
Write(1,*) '1 atom types'
Write(1,*) ''
Write(1,*) d*(-1E5),'', d*(1E5),'', 'xlo xhi'
Write(1,*) d*(-1E5),'', d*(1E5),'', 'ylo yhi'
Write(1,*) d*(-1E5),'', d*(1E5),'', 'zlo zhi'
Write(1,*) ''
Write(1,*) 'Masses'
Write(1,*) ''
Write(1,*) '1', q
Write(1,*) ''
Write(1,*) 'Atoms # hybrid'
Write(1,*) ''
Write(2,*) cnt
Write(2,*) 'generated by VMD'
write(2,*) 'c 0.0 0.0 0.0' !origin particle
call xyz(gr, ga, cnt, n, pi, a, j, l, i, lat, lon, x, y, z, q, d, de, df, m) !subroutine objetct generator
call velocity(cnt, k) !subroutine velocity particles
end
subroutine xyz(gr, ga, cnt, n, pi, a, j, l, i, lat, lon, x, y, z, q, d, de, df, m)
Implicit none
real*8 gr, ga, pi, a, b, c, lat, lon, x, y, z, q, d, de, df, m
integer cnt, j, i, n, l
gr=(sqrt(5.0)+1.0)/2.0 !golden ratio
ga=(2.0-gr)*(2.0*3.1415) !golden angle
cnt=0 !counter
do j=1,l
n=((4.0*pi*((a+(d*j))**2.0))/(pi*(d**2.0)))/df !number of particle in the layer
do i=1,n
lat=asin(-1+2.0*i/(n+1)) !latitude
lon=ga*i !longitude
x = (a+(d*(j-1)))*cos(lon)*cos(lat) !x coordenates particle
y = (a+(d*(j-1)))*sin(lon)*cos(lat) !y coordenates particle
z = (a+(d*(j-1)))*sin(lat) !z coordenates particle
cnt=cnt+1
write(1,*) cnt, '1', x, y, z, d, de, q, '0 0 0' ! write lammps data
write(2,*) 'c', x, y, z !write vmd xyz
enddo
enddo
Print*, 'Number of fragments:', cnt
Print*, 'Total Object Mass:', cnt*m
return
end
subroutine id(a,j, i, cnt, l, n, pi, d, df)
Implicit none
real*8 a, pi, d, df
integer j, i, cnt, n, l
do j=1,l
n=((4.0*pi*((a+(d*j))**2.0))/(pi*(d**2.0)))/df
do i=1,n
cnt=cnt+1
enddo
enddo
return
end
subroutine velocity(cnt, k)
Implicit none
integer cnt, k
Write(1,*) ''
Write(1,*) 'Velocities'
Write(1,*) ''
do k=1,cnt
write(1,*) k, '0.000000000 0.000000000 0.000000000 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00'
enddo
return
end