1 |
+ |
!! do_Forces.F90 |
2 |
+ |
!! module do_Forces |
3 |
|
!! Calculates Long Range forces. |
4 |
+ |
|
5 |
|
!! @author Charles F. Vardeman II |
6 |
|
!! @author Matthew Meineke |
7 |
< |
!! @version $Id: do_Forces.F90,v 1.2 2003-03-06 16:07:55 mmeineke Exp $, $Date: 2003-03-06 16:07:55 $, $Name: not supported by cvs2svn $, $Revision: 1.2 $ |
7 |
> |
!! @version $Id: do_Forces.F90,v 1.16 2003-03-12 23:15:46 gezelter Exp $, $Date: 2003-03-12 23:15:46 $, $Name: not supported by cvs2svn $, $Revision: 1.16 $ |
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
module do_Forces |
12 |
|
use simulation |
13 |
|
use definitions |
14 |
< |
use generic_atypes |
15 |
< |
use neighborLists |
16 |
< |
|
17 |
< |
use lj_FF |
18 |
< |
use sticky_FF |
16 |
< |
use dp_FF |
17 |
< |
use gb_FF |
14 |
> |
use atype_module |
15 |
> |
use neighborLists |
16 |
> |
use lj |
17 |
> |
use sticky_pair |
18 |
> |
use dipole_dipole |
19 |
|
|
20 |
|
#ifdef IS_MPI |
21 |
|
use mpiSimulation |
23 |
|
implicit none |
24 |
|
PRIVATE |
25 |
|
|
26 |
< |
!! Number of lj_atypes in lj_atype_list |
27 |
< |
integer, save :: n_atypes = 0 |
26 |
> |
logical, save :: do_forces_initialized = .false. |
27 |
> |
logical, save :: FF_uses_LJ |
28 |
> |
logical, save :: FF_uses_sticky |
29 |
> |
logical, save :: FF_uses_dipoles |
30 |
> |
logical, save :: FF_uses_RF |
31 |
> |
logical, save :: FF_uses_GB |
32 |
> |
logical, save :: FF_uses_EAM |
33 |
|
|
28 |
– |
!! Global list of lj atypes in simulation |
29 |
– |
type (atype), pointer :: ListHead => null() |
30 |
– |
type (atype), pointer :: ListTail => null() |
34 |
|
|
32 |
– |
|
33 |
– |
!! LJ mixing array |
34 |
– |
! type (lj_atype), dimension(:,:), pointer :: ljMixed => null() |
35 |
– |
|
36 |
– |
|
37 |
– |
logical, save :: firstTime = .True. |
38 |
– |
|
39 |
– |
!! Atype identity pointer lists |
40 |
– |
#ifdef IS_MPI |
41 |
– |
!! Row lj_atype pointer list |
42 |
– |
type (identPtrList), dimension(:), pointer :: identPtrListRow => null() |
43 |
– |
!! Column lj_atype pointer list |
44 |
– |
type (identPtrList), dimension(:), pointer :: identPtrListColumn => null() |
45 |
– |
#else |
46 |
– |
type(identPtrList ), dimension(:), pointer :: identPtrList => null() |
47 |
– |
#endif |
48 |
– |
|
49 |
– |
|
50 |
– |
!! Logical has lj force field module been initialized? |
51 |
– |
logical, save :: isFFinit = .false. |
52 |
– |
|
53 |
– |
|
54 |
– |
!! Public methods and data |
55 |
– |
public :: new_atype |
56 |
– |
public :: do_forceLoop |
57 |
– |
public :: getLjPot |
35 |
|
public :: init_FF |
36 |
+ |
public :: do_force_loop |
37 |
|
|
60 |
– |
|
61 |
– |
|
62 |
– |
|
38 |
|
contains |
39 |
|
|
40 |
< |
!! Adds a new lj_atype to the list. |
41 |
< |
subroutine new_atype(ident,mass,epsilon,sigma, & |
42 |
< |
is_LJ,is_Sticky,is_DP,is_GB,w0,v0,dipoleMoment,status) |
43 |
< |
real( kind = dp ), intent(in) :: mass |
69 |
< |
real( kind = dp ), intent(in) :: epsilon |
70 |
< |
real( kind = dp ), intent(in) :: sigma |
71 |
< |
real( kind = dp ), intent(in) :: w0 |
72 |
< |
real( kind = dp ), intent(in) :: v0 |
73 |
< |
real( kind = dp ), intent(in) :: dipoleMoment |
40 |
> |
subroutine init_FF(thisStat) |
41 |
> |
|
42 |
> |
integer, intent(out) :: my_status |
43 |
> |
integer :: thisStat = 0 |
44 |
|
|
45 |
< |
integer, intent(in) :: ident |
76 |
< |
integer, intent(out) :: status |
77 |
< |
integer, intent(in) :: is_Sticky |
78 |
< |
integer, intent(in) :: is_DP |
79 |
< |
integer, intent(in) :: is_GB |
80 |
< |
integer, intent(in) :: is_LJ |
45 |
> |
! be a smarter subroutine. |
46 |
|
|
47 |
< |
|
48 |
< |
type (atype), pointer :: the_new_atype |
49 |
< |
integer :: alloc_error |
50 |
< |
integer :: atype_counter = 0 |
86 |
< |
integer :: alloc_size |
87 |
< |
integer :: err_stat |
88 |
< |
status = 0 |
89 |
< |
|
90 |
< |
|
91 |
< |
|
92 |
< |
! allocate a new atype |
93 |
< |
allocate(the_new_atype,stat=alloc_error) |
94 |
< |
if (alloc_error /= 0 ) then |
95 |
< |
status = -1 |
47 |
> |
|
48 |
> |
call init_lj_FF(my_status) |
49 |
> |
if (my_status /= 0) then |
50 |
> |
thisStat = -1 |
51 |
|
return |
52 |
|
end if |
98 |
– |
|
99 |
– |
! assign our new atype information |
100 |
– |
the_new_atype%mass = mass |
101 |
– |
the_new_atype%epsilon = epsilon |
102 |
– |
the_new_atype%sigma = sigma |
103 |
– |
the_new_atype%sigma2 = sigma * sigma |
104 |
– |
the_new_atype%sigma6 = the_new_atype%sigma2 * the_new_atype%sigma2 & |
105 |
– |
* the_new_atype%sigma2 |
106 |
– |
the_new_atype%w0 = w0 |
107 |
– |
the_new_atype%v0 = v0 |
108 |
– |
the_new_atype%dipoleMoment = dipoleMoment |
109 |
– |
|
53 |
|
|
54 |
< |
! assume that this atype will be successfully added |
55 |
< |
the_new_atype%atype_ident = ident |
56 |
< |
the_new_atype%atype_number = n_lj_atypes + 1 |
54 |
> |
call check_sticky_FF(my_status) |
55 |
> |
if (my_status /= 0) then |
56 |
> |
thisStat = -1 |
57 |
> |
return |
58 |
> |
end if |
59 |
|
|
60 |
< |
if ( is_Sticky /= 0 ) the_new_atype%is_Sticky = .true. |
61 |
< |
if ( is_GB /= 0 ) the_new_atype%is_GB = .true. |
62 |
< |
if ( is_LJ /= 0 ) the_new_atype%is_LJ = .true. |
118 |
< |
if ( is_DP /= 0 ) the_new_atype%is_DP = .true. |
60 |
> |
do_forces_initialized = .true. |
61 |
> |
|
62 |
> |
end subroutine init_FF |
63 |
|
|
120 |
– |
call add_atype(the_new_atype,ListHead,ListTail,err_stat) |
121 |
– |
if (err_stat /= 0 ) then |
122 |
– |
status = -1 |
123 |
– |
return |
124 |
– |
endif |
64 |
|
|
126 |
– |
n_atypes = n_atypes + 1 |
65 |
|
|
66 |
+ |
!! Does force loop over i,j pairs. Calls do_pair to calculates forces. |
67 |
+ |
!-------------------------------------------------------------> |
68 |
+ |
subroutine do_force_loop(q, A, u_l, f, t, tau, pot, do_pot_c, do_stress_c, & |
69 |
+ |
error) |
70 |
+ |
!! Position array provided by C, dimensioned by getNlocal |
71 |
+ |
real ( kind = dp ), dimension(3,getNlocal()) :: q |
72 |
+ |
!! Rotation Matrix for each long range particle in simulation. |
73 |
+ |
real( kind = dp), dimension(9,getNlocal()) :: A |
74 |
+ |
!! Unit vectors for dipoles (lab frame) |
75 |
+ |
real( kind = dp ), dimension(3,getNlocal()) :: u_l |
76 |
+ |
!! Force array provided by C, dimensioned by getNlocal |
77 |
+ |
real ( kind = dp ), dimension(3,getNlocal()) :: f |
78 |
+ |
!! Torsion array provided by C, dimensioned by getNlocal |
79 |
+ |
real( kind = dp ), dimension(3,getNlocal()) :: t |
80 |
+ |
!! Stress Tensor |
81 |
+ |
real( kind = dp), dimension(9) :: tau |
82 |
+ |
real ( kind = dp ) :: pot |
83 |
+ |
logical ( kind = 2) :: do_pot_c, do_stress_c |
84 |
+ |
logical :: do_pot |
85 |
+ |
logical :: do_stress |
86 |
+ |
#ifdef IS_MPI |
87 |
+ |
real( kind = DP ) :: pot_local |
88 |
+ |
integer :: nrow |
89 |
+ |
integer :: ncol |
90 |
+ |
#endif |
91 |
+ |
integer :: nlocal |
92 |
+ |
integer :: natoms |
93 |
+ |
logical :: update_nlist |
94 |
+ |
integer :: i, j, jbeg, jend, jnab |
95 |
+ |
integer :: nlist |
96 |
+ |
real( kind = DP ) :: rijsq, rlistsq, rcutsq, rlist, rcut |
97 |
+ |
real(kind=dp),dimension(3) :: d |
98 |
+ |
real(kind=dp) :: rfpot, mu_i, virial |
99 |
+ |
integer :: me_i |
100 |
+ |
logical :: is_dp_i |
101 |
+ |
integer :: neighborListSize |
102 |
+ |
integer :: listerror, error |
103 |
|
|
104 |
< |
end subroutine new_atype |
104 |
> |
!! initialize local variables |
105 |
|
|
106 |
+ |
#ifdef IS_MPI |
107 |
+ |
nlocal = getNlocal() |
108 |
+ |
nrow = getNrow(plan_row) |
109 |
+ |
ncol = getNcol(plan_col) |
110 |
+ |
#else |
111 |
+ |
nlocal = getNlocal() |
112 |
+ |
natoms = nlocal |
113 |
+ |
#endif |
114 |
|
|
115 |
< |
subroutine init_FF(nComponents,ident, status) |
116 |
< |
!! Number of components in ident array |
117 |
< |
integer, intent(inout) :: nComponents |
118 |
< |
!! Array of identities nComponents long corresponding to |
119 |
< |
!! ljatype ident. |
137 |
< |
integer, dimension(nComponents),intent(inout) :: ident |
138 |
< |
!! Result status, success = 0, error = -1 |
139 |
< |
integer, intent(out) :: Status |
115 |
> |
call getRcut(rcut,rcut2=rcutsq) |
116 |
> |
call getRlist(rlist,rlistsq) |
117 |
> |
|
118 |
> |
call check_initialization() |
119 |
> |
call zero_work_arrays() |
120 |
|
|
121 |
< |
integer :: alloc_stat |
121 |
> |
do_pot = do_pot_c |
122 |
> |
do_stress = do_stress_c |
123 |
|
|
124 |
< |
integer :: thisStat |
125 |
< |
integer :: i |
124 |
> |
! Gather all information needed by all force loops: |
125 |
> |
|
126 |
> |
#ifdef IS_MPI |
127 |
|
|
128 |
< |
integer :: myNode |
129 |
< |
#ifdef IS_MPI |
130 |
< |
integer, allocatable, dimension(:) :: identRow |
131 |
< |
integer, allocatable, dimension(:) :: identCol |
132 |
< |
integer :: nrow |
133 |
< |
integer :: ncol |
128 |
> |
call gather(q,q_Row,plan_row3d) |
129 |
> |
call gather(q,q_Col,plan_col3d) |
130 |
> |
|
131 |
> |
if (FF_UsesDirectionalAtoms() .and. SimUsesDirectionalAtoms()) then |
132 |
> |
call gather(u_l,u_l_Row,plan_row3d) |
133 |
> |
call gather(u_l,u_l_Col,plan_col3d) |
134 |
> |
|
135 |
> |
call gather(A,A_Row,plan_row_rotation) |
136 |
> |
call gather(A,A_Col,plan_col_rotation) |
137 |
> |
endif |
138 |
> |
|
139 |
|
#endif |
153 |
– |
status = 0 |
154 |
– |
|
155 |
– |
|
140 |
|
|
141 |
< |
|
142 |
< |
!! if were're not in MPI, we just update ljatypePtrList |
143 |
< |
#ifndef IS_MPI |
144 |
< |
call create_IdentPtrlst(ident,ListHead,identPtrList,thisStat) |
145 |
< |
if ( thisStat /= 0 ) then |
146 |
< |
status = -1 |
147 |
< |
return |
141 |
> |
if (FF_RequiresPrepairCalc() .and. SimRequiresPrepairCalc()) then |
142 |
> |
!! See if we need to update neighbor lists |
143 |
> |
call checkNeighborList(nlocal, q, rcut, rlist, update_nlist) |
144 |
> |
!! if_mpi_gather_stuff_for_prepair |
145 |
> |
!! do_prepair_loop_if_needed |
146 |
> |
!! if_mpi_scatter_stuff_from_prepair |
147 |
> |
!! if_mpi_gather_stuff_from_prepair_to_main_loop |
148 |
> |
else |
149 |
> |
!! See if we need to update neighbor lists |
150 |
> |
call checkNeighborList(nlocal, q, rcut, rlist, update_nlist) |
151 |
|
endif |
152 |
+ |
|
153 |
+ |
#ifdef IS_MPI |
154 |
+ |
|
155 |
+ |
if (update_nlist) then |
156 |
+ |
|
157 |
+ |
!! save current configuration, construct neighbor list, |
158 |
+ |
!! and calculate forces |
159 |
+ |
call save_neighborList(q) |
160 |
+ |
|
161 |
+ |
neighborListSize = getNeighborListSize() |
162 |
+ |
nlist = 0 |
163 |
+ |
|
164 |
+ |
do i = 1, nrow |
165 |
+ |
point(i) = nlist + 1 |
166 |
+ |
|
167 |
+ |
inner: do j = 1, ncol |
168 |
+ |
|
169 |
+ |
if (checkExcludes(i,j)) cycle inner: |
170 |
+ |
|
171 |
+ |
call get_interatomic_vector(q_Row(:,i), q_Col(:,j), d, rijsq) |
172 |
+ |
|
173 |
+ |
if (rijsq < rlistsq) then |
174 |
+ |
|
175 |
+ |
nlist = nlist + 1 |
176 |
+ |
|
177 |
+ |
if (nlist > neighborListSize) then |
178 |
+ |
call expandNeighborList(nlocal, listerror) |
179 |
+ |
if (listerror /= 0) then |
180 |
+ |
error = -1 |
181 |
+ |
write(DEFAULT_ERROR,*) "ERROR: nlist > list size and max allocations exceeded." |
182 |
+ |
return |
183 |
+ |
end if |
184 |
+ |
endif |
185 |
+ |
|
186 |
+ |
list(nlist) = j |
187 |
+ |
|
188 |
+ |
if (rijsq < rcutsq) then |
189 |
+ |
call do_pair(i, j, rijsq, d, do_pot, do_stress) |
190 |
+ |
endif |
191 |
+ |
endif |
192 |
+ |
enddo inner |
193 |
+ |
enddo |
194 |
|
|
195 |
+ |
point(nrow + 1) = nlist + 1 |
196 |
+ |
|
197 |
+ |
else !! (of update_check) |
198 |
+ |
|
199 |
+ |
! use the list to find the neighbors |
200 |
+ |
do i = 1, nrow |
201 |
+ |
JBEG = POINT(i) |
202 |
+ |
JEND = POINT(i+1) - 1 |
203 |
+ |
! check thiat molecule i has neighbors |
204 |
+ |
if (jbeg .le. jend) then |
205 |
+ |
|
206 |
+ |
do jnab = jbeg, jend |
207 |
+ |
j = list(jnab) |
208 |
+ |
|
209 |
+ |
call get_interatomic_vector(q_Row(:,i), q_Col(:,j), d, rijsq) |
210 |
+ |
call do_pair(i, j, rijsq, d, do_pot, do_stress) |
211 |
+ |
|
212 |
+ |
enddo |
213 |
+ |
endif |
214 |
+ |
enddo |
215 |
+ |
endif |
216 |
|
|
167 |
– |
! if were're in MPI, we also have to worry about row and col lists |
217 |
|
#else |
218 |
< |
|
219 |
< |
! We can only set up forces if mpiSimulation has been setup. |
220 |
< |
if (.not. isMPISimSet()) then |
221 |
< |
write(default_error,*) "MPI is not set" |
222 |
< |
status = -1 |
223 |
< |
return |
224 |
< |
endif |
225 |
< |
nrow = getNrow(plan_row) |
226 |
< |
ncol = getNcol(plan_col) |
227 |
< |
mynode = getMyNode() |
228 |
< |
!! Allocate temperary arrays to hold gather information |
229 |
< |
allocate(identRow(nrow),stat=alloc_stat) |
230 |
< |
if (alloc_stat /= 0 ) then |
231 |
< |
status = -1 |
232 |
< |
return |
233 |
< |
endif |
218 |
> |
|
219 |
> |
if (update_nlist) then |
220 |
> |
|
221 |
> |
! save current configuration, contruct neighbor list, |
222 |
> |
! and calculate forces |
223 |
> |
call save_neighborList(q) |
224 |
> |
|
225 |
> |
neighborListSize = getNeighborListSize() |
226 |
> |
nlist = 0 |
227 |
> |
|
228 |
> |
do i = 1, natoms-1 |
229 |
> |
point(i) = nlist + 1 |
230 |
> |
|
231 |
> |
inner: do j = i+1, natoms |
232 |
> |
|
233 |
> |
if (checkExcludes(i,j)) cycle inner: |
234 |
> |
|
235 |
> |
call get_interatomic_vector(q(:,i), q(:,j), d, rijsq) |
236 |
> |
|
237 |
> |
if (rijsq < rlistsq) then |
238 |
> |
|
239 |
> |
nlist = nlist + 1 |
240 |
> |
|
241 |
> |
if (nlist > neighborListSize) then |
242 |
> |
call expandList(natoms, listerror) |
243 |
> |
if (listerror /= 0) then |
244 |
> |
error = -1 |
245 |
> |
write(DEFAULT_ERROR,*) "ERROR: nlist > list size and max allocations exceeded." |
246 |
> |
return |
247 |
> |
end if |
248 |
> |
endif |
249 |
> |
|
250 |
> |
list(nlist) = j |
251 |
> |
|
252 |
> |
if (rijsq < rcutsq) then |
253 |
> |
call do_pair(i, j, rijsq, d, do_pot, do_stress) |
254 |
> |
endif |
255 |
> |
endif |
256 |
> |
enddo inner |
257 |
> |
enddo |
258 |
> |
|
259 |
> |
point(natoms) = nlist + 1 |
260 |
> |
|
261 |
> |
else !! (update) |
262 |
> |
|
263 |
> |
! use the list to find the neighbors |
264 |
> |
do i = 1, natoms-1 |
265 |
> |
JBEG = POINT(i) |
266 |
> |
JEND = POINT(i+1) - 1 |
267 |
> |
! check thiat molecule i has neighbors |
268 |
> |
if (jbeg .le. jend) then |
269 |
> |
|
270 |
> |
do jnab = jbeg, jend |
271 |
> |
j = list(jnab) |
272 |
|
|
273 |
< |
allocate(identCol(ncol),stat=alloc_stat) |
274 |
< |
if (alloc_stat /= 0 ) then |
188 |
< |
status = -1 |
189 |
< |
return |
190 |
< |
endif |
273 |
> |
call get_interatomic_vector(q(:,i), q(:,j), d, rijsq) |
274 |
> |
call do_pair(i, j, rijsq, d, do_pot, do_stress) |
275 |
|
|
276 |
< |
!! Gather idents into row and column idents |
277 |
< |
|
278 |
< |
call gather(ident,identRow,plan_row) |
279 |
< |
call gather(ident,identCol,plan_col) |
276 |
> |
enddo |
277 |
> |
endif |
278 |
> |
enddo |
279 |
> |
endif |
280 |
|
|
281 |
< |
|
282 |
< |
!! Create row and col pointer lists |
283 |
< |
|
284 |
< |
call create_IdentPtrlst(identRow,ListHead,identPtrListRow,thisStat) |
285 |
< |
if (thisStat /= 0 ) then |
286 |
< |
status = -1 |
287 |
< |
return |
281 |
> |
#endif |
282 |
> |
|
283 |
> |
! phew, done with main loop. |
284 |
> |
|
285 |
> |
#ifdef IS_MPI |
286 |
> |
!!distribute forces |
287 |
> |
|
288 |
> |
call scatter(f_Row,f,plan_row3d) |
289 |
> |
call scatter(f_Col,f_temp,plan_col3d) |
290 |
> |
do i = 1,nlocal |
291 |
> |
f(1:3,i) = f(1:3,i) + f_temp(1:3,i) |
292 |
> |
end do |
293 |
> |
|
294 |
> |
if (FF_UsesDirectionalAtoms() .and. SimUsesDirectionalAtoms()) then |
295 |
> |
call scatter(t_Row,t,plan_row3d) |
296 |
> |
call scatter(t_Col,t_temp,plan_col3d) |
297 |
> |
|
298 |
> |
do i = 1,nlocal |
299 |
> |
t(1:3,i) = t(1:3,i) + t_temp(1:3,i) |
300 |
> |
end do |
301 |
|
endif |
302 |
< |
|
303 |
< |
call create_IdentPtrlst(identCol,ListHead,identPtrListColumn,thisStat) |
304 |
< |
if (thisStat /= 0 ) then |
305 |
< |
status = -1 |
306 |
< |
return |
307 |
< |
endif |
302 |
> |
|
303 |
> |
if (do_pot) then |
304 |
> |
! scatter/gather pot_row into the members of my column |
305 |
> |
call scatter(pot_Row, pot_Temp, plan_row) |
306 |
> |
|
307 |
> |
! scatter/gather pot_local into all other procs |
308 |
> |
! add resultant to get total pot |
309 |
> |
do i = 1, nlocal |
310 |
> |
pot_local = pot_local + pot_Temp(i) |
311 |
> |
enddo |
312 |
|
|
313 |
< |
!! free temporary ident arrays |
213 |
< |
if (allocated(identCol)) then |
214 |
< |
deallocate(identCol) |
215 |
< |
end if |
216 |
< |
if (allocated(identCol)) then |
217 |
< |
deallocate(identRow) |
218 |
< |
endif |
313 |
> |
pot_Temp = 0.0_DP |
314 |
|
|
315 |
+ |
call scatter(pot_Col, pot_Temp, plan_col) |
316 |
+ |
do i = 1, nlocal |
317 |
+ |
pot_local = pot_local + pot_Temp(i) |
318 |
+ |
enddo |
319 |
+ |
|
320 |
+ |
endif |
321 |
|
#endif |
221 |
– |
|
222 |
– |
call initForce_Modules(thisStat) |
223 |
– |
if (thisStat /= 0) then |
224 |
– |
status = -1 |
225 |
– |
return |
226 |
– |
endif |
322 |
|
|
323 |
< |
!! Create neighbor lists |
324 |
< |
call expandList(thisStat) |
325 |
< |
if (thisStat /= 0) then |
326 |
< |
status = -1 |
327 |
< |
return |
323 |
> |
if (FF_RequiresPostpairCalc() .and. SimRequiresPostpairCalc()) then |
324 |
> |
|
325 |
> |
if (FF_uses_RF .and. SimUsesRF()) then |
326 |
> |
|
327 |
> |
#ifdef IS_MPI |
328 |
> |
call scatter(rf_Row,rf,plan_row3d) |
329 |
> |
call scatter(rf_Col,rf_Temp,plan_col3d) |
330 |
> |
do i = 1,nlocal |
331 |
> |
rf(1:3,i) = rf(1:3,i) + rf_Temp(1:3,i) |
332 |
> |
end do |
333 |
> |
#endif |
334 |
> |
|
335 |
> |
do i = 1, getNlocal() |
336 |
> |
|
337 |
> |
rfpot = 0.0_DP |
338 |
> |
#ifdef IS_MPI |
339 |
> |
me_i = atid_row(i) |
340 |
> |
#else |
341 |
> |
me_i = atid(i) |
342 |
> |
#endif |
343 |
> |
call getElementProperty(atypes, me_i, "is_DP", is_DP_i) |
344 |
> |
if ( is_DP_i ) then |
345 |
> |
call getElementProperty(atypes, me_i, "dipole_moment", mu_i) |
346 |
> |
!! The reaction field needs to include a self contribution |
347 |
> |
!! to the field: |
348 |
> |
call accumulate_self_rf(i, mu_i, u_l) |
349 |
> |
!! Get the reaction field contribution to the |
350 |
> |
!! potential and torques: |
351 |
> |
call reaction_field_final(i, mu_i, u_l, rfpot, t, do_pot) |
352 |
> |
#ifdef IS_MPI |
353 |
> |
pot_local = pot_local + rfpot |
354 |
> |
#else |
355 |
> |
pot = pot + rfpot |
356 |
> |
#endif |
357 |
> |
endif |
358 |
> |
enddo |
359 |
> |
endif |
360 |
|
endif |
361 |
|
|
235 |
– |
isFFinit = .true. |
362 |
|
|
363 |
+ |
#ifdef IS_MPI |
364 |
|
|
365 |
< |
end subroutine init_FF |
365 |
> |
if (do_pot) then |
366 |
> |
pot = pot_local |
367 |
> |
!! we assume the c code will do the allreduce to get the total potential |
368 |
> |
!! we could do it right here if we needed to... |
369 |
> |
endif |
370 |
|
|
371 |
+ |
if (do_stress) then |
372 |
+ |
call mpi_allreduce(tau, tau_Temp,9,mpi_double_precision,mpi_sum, & |
373 |
+ |
mpi_comm_world,mpi_err) |
374 |
+ |
call mpi_allreduce(virial, virial_Temp,1,mpi_double_precision,mpi_sum, & |
375 |
+ |
mpi_comm_world,mpi_err) |
376 |
+ |
endif |
377 |
|
|
378 |
+ |
#else |
379 |
|
|
380 |
+ |
if (do_stress) then |
381 |
+ |
tau = tau_Temp |
382 |
+ |
virial = virial_Temp |
383 |
+ |
endif |
384 |
|
|
385 |
< |
subroutine initForce_Modules(thisStat) |
244 |
< |
integer, intent(out) :: thisStat |
245 |
< |
integer :: my_status |
385 |
> |
#endif |
386 |
|
|
387 |
< |
thisStat = 0 |
248 |
< |
call init_lj_FF(ListHead,my_status) |
249 |
< |
if (my_status /= 0) then |
250 |
< |
thisStat = -1 |
251 |
< |
return |
252 |
< |
end if |
387 |
> |
end subroutine do_force_loop |
388 |
|
|
254 |
– |
end subroutine initForce_Modules |
389 |
|
|
390 |
+ |
!! Calculate any pre-force loop components and update nlist if necessary. |
391 |
+ |
subroutine do_preForce(updateNlist) |
392 |
+ |
logical, intent(inout) :: updateNlist |
393 |
|
|
394 |
|
|
395 |
|
|
396 |
< |
!! FORCE routine Calculates Lennard Jones forces. |
260 |
< |
!-------------------------------------------------------------> |
261 |
< |
subroutine do__force_loop(q,A,mu,u_l,f,t,tau,potE,do_pot,FFerror) |
262 |
< |
!! Position array provided by C, dimensioned by getNlocal |
263 |
< |
real ( kind = dp ), dimension(3,getNlocal()) :: q |
264 |
< |
!! Rotation Matrix for each long range particle in simulation. |
265 |
< |
real( kind = dp), dimension(9,getNlocal()) :: A |
396 |
> |
end subroutine do_preForce |
397 |
|
|
398 |
< |
!! Magnitude dipole moment |
399 |
< |
real( kind = dp ), dimension(3,getNlocal()) :: mu |
400 |
< |
!! Unit vectors for dipoles (lab frame) |
398 |
> |
!! Calculate any post force loop components, i.e. reaction field, etc. |
399 |
> |
subroutine do_postForce() |
400 |
> |
|
401 |
> |
|
402 |
> |
|
403 |
> |
end subroutine do_postForce |
404 |
> |
|
405 |
> |
subroutine do_pair(i, j, rijsq, d, do_pot, do_stress) |
406 |
> |
|
407 |
> |
real( kind = dp ) :: pot |
408 |
|
real( kind = dp ), dimension(3,getNlocal()) :: u_l |
409 |
< |
!! Force array provided by C, dimensioned by getNlocal |
410 |
< |
real ( kind = dp ), dimension(3,getNlocal()) :: f |
411 |
< |
!! Torsion array provided by C, dimensioned by getNlocal |
274 |
< |
real( kind = dp ), dimension(3,getNlocal()) :: t |
409 |
> |
real (kind=dp), dimension(9,getNlocal()) :: A |
410 |
> |
real (kind=dp), dimension(3,getNlocal()) :: f |
411 |
> |
real (kind=dp), dimension(3,getNlocal()) :: t |
412 |
|
|
413 |
< |
!! Stress Tensor |
414 |
< |
real( kind = dp), dimension(9) :: tau |
415 |
< |
real( kind = dp), dimension(9) :: tauTemp |
416 |
< |
real ( kind = dp ) :: potE |
417 |
< |
logical ( kind = 2) :: do_pot |
418 |
< |
integer :: FFerror |
413 |
> |
logical, intent(inout) :: do_pot, do_stress |
414 |
> |
integer, intent(in) :: i, j |
415 |
> |
real ( kind = dp ), intent(in) :: rijsq |
416 |
> |
real ( kind = dp ) :: r |
417 |
> |
real ( kind = dp ), intent(inout) :: d(3) |
418 |
> |
logical :: is_LJ_i, is_LJ_j |
419 |
> |
logical :: is_DP_i, is_DP_j |
420 |
> |
logical :: is_Sticky_i, is_Sticky_j |
421 |
> |
integer :: me_i, me_j |
422 |
|
|
423 |
+ |
r = sqrt(rijsq) |
424 |
|
|
425 |
< |
type(atype), pointer :: Atype_i |
285 |
< |
type(atype), pointer :: Atype_j |
425 |
> |
#ifdef IS_MPI |
426 |
|
|
427 |
+ |
me_i = atid_row(i) |
428 |
+ |
me_j = atid_col(j) |
429 |
|
|
430 |
+ |
#else |
431 |
|
|
432 |
+ |
me_i = atid(i) |
433 |
+ |
me_j = atid(j) |
434 |
|
|
435 |
< |
|
435 |
> |
#endif |
436 |
|
|
292 |
– |
#ifdef IS_MPI |
293 |
– |
real( kind = DP ) :: pot_local |
437 |
|
|
438 |
< |
!! Local arrays needed for MPI |
439 |
< |
real(kind = dp), dimension(3,getNrow(plan_row)) :: qRow = 0.0_dp |
440 |
< |
real(kind = dp), dimension(3,getNcol(plan_col)) :: qCol = 0.0_dp |
438 |
> |
if (FF_uses_LJ .and. SimUsesLJ()) then |
439 |
> |
call getElementProperty(atypes, me_i, "is_LJ", is_LJ_i) |
440 |
> |
call getElementProperty(atypes, me_j, "is_LJ", is_LJ_j) |
441 |
> |
|
442 |
> |
if ( is_LJ_i .and. is_LJ_j ) & |
443 |
> |
call do_lj_pair(i, j, d, r, rijsq, pot, f, do_pot, do_stress) |
444 |
> |
endif |
445 |
> |
|
446 |
|
|
447 |
< |
real(kind = dp), dimension(3,getNrow(plan_row)) :: muRow = 0.0_dp |
448 |
< |
real(kind = dp), dimension(3,getNcol(plan_col)) :: muCol = 0.0_dp |
447 |
> |
if (FF_uses_dipoles .and. SimUsesDipoles()) then |
448 |
> |
call getElementProperty(atypes, me_i, "is_DP", is_DP_i) |
449 |
> |
call getElementProperty(atypes, me_j, "is_DP", is_DP_j) |
450 |
> |
|
451 |
> |
if ( is_DP_i .and. is_DP_j ) then |
452 |
> |
|
453 |
> |
call do_dipole_pair(i, j, d, r, pot, u_l, f, t, do_pot, do_stress) |
454 |
> |
|
455 |
> |
if (FF_uses_RF .and. SimUsesRF()) then |
456 |
> |
|
457 |
> |
call accumulate_rf(i, j, r, u_l) |
458 |
> |
call rf_correct_forces(i, j, d, r, u_l, f, do_stress) |
459 |
> |
|
460 |
> |
endif |
461 |
> |
|
462 |
> |
endif |
463 |
> |
endif |
464 |
|
|
465 |
< |
real(kind = dp), dimension(3,getNrow(plan_row)) :: u_lRow = 0.0_dp |
303 |
< |
real(kind = dp), dimension(3,getNcol(plan_col)) :: u_lCol = 0.0_dp |
465 |
> |
if (FF_uses_Sticky .and. SimUsesSticky()) then |
466 |
|
|
467 |
< |
real(kind = dp), dimension(3,getNrow(plan_row)) :: ARow = 0.0_dp |
468 |
< |
real(kind = dp), dimension(3,getNcol(plan_col)) :: ACol = 0.0_dp |
467 |
> |
call getElementProperty(atypes, me_i, "is_Sticky", is_Sticky_i) |
468 |
> |
call getElementProperty(atypes, me_j, "is_Sticky", is_Sticky_j) |
469 |
> |
|
470 |
> |
if ( is_Sticky_i .and. is_Sticky_j ) then |
471 |
> |
call do_sticky_pair(i, j, d, r, rijsq, A, pot, f, t, & |
472 |
> |
do_pot, do_stress) |
473 |
> |
endif |
474 |
> |
endif |
475 |
> |
|
476 |
> |
end subroutine do_pair |
477 |
|
|
308 |
– |
|
478 |
|
|
479 |
< |
real(kind = dp), dimension(3,getNrow(plan_row)) :: fRow = 0.0_dp |
480 |
< |
real(kind = dp), dimension(3,getNcol(plan_col)) :: fCol = 0.0_dp |
481 |
< |
real(kind = dp), dimension(3,getNlocal()) :: fMPITemp = 0.0_dp |
479 |
> |
subroutine get_interatomic_vector(q_i, q_j, d, r_sq) |
480 |
> |
|
481 |
> |
real (kind = dp), dimension(3) :: q_i |
482 |
> |
real (kind = dp), dimension(3) :: q_j |
483 |
> |
real ( kind = dp ), intent(out) :: r_sq |
484 |
> |
real( kind = dp ) :: d(3) |
485 |
|
|
486 |
< |
real(kind = dp), dimension(3,getNrow(plan_row)) :: tRow = 0.0_dp |
487 |
< |
real(kind = dp), dimension(3,getNcol(plan_col)) :: tCol = 0.0_dp |
488 |
< |
real(kind = dp), dimension(3,getNlocal()) :: tMPITemp = 0.0_dp |
486 |
> |
d(1:3) = q_i(1:3) - q_j(1:3) |
487 |
> |
|
488 |
> |
! Wrap back into periodic box if necessary |
489 |
> |
if ( SimUsesPBC() ) then |
490 |
> |
d(1:3) = d(1:3) - box(1:3) * sign(1.0_dp,box(1:3)) * & |
491 |
> |
int(abs(d(1:3)/box(1:3) + 0.5_dp)) |
492 |
> |
endif |
493 |
> |
|
494 |
> |
r_sq = dot_product(d,d) |
495 |
> |
|
496 |
> |
end subroutine get_interatomic_vector |
497 |
|
|
498 |
+ |
subroutine check_initialization(error) |
499 |
+ |
integer, intent(out) :: error |
500 |
|
|
501 |
< |
real(kind = dp), dimension(getNrow(plan_row)) :: eRow = 0.0_dp |
502 |
< |
real(kind = dp), dimension(getNcol(plan_col)) :: eCol = 0.0_dp |
503 |
< |
|
504 |
< |
real(kind = dp), dimension(getNlocal()) :: eTemp = 0.0_dp |
505 |
< |
|
506 |
< |
#endif |
507 |
< |
|
326 |
< |
|
327 |
< |
|
328 |
< |
real( kind = DP ) :: pe |
329 |
< |
logical :: update_nlist |
330 |
< |
|
331 |
< |
|
332 |
< |
integer :: i, j, jbeg, jend, jnab, idim, jdim, idim2, jdim2, dim, dim2 |
333 |
< |
integer :: nlist |
334 |
< |
integer :: j_start |
335 |
< |
integer :: tag_i,tag_j |
336 |
< |
real( kind = DP ) :: r, pot, ftmp, dudr, d2, drdx1, kt1, kt2, kt3, ktmp |
337 |
< |
real( kind = dp ) :: fx,fy,fz |
338 |
< |
real( kind = DP ) :: drdx, drdy, drdz |
339 |
< |
real( kind = DP ) :: rxi, ryi, rzi, rxij, ryij, rzij, rijsq |
340 |
< |
real( kind = DP ) :: rlistsq, rcutsq,rlist,rcut |
341 |
< |
|
342 |
< |
real( kind = DP ) :: dielectric = 0.0_dp |
343 |
< |
|
344 |
< |
! a rig that need to be fixed. |
501 |
> |
error = 0 |
502 |
> |
! Make sure we are properly initialized. |
503 |
> |
if (.not. do_Forces_initialized) then |
504 |
> |
write(default_error,*) "ERROR: do_Forces has not been initialized!" |
505 |
> |
error = -1 |
506 |
> |
return |
507 |
> |
endif |
508 |
|
#ifdef IS_MPI |
346 |
– |
logical :: newtons_thrd = .true. |
347 |
– |
real( kind = dp ) :: pe_local |
348 |
– |
integer :: nlocal |
349 |
– |
#endif |
350 |
– |
integer :: nrow |
351 |
– |
integer :: ncol |
352 |
– |
integer :: natoms |
353 |
– |
integer :: neighborListSize |
354 |
– |
integer :: listerror |
355 |
– |
!! should we calculate the stress tensor |
356 |
– |
logical :: do_stress = .false. |
357 |
– |
|
358 |
– |
|
359 |
– |
FFerror = 0 |
360 |
– |
|
361 |
– |
! Make sure we are properly initialized. |
362 |
– |
if (.not. isFFInit) then |
363 |
– |
write(default_error,*) "ERROR: lj_FF has not been properly initialized" |
364 |
– |
FFerror = -1 |
365 |
– |
return |
366 |
– |
endif |
367 |
– |
#ifdef IS_MPI |
509 |
|
if (.not. isMPISimSet()) then |
510 |
< |
write(default_error,*) "ERROR: mpiSimulation has not been properly initialized" |
511 |
< |
FFerror = -1 |
512 |
< |
return |
513 |
< |
endif |
510 |
> |
write(default_error,*) "ERROR: mpiSimulation has not been initialized!" |
511 |
> |
error = -1 |
512 |
> |
return |
513 |
> |
endif |
514 |
|
#endif |
515 |
|
|
516 |
< |
!! initialize local variables |
517 |
< |
natoms = getNlocal() |
377 |
< |
call getRcut(rcut,rcut2=rcutsq) |
378 |
< |
call getRlist(rlist,rlistsq) |
379 |
< |
!! Find ensemble |
380 |
< |
if (isEnsemble("NPT")) do_stress = .true. |
516 |
> |
return |
517 |
> |
end subroutine check_initialization |
518 |
|
|
382 |
– |
#ifndef IS_MPI |
383 |
– |
nrow = natoms - 1 |
384 |
– |
ncol = natoms |
385 |
– |
#else |
386 |
– |
nrow = getNrow(plan_row) |
387 |
– |
ncol = getNcol(plan_col) |
388 |
– |
nlocal = natoms |
389 |
– |
j_start = 1 |
390 |
– |
#endif |
391 |
– |
|
519 |
|
|
520 |
< |
!! See if we need to update neighbor lists |
521 |
< |
call check(q,update_nlist) |
522 |
< |
! if (firstTime) then |
396 |
< |
! update_nlist = .true. |
397 |
< |
! firstTime = .false. |
398 |
< |
! endif |
520 |
> |
subroutine zero_work_arrays() |
521 |
> |
|
522 |
> |
#ifdef IS_MPI |
523 |
|
|
524 |
< |
!--------------WARNING........................... |
525 |
< |
! Zero variables, NOTE:::: Forces are zeroed in C |
526 |
< |
! Zeroing them here could delete previously computed |
527 |
< |
! Forces. |
528 |
< |
!------------------------------------------------ |
529 |
< |
#ifndef IS_MPI |
530 |
< |
! nloops = nloops + 1 |
531 |
< |
pe = 0.0E0_DP |
524 |
> |
q_Row = 0.0_dp |
525 |
> |
q_Col = 0.0_dp |
526 |
> |
|
527 |
> |
u_l_Row = 0.0_dp |
528 |
> |
u_l_Col = 0.0_dp |
529 |
> |
|
530 |
> |
A_Row = 0.0_dp |
531 |
> |
A_Col = 0.0_dp |
532 |
> |
|
533 |
> |
f_Row = 0.0_dp |
534 |
> |
f_Col = 0.0_dp |
535 |
> |
f_Temp = 0.0_dp |
536 |
> |
|
537 |
> |
t_Row = 0.0_dp |
538 |
> |
t_Col = 0.0_dp |
539 |
> |
t_Temp = 0.0_dp |
540 |
|
|
541 |
< |
#else |
542 |
< |
fRow = 0.0E0_DP |
543 |
< |
fCol = 0.0E0_DP |
541 |
> |
pot_Row = 0.0_dp |
542 |
> |
pot_Col = 0.0_dp |
543 |
> |
pot_Temp = 0.0_dp |
544 |
|
|
413 |
– |
pe_local = 0.0E0_DP |
414 |
– |
|
415 |
– |
eRow = 0.0E0_DP |
416 |
– |
eCol = 0.0E0_DP |
417 |
– |
eTemp = 0.0E0_DP |
545 |
|
#endif |
546 |
|
|
547 |
< |
! communicate MPI positions |
548 |
< |
#ifdef IS_MPI |
549 |
< |
call gather(q,qRow,plan_row3d) |
550 |
< |
call gather(q,qCol,plan_col3d) |
547 |
> |
tau_Temp = 0.0_dp |
548 |
> |
virial_Temp = 0.0_dp |
549 |
> |
|
550 |
> |
end subroutine zero_work_arrays |
551 |
> |
|
552 |
|
|
553 |
< |
call gather(mu,muRow,plan_row3d) |
554 |
< |
call gather(mu,muCol,plan_col3d) |
553 |
> |
!! Function to properly build neighbor lists in MPI using newtons 3rd law. |
554 |
> |
!! We don't want 2 processors doing the same i j pair twice. |
555 |
> |
!! Also checks to see if i and j are the same particle. |
556 |
|
|
557 |
< |
call gather(u_l,u_lRow,plan_row3d) |
558 |
< |
call gather(u_l,u_lCol,plan_col3d) |
559 |
< |
|
560 |
< |
call gather(A,ARow,plan_row_rotation) |
561 |
< |
call gather(A,ACol,plan_col_rotation) |
562 |
< |
|
563 |
< |
#endif |
564 |
< |
|
565 |
< |
|
566 |
< |
if (update_nlist) then |
567 |
< |
|
568 |
< |
! save current configuration, contruct neighbor list, |
569 |
< |
! and calculate forces |
570 |
< |
call save_neighborList(q) |
442 |
< |
|
443 |
< |
neighborListSize = getNeighborListSize() |
444 |
< |
nlist = 0 |
445 |
< |
|
557 |
> |
function checkExcludes(atom1,atom2) result(do_cycle) |
558 |
> |
!--------------- Arguments-------------------------- |
559 |
> |
! Index i |
560 |
> |
integer,intent(in) :: atom1 |
561 |
> |
! Index j |
562 |
> |
integer,intent(in), optional :: atom2 |
563 |
> |
! Result do_cycle |
564 |
> |
logical :: do_cycle |
565 |
> |
!--------------- Local variables-------------------- |
566 |
> |
integer :: tag_i |
567 |
> |
integer :: tag_j |
568 |
> |
integer :: i, j |
569 |
> |
!--------------- END DECLARATIONS------------------ |
570 |
> |
do_cycle = .false. |
571 |
|
|
447 |
– |
|
448 |
– |
do i = 1, nrow |
449 |
– |
point(i) = nlist + 1 |
572 |
|
#ifdef IS_MPI |
573 |
< |
ljAtype_i => identPtrListRow(i)%this |
452 |
< |
tag_i = tagRow(i) |
453 |
< |
rxi = qRow(1,i) |
454 |
< |
ryi = qRow(2,i) |
455 |
< |
rzi = qRow(3,i) |
573 |
> |
tag_i = tagRow(atom1) |
574 |
|
#else |
575 |
< |
ljAtype_i => identPtrList(i)%this |
458 |
< |
j_start = i + 1 |
459 |
< |
rxi = q(1,i) |
460 |
< |
ryi = q(2,i) |
461 |
< |
rzi = q(3,i) |
575 |
> |
tag_i = tag(atom1) |
576 |
|
#endif |
577 |
+ |
|
578 |
+ |
!! Check global excludes first |
579 |
+ |
if (.not. present(atom2)) then |
580 |
+ |
do i = 1, nExcludes_global |
581 |
+ |
if (excludeGlobal(i) == tag_i) then |
582 |
+ |
do_cycle = .true. |
583 |
+ |
return |
584 |
+ |
end if |
585 |
+ |
end do |
586 |
+ |
return !! return after checking globals |
587 |
+ |
end if |
588 |
|
|
589 |
< |
inner: do j = j_start, ncol |
590 |
< |
#ifdef IS_MPI |
466 |
< |
! Assign identity pointers and tags |
467 |
< |
ljAtype_j => identPtrListColumn(j)%this |
468 |
< |
tag_j = tagColumn(j) |
469 |
< |
if (newtons_thrd) then |
470 |
< |
if (tag_i <= tag_j) then |
471 |
< |
if (mod(tag_i + tag_j,2) == 0) cycle inner |
472 |
< |
else |
473 |
< |
if (mod(tag_i + tag_j,2) == 1) cycle inner |
474 |
< |
endif |
475 |
< |
endif |
476 |
< |
|
477 |
< |
rxij = wrap(rxi - qCol(1,j), 1) |
478 |
< |
ryij = wrap(ryi - qCol(2,j), 2) |
479 |
< |
rzij = wrap(rzi - qCol(3,j), 3) |
480 |
< |
#else |
481 |
< |
ljAtype_j => identPtrList(j)%this |
482 |
< |
rxij = wrap(rxi - q(1,j), 1) |
483 |
< |
ryij = wrap(ryi - q(2,j), 2) |
484 |
< |
rzij = wrap(rzi - q(3,j), 3) |
485 |
< |
|
486 |
< |
#endif |
487 |
< |
rijsq = rxij*rxij + ryij*ryij + rzij*rzij |
488 |
< |
|
489 |
< |
#ifdef IS_MPI |
490 |
< |
if (rijsq <= rlistsq .AND. & |
491 |
< |
tag_j /= tag_i) then |
492 |
< |
#else |
493 |
< |
|
494 |
< |
if (rijsq < rlistsq) then |
495 |
< |
#endif |
496 |
< |
|
497 |
< |
nlist = nlist + 1 |
498 |
< |
if (nlist > neighborListSize) then |
499 |
< |
call expandList(listerror) |
500 |
< |
if (listerror /= 0) then |
501 |
< |
FFerror = -1 |
502 |
< |
write(DEFAULT_ERROR,*) "ERROR: nlist > list size and max allocations exceeded." |
503 |
< |
return |
504 |
< |
end if |
505 |
< |
endif |
506 |
< |
list(nlist) = j |
507 |
< |
|
589 |
> |
!! we return if atom2 not present here. |
590 |
> |
tag_j = tagColumn(atom2) |
591 |
|
|
592 |
< |
if (rijsq < rcutsq) then |
593 |
< |
|
594 |
< |
r = dsqrt(rijsq) |
595 |
< |
|
513 |
< |
call getLJPot(r,pot,dudr,ljAtype_i,ljAtype_j) |
514 |
< |
|
515 |
< |
#ifdef IS_MPI |
516 |
< |
eRow(i) = eRow(i) + pot*0.5 |
517 |
< |
eCol(i) = eCol(i) + pot*0.5 |
518 |
< |
#else |
519 |
< |
pe = pe + pot |
520 |
< |
#endif |
521 |
< |
|
522 |
< |
drdx = -rxij / r |
523 |
< |
drdy = -ryij / r |
524 |
< |
drdz = -rzij / r |
525 |
< |
|
526 |
< |
fx = dudr * drdx |
527 |
< |
fy = dudr * drdy |
528 |
< |
fz = dudr * drdz |
529 |
< |
|
530 |
< |
#ifdef IS_MPI |
531 |
< |
fCol(1,j) = fCol(1,j) - fx |
532 |
< |
fCol(2,j) = fCol(2,j) - fy |
533 |
< |
fCol(3,j) = fCol(3,j) - fz |
534 |
< |
|
535 |
< |
fRow(1,j) = fRow(1,j) + fx |
536 |
< |
fRow(2,j) = fRow(2,j) + fy |
537 |
< |
fRow(3,j) = fRow(3,j) + fz |
538 |
< |
#else |
539 |
< |
f(1,j) = f(1,j) - fx |
540 |
< |
f(2,j) = f(2,j) - fy |
541 |
< |
f(3,j) = f(3,j) - fz |
542 |
< |
f(1,i) = f(1,i) + fx |
543 |
< |
f(2,i) = f(2,i) + fy |
544 |
< |
f(3,i) = f(3,i) + fz |
545 |
< |
#endif |
546 |
< |
|
547 |
< |
if (do_stress) then |
548 |
< |
tauTemp(1) = tauTemp(1) + fx * rxij |
549 |
< |
tauTemp(2) = tauTemp(2) + fx * ryij |
550 |
< |
tauTemp(3) = tauTemp(3) + fx * rzij |
551 |
< |
tauTemp(4) = tauTemp(4) + fy * rxij |
552 |
< |
tauTemp(5) = tauTemp(5) + fy * ryij |
553 |
< |
tauTemp(6) = tauTemp(6) + fy * rzij |
554 |
< |
tauTemp(7) = tauTemp(7) + fz * rxij |
555 |
< |
tauTemp(8) = tauTemp(8) + fz * ryij |
556 |
< |
tauTemp(9) = tauTemp(9) + fz * rzij |
557 |
< |
endif |
558 |
< |
endif |
559 |
< |
enddo inner |
560 |
< |
enddo |
561 |
< |
|
562 |
< |
#ifdef IS_MPI |
563 |
< |
point(nrow + 1) = nlist + 1 |
564 |
< |
#else |
565 |
< |
point(natoms) = nlist + 1 |
566 |
< |
#endif |
567 |
< |
|
568 |
< |
else |
569 |
< |
|
570 |
< |
! use the list to find the neighbors |
571 |
< |
do i = 1, nrow |
572 |
< |
JBEG = POINT(i) |
573 |
< |
JEND = POINT(i+1) - 1 |
574 |
< |
! check thiat molecule i has neighbors |
575 |
< |
if (jbeg .le. jend) then |
576 |
< |
#ifdef IS_MPI |
577 |
< |
ljAtype_i => identPtrListRow(i)%this |
578 |
< |
rxi = qRow(1,i) |
579 |
< |
ryi = qRow(2,i) |
580 |
< |
rzi = qRow(3,i) |
581 |
< |
#else |
582 |
< |
ljAtype_i => identPtrList(i)%this |
583 |
< |
rxi = q(1,i) |
584 |
< |
ryi = q(2,i) |
585 |
< |
rzi = q(3,i) |
586 |
< |
#endif |
587 |
< |
do jnab = jbeg, jend |
588 |
< |
j = list(jnab) |
589 |
< |
#ifdef IS_MPI |
590 |
< |
ljAtype_j = identPtrListColumn(j)%this |
591 |
< |
rxij = wrap(rxi - qCol(1,j), 1) |
592 |
< |
ryij = wrap(ryi - qCol(2,j), 2) |
593 |
< |
rzij = wrap(rzi - qCol(3,j), 3) |
594 |
< |
#else |
595 |
< |
ljAtype_j = identPtrList(j)%this |
596 |
< |
rxij = wrap(rxi - q(1,j), 1) |
597 |
< |
ryij = wrap(ryi - q(2,j), 2) |
598 |
< |
rzij = wrap(rzi - q(3,j), 3) |
599 |
< |
#endif |
600 |
< |
rijsq = rxij*rxij + ryij*ryij + rzij*rzij |
601 |
< |
|
602 |
< |
if (rijsq < rcutsq) then |
603 |
< |
|
604 |
< |
r = dsqrt(rijsq) |
605 |
< |
|
606 |
< |
call getLJPot(r,pot,dudr,ljAtype_i,ljAtype_j) |
607 |
< |
#ifdef IS_MPI |
608 |
< |
eRow(i) = eRow(i) + pot*0.5 |
609 |
< |
eCol(i) = eCol(i) + pot*0.5 |
610 |
< |
#else |
611 |
< |
pe = pe + pot |
612 |
< |
#endif |
613 |
< |
|
614 |
< |
drdx = -rxij / r |
615 |
< |
drdy = -ryij / r |
616 |
< |
drdz = -rzij / r |
617 |
< |
|
618 |
< |
fx = dudr * drdx |
619 |
< |
fy = dudr * drdy |
620 |
< |
fz = dudr * drdz |
621 |
< |
|
622 |
< |
#ifdef IS_MPI |
623 |
< |
fCol(1,j) = fCol(1,j) - fx |
624 |
< |
fCol(2,j) = fCol(2,j) - fy |
625 |
< |
fCol(3,j) = fCol(3,j) - fz |
626 |
< |
|
627 |
< |
fRow(1,j) = fRow(1,j) + fx |
628 |
< |
fRow(2,j) = fRow(2,j) + fy |
629 |
< |
fRow(3,j) = fRow(3,j) + fz |
630 |
< |
#else |
631 |
< |
f(1,j) = f(1,j) - fx |
632 |
< |
f(2,j) = f(2,j) - fy |
633 |
< |
f(3,j) = f(3,j) - fz |
634 |
< |
f(1,i) = f(1,i) + fx |
635 |
< |
f(2,i) = f(2,i) + fy |
636 |
< |
f(3,i) = f(3,i) + fz |
637 |
< |
#endif |
638 |
< |
|
639 |
< |
if (do_stress) then |
640 |
< |
tauTemp(1) = tauTemp(1) + fx * rxij |
641 |
< |
tauTemp(2) = tauTemp(2) + fx * ryij |
642 |
< |
tauTemp(3) = tauTemp(3) + fx * rzij |
643 |
< |
tauTemp(4) = tauTemp(4) + fy * rxij |
644 |
< |
tauTemp(5) = tauTemp(5) + fy * ryij |
645 |
< |
tauTemp(6) = tauTemp(6) + fy * rzij |
646 |
< |
tauTemp(7) = tauTemp(7) + fz * rxij |
647 |
< |
tauTemp(8) = tauTemp(8) + fz * ryij |
648 |
< |
tauTemp(9) = tauTemp(9) + fz * rzij |
649 |
< |
endif |
650 |
< |
|
651 |
< |
|
652 |
< |
endif |
653 |
< |
enddo |
654 |
< |
endif |
655 |
< |
enddo |
656 |
< |
endif |
657 |
< |
|
658 |
< |
|
659 |
< |
|
660 |
< |
#ifdef IS_MPI |
661 |
< |
!!distribute forces |
662 |
< |
|
663 |
< |
call scatter(fRow,f,plan_row3d) |
664 |
< |
call scatter(fCol,fMPITemp,plan_col3d) |
665 |
< |
|
666 |
< |
do i = 1,nlocal |
667 |
< |
f(1:3,i) = f(1:3,i) + fMPITemp(1:3,i) |
668 |
< |
end do |
669 |
< |
|
670 |
< |
|
671 |
< |
call scatter(tRow,t,plan_row3d) |
672 |
< |
call scatter(tCol,tMPITemp,plan_col3d) |
592 |
> |
if (tag_i == tag_j) then |
593 |
> |
do_cycle = .true. |
594 |
> |
return |
595 |
> |
end if |
596 |
|
|
597 |
< |
do i = 1,nlocal |
598 |
< |
t(1:3,i) = t(1:3,i) + tMPITemp(1:3,i) |
597 |
> |
if (tag_i < tag_j) then |
598 |
> |
if (mod(tag_i + tag_j,2) == 0) do_cycle = .true. |
599 |
> |
return |
600 |
> |
else |
601 |
> |
if (mod(tag_i + tag_j,2) == 1) do_cycle = .true. |
602 |
> |
endif |
603 |
> |
|
604 |
> |
do i = 1, nExcludes_local |
605 |
> |
if ((tag_i == excludesLocal(1,i)) .and. (excludesLocal(2,i) < 0)) then |
606 |
> |
do_cycle = .true. |
607 |
> |
return |
608 |
> |
end if |
609 |
|
end do |
610 |
+ |
|
611 |
+ |
|
612 |
+ |
end function checkExcludes |
613 |
|
|
614 |
< |
|
615 |
< |
if (do_pot) then |
616 |
< |
! scatter/gather pot_row into the members of my column |
617 |
< |
call scatter(eRow,eTemp,plan_row) |
618 |
< |
|
619 |
< |
! scatter/gather pot_local into all other procs |
620 |
< |
! add resultant to get total pot |
621 |
< |
do i = 1, nlocal |
622 |
< |
pe_local = pe_local + eTemp(i) |
623 |
< |
enddo |
624 |
< |
if (newtons_thrd) then |
625 |
< |
eTemp = 0.0E0_DP |
626 |
< |
call scatter(eCol,eTemp,plan_col) |
627 |
< |
do i = 1, nlocal |
628 |
< |
pe_local = pe_local + eTemp(i) |
629 |
< |
enddo |
694 |
< |
endif |
695 |
< |
pe = pe_local |
696 |
< |
endif |
697 |
< |
|
698 |
< |
#endif |
699 |
< |
|
700 |
< |
potE = pe |
701 |
< |
|
702 |
< |
|
703 |
< |
if (do_stress) then |
704 |
< |
#ifdef IS_MPI |
705 |
< |
mpi_allreduce = (tau,tauTemp,9,mpi_double_precision,mpi_sum, & |
706 |
< |
mpi_comm_world,mpi_err) |
707 |
< |
#else |
708 |
< |
tau = tauTemp |
709 |
< |
#endif |
710 |
< |
endif |
711 |
< |
|
712 |
< |
|
713 |
< |
end subroutine do_force_loop |
714 |
< |
|
715 |
< |
|
716 |
< |
|
614 |
> |
function FF_UsesDirectionalAtoms() result(doesit) |
615 |
> |
logical :: doesit |
616 |
> |
doesit = FF_uses_dipoles .or. FF_uses_sticky .or. & |
617 |
> |
FF_uses_GB .or. FF_uses_RF |
618 |
> |
end function FF_UsesDirectionalAtoms |
619 |
> |
|
620 |
> |
function FF_RequiresPrepairCalc() result(doesit) |
621 |
> |
logical :: doesit |
622 |
> |
doesit = FF_uses_EAM |
623 |
> |
end function FF_RequiresPrepairCalc |
624 |
> |
|
625 |
> |
function FF_RequiresPostpairCalc() result(doesit) |
626 |
> |
logical :: doesit |
627 |
> |
doesit = FF_uses_RF |
628 |
> |
end function FF_RequiresPostpairCalc |
629 |
> |
|
630 |
|
end module do_Forces |