ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE_old/src/mdtools/libmdCode/forceGlobals.F90
Revision: 317
Committed: Tue Mar 11 23:13:06 2003 UTC (21 years, 6 months ago) by gezelter
File size: 7071 byte(s)
Log Message:
Bug fixes

File Contents

# Content
1 module forceGlobals
2
3 use definitions
4 use simulation
5 use atype_typedefs
6 use vector_class
7 #ifdef IS_MPI
8 use mpiSimulation
9 #endif
10
11 logical, save :: atype_vector_initialized = .false.
12 logical, save :: ff_initialized = .false.
13
14 #ifdef IS_MPI
15 real( kind = dp ), allocatable, dimension(:,:) :: q_Row
16 real( kind = dp ), allocatable, dimension(:,:) :: q_Col
17 real( kind = dp ), allocatable, dimension(:,:) :: u_l_Row
18 real( kind = dp ), allocatable, dimension(:,:) :: u_l_Col
19 real( kind = dp ), allocatable, dimension(:,:) :: A_Row
20 real( kind = dp ), allocatable, dimension(:,:) :: A_Col
21
22 real( kind = dp ), allocatable, dimension(:) :: pot_Row
23 real( kind = dp ), allocatable, dimension(:) :: pot_Col
24 real( kind = dp ), allocatable, dimension(:) :: pot_Temp
25 real( kind = dp ), allocatable, dimension(:,:) :: f_Row
26 real( kind = dp ), allocatable, dimension(:,:) :: f_Col
27 real( kind = dp ), allocatable, dimension(:,:) :: f_Temp
28 real( kind = dp ), allocatable, dimension(:,:) :: t_Row
29 real( kind = dp ), allocatable, dimension(:,:) :: t_Col
30 real( kind = dp ), allocatable, dimension(:,:) :: t_Temp
31 integer, allocatable, dimension(:) :: atid_Row
32 integer, allocatable, dimension(:) :: atid_Col
33 #else
34 integer, allocatable, dimension(:) :: atid
35 #endif
36
37 real(kind = dp) :: pot = 0.0_dp
38 real(kind = dp), dimension(9) :: tau_Temp = 0.0_dp
39 real(kind = dp) :: virial_Temp = 0.0_dp
40
41 public :: new_atype
42 public :: init_FF
43
44 contains
45
46 subroutine new_atype(c_ident, is_LJ, is_Sticky, is_DP, is_GB, &
47 lj_epsilon, lj_sigma, &
48 dipole_moment, &
49 sticky_w0, sticky_v0, &
50 GB_sigma, GB_l2b_ratio, GB_eps, GB_eps_ratio, GB_mu, GB_nu, &
51 status)
52
53 real( kind = dp ), intent(in) :: lj_epsilon
54 real( kind = dp ), intent(in) :: lj_sigma
55 real( kind = dp ), intent(in) :: sticky_w0
56 real( kind = dp ), intent(in) :: sticky_v0
57 real( kind = dp ), intent(in) :: dipole_moment
58 real( kind = dp ), intent(in) :: GB_sigma, GB_l2b_ratio, GB_eps
59 real( kind = dp ), intent(in) :: GB_eps_ratio, GB_mu, GB_nu
60
61 integer, intent(in) :: c_ident
62 integer, intent(out) :: status
63 integer, intent(in) :: is_Sticky
64 integer, intent(in) :: is_DP
65 integer, intent(in) :: is_GB
66 integer, intent(in) :: is_LJ
67 integer :: me
68 logical :: l_is_LJ, l_is_DP, l_is_Sticky, l_is_GB
69
70 status = 0
71
72 if (.not.atype_vector_initialized) then
73 !! There are 16 properties to worry about for now.
74 !! Fix this if needed for more atomic properties
75 atypes = initialize(16)
76 if (.not.associated(atypes)) then
77 status = -1
78 return
79 endif
80 endif
81
82 me = addElement(atypes)
83
84 call setElementProperty(atypes, me, "c_ident", c_ident)
85
86 l_is_LJ = (is_LJ .ne. 0)
87 l_is_DP = (is_DP .ne. 0)
88 l_is_Sticky = (is_Sticky .ne. 0)
89 l_is_GB = (is_GB .ne. 0)
90
91 call setElementProperty(atypes, me, "is_LJ", l_is_LJ)
92 call setElementProperty(atypes, me, "is_DP", l_is_DP)
93 call setElementProperty(atypes, me, "is_Sticky", l_is_Sticky)
94 call setElementProperty(atypes, me, "is_GB", l_is_GB)
95
96 if (l_is_LJ) then
97 call setElementProperty(atypes, me, "lj_sigma", lj_sigma)
98 call setElementProperty(atypes, me, "lj_epsilon", lj_epsilon)
99 endif
100 if (l_is_DP) then
101 call setElementProperty(atypes, me, "dipole_moment", dipole_moment)
102 endif
103 if (l_is_Sticky) then
104 call setElementProperty(atypes, me, "sticky_w0", sticky_w0)
105 call setElementProperty(atypes, me, "sticky_v0", sticky_v0)
106 endif
107 if (l_is_GB) then
108 call setElementProperty(atypes, me, "GB_sigma", GB_sigma)
109 call setElementProperty(atypes, me, "GB_l2b_ratio", GB_l2b_ratio)
110 call setElementProperty(atypes, me, "GB_eps", GB_eps)
111 call setElementProperty(atypes, me, "GB_eps_ratio", GB_eps_ratio)
112 call setElementProperty(atypes, me, "GB_mu", GB_mu)
113 call setElementProperty(atypes, me, "GB_nu", GB_nu)
114 endif
115
116 end subroutine new_atype
117
118
119 subroutine init_FF(nComponents, c_idents, nExcludes, excludesLocal, status)
120 !! Number of components in c_idents array
121 integer, intent(inout) :: nComponents
122 !! Array of identities nComponents long corresponding to
123 !! ljatype ident.
124 integer, dimension(nComponents),intent(inout) :: c_idents
125 integer :: nExcludes
126 integer, dimension(nExcludes),intent(inout) :: excludesLocal
127 !! Result status, success = 0, error = -1
128 integer, intent(out) :: status
129 integer :: i, me, thisStat
130 integer :: myNode
131
132 #ifdef IS_MPI
133 integer, allocatable, dimension(:) :: c_idents_Row
134 integer, allocatable, dimension(:) :: c_idents_Col
135 integer :: nrow
136 integer :: ncol
137 #endif
138
139 status = 0
140
141
142 #ifdef IS_MPI
143 ! We can only set up forces if mpiSimulation has been setup.
144 if (.not. isMPISimSet()) then
145 write(default_error,*) "MPI is not set"
146 status = -1
147 return
148 endif
149 nrow = getNrow(plan_row)
150 ncol = getNcol(plan_col)
151 mynode = getMyNode()
152
153 allocate(c_idents_Row(nrow),stat=alloc_stat)
154 if (alloc_stat /= 0 ) then
155 status = -1
156 return
157 endif
158
159 allocate(c_idents_Col(ncol),stat=alloc_stat)
160 if (alloc_stat /= 0 ) then
161 status = -1
162 return
163 endif
164
165 call gather(c_idents, c_idents_Row, plan_row)
166 call gather(c_idents, c_idents_Col, plan_col)
167
168 allocate(atid_Row(nrow),stat=alloc_stat)
169 if (alloc_stat /= 0 ) then
170 status = -1
171 return
172 endif
173
174 allocate(atid_Col(ncol),stat=alloc_stat)
175 if (alloc_stat /= 0 ) then
176 status = -1
177 return
178 endif
179
180 do i = 1, nrow
181 me = getFirstMatchingElement(atypes, "c_ident", c_idents_Row(i))
182 atid_Row(i) = me
183 enddo
184
185 do i = 1, ncol
186 me = getFirstMatchingElement(atypes, "c_ident", c_idents_Col(i))
187 atid_Col(i) = me
188 enddo
189
190 !! free temporary ident arrays
191 if (allocated(identCol)) then
192 deallocate(identCol)
193 end if
194 if (allocated(identCol)) then
195 deallocate(identRow)
196 endif
197
198 #else
199 do i = 1, nComponents
200
201 me = getFirstMatchingElement(atypes, "c_ident", c_idents(i))
202 atid(i) = me
203
204 enddo
205 #endif
206
207 call initForce_Modules(thisStat)
208 if (thisStat /= 0) then
209 status = -1
210 return
211 endif
212
213 !! Create neighbor lists
214 call expandList(thisStat)
215 if (thisStat /= 0) then
216 status = -1
217 return
218 endif
219
220 call setupGlobals(thisStat)
221 if (thisStat /= 0) then
222 status = -1
223 return
224 endif
225
226 ff_initialized = .true.
227
228
229 end subroutine init_FF
230
231 subroutine setupGlobals(thisStat)
232 integer, intent(out) :: thisStat
233
234 end subroutine setupGlobals
235
236
237 subroutine initForce_Modules(thisStat)
238 integer, intent(out) :: thisStat
239 integer :: my_status
240
241 thisStat = 0
242 call init_lj_FF(my_status)
243 if (my_status /= 0) then
244 thisStat = -1
245 return
246 end if
247
248 end subroutine initForce_Modules
249
250 end module forceGlobals