4 |
|
|
5 |
|
!! @author Charles F. Vardeman II |
6 |
|
!! @author Matthew Meineke |
7 |
< |
!! @version $Id: do_Forces.F90,v 1.8 2003-03-10 19:26:45 chuckv Exp $, $Date: 2003-03-10 19:26:45 $, $Name: not supported by cvs2svn $, $Revision: 1.8 $ |
7 |
> |
!! @version $Id: do_Forces.F90,v 1.11 2003-03-11 23:13:06 gezelter Exp $, $Date: 2003-03-11 23:13:06 $, $Name: not supported by cvs2svn $, $Revision: 1.11 $ |
8 |
|
|
9 |
|
|
10 |
|
|
16 |
|
use neighborLists |
17 |
|
|
18 |
|
|
19 |
< |
use lj_FF |
19 |
> |
use lj |
20 |
|
use sticky_FF |
21 |
< |
use dp_FF |
21 |
> |
use dipole_dipole |
22 |
|
use gb_FF |
23 |
|
|
24 |
|
#ifdef IS_MPI |
31 |
|
|
32 |
|
contains |
33 |
|
|
34 |
< |
!! Does force loop over i,j pairs. Calls do_pair to calculates forces. |
35 |
< |
!-------------------------------------------------------------> |
34 |
> |
!! Does force loop over i,j pairs. Calls do_pair to calculates forces. |
35 |
> |
!-------------------------------------------------------------> |
36 |
|
subroutine do_force_loop(q,A,mu,u_l,f,t,tau,potE,do_pot,FFerror) |
37 |
< |
!! Position array provided by C, dimensioned by getNlocal |
37 |
> |
!! Position array provided by C, dimensioned by getNlocal |
38 |
|
real ( kind = dp ), dimension(3,getNlocal()) :: q |
39 |
< |
!! Rotation Matrix for each long range particle in simulation. |
39 |
> |
!! Rotation Matrix for each long range particle in simulation. |
40 |
|
real( kind = dp), dimension(9,getNlocal()) :: A |
41 |
< |
|
42 |
< |
!! Magnitude dipole moment |
41 |
> |
|
42 |
> |
!! Magnitude dipole moment |
43 |
|
real( kind = dp ), dimension(3,getNlocal()) :: mu |
44 |
< |
!! Unit vectors for dipoles (lab frame) |
44 |
> |
!! Unit vectors for dipoles (lab frame) |
45 |
|
real( kind = dp ), dimension(3,getNlocal()) :: u_l |
46 |
< |
!! Force array provided by C, dimensioned by getNlocal |
46 |
> |
!! Force array provided by C, dimensioned by getNlocal |
47 |
|
real ( kind = dp ), dimension(3,getNlocal()) :: f |
48 |
< |
!! Torsion array provided by C, dimensioned by getNlocal |
48 |
> |
!! Torsion array provided by C, dimensioned by getNlocal |
49 |
|
real( kind = dp ), dimension(3,getNlocal()) :: t |
50 |
< |
|
51 |
< |
!! Stress Tensor |
50 |
> |
|
51 |
> |
!! Stress Tensor |
52 |
|
real( kind = dp), dimension(9) :: tau |
53 |
< |
|
53 |
> |
|
54 |
|
real ( kind = dp ) :: potE |
55 |
|
logical ( kind = 2) :: do_pot |
56 |
|
integer :: FFerror |
57 |
|
|
58 |
+ |
#ifdef IS_MPI |
59 |
+ |
real( kind = DP ) :: pot_local |
60 |
+ |
#endif |
61 |
|
|
62 |
< |
type(atype), pointer :: Atype_i |
63 |
< |
type(atype), pointer :: Atype_j |
62 |
> |
real( kind = DP ) :: pe |
63 |
> |
logical :: update_nlist |
64 |
> |
|
65 |
|
|
66 |
+ |
integer :: i, j, jbeg, jend, jnab, idim, jdim, idim2, jdim2, dim, dim2 |
67 |
+ |
integer :: nlist |
68 |
+ |
integer :: j_start |
69 |
+ |
|
70 |
+ |
real( kind = DP ) :: r_ij, pot, ftmp, dudr, d2, drdx1, kt1, kt2, kt3, ktmp |
71 |
+ |
|
72 |
+ |
real( kind = DP ) :: rx_ij, ry_ij, rz_ij, rijsq |
73 |
+ |
real( kind = DP ) :: rlistsq, rcutsq, rlist, rcut |
74 |
|
|
75 |
< |
|
64 |
< |
|
65 |
< |
|
66 |
< |
|
75 |
> |
! a rig that need to be fixed. |
76 |
|
#ifdef IS_MPI |
77 |
< |
real( kind = DP ) :: pot_local |
78 |
< |
|
70 |
< |
!! Local arrays needed for MPI |
71 |
< |
|
72 |
< |
#endif |
73 |
< |
|
74 |
< |
|
75 |
< |
|
76 |
< |
real( kind = DP ) :: pe |
77 |
< |
logical :: update_nlist |
78 |
< |
|
79 |
< |
|
80 |
< |
integer :: i, j, jbeg, jend, jnab, idim, jdim, idim2, jdim2, dim, dim2 |
81 |
< |
integer :: nlist |
82 |
< |
integer :: j_start |
83 |
< |
|
84 |
< |
real( kind = DP ) :: r_ij, pot, ftmp, dudr, d2, drdx1, kt1, kt2, kt3, ktmp |
85 |
< |
|
86 |
< |
real( kind = DP ) :: rx_ij, ry_ij, rz_ij, rijsq |
87 |
< |
real( kind = DP ) :: rlistsq, rcutsq,rlist,rcut |
88 |
< |
|
89 |
< |
|
90 |
< |
|
91 |
< |
! a rig that need to be fixed. |
92 |
< |
#ifdef IS_MPI |
93 |
< |
real( kind = dp ) :: pe_local |
94 |
< |
integer :: nlocal |
77 |
> |
real( kind = dp ) :: pe_local |
78 |
> |
integer :: nlocal |
79 |
|
#endif |
80 |
< |
integer :: nrow |
81 |
< |
integer :: ncol |
82 |
< |
integer :: natoms |
83 |
< |
integer :: neighborListSize |
84 |
< |
integer :: listerror |
85 |
< |
!! should we calculate the stress tensor |
86 |
< |
logical :: do_stress = .false. |
80 |
> |
integer :: nrow |
81 |
> |
integer :: ncol |
82 |
> |
integer :: natoms |
83 |
> |
integer :: neighborListSize |
84 |
> |
integer :: listerror |
85 |
> |
!! should we calculate the stress tensor |
86 |
> |
logical :: do_stress = .false. |
87 |
> |
FFerror = 0 |
88 |
|
|
89 |
< |
|
90 |
< |
FFerror = 0 |
91 |
< |
|
92 |
< |
! Make sure we are properly initialized. |
93 |
< |
if (.not. isFFInit) then |
94 |
< |
write(default_error,*) "ERROR: lj_FF has not been properly initialized" |
110 |
< |
FFerror = -1 |
111 |
< |
return |
112 |
< |
endif |
89 |
> |
! Make sure we are properly initialized. |
90 |
> |
if (.not. isFFInit) then |
91 |
> |
write(default_error,*) "ERROR: lj_FF has not been properly initialized" |
92 |
> |
FFerror = -1 |
93 |
> |
return |
94 |
> |
endif |
95 |
|
#ifdef IS_MPI |
96 |
|
if (.not. isMPISimSet()) then |
97 |
< |
write(default_error,*) "ERROR: mpiSimulation has not been properly initialized" |
98 |
< |
FFerror = -1 |
99 |
< |
return |
100 |
< |
endif |
97 |
> |
write(default_error,*) "ERROR: mpiSimulation has not been properly initialized" |
98 |
> |
FFerror = -1 |
99 |
> |
return |
100 |
> |
endif |
101 |
|
#endif |
102 |
< |
|
103 |
< |
!! initialize local variables |
104 |
< |
natoms = getNlocal() |
105 |
< |
call getRcut(rcut,rcut2=rcutsq) |
106 |
< |
call getRlist(rlist,rlistsq) |
107 |
< |
|
108 |
< |
!! Find ensemble |
109 |
< |
if (isEnsemble("NPT")) do_stress = .true. |
110 |
< |
!! set to wrap |
111 |
< |
if (isPBC()) wrap = .true. |
112 |
< |
|
113 |
< |
|
114 |
< |
|
115 |
< |
|
116 |
< |
!! See if we need to update neighbor lists |
135 |
< |
call check(q,update_nlist) |
136 |
< |
|
137 |
< |
!--------------WARNING........................... |
138 |
< |
! Zero variables, NOTE:::: Forces are zeroed in C |
139 |
< |
! Zeroing them here could delete previously computed |
140 |
< |
! Forces. |
141 |
< |
!------------------------------------------------ |
142 |
< |
call zero_module_variables() |
143 |
< |
|
144 |
< |
|
145 |
< |
! communicate MPI positions |
146 |
< |
#ifdef IS_MPI |
147 |
< |
call gather(q,qRow,plan_row3d) |
148 |
< |
call gather(q,qCol,plan_col3d) |
102 |
> |
|
103 |
> |
!! initialize local variables |
104 |
> |
natoms = getNlocal() |
105 |
> |
call getRcut(rcut,rcut2=rcutsq) |
106 |
> |
call getRlist(rlist,rlistsq) |
107 |
> |
|
108 |
> |
!! See if we need to update neighbor lists |
109 |
> |
call check(q, update_nlist) |
110 |
> |
|
111 |
> |
!--------------WARNING........................... |
112 |
> |
! Zero variables, NOTE:::: Forces are zeroed in C |
113 |
> |
! Zeroing them here could delete previously computed |
114 |
> |
! Forces. |
115 |
> |
!------------------------------------------------ |
116 |
> |
call zero_module_variables() |
117 |
|
|
118 |
< |
call gather(mu,muRow,plan_row3d) |
119 |
< |
call gather(mu,muCol,plan_col3d) |
120 |
< |
|
121 |
< |
call gather(u_l,u_lRow,plan_row3d) |
122 |
< |
call gather(u_l,u_lCol,plan_col3d) |
123 |
< |
|
124 |
< |
call gather(A,ARow,plan_row_rotation) |
125 |
< |
call gather(A,ACol,plan_col_rotation) |
118 |
> |
! communicate MPI positions |
119 |
> |
#ifdef IS_MPI |
120 |
> |
call gather(q,q_Row,plan_row3d) |
121 |
> |
call gather(q,q_Col,plan_col3d) |
122 |
> |
|
123 |
> |
call gather(u_l,u_l_Row,plan_row3d) |
124 |
> |
call gather(u_l,u_l_Col,plan_col3d) |
125 |
> |
|
126 |
> |
call gather(A,A_Row,plan_row_rotation) |
127 |
> |
call gather(A,A_Col,plan_col_rotation) |
128 |
|
#endif |
129 |
|
|
130 |
|
|
145 |
|
|
146 |
|
do i = 1, nrow |
147 |
|
point(i) = nlist + 1 |
178 |
– |
Atype_i => identPtrListRow(i)%this |
148 |
|
|
149 |
|
inner: do j = 1, ncol |
181 |
– |
Atype_j => identPtrListColumn(j)%this |
150 |
|
|
151 |
< |
call get_interatomic_vector(i,j,qRow(:,i),qCol(:,j),& |
152 |
< |
rxij,ryij,rzij,rijsq,r) |
153 |
< |
|
154 |
< |
! skip the loop if the atoms are identical |
187 |
< |
if (mpi_cycle_jLoop(i,j)) cycle inner: |
188 |
< |
|
151 |
> |
if (check_exclude(i,j)) cycle inner: |
152 |
> |
|
153 |
> |
call get_interatomic_vector(q_Row(:,i), q_Col(:,j), d, rijsq) |
154 |
> |
|
155 |
|
if (rijsq < rlistsq) then |
156 |
|
|
157 |
|
nlist = nlist + 1 |
166 |
|
endif |
167 |
|
|
168 |
|
list(nlist) = j |
169 |
< |
|
204 |
< |
|
169 |
> |
|
170 |
|
if (rijsq < rcutsq) then |
171 |
< |
call do_pair(Atype_i,Atype_j,i,j,r,rxij,ryij,rzij) |
171 |
> |
call do_pair(i, j, rijsq, d) |
172 |
|
endif |
173 |
|
endif |
174 |
|
enddo inner |
184 |
|
JEND = POINT(i+1) - 1 |
185 |
|
! check thiat molecule i has neighbors |
186 |
|
if (jbeg .le. jend) then |
187 |
< |
|
223 |
< |
Atype_i => identPtrListRow(i)%this |
187 |
> |
|
188 |
|
do jnab = jbeg, jend |
189 |
|
j = list(jnab) |
190 |
< |
Atype_j = identPtrListColumn(j)%this |
191 |
< |
call get_interatomic_vector(i,j,qRow(:,i),qCol(:,j),& |
192 |
< |
rxij,ryij,rzij,rijsq,r) |
193 |
< |
|
230 |
< |
call do_pair(Atype_i,Atype_j,i,j,r,rxij,ryij,rzij) |
190 |
> |
|
191 |
> |
call get_interatomic_vector(q_Row(:,i), q_Col(:,j), d, rijsq) |
192 |
> |
call do_pair(i, j, rijsq, d) |
193 |
> |
|
194 |
|
enddo |
195 |
|
endif |
196 |
|
enddo |
206 |
|
|
207 |
|
neighborListSize = getNeighborListSize() |
208 |
|
nlist = 0 |
209 |
< |
|
247 |
< |
|
209 |
> |
|
210 |
|
do i = 1, natoms-1 |
211 |
|
point(i) = nlist + 1 |
250 |
– |
Atype_i => identPtrList(i)%this |
212 |
|
|
213 |
|
inner: do j = i+1, natoms |
214 |
< |
Atype_j => identPtrList(j)%this |
215 |
< |
call get_interatomic_vector(i,j,q(:,i),q(:,j),& |
216 |
< |
rxij,ryij,rzij,rijsq,r) |
214 |
> |
|
215 |
> |
if (check_exclude(i,j)) cycle inner: |
216 |
> |
|
217 |
> |
call get_interatomic_vector(q(:,i), q(:,j), d, rijsq) |
218 |
|
|
219 |
|
if (rijsq < rlistsq) then |
220 |
< |
|
220 |
> |
|
221 |
|
nlist = nlist + 1 |
222 |
|
|
223 |
|
if (nlist > neighborListSize) then |
230 |
|
endif |
231 |
|
|
232 |
|
list(nlist) = j |
233 |
< |
|
272 |
< |
|
233 |
> |
|
234 |
|
if (rijsq < rcutsq) then |
235 |
< |
call do_pair(Atype_i,Atype_j,i,j,r,rxij,ryij,rzij) |
235 |
> |
call do_pair(i, j, rijsq, d) |
236 |
|
endif |
237 |
|
endif |
238 |
|
enddo inner |
249 |
|
! check thiat molecule i has neighbors |
250 |
|
if (jbeg .le. jend) then |
251 |
|
|
291 |
– |
Atype_i => identPtrList(i)%this |
252 |
|
do jnab = jbeg, jend |
253 |
|
j = list(jnab) |
254 |
< |
Atype_j = identPtrList(j)%this |
255 |
< |
call get_interatomic_vector(i,j,q(:,i),q(:,j),& |
256 |
< |
rxij,ryij,rzij,rijsq,r) |
257 |
< |
call do_pair(Atype_i,Atype_j,i,j,r,rxij,ryij,rzij) |
254 |
> |
|
255 |
> |
call get_interatomic_vector(q(:,i), q(:,j), d, rijsq) |
256 |
> |
call do_pair(i, j, rijsq, d) |
257 |
> |
|
258 |
|
enddo |
259 |
|
endif |
260 |
|
enddo |
261 |
|
endif |
262 |
< |
|
262 |
> |
|
263 |
|
#endif |
264 |
< |
|
265 |
< |
|
264 |
> |
|
265 |
> |
|
266 |
|
#ifdef IS_MPI |
267 |
|
!! distribute all reaction field stuff (or anything for post-pair): |
268 |
|
call scatter(rflRow,rflTemp1,plan_row3d) |
271 |
|
rflTemp(1:3,i) = rflTemp1(1:3,i) + rflTemp2(1:3,i) |
272 |
|
end do |
273 |
|
#endif |
274 |
< |
|
274 |
> |
|
275 |
|
! This is the post-pair loop: |
276 |
|
#ifdef IS_MPI |
277 |
< |
|
277 |
> |
|
278 |
|
if (system_has_postpair_atoms) then |
279 |
|
do i = 1, nlocal |
280 |
|
Atype_i => identPtrListRow(i)%this |
281 |
|
call do_postpair(i, Atype_i) |
282 |
|
enddo |
283 |
|
endif |
284 |
< |
|
284 |
> |
|
285 |
|
#else |
286 |
< |
|
286 |
> |
|
287 |
|
if (system_has_postpair_atoms) then |
288 |
|
do i = 1, natoms |
289 |
|
Atype_i => identPtr(i)%this |
290 |
|
call do_postpair(i, Atype_i) |
291 |
|
enddo |
292 |
|
endif |
293 |
< |
|
293 |
> |
|
294 |
|
#endif |
295 |
+ |
|
296 |
|
|
336 |
– |
|
337 |
– |
|
338 |
– |
|
297 |
|
#ifdef IS_MPI |
298 |
|
!!distribute forces |
299 |
|
|
300 |
< |
call scatter(fRow,fTemp1,plan_row3d) |
301 |
< |
call scatter(fCol,fTemp2,plan_col3d) |
344 |
< |
|
345 |
< |
|
300 |
> |
call scatter(f_Row,f,plan_row3d) |
301 |
> |
call scatter(f_Col,f_temp,plan_col3d) |
302 |
|
do i = 1,nlocal |
303 |
< |
fTemp(1:3,i) = fTemp1(1:3,i) + fTemp2(1:3,i) |
303 |
> |
f(1:3,i) = f(1:3,i) + f_temp(1:3,i) |
304 |
|
end do |
305 |
|
|
306 |
< |
if (do_torque) then |
307 |
< |
call scatter(tRow,tTemp1,plan_row3d) |
308 |
< |
call scatter(tCol,tTemp2,plan_col3d) |
306 |
> |
if (doTorque()) then |
307 |
> |
call scatter(t_Row,t,plan_row3d) |
308 |
> |
call scatter(t_Col,t_temp,plan_col3d) |
309 |
|
|
310 |
|
do i = 1,nlocal |
311 |
< |
tTemp(1:3,i) = tTemp1(1:3,i) + tTemp2(1:3,i) |
311 |
> |
t(1:3,i) = t(1:3,i) + t_temp(1:3,i) |
312 |
|
end do |
313 |
|
endif |
314 |
< |
|
314 |
> |
|
315 |
|
if (do_pot) then |
316 |
|
! scatter/gather pot_row into the members of my column |
317 |
< |
call scatter(eRow,eTemp,plan_row) |
317 |
> |
call scatter(pot_Row, pot_Temp, plan_row) |
318 |
|
|
319 |
|
! scatter/gather pot_local into all other procs |
320 |
|
! add resultant to get total pot |
321 |
|
do i = 1, nlocal |
322 |
< |
pe_local = pe_local + eTemp(i) |
322 |
> |
pot_local = pot_local + pot_Temp(i) |
323 |
|
enddo |
324 |
|
|
325 |
< |
eTemp = 0.0E0_DP |
326 |
< |
call scatter(eCol,eTemp,plan_col) |
325 |
> |
pot_Temp = 0.0_DP |
326 |
> |
|
327 |
> |
call scatter(pot_Col, pot_Temp, plan_col) |
328 |
|
do i = 1, nlocal |
329 |
< |
pe_local = pe_local + eTemp(i) |
329 |
> |
pot_local = pot_local + pot_Temp(i) |
330 |
|
enddo |
331 |
|
|
332 |
< |
pe = pe_local |
332 |
> |
pot = pot_local |
333 |
|
endif |
377 |
– |
#else |
378 |
– |
! Copy local array into return array for c |
379 |
– |
f = f+fTemp |
380 |
– |
t = t+tTemp |
381 |
– |
#endif |
334 |
|
|
335 |
< |
potE = pe |
335 |
> |
if (doStress()) then |
336 |
> |
mpi_allreduce(tau, tau_Temp,9,mpi_double_precision,mpi_sum, & |
337 |
> |
mpi_comm_world,mpi_err) |
338 |
> |
mpi_allreduce(virial, virial_Temp,1,mpi_double_precision,mpi_sum, & |
339 |
> |
mpi_comm_world,mpi_err) |
340 |
> |
endif |
341 |
|
|
342 |
+ |
#endif |
343 |
|
|
344 |
< |
if (do_stress) then |
345 |
< |
#ifdef IS_MPI |
346 |
< |
mpi_allreduce = (tau,tauTemp,9,mpi_double_precision,mpi_sum, & |
389 |
< |
mpi_comm_world,mpi_err) |
390 |
< |
#else |
391 |
< |
tau = tauTemp |
392 |
< |
#endif |
344 |
> |
if (doStress()) then |
345 |
> |
tau = tau_Temp |
346 |
> |
virial = virial_Temp |
347 |
|
endif |
348 |
|
|
349 |
|
end subroutine do_force_loop |
350 |
|
|
351 |
|
|
398 |
– |
|
399 |
– |
|
400 |
– |
|
401 |
– |
|
402 |
– |
|
403 |
– |
|
404 |
– |
|
405 |
– |
|
352 |
|
!! Calculate any pre-force loop components and update nlist if necessary. |
353 |
|
subroutine do_preForce(updateNlist) |
354 |
|
logical, intent(inout) :: updateNlist |
357 |
|
|
358 |
|
end subroutine do_preForce |
359 |
|
|
414 |
– |
|
415 |
– |
|
416 |
– |
|
417 |
– |
|
418 |
– |
|
419 |
– |
|
420 |
– |
|
421 |
– |
|
422 |
– |
|
423 |
– |
|
424 |
– |
|
425 |
– |
|
360 |
|
!! Calculate any post force loop components, i.e. reaction field, etc. |
361 |
|
subroutine do_postForce() |
362 |
|
|
364 |
|
|
365 |
|
end subroutine do_postForce |
366 |
|
|
367 |
+ |
subroutine do_pair(i, j, rijsq, d) |
368 |
|
|
369 |
+ |
integer, intent(in) :: i, j |
370 |
+ |
real ( kind = dp ), intent(in) :: rijsq |
371 |
+ |
real ( kind = dp ) :: r |
372 |
+ |
real ( kind = dp ), intent(inout) :: d(3) |
373 |
|
|
374 |
< |
|
436 |
< |
|
437 |
< |
|
438 |
< |
|
439 |
< |
|
440 |
< |
|
441 |
< |
|
442 |
< |
|
443 |
< |
|
444 |
< |
|
445 |
< |
|
446 |
< |
|
447 |
< |
|
448 |
< |
|
449 |
< |
subroutine do_pair(atype_i,atype_j,i,j,r_ij,rx_ij,ry_ij,rz_ij) |
450 |
< |
type (atype ), pointer, intent(inout) :: atype_i |
451 |
< |
type (atype ), pointer, intent(inout) :: atype_j |
452 |
< |
integer :: i |
453 |
< |
integer :: j |
454 |
< |
real ( kind = dp ), intent(inout) :: rx_ij |
455 |
< |
real ( kind = dp ), intent(inout) :: ry_ij |
456 |
< |
real ( kind = dp ), intent(inout) :: rz_ij |
457 |
< |
|
458 |
< |
|
459 |
< |
real( kind = dp ) :: fx = 0.0_dp |
460 |
< |
real( kind = dp ) :: fy = 0.0_dp |
461 |
< |
real( kind = dp ) :: fz = 0.0_dp |
462 |
< |
|
463 |
< |
real( kind = dp ) :: drdx = 0.0_dp |
464 |
< |
real( kind = dp ) :: drdy = 0.0_dp |
465 |
< |
real( kind = dp ) :: drdz = 0.0_dp |
374 |
> |
r = sqrt(rijsq) |
375 |
|
|
376 |
+ |
logical :: is_LJ_i, is_LJ_j |
377 |
+ |
logical :: is_DP_i, is_DP_j |
378 |
+ |
logical :: is_Sticky_i, is_Sticky_j |
379 |
+ |
integer :: me_i, me_j |
380 |
|
|
381 |
|
#ifdef IS_MPI |
382 |
|
|
383 |
< |
if (Atype_i%is_LJ .and. Atype_j%is_LJ) then |
384 |
< |
call getLJForce(r,pot,dudr,ljAtype_i,ljAtype_j,fx,fy,fz) |
472 |
< |
endif |
383 |
> |
me_i = atid_row(i) |
384 |
> |
me_j = atid_col(j) |
385 |
|
|
386 |
< |
if (Atype_i%is_dp .and. Atype_j%is_dp) then |
386 |
> |
#else |
387 |
|
|
388 |
< |
call dipole_dipole(i, j, atype_i, atype_j, rx_ij, ry_ij, rz_ij, r_ij, & |
389 |
< |
ulRow(:,i), ulCol(:,j), rt, rrf, pot) |
388 |
> |
me_i = atid(i) |
389 |
> |
me_j = atid(j) |
390 |
|
|
391 |
< |
if (do_reaction_field) then |
480 |
< |
call accumulate_rf(i, j, r_ij, rflRow(:,i), rflCol(:j), & |
481 |
< |
ulRow(:i), ulCol(:,j), rt, rrf) |
482 |
< |
endif |
391 |
> |
#endif |
392 |
|
|
393 |
< |
endif |
393 |
> |
call getElementProperty(atypes, me_i, "is_LJ", is_LJ_i) |
394 |
> |
call getElementProperty(atypes, me_j, "is_LJ", is_LJ_j) |
395 |
|
|
396 |
< |
if (Atype_i%is_sticky .and. Atype_j%is_sticky) then |
487 |
< |
call getstickyforce(r, pot, dudr, Atype_i, Atype_j) |
488 |
< |
endif |
396 |
> |
if ( is_LJ_i .and. is_LJ_j ) call do_lj_pair(i, j, d, r, pot, f) |
397 |
|
|
398 |
< |
#else |
398 |
> |
call getElementProperty(atypes, me_i, "is_DP", is_DP_i) |
399 |
> |
call getElementProperty(atypes, me_j, "is_DP", is_DP_j) |
400 |
|
|
401 |
< |
if (Atype_i%is_LJ .and. Atype_j%is_LJ) then |
493 |
< |
call getLJForce(r,pot,dudr,ljAtype_i,ljAtype_j,fx,fy,fz) |
494 |
< |
endif |
401 |
> |
if ( is_DP_i .and. is_DP_j ) then |
402 |
|
|
403 |
< |
if (Atype_i%is_dp .and. Atype_j%is_dp) then |
497 |
< |
call dipole_dipole(i, j, atype_i, atype_j, rx_ij, ry_ij, rz_ij, r_ij, & |
498 |
< |
ul(:,i), ul(:,j), rt, rrf, pot) |
403 |
> |
call do_dipole_pair(i, j, d, r, pot, u_l, f, t) |
404 |
|
|
405 |
|
if (do_reaction_field) then |
406 |
< |
call accumulate_rf(i, j, r_ij, rfl(:,i), rfl(:j), & |
502 |
< |
ul(:,i), ul(:,j), rt, rrf) |
406 |
> |
call accumulate_rf(i, j, r_ij) |
407 |
|
endif |
408 |
|
|
409 |
|
endif |
410 |
|
|
411 |
< |
if (Atype_i%is_sticky .and. Atype_j%is_sticky) then |
412 |
< |
call getstickyforce(r,pot,dudr, Atype_i, Atype_j) |
411 |
> |
call getElementProperty(atypes, me_i, "is_Sticky", is_Sticky_i) |
412 |
> |
call getElementProperty(atypes, me_j, "is_Sticky", is_Sticky_j) |
413 |
> |
|
414 |
> |
if ( is_Sticky_i .and. is_Sticky_j ) then |
415 |
> |
call do_sticky_pair(i, j, d, r, pot, u_l, f, t) |
416 |
|
endif |
417 |
|
|
418 |
< |
#endif |
512 |
< |
|
513 |
< |
|
514 |
< |
#ifdef IS_MPI |
515 |
< |
eRow(i) = eRow(i) + pot*0.5 |
516 |
< |
eCol(i) = eCol(i) + pot*0.5 |
517 |
< |
#else |
518 |
< |
pe = pe + pot |
519 |
< |
#endif |
520 |
< |
|
521 |
< |
drdx = -rxij / r |
522 |
< |
drdy = -ryij / r |
523 |
< |
drdz = -rzij / r |
524 |
< |
|
525 |
< |
fx = dudr * drdx |
526 |
< |
fy = dudr * drdy |
527 |
< |
fz = dudr * drdz |
528 |
< |
|
529 |
< |
#ifdef IS_MPI |
530 |
< |
fCol(1,j) = fCol(1,j) - fx |
531 |
< |
fCol(2,j) = fCol(2,j) - fy |
532 |
< |
fCol(3,j) = fCol(3,j) - fz |
533 |
< |
|
534 |
< |
fRow(1,j) = fRow(1,j) + fx |
535 |
< |
fRow(2,j) = fRow(2,j) + fy |
536 |
< |
fRow(3,j) = fRow(3,j) + fz |
537 |
< |
#else |
538 |
< |
fTemp(1,j) = fTemp(1,j) - fx |
539 |
< |
fTemp(2,j) = fTemp(2,j) - fy |
540 |
< |
fTemp(3,j) = fTemp(3,j) - fz |
541 |
< |
fTemp(1,i) = fTemp(1,i) + fx |
542 |
< |
fTemp(2,i) = fTemp(2,i) + fy |
543 |
< |
fTemp(3,i) = fTemp(3,i) + fz |
544 |
< |
#endif |
545 |
< |
|
546 |
< |
if (do_stress) then |
547 |
< |
tauTemp(1) = tauTemp(1) + fx * rxij |
548 |
< |
tauTemp(2) = tauTemp(2) + fx * ryij |
549 |
< |
tauTemp(3) = tauTemp(3) + fx * rzij |
550 |
< |
tauTemp(4) = tauTemp(4) + fy * rxij |
551 |
< |
tauTemp(5) = tauTemp(5) + fy * ryij |
552 |
< |
tauTemp(6) = tauTemp(6) + fy * rzij |
553 |
< |
tauTemp(7) = tauTemp(7) + fz * rxij |
554 |
< |
tauTemp(8) = tauTemp(8) + fz * ryij |
555 |
< |
tauTemp(9) = tauTemp(9) + fz * rzij |
556 |
< |
endif |
557 |
< |
|
558 |
< |
|
559 |
< |
|
418 |
> |
|
419 |
|
end subroutine do_pair |
420 |
|
|
421 |
|
|
422 |
< |
|
423 |
< |
|
565 |
< |
|
566 |
< |
|
567 |
< |
|
568 |
< |
|
569 |
< |
|
570 |
< |
|
571 |
< |
|
572 |
< |
|
573 |
< |
|
574 |
< |
|
575 |
< |
|
576 |
< |
|
577 |
< |
subroutine get_interatomic_vector(q_i,q_j,rx_ij,ry_ij,rz_ij,r_sq,r_ij) |
578 |
< |
!---------------- Arguments------------------------------- |
579 |
< |
!! index i |
580 |
< |
|
581 |
< |
!! Position array |
422 |
> |
subroutine get_interatomic_vector(q_i, q_j, d, r_sq) |
423 |
> |
|
424 |
|
real (kind = dp), dimension(3) :: q_i |
425 |
|
real (kind = dp), dimension(3) :: q_j |
584 |
– |
!! x component of vector between i and j |
585 |
– |
real ( kind = dp ), intent(out) :: rx_ij |
586 |
– |
!! y component of vector between i and j |
587 |
– |
real ( kind = dp ), intent(out) :: ry_ij |
588 |
– |
!! z component of vector between i and j |
589 |
– |
real ( kind = dp ), intent(out) :: rz_ij |
590 |
– |
!! magnitude of r squared |
426 |
|
real ( kind = dp ), intent(out) :: r_sq |
592 |
– |
!! magnitude of vector r between atoms i and j. |
593 |
– |
real ( kind = dp ), intent(out) :: r_ij |
594 |
– |
!! wrap into periodic box. |
595 |
– |
logical, intent(in) :: wrap |
596 |
– |
|
597 |
– |
!--------------- Local Variables--------------------------- |
598 |
– |
!! Distance between i and j |
427 |
|
real( kind = dp ) :: d(3) |
600 |
– |
!---------------- END DECLARATIONS------------------------- |
428 |
|
|
602 |
– |
|
603 |
– |
! Find distance between i and j |
429 |
|
d(1:3) = q_i(1:3) - q_j(1:3) |
430 |
< |
|
431 |
< |
! Wrap back into periodic box if necessary |
432 |
< |
if ( wrap ) then |
430 |
> |
|
431 |
> |
! Wrap back into periodic box if necessary |
432 |
> |
if ( isPBC() ) then |
433 |
|
d(1:3) = d(1:3) - thisSim%box(1:3) * sign(1.0_dp,thisSim%box(1:3)) * & |
434 |
|
int(abs(d(1:3)/thisSim%box(1:3) + 0.5_dp) |
435 |
< |
end if |
435 |
> |
endif |
436 |
|
|
612 |
– |
! Find Magnitude of the vector |
437 |
|
r_sq = dot_product(d,d) |
438 |
< |
r_ij = sqrt(r_sq) |
615 |
< |
|
616 |
< |
! Set each component for force calculation |
617 |
< |
rx_ij = d(1) |
618 |
< |
ry_ij = d(2) |
619 |
< |
rz_ij = d(3) |
620 |
< |
|
621 |
< |
|
438 |
> |
|
439 |
|
end subroutine get_interatomic_vector |
440 |
< |
|
440 |
> |
|
441 |
|
subroutine zero_module_variables() |
442 |
|
|
443 |
|
#ifndef IS_MPI |