1 |
+ |
!! |
2 |
+ |
!! Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
+ |
!! |
4 |
+ |
!! The University of Notre Dame grants you ("Licensee") a |
5 |
+ |
!! non-exclusive, royalty free, license to use, modify and |
6 |
+ |
!! redistribute this software in source and binary code form, provided |
7 |
+ |
!! that the following conditions are met: |
8 |
+ |
!! |
9 |
+ |
!! 1. Acknowledgement of the program authors must be made in any |
10 |
+ |
!! publication of scientific results based in part on use of the |
11 |
+ |
!! program. An acceptable form of acknowledgement is citation of |
12 |
+ |
!! the article in which the program was described (Matthew |
13 |
+ |
!! A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
14 |
+ |
!! J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
15 |
+ |
!! Parallel Simulation Engine for Molecular Dynamics," |
16 |
+ |
!! J. Comput. Chem. 26, pp. 252-271 (2005)) |
17 |
+ |
!! |
18 |
+ |
!! 2. Redistributions of source code must retain the above copyright |
19 |
+ |
!! notice, this list of conditions and the following disclaimer. |
20 |
+ |
!! |
21 |
+ |
!! 3. Redistributions in binary form must reproduce the above copyright |
22 |
+ |
!! notice, this list of conditions and the following disclaimer in the |
23 |
+ |
!! documentation and/or other materials provided with the |
24 |
+ |
!! distribution. |
25 |
+ |
!! |
26 |
+ |
!! This software is provided "AS IS," without a warranty of any |
27 |
+ |
!! kind. All express or implied conditions, representations and |
28 |
+ |
!! warranties, including any implied warranty of merchantability, |
29 |
+ |
!! fitness for a particular purpose or non-infringement, are hereby |
30 |
+ |
!! excluded. The University of Notre Dame and its licensors shall not |
31 |
+ |
!! be liable for any damages suffered by licensee as a result of |
32 |
+ |
!! using, modifying or distributing the software or its |
33 |
+ |
!! derivatives. In no event will the University of Notre Dame or its |
34 |
+ |
!! licensors be liable for any lost revenue, profit or data, or for |
35 |
+ |
!! direct, indirect, special, consequential, incidental or punitive |
36 |
+ |
!! damages, however caused and regardless of the theory of liability, |
37 |
+ |
!! arising out of the use of or inability to use software, even if the |
38 |
+ |
!! University of Notre Dame has been advised of the possibility of |
39 |
+ |
!! such damages. |
40 |
+ |
!! |
41 |
+ |
|
42 |
|
!! doForces.F90 |
43 |
|
!! module doForces |
44 |
|
!! Calculates Long Range forces. |
45 |
|
|
46 |
|
!! @author Charles F. Vardeman II |
47 |
|
!! @author Matthew Meineke |
48 |
< |
!! @version $Id: doForces.F90,v 1.6 2004-10-29 22:28:12 chrisfen Exp $, $Date: 2004-10-29 22:28:12 $, $Name: not supported by cvs2svn $, $Revision: 1.6 $ |
48 |
> |
!! @version $Id: doForces.F90,v 1.30 2005-08-17 15:26:37 gezelter Exp $, $Date: 2005-08-17 15:26:37 $, $Name: not supported by cvs2svn $, $Revision: 1.30 $ |
49 |
|
|
50 |
+ |
|
51 |
|
module doForces |
52 |
|
use force_globals |
53 |
|
use simulation |
56 |
|
use switcheroo |
57 |
|
use neighborLists |
58 |
|
use lj |
59 |
< |
use sticky_pair |
60 |
< |
use dipole_dipole |
19 |
< |
use charge_charge |
59 |
> |
use sticky |
60 |
> |
use electrostatic_module |
61 |
|
use reaction_field |
62 |
|
use gb_pair |
63 |
|
use shapes |
73 |
|
|
74 |
|
#define __FORTRAN90 |
75 |
|
#include "UseTheForce/fSwitchingFunction.h" |
76 |
+ |
#include "UseTheForce/fCutoffPolicy.h" |
77 |
+ |
#include "UseTheForce/DarkSide/fInteractionMap.h" |
78 |
|
|
79 |
+ |
|
80 |
|
INTEGER, PARAMETER:: PREPAIR_LOOP = 1 |
81 |
|
INTEGER, PARAMETER:: PAIR_LOOP = 2 |
82 |
|
|
39 |
– |
logical, save :: haveRlist = .false. |
83 |
|
logical, save :: haveNeighborList = .false. |
84 |
|
logical, save :: haveSIMvariables = .false. |
42 |
– |
logical, save :: havePropertyMap = .false. |
85 |
|
logical, save :: haveSaneForceField = .false. |
86 |
< |
|
86 |
> |
logical, save :: haveInteractionHash = .false. |
87 |
> |
logical, save :: haveGtypeCutoffMap = .false. |
88 |
> |
|
89 |
|
logical, save :: FF_uses_DirectionalAtoms |
90 |
< |
logical, save :: FF_uses_LennardJones |
47 |
< |
logical, save :: FF_uses_Electrostatic |
48 |
< |
logical, save :: FF_uses_charges |
49 |
< |
logical, save :: FF_uses_dipoles |
50 |
< |
logical, save :: FF_uses_sticky |
90 |
> |
logical, save :: FF_uses_Dipoles |
91 |
|
logical, save :: FF_uses_GayBerne |
92 |
|
logical, save :: FF_uses_EAM |
53 |
– |
logical, save :: FF_uses_Shapes |
54 |
– |
logical, save :: FF_uses_FLARB |
93 |
|
logical, save :: FF_uses_RF |
94 |
|
|
95 |
|
logical, save :: SIM_uses_DirectionalAtoms |
58 |
– |
logical, save :: SIM_uses_LennardJones |
59 |
– |
logical, save :: SIM_uses_Electrostatics |
60 |
– |
logical, save :: SIM_uses_Charges |
61 |
– |
logical, save :: SIM_uses_Dipoles |
62 |
– |
logical, save :: SIM_uses_Sticky |
63 |
– |
logical, save :: SIM_uses_GayBerne |
96 |
|
logical, save :: SIM_uses_EAM |
65 |
– |
logical, save :: SIM_uses_Shapes |
66 |
– |
logical, save :: SIM_uses_FLARB |
97 |
|
logical, save :: SIM_uses_RF |
98 |
|
logical, save :: SIM_requires_postpair_calc |
99 |
|
logical, save :: SIM_requires_prepair_calc |
100 |
|
logical, save :: SIM_uses_PBC |
71 |
– |
logical, save :: SIM_uses_molecular_cutoffs |
101 |
|
|
73 |
– |
real(kind=dp), save :: rlist, rlistsq |
74 |
– |
|
102 |
|
public :: init_FF |
103 |
+ |
public :: setDefaultCutoffs |
104 |
|
public :: do_force_loop |
105 |
< |
public :: setRlistDF |
105 |
> |
public :: createInteractionHash |
106 |
> |
public :: createGtypeCutoffMap |
107 |
|
|
108 |
|
#ifdef PROFILE |
109 |
|
public :: getforcetime |
111 |
|
real :: forceTimeInitial, forceTimeFinal |
112 |
|
integer :: nLoops |
113 |
|
#endif |
114 |
+ |
|
115 |
+ |
!! Variables for cutoff mapping and interaction mapping |
116 |
+ |
! Bit hash to determine pair-pair interactions. |
117 |
+ |
integer, dimension(:,:), allocatable :: InteractionHash |
118 |
+ |
real(kind=dp), dimension(:), allocatable :: atypeMaxCutoff |
119 |
+ |
real(kind=dp), dimension(:), allocatable :: groupMaxCutoff |
120 |
+ |
integer, dimension(:), allocatable :: groupToGtype |
121 |
+ |
real(kind=dp), dimension(:), allocatable :: gtypeMaxCutoff |
122 |
+ |
type ::gtypeCutoffs |
123 |
+ |
real(kind=dp) :: rcut |
124 |
+ |
real(kind=dp) :: rcutsq |
125 |
+ |
real(kind=dp) :: rlistsq |
126 |
+ |
end type gtypeCutoffs |
127 |
+ |
type(gtypeCutoffs), dimension(:,:), allocatable :: gtypeCutoffMap |
128 |
|
|
129 |
< |
type :: Properties |
130 |
< |
logical :: is_Directional = .false. |
131 |
< |
logical :: is_LennardJones = .false. |
89 |
< |
logical :: is_Electrostatic = .false. |
90 |
< |
logical :: is_Charge = .false. |
91 |
< |
logical :: is_Dipole = .false. |
92 |
< |
logical :: is_Sticky = .false. |
93 |
< |
logical :: is_GayBerne = .false. |
94 |
< |
logical :: is_EAM = .false. |
95 |
< |
logical :: is_Shape = .false. |
96 |
< |
logical :: is_FLARB = .false. |
97 |
< |
end type Properties |
98 |
< |
|
99 |
< |
type(Properties), dimension(:),allocatable :: PropertyMap |
100 |
< |
|
129 |
> |
integer, save :: cutoffPolicy = TRADITIONAL_CUTOFF_POLICY |
130 |
> |
real(kind=dp),save :: defaultRcut, defaultRsw, defaultRlist |
131 |
> |
|
132 |
|
contains |
133 |
|
|
134 |
< |
subroutine setRlistDF( this_rlist ) |
104 |
< |
|
105 |
< |
real(kind=dp) :: this_rlist |
106 |
< |
|
107 |
< |
rlist = this_rlist |
108 |
< |
rlistsq = rlist * rlist |
109 |
< |
|
110 |
< |
haveRlist = .true. |
111 |
< |
|
112 |
< |
end subroutine setRlistDF |
113 |
< |
|
114 |
< |
subroutine createPropertyMap(status) |
134 |
> |
subroutine createInteractionHash(status) |
135 |
|
integer :: nAtypes |
136 |
< |
integer :: status |
136 |
> |
integer, intent(out) :: status |
137 |
|
integer :: i |
138 |
< |
logical :: thisProperty |
139 |
< |
real (kind=DP) :: thisDPproperty |
138 |
> |
integer :: j |
139 |
> |
integer :: iHash |
140 |
> |
!! Test Types |
141 |
> |
logical :: i_is_LJ |
142 |
> |
logical :: i_is_Elect |
143 |
> |
logical :: i_is_Sticky |
144 |
> |
logical :: i_is_StickyP |
145 |
> |
logical :: i_is_GB |
146 |
> |
logical :: i_is_EAM |
147 |
> |
logical :: i_is_Shape |
148 |
> |
logical :: j_is_LJ |
149 |
> |
logical :: j_is_Elect |
150 |
> |
logical :: j_is_Sticky |
151 |
> |
logical :: j_is_StickyP |
152 |
> |
logical :: j_is_GB |
153 |
> |
logical :: j_is_EAM |
154 |
> |
logical :: j_is_Shape |
155 |
> |
|
156 |
> |
status = 0 |
157 |
|
|
158 |
< |
status = 0 |
159 |
< |
|
158 |
> |
if (.not. associated(atypes)) then |
159 |
> |
call handleError("atype", "atypes was not present before call of createInteractionHash!") |
160 |
> |
status = -1 |
161 |
> |
return |
162 |
> |
endif |
163 |
> |
|
164 |
|
nAtypes = getSize(atypes) |
165 |
< |
|
165 |
> |
|
166 |
|
if (nAtypes == 0) then |
167 |
|
status = -1 |
168 |
|
return |
169 |
|
end if |
170 |
< |
|
171 |
< |
if (.not. allocated(PropertyMap)) then |
172 |
< |
allocate(PropertyMap(nAtypes)) |
170 |
> |
|
171 |
> |
if (.not. allocated(InteractionHash)) then |
172 |
> |
allocate(InteractionHash(nAtypes,nAtypes)) |
173 |
|
endif |
174 |
|
|
175 |
+ |
if (.not. allocated(atypeMaxCutoff)) then |
176 |
+ |
allocate(atypeMaxCutoff(nAtypes)) |
177 |
+ |
endif |
178 |
+ |
|
179 |
|
do i = 1, nAtypes |
180 |
< |
call getElementProperty(atypes, i, "is_Directional", thisProperty) |
181 |
< |
PropertyMap(i)%is_Directional = thisProperty |
180 |
> |
call getElementProperty(atypes, i, "is_LennardJones", i_is_LJ) |
181 |
> |
call getElementProperty(atypes, i, "is_Electrostatic", i_is_Elect) |
182 |
> |
call getElementProperty(atypes, i, "is_Sticky", i_is_Sticky) |
183 |
> |
call getElementProperty(atypes, i, "is_StickyPower", i_is_StickyP) |
184 |
> |
call getElementProperty(atypes, i, "is_GayBerne", i_is_GB) |
185 |
> |
call getElementProperty(atypes, i, "is_EAM", i_is_EAM) |
186 |
> |
call getElementProperty(atypes, i, "is_Shape", i_is_Shape) |
187 |
|
|
188 |
< |
call getElementProperty(atypes, i, "is_LennardJones", thisProperty) |
139 |
< |
PropertyMap(i)%is_LennardJones = thisProperty |
140 |
< |
|
141 |
< |
call getElementProperty(atypes, i, "is_Electrostatic", thisProperty) |
142 |
< |
PropertyMap(i)%is_Electrostatic = thisProperty |
188 |
> |
do j = i, nAtypes |
189 |
|
|
190 |
< |
call getElementProperty(atypes, i, "is_Charge", thisProperty) |
191 |
< |
PropertyMap(i)%is_Charge = thisProperty |
146 |
< |
|
147 |
< |
call getElementProperty(atypes, i, "is_Dipole", thisProperty) |
148 |
< |
PropertyMap(i)%is_Dipole = thisProperty |
190 |
> |
iHash = 0 |
191 |
> |
myRcut = 0.0_dp |
192 |
|
|
193 |
< |
call getElementProperty(atypes, i, "is_Sticky", thisProperty) |
194 |
< |
PropertyMap(i)%is_Sticky = thisProperty |
193 |
> |
call getElementProperty(atypes, j, "is_LennardJones", j_is_LJ) |
194 |
> |
call getElementProperty(atypes, j, "is_Electrostatic", j_is_Elect) |
195 |
> |
call getElementProperty(atypes, j, "is_Sticky", j_is_Sticky) |
196 |
> |
call getElementProperty(atypes, j, "is_StickyPower", j_is_StickyP) |
197 |
> |
call getElementProperty(atypes, j, "is_GayBerne", j_is_GB) |
198 |
> |
call getElementProperty(atypes, j, "is_EAM", j_is_EAM) |
199 |
> |
call getElementProperty(atypes, j, "is_Shape", j_is_Shape) |
200 |
|
|
201 |
< |
call getElementProperty(atypes, i, "is_GayBerne", thisProperty) |
202 |
< |
PropertyMap(i)%is_GayBerne = thisProperty |
201 |
> |
if (i_is_LJ .and. j_is_LJ) then |
202 |
> |
iHash = ior(iHash, LJ_PAIR) |
203 |
> |
endif |
204 |
> |
|
205 |
> |
if (i_is_Elect .and. j_is_Elect) then |
206 |
> |
iHash = ior(iHash, ELECTROSTATIC_PAIR) |
207 |
> |
endif |
208 |
> |
|
209 |
> |
if (i_is_Sticky .and. j_is_Sticky) then |
210 |
> |
iHash = ior(iHash, STICKY_PAIR) |
211 |
> |
endif |
212 |
|
|
213 |
< |
call getElementProperty(atypes, i, "is_EAM", thisProperty) |
214 |
< |
PropertyMap(i)%is_EAM = thisProperty |
213 |
> |
if (i_is_StickyP .and. j_is_StickyP) then |
214 |
> |
iHash = ior(iHash, STICKYPOWER_PAIR) |
215 |
> |
endif |
216 |
|
|
217 |
< |
call getElementProperty(atypes, i, "is_Shape", thisProperty) |
218 |
< |
PropertyMap(i)%is_Shape = thisProperty |
217 |
> |
if (i_is_EAM .and. j_is_EAM) then |
218 |
> |
iHash = ior(iHash, EAM_PAIR) |
219 |
> |
endif |
220 |
|
|
221 |
< |
call getElementProperty(atypes, i, "is_FLARB", thisProperty) |
222 |
< |
PropertyMap(i)%is_FLARB = thisProperty |
221 |
> |
if (i_is_GB .and. j_is_GB) iHash = ior(iHash, GAYBERNE_PAIR) |
222 |
> |
if (i_is_GB .and. j_is_LJ) iHash = ior(iHash, GAYBERNE_LJ) |
223 |
> |
if (i_is_LJ .and. j_is_GB) iHash = ior(iHash, GAYBERNE_LJ) |
224 |
> |
|
225 |
> |
if (i_is_Shape .and. j_is_Shape) iHash = ior(iHash, SHAPE_PAIR) |
226 |
> |
if (i_is_Shape .and. j_is_LJ) iHash = ior(iHash, SHAPE_LJ) |
227 |
> |
if (i_is_LJ .and. j_is_Shape) iHash = ior(iHash, SHAPE_LJ) |
228 |
> |
|
229 |
> |
|
230 |
> |
InteractionHash(i,j) = iHash |
231 |
> |
InteractionHash(j,i) = iHash |
232 |
> |
|
233 |
> |
end do |
234 |
> |
|
235 |
|
end do |
236 |
|
|
237 |
< |
havePropertyMap = .true. |
237 |
> |
haveInteractionHash = .true. |
238 |
> |
end subroutine createInteractionHash |
239 |
|
|
240 |
< |
end subroutine createPropertyMap |
240 |
> |
subroutine createGtypeCutoffMap() |
241 |
|
|
242 |
+ |
logical :: i_is_LJ |
243 |
+ |
logical :: i_is_Elect |
244 |
+ |
logical :: i_is_Sticky |
245 |
+ |
logical :: i_is_StickyP |
246 |
+ |
logical :: i_is_GB |
247 |
+ |
logical :: i_is_EAM |
248 |
+ |
logical :: i_is_Shape |
249 |
+ |
|
250 |
+ |
integer :: myStatus, nAtypes |
251 |
+ |
real(kind=dp):: thisSigma, bigSigma |
252 |
+ |
|
253 |
+ |
stat = 0 |
254 |
+ |
if (.not. haveInteractionHash) then |
255 |
+ |
call createInteractionHash(myStatus) |
256 |
+ |
if (myStatus .ne. 0) then |
257 |
+ |
write(default_error, *) 'createInteractionHash failed in doForces!' |
258 |
+ |
stat = -1 |
259 |
+ |
return |
260 |
+ |
endif |
261 |
+ |
endif |
262 |
+ |
|
263 |
+ |
nAtypes = getSize(atypes) |
264 |
+ |
|
265 |
+ |
do i = 1, nAtypes |
266 |
+ |
if (SimHasAtype(i)) then |
267 |
+ |
call getElementProperty(atypes, i, "is_LennardJones", i_is_LJ) |
268 |
+ |
call getElementProperty(atypes, i, "is_Electrostatic", i_is_Elect) |
269 |
+ |
call getElementProperty(atypes, i, "is_Sticky", i_is_Sticky) |
270 |
+ |
call getElementProperty(atypes, i, "is_StickyPower", i_is_StickyP) |
271 |
+ |
call getElementProperty(atypes, i, "is_GayBerne", i_is_GB) |
272 |
+ |
call getElementProperty(atypes, i, "is_EAM", i_is_EAM) |
273 |
+ |
call getElementProperty(atypes, i, "is_Shape", i_is_Shape) |
274 |
+ |
|
275 |
+ |
if (i_is_LJ) then |
276 |
+ |
thisRcut = getSigma(i) * 2.5_dp |
277 |
+ |
if (thisRCut .gt. atypeMaxCutoff(i)) atypeMaxCutoff(i) = thisRCut |
278 |
+ |
endif |
279 |
+ |
if (i_is_Elect) then |
280 |
+ |
thisRcut = defaultRcut |
281 |
+ |
if (thisRCut .gt. atypeMaxCutoff(i)) atypeMaxCutoff(i) = thisRCut |
282 |
+ |
endif |
283 |
+ |
if (i_is_Sticky) then |
284 |
+ |
thisRcut = getStickyCut(i) |
285 |
+ |
if (thisRCut .gt. atypeMaxCutoff(i)) atypeMaxCutoff(i) = thisRCut |
286 |
+ |
endif |
287 |
+ |
if (i_is_StickyPower) then |
288 |
+ |
thisRcut = getStickyPowerCut(i) |
289 |
+ |
if (thisRCut .gt. atypeMaxCutoff(i)) atypeMaxCutoff(i) = thisRCut |
290 |
+ |
endif |
291 |
+ |
if (i_is_GayBerne) then |
292 |
+ |
thisRcut = getGayBerneCut(i) |
293 |
+ |
if (thisRCut .gt. atypeMaxCutoff(i)) atypeMaxCutoff(i) = thisRCut |
294 |
+ |
endif |
295 |
+ |
if (i_is_EAM) then |
296 |
+ |
thisRcut = getEAMCut(i) |
297 |
+ |
if (thisRCut .gt. atypeMaxCutoff(i)) atypeMaxCutoff(i) = thisRCut |
298 |
+ |
endif |
299 |
+ |
if (i_is_Shape) then |
300 |
+ |
thisRcut = getShapeCut(i) |
301 |
+ |
if (thisRCut .gt. atypeMaxCutoff(i)) atypeMaxCutoff(i) = thisRCut |
302 |
+ |
endif |
303 |
+ |
|
304 |
+ |
if (atypeMaxCutoff(i).gt.biggestAtypeCutoff) then |
305 |
+ |
biggestAtypeCutoff = atypeMaxCutoff(i) |
306 |
+ |
endif |
307 |
+ |
endif |
308 |
+ |
enddo |
309 |
+ |
|
310 |
+ |
istart = 1 |
311 |
+ |
#ifdef IS_MPI |
312 |
+ |
iend = nGroupsInRow |
313 |
+ |
#else |
314 |
+ |
iend = nGroups |
315 |
+ |
#endif |
316 |
+ |
outer: do i = istart, iend |
317 |
+ |
|
318 |
+ |
n_in_i = groupStartRow(i+1) - groupStartRow(i) |
319 |
+ |
|
320 |
+ |
#ifdef IS_MPI |
321 |
+ |
jstart = 1 |
322 |
+ |
jend = nGroupsInCol |
323 |
+ |
#else |
324 |
+ |
jstart = i+1 |
325 |
+ |
jend = nGroups |
326 |
+ |
#endif |
327 |
+ |
|
328 |
+ |
|
329 |
+ |
|
330 |
+ |
|
331 |
+ |
|
332 |
+ |
|
333 |
+ |
|
334 |
+ |
haveGtypeCutoffMap = .true. |
335 |
+ |
end subroutine createGtypeCutoffMap |
336 |
+ |
|
337 |
+ |
subroutine setDefaultCutoffs(defRcut, defRsw, defRlist, cutPolicy) |
338 |
+ |
real(kind=dp),intent(in) :: defRcut, defRsw, defRlist |
339 |
+ |
integer, intent(in) :: cutPolicy |
340 |
+ |
|
341 |
+ |
defaultRcut = defRcut |
342 |
+ |
defaultRsw = defRsw |
343 |
+ |
defaultRlist = defRlist |
344 |
+ |
cutoffPolicy = cutPolicy |
345 |
+ |
end subroutine setDefaultCutoffs |
346 |
+ |
|
347 |
+ |
subroutine setCutoffPolicy(cutPolicy) |
348 |
+ |
|
349 |
+ |
integer, intent(in) :: cutPolicy |
350 |
+ |
cutoffPolicy = cutPolicy |
351 |
+ |
call createGtypeCutoffMap() |
352 |
+ |
|
353 |
+ |
end subroutine setDefaultCutoffs |
354 |
+ |
|
355 |
+ |
|
356 |
|
subroutine setSimVariables() |
357 |
|
SIM_uses_DirectionalAtoms = SimUsesDirectionalAtoms() |
172 |
– |
SIM_uses_LennardJones = SimUsesLennardJones() |
173 |
– |
SIM_uses_Electrostatics = SimUsesElectrostatics() |
174 |
– |
SIM_uses_Charges = SimUsesCharges() |
175 |
– |
SIM_uses_Dipoles = SimUsesDipoles() |
176 |
– |
SIM_uses_Sticky = SimUsesSticky() |
177 |
– |
SIM_uses_GayBerne = SimUsesGayBerne() |
358 |
|
SIM_uses_EAM = SimUsesEAM() |
179 |
– |
SIM_uses_Shapes = SimUsesShapes() |
180 |
– |
SIM_uses_FLARB = SimUsesFLARB() |
359 |
|
SIM_uses_RF = SimUsesRF() |
360 |
|
SIM_requires_postpair_calc = SimRequiresPostpairCalc() |
361 |
|
SIM_requires_prepair_calc = SimRequiresPrepairCalc() |
372 |
|
integer :: myStatus |
373 |
|
|
374 |
|
error = 0 |
197 |
– |
|
198 |
– |
if (.not. havePropertyMap) then |
375 |
|
|
376 |
< |
myStatus = 0 |
376 |
> |
if (.not. haveInteractionHash) then |
377 |
> |
myStatus = 0 |
378 |
> |
call createInteractionHash(myStatus) |
379 |
> |
if (myStatus .ne. 0) then |
380 |
> |
write(default_error, *) 'createInteractionHash failed in doForces!' |
381 |
> |
error = -1 |
382 |
> |
return |
383 |
> |
endif |
384 |
> |
endif |
385 |
|
|
386 |
< |
call createPropertyMap(myStatus) |
387 |
< |
|
386 |
> |
if (.not. haveGtypeCutoffMap) then |
387 |
> |
myStatus = 0 |
388 |
> |
call createGtypeCutoffMap(myStatus) |
389 |
|
if (myStatus .ne. 0) then |
390 |
< |
write(default_error, *) 'createPropertyMap failed in doForces!' |
390 |
> |
write(default_error, *) 'createGtypeCutoffMap failed in doForces!' |
391 |
|
error = -1 |
392 |
|
return |
393 |
|
endif |
424 |
|
#endif |
425 |
|
return |
426 |
|
end subroutine doReadyCheck |
242 |
– |
|
427 |
|
|
428 |
+ |
|
429 |
|
subroutine init_FF(use_RF_c, thisStat) |
430 |
|
|
431 |
|
logical, intent(in) :: use_RF_c |
440 |
|
|
441 |
|
!! Fortran's version of a cast: |
442 |
|
FF_uses_RF = use_RF_c |
443 |
< |
|
443 |
> |
|
444 |
|
!! init_FF is called *after* all of the atom types have been |
445 |
|
!! defined in atype_module using the new_atype subroutine. |
446 |
|
!! |
447 |
|
!! this will scan through the known atypes and figure out what |
448 |
|
!! interactions are used by the force field. |
449 |
< |
|
449 |
> |
|
450 |
|
FF_uses_DirectionalAtoms = .false. |
266 |
– |
FF_uses_LennardJones = .false. |
267 |
– |
FF_uses_Electrostatic = .false. |
268 |
– |
FF_uses_Charges = .false. |
451 |
|
FF_uses_Dipoles = .false. |
270 |
– |
FF_uses_Sticky = .false. |
452 |
|
FF_uses_GayBerne = .false. |
453 |
|
FF_uses_EAM = .false. |
454 |
< |
FF_uses_Shapes = .false. |
274 |
< |
FF_uses_FLARB = .false. |
275 |
< |
|
454 |
> |
|
455 |
|
call getMatchingElementList(atypes, "is_Directional", .true., & |
456 |
|
nMatches, MatchList) |
457 |
|
if (nMatches .gt. 0) FF_uses_DirectionalAtoms = .true. |
458 |
|
|
280 |
– |
call getMatchingElementList(atypes, "is_LennardJones", .true., & |
281 |
– |
nMatches, MatchList) |
282 |
– |
if (nMatches .gt. 0) FF_uses_LennardJones = .true. |
283 |
– |
|
284 |
– |
call getMatchingElementList(atypes, "is_Electrostatic", .true., & |
285 |
– |
nMatches, MatchList) |
286 |
– |
if (nMatches .gt. 0) then |
287 |
– |
FF_uses_Electrostatic = .true. |
288 |
– |
endif |
289 |
– |
|
290 |
– |
call getMatchingElementList(atypes, "is_Charge", .true., & |
291 |
– |
nMatches, MatchList) |
292 |
– |
if (nMatches .gt. 0) then |
293 |
– |
FF_uses_charges = .true. |
294 |
– |
FF_uses_electrostatic = .true. |
295 |
– |
endif |
296 |
– |
|
459 |
|
call getMatchingElementList(atypes, "is_Dipole", .true., & |
460 |
|
nMatches, MatchList) |
461 |
< |
if (nMatches .gt. 0) then |
300 |
< |
FF_uses_dipoles = .true. |
301 |
< |
FF_uses_electrostatic = .true. |
302 |
< |
FF_uses_DirectionalAtoms = .true. |
303 |
< |
endif |
461 |
> |
if (nMatches .gt. 0) FF_uses_Dipoles = .true. |
462 |
|
|
305 |
– |
call getMatchingElementList(atypes, "is_Sticky", .true., nMatches, & |
306 |
– |
MatchList) |
307 |
– |
if (nMatches .gt. 0) then |
308 |
– |
FF_uses_Sticky = .true. |
309 |
– |
FF_uses_DirectionalAtoms = .true. |
310 |
– |
endif |
311 |
– |
|
463 |
|
call getMatchingElementList(atypes, "is_GayBerne", .true., & |
464 |
|
nMatches, MatchList) |
465 |
< |
if (nMatches .gt. 0) then |
466 |
< |
FF_uses_GayBerne = .true. |
316 |
< |
FF_uses_DirectionalAtoms = .true. |
317 |
< |
endif |
318 |
< |
|
465 |
> |
if (nMatches .gt. 0) FF_uses_GayBerne = .true. |
466 |
> |
|
467 |
|
call getMatchingElementList(atypes, "is_EAM", .true., nMatches, MatchList) |
468 |
|
if (nMatches .gt. 0) FF_uses_EAM = .true. |
321 |
– |
|
322 |
– |
call getMatchingElementList(atypes, "is_Shape", .true., & |
323 |
– |
nMatches, MatchList) |
324 |
– |
if (nMatches .gt. 0) then |
325 |
– |
FF_uses_Shapes = .true. |
326 |
– |
FF_uses_DirectionalAtoms = .true. |
327 |
– |
endif |
469 |
|
|
329 |
– |
call getMatchingElementList(atypes, "is_FLARB", .true., & |
330 |
– |
nMatches, MatchList) |
331 |
– |
if (nMatches .gt. 0) FF_uses_FLARB = .true. |
470 |
|
|
333 |
– |
!! Assume sanity (for the sake of argument) |
471 |
|
haveSaneForceField = .true. |
472 |
< |
|
472 |
> |
|
473 |
|
!! check to make sure the FF_uses_RF setting makes sense |
474 |
< |
|
475 |
< |
if (FF_uses_dipoles) then |
474 |
> |
|
475 |
> |
if (FF_uses_Dipoles) then |
476 |
|
if (FF_uses_RF) then |
477 |
|
dielect = getDielect() |
478 |
|
call initialize_rf(dielect) |
484 |
|
haveSaneForceField = .false. |
485 |
|
return |
486 |
|
endif |
350 |
– |
endif |
351 |
– |
|
352 |
– |
if (FF_uses_sticky) then |
353 |
– |
call check_sticky_FF(my_status) |
354 |
– |
if (my_status /= 0) then |
355 |
– |
thisStat = -1 |
356 |
– |
haveSaneForceField = .false. |
357 |
– |
return |
358 |
– |
end if |
487 |
|
endif |
488 |
|
|
489 |
|
if (FF_uses_EAM) then |
490 |
< |
call init_EAM_FF(my_status) |
490 |
> |
call init_EAM_FF(my_status) |
491 |
|
if (my_status /= 0) then |
492 |
|
write(default_error, *) "init_EAM_FF returned a bad status" |
493 |
|
thisStat = -1 |
505 |
|
endif |
506 |
|
endif |
507 |
|
|
380 |
– |
if (FF_uses_GayBerne .and. FF_uses_LennardJones) then |
381 |
– |
endif |
382 |
– |
|
508 |
|
if (.not. haveNeighborList) then |
509 |
|
!! Create neighbor lists |
510 |
|
call expandNeighborList(nLocal, my_status) |
514 |
|
return |
515 |
|
endif |
516 |
|
haveNeighborList = .true. |
517 |
< |
endif |
518 |
< |
|
517 |
> |
endif |
518 |
> |
|
519 |
|
end subroutine init_FF |
395 |
– |
|
520 |
|
|
521 |
+ |
|
522 |
|
!! Does force loop over i,j pairs. Calls do_pair to calculates forces. |
523 |
|
!-------------------------------------------------------------> |
524 |
< |
subroutine do_force_loop(q, q_group, A, u_l, f, t, tau, pot, & |
524 |
> |
subroutine do_force_loop(q, q_group, A, eFrame, f, t, tau, pot, & |
525 |
|
do_pot_c, do_stress_c, error) |
526 |
|
!! Position array provided by C, dimensioned by getNlocal |
527 |
|
real ( kind = dp ), dimension(3, nLocal) :: q |
530 |
|
!! Rotation Matrix for each long range particle in simulation. |
531 |
|
real( kind = dp), dimension(9, nLocal) :: A |
532 |
|
!! Unit vectors for dipoles (lab frame) |
533 |
< |
real( kind = dp ), dimension(3,nLocal) :: u_l |
533 |
> |
real( kind = dp ), dimension(9,nLocal) :: eFrame |
534 |
|
!! Force array provided by C, dimensioned by getNlocal |
535 |
|
real ( kind = dp ), dimension(3,nLocal) :: f |
536 |
|
!! Torsion array provided by C, dimensioned by getNlocal |
568 |
|
integer :: localError |
569 |
|
integer :: propPack_i, propPack_j |
570 |
|
integer :: loopStart, loopEnd, loop |
571 |
< |
|
571 |
> |
integer :: iHash |
572 |
|
real(kind=dp) :: listSkin = 1.0 |
573 |
< |
|
573 |
> |
|
574 |
|
!! initialize local variables |
575 |
< |
|
575 |
> |
|
576 |
|
#ifdef IS_MPI |
577 |
|
pot_local = 0.0_dp |
578 |
|
nAtomsInRow = getNatomsInRow(plan_atom_row) |
582 |
|
#else |
583 |
|
natoms = nlocal |
584 |
|
#endif |
585 |
< |
|
585 |
> |
|
586 |
|
call doReadyCheck(localError) |
587 |
|
if ( localError .ne. 0 ) then |
588 |
|
call handleError("do_force_loop", "Not Initialized") |
590 |
|
return |
591 |
|
end if |
592 |
|
call zero_work_arrays() |
593 |
< |
|
593 |
> |
|
594 |
|
do_pot = do_pot_c |
595 |
|
do_stress = do_stress_c |
596 |
< |
|
596 |
> |
|
597 |
|
! Gather all information needed by all force loops: |
598 |
< |
|
598 |
> |
|
599 |
|
#ifdef IS_MPI |
600 |
< |
|
600 |
> |
|
601 |
|
call gather(q, q_Row, plan_atom_row_3d) |
602 |
|
call gather(q, q_Col, plan_atom_col_3d) |
603 |
|
|
604 |
|
call gather(q_group, q_group_Row, plan_group_row_3d) |
605 |
|
call gather(q_group, q_group_Col, plan_group_col_3d) |
606 |
< |
|
606 |
> |
|
607 |
|
if (FF_UsesDirectionalAtoms() .and. SIM_uses_DirectionalAtoms) then |
608 |
< |
call gather(u_l, u_l_Row, plan_atom_row_3d) |
609 |
< |
call gather(u_l, u_l_Col, plan_atom_col_3d) |
610 |
< |
|
608 |
> |
call gather(eFrame, eFrame_Row, plan_atom_row_rotation) |
609 |
> |
call gather(eFrame, eFrame_Col, plan_atom_col_rotation) |
610 |
> |
|
611 |
|
call gather(A, A_Row, plan_atom_row_rotation) |
612 |
|
call gather(A, A_Col, plan_atom_col_rotation) |
613 |
|
endif |
614 |
< |
|
614 |
> |
|
615 |
|
#endif |
616 |
< |
|
616 |
> |
|
617 |
|
!! Begin force loop timing: |
618 |
|
#ifdef PROFILE |
619 |
|
call cpu_time(forceTimeInitial) |
620 |
|
nloops = nloops + 1 |
621 |
|
#endif |
622 |
< |
|
622 |
> |
|
623 |
|
loopEnd = PAIR_LOOP |
624 |
|
if (FF_RequiresPrepairCalc() .and. SIM_requires_prepair_calc) then |
625 |
|
loopStart = PREPAIR_LOOP |
634 |
|
if (loop .eq. loopStart) then |
635 |
|
#ifdef IS_MPI |
636 |
|
call checkNeighborList(nGroupsInRow, q_group_row, listSkin, & |
637 |
< |
update_nlist) |
637 |
> |
update_nlist) |
638 |
|
#else |
639 |
|
call checkNeighborList(nGroups, q_group, listSkin, & |
640 |
< |
update_nlist) |
640 |
> |
update_nlist) |
641 |
|
#endif |
642 |
|
endif |
643 |
< |
|
643 |
> |
|
644 |
|
if (update_nlist) then |
645 |
|
!! save current configuration and construct neighbor list |
646 |
|
#ifdef IS_MPI |
651 |
|
neighborListSize = size(list) |
652 |
|
nlist = 0 |
653 |
|
endif |
654 |
< |
|
654 |
> |
|
655 |
|
istart = 1 |
656 |
|
#ifdef IS_MPI |
657 |
|
iend = nGroupsInRow |
661 |
|
outer: do i = istart, iend |
662 |
|
|
663 |
|
if (update_nlist) point(i) = nlist + 1 |
664 |
< |
|
664 |
> |
|
665 |
|
n_in_i = groupStartRow(i+1) - groupStartRow(i) |
666 |
< |
|
666 |
> |
|
667 |
|
if (update_nlist) then |
668 |
|
#ifdef IS_MPI |
669 |
|
jstart = 1 |
678 |
|
! make sure group i has neighbors |
679 |
|
if (jstart .gt. jend) cycle outer |
680 |
|
endif |
681 |
< |
|
681 |
> |
|
682 |
|
do jnab = jstart, jend |
683 |
|
if (update_nlist) then |
684 |
|
j = jnab |
687 |
|
endif |
688 |
|
|
689 |
|
#ifdef IS_MPI |
690 |
+ |
me_j = atid_col(j) |
691 |
|
call get_interatomic_vector(q_group_Row(:,i), & |
692 |
|
q_group_Col(:,j), d_grp, rgrpsq) |
693 |
|
#else |
694 |
+ |
me_j = atid(j) |
695 |
|
call get_interatomic_vector(q_group(:,i), & |
696 |
|
q_group(:,j), d_grp, rgrpsq) |
697 |
|
#endif |
698 |
|
|
699 |
< |
if (rgrpsq < rlistsq) then |
699 |
> |
if (rgrpsq < InteractionHash(me_i,me_j)%rListsq) then |
700 |
|
if (update_nlist) then |
701 |
|
nlist = nlist + 1 |
702 |
< |
|
702 |
> |
|
703 |
|
if (nlist > neighborListSize) then |
704 |
|
#ifdef IS_MPI |
705 |
|
call expandNeighborList(nGroupsInRow, listerror) |
713 |
|
end if |
714 |
|
neighborListSize = size(list) |
715 |
|
endif |
716 |
< |
|
716 |
> |
|
717 |
|
list(nlist) = j |
718 |
|
endif |
719 |
< |
|
719 |
> |
|
720 |
|
if (loop .eq. PAIR_LOOP) then |
721 |
|
vij = 0.0d0 |
722 |
|
fij(1:3) = 0.0d0 |
723 |
|
endif |
724 |
< |
|
724 |
> |
|
725 |
|
call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & |
726 |
|
in_switching_region) |
727 |
< |
|
727 |
> |
|
728 |
|
n_in_j = groupStartCol(j+1) - groupStartCol(j) |
729 |
< |
|
729 |
> |
|
730 |
|
do ia = groupStartRow(i), groupStartRow(i+1)-1 |
731 |
< |
|
731 |
> |
|
732 |
|
atom1 = groupListRow(ia) |
733 |
< |
|
733 |
> |
|
734 |
|
inner: do jb = groupStartCol(j), groupStartCol(j+1)-1 |
735 |
< |
|
735 |
> |
|
736 |
|
atom2 = groupListCol(jb) |
737 |
< |
|
737 |
> |
|
738 |
|
if (skipThisPair(atom1, atom2)) cycle inner |
739 |
|
|
740 |
|
if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then |
754 |
|
#ifdef IS_MPI |
755 |
|
call do_prepair(atom1, atom2, ratmsq, d_atm, sw, & |
756 |
|
rgrpsq, d_grp, do_pot, do_stress, & |
757 |
< |
u_l, A, f, t, pot_local) |
757 |
> |
eFrame, A, f, t, pot_local) |
758 |
|
#else |
759 |
|
call do_prepair(atom1, atom2, ratmsq, d_atm, sw, & |
760 |
|
rgrpsq, d_grp, do_pot, do_stress, & |
761 |
< |
u_l, A, f, t, pot) |
761 |
> |
eFrame, A, f, t, pot) |
762 |
|
#endif |
763 |
|
else |
764 |
|
#ifdef IS_MPI |
765 |
|
call do_pair(atom1, atom2, ratmsq, d_atm, sw, & |
766 |
|
do_pot, & |
767 |
< |
u_l, A, f, t, pot_local, vpair, fpair) |
767 |
> |
eFrame, A, f, t, pot_local, vpair, fpair) |
768 |
|
#else |
769 |
|
call do_pair(atom1, atom2, ratmsq, d_atm, sw, & |
770 |
|
do_pot, & |
771 |
< |
u_l, A, f, t, pot, vpair, fpair) |
771 |
> |
eFrame, A, f, t, pot, vpair, fpair) |
772 |
|
#endif |
773 |
|
|
774 |
|
vij = vij + vpair |
776 |
|
endif |
777 |
|
enddo inner |
778 |
|
enddo |
779 |
< |
|
779 |
> |
|
780 |
|
if (loop .eq. PAIR_LOOP) then |
781 |
|
if (in_switching_region) then |
782 |
|
swderiv = vij*dswdr/rgrp |
783 |
|
fij(1) = fij(1) + swderiv*d_grp(1) |
784 |
|
fij(2) = fij(2) + swderiv*d_grp(2) |
785 |
|
fij(3) = fij(3) + swderiv*d_grp(3) |
786 |
< |
|
786 |
> |
|
787 |
|
do ia=groupStartRow(i), groupStartRow(i+1)-1 |
788 |
|
atom1=groupListRow(ia) |
789 |
|
mf = mfactRow(atom1) |
797 |
|
f(3,atom1) = f(3,atom1) + swderiv*d_grp(3)*mf |
798 |
|
#endif |
799 |
|
enddo |
800 |
< |
|
800 |
> |
|
801 |
|
do jb=groupStartCol(j), groupStartCol(j+1)-1 |
802 |
|
atom2=groupListCol(jb) |
803 |
|
mf = mfactCol(atom2) |
812 |
|
#endif |
813 |
|
enddo |
814 |
|
endif |
815 |
< |
|
815 |
> |
|
816 |
|
if (do_stress) call add_stress_tensor(d_grp, fij) |
817 |
|
endif |
818 |
|
end if |
819 |
|
enddo |
820 |
|
enddo outer |
821 |
< |
|
821 |
> |
|
822 |
|
if (update_nlist) then |
823 |
|
#ifdef IS_MPI |
824 |
|
point(nGroupsInRow + 1) = nlist + 1 |
832 |
|
update_nlist = .false. |
833 |
|
endif |
834 |
|
endif |
835 |
< |
|
835 |
> |
|
836 |
|
if (loop .eq. PREPAIR_LOOP) then |
837 |
|
call do_preforce(nlocal, pot) |
838 |
|
endif |
839 |
< |
|
839 |
> |
|
840 |
|
enddo |
841 |
< |
|
841 |
> |
|
842 |
|
!! Do timing |
843 |
|
#ifdef PROFILE |
844 |
|
call cpu_time(forceTimeFinal) |
845 |
|
forceTime = forceTime + forceTimeFinal - forceTimeInitial |
846 |
|
#endif |
847 |
< |
|
847 |
> |
|
848 |
|
#ifdef IS_MPI |
849 |
|
!!distribute forces |
850 |
< |
|
850 |
> |
|
851 |
|
f_temp = 0.0_dp |
852 |
|
call scatter(f_Row,f_temp,plan_atom_row_3d) |
853 |
|
do i = 1,nlocal |
854 |
|
f(1:3,i) = f(1:3,i) + f_temp(1:3,i) |
855 |
|
end do |
856 |
< |
|
856 |
> |
|
857 |
|
f_temp = 0.0_dp |
858 |
|
call scatter(f_Col,f_temp,plan_atom_col_3d) |
859 |
|
do i = 1,nlocal |
860 |
|
f(1:3,i) = f(1:3,i) + f_temp(1:3,i) |
861 |
|
end do |
862 |
< |
|
862 |
> |
|
863 |
|
if (FF_UsesDirectionalAtoms() .and. SIM_uses_DirectionalAtoms) then |
864 |
|
t_temp = 0.0_dp |
865 |
|
call scatter(t_Row,t_temp,plan_atom_row_3d) |
868 |
|
end do |
869 |
|
t_temp = 0.0_dp |
870 |
|
call scatter(t_Col,t_temp,plan_atom_col_3d) |
871 |
< |
|
871 |
> |
|
872 |
|
do i = 1,nlocal |
873 |
|
t(1:3,i) = t(1:3,i) + t_temp(1:3,i) |
874 |
|
end do |
875 |
|
endif |
876 |
< |
|
876 |
> |
|
877 |
|
if (do_pot) then |
878 |
|
! scatter/gather pot_row into the members of my column |
879 |
|
call scatter(pot_Row, pot_Temp, plan_atom_row) |
880 |
< |
|
880 |
> |
|
881 |
|
! scatter/gather pot_local into all other procs |
882 |
|
! add resultant to get total pot |
883 |
|
do i = 1, nlocal |
884 |
|
pot_local = pot_local + pot_Temp(i) |
885 |
|
enddo |
886 |
< |
|
886 |
> |
|
887 |
|
pot_Temp = 0.0_DP |
888 |
< |
|
888 |
> |
|
889 |
|
call scatter(pot_Col, pot_Temp, plan_atom_col) |
890 |
|
do i = 1, nlocal |
891 |
|
pot_local = pot_local + pot_Temp(i) |
892 |
|
enddo |
893 |
< |
|
893 |
> |
|
894 |
|
endif |
895 |
|
#endif |
896 |
< |
|
896 |
> |
|
897 |
|
if (FF_RequiresPostpairCalc() .and. SIM_requires_postpair_calc) then |
898 |
< |
|
898 |
> |
|
899 |
|
if (FF_uses_RF .and. SIM_uses_RF) then |
900 |
< |
|
900 |
> |
|
901 |
|
#ifdef IS_MPI |
902 |
|
call scatter(rf_Row,rf,plan_atom_row_3d) |
903 |
|
call scatter(rf_Col,rf_Temp,plan_atom_col_3d) |
905 |
|
rf(1:3,i) = rf(1:3,i) + rf_Temp(1:3,i) |
906 |
|
end do |
907 |
|
#endif |
908 |
< |
|
908 |
> |
|
909 |
|
do i = 1, nLocal |
910 |
< |
|
910 |
> |
|
911 |
|
rfpot = 0.0_DP |
912 |
|
#ifdef IS_MPI |
913 |
|
me_i = atid_row(i) |
914 |
|
#else |
915 |
|
me_i = atid(i) |
916 |
|
#endif |
917 |
+ |
iHash = InteractionHash(me_i,me_j) |
918 |
|
|
919 |
< |
if (PropertyMap(me_i)%is_Dipole) then |
920 |
< |
|
919 |
> |
if ( iand(iHash, ELECTROSTATIC_PAIR).ne.0 ) then |
920 |
> |
|
921 |
|
mu_i = getDipoleMoment(me_i) |
922 |
< |
|
922 |
> |
|
923 |
|
!! The reaction field needs to include a self contribution |
924 |
|
!! to the field: |
925 |
< |
call accumulate_self_rf(i, mu_i, u_l) |
925 |
> |
call accumulate_self_rf(i, mu_i, eFrame) |
926 |
|
!! Get the reaction field contribution to the |
927 |
|
!! potential and torques: |
928 |
< |
call reaction_field_final(i, mu_i, u_l, rfpot, t, do_pot) |
928 |
> |
call reaction_field_final(i, mu_i, eFrame, rfpot, t, do_pot) |
929 |
|
#ifdef IS_MPI |
930 |
|
pot_local = pot_local + rfpot |
931 |
|
#else |
932 |
|
pot = pot + rfpot |
933 |
< |
|
933 |
> |
|
934 |
|
#endif |
935 |
< |
endif |
935 |
> |
endif |
936 |
|
enddo |
937 |
|
endif |
938 |
|
endif |
939 |
< |
|
940 |
< |
|
939 |
> |
|
940 |
> |
|
941 |
|
#ifdef IS_MPI |
942 |
< |
|
942 |
> |
|
943 |
|
if (do_pot) then |
944 |
|
pot = pot + pot_local |
945 |
|
!! we assume the c code will do the allreduce to get the total potential |
946 |
|
!! we could do it right here if we needed to... |
947 |
|
endif |
948 |
< |
|
948 |
> |
|
949 |
|
if (do_stress) then |
950 |
|
call mpi_allreduce(tau_Temp, tau, 9,mpi_double_precision,mpi_sum, & |
951 |
|
mpi_comm_world,mpi_err) |
952 |
|
call mpi_allreduce(virial_Temp, virial,1,mpi_double_precision,mpi_sum, & |
953 |
|
mpi_comm_world,mpi_err) |
954 |
|
endif |
955 |
< |
|
955 |
> |
|
956 |
|
#else |
957 |
< |
|
957 |
> |
|
958 |
|
if (do_stress) then |
959 |
|
tau = tau_Temp |
960 |
|
virial = virial_Temp |
961 |
|
endif |
962 |
< |
|
962 |
> |
|
963 |
|
#endif |
964 |
< |
|
964 |
> |
|
965 |
|
end subroutine do_force_loop |
966 |
< |
|
966 |
> |
|
967 |
|
subroutine do_pair(i, j, rijsq, d, sw, do_pot, & |
968 |
< |
u_l, A, f, t, pot, vpair, fpair) |
968 |
> |
eFrame, A, f, t, pot, vpair, fpair) |
969 |
|
|
970 |
|
real( kind = dp ) :: pot, vpair, sw |
971 |
|
real( kind = dp ), dimension(3) :: fpair |
972 |
|
real( kind = dp ), dimension(nLocal) :: mfact |
973 |
< |
real( kind = dp ), dimension(3,nLocal) :: u_l |
973 |
> |
real( kind = dp ), dimension(9,nLocal) :: eFrame |
974 |
|
real( kind = dp ), dimension(9,nLocal) :: A |
975 |
|
real( kind = dp ), dimension(3,nLocal) :: f |
976 |
|
real( kind = dp ), dimension(3,nLocal) :: t |
980 |
|
real ( kind = dp ), intent(inout) :: rijsq |
981 |
|
real ( kind = dp ) :: r |
982 |
|
real ( kind = dp ), intent(inout) :: d(3) |
983 |
+ |
real ( kind = dp ) :: ebalance |
984 |
|
integer :: me_i, me_j |
985 |
|
|
986 |
+ |
integer :: iHash |
987 |
+ |
|
988 |
|
r = sqrt(rijsq) |
989 |
|
vpair = 0.0d0 |
990 |
|
fpair(1:3) = 0.0d0 |
996 |
|
me_i = atid(i) |
997 |
|
me_j = atid(j) |
998 |
|
#endif |
999 |
< |
|
1000 |
< |
if (FF_uses_LennardJones .and. SIM_uses_LennardJones) then |
1001 |
< |
|
1002 |
< |
if ( PropertyMap(me_i)%is_LennardJones .and. & |
1003 |
< |
PropertyMap(me_j)%is_LennardJones ) then |
873 |
< |
call do_lj_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, f, do_pot) |
874 |
< |
endif |
875 |
< |
|
999 |
> |
|
1000 |
> |
iHash = InteractionHash(me_i, me_j) |
1001 |
> |
|
1002 |
> |
if ( iand(iHash, LJ_PAIR).ne.0 ) then |
1003 |
> |
call do_lj_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, f, do_pot) |
1004 |
|
endif |
1005 |
< |
|
1006 |
< |
if (FF_uses_charges .and. SIM_uses_charges) then |
1007 |
< |
|
1008 |
< |
if (PropertyMap(me_i)%is_Charge .and. PropertyMap(me_j)%is_Charge) then |
1009 |
< |
call do_charge_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1010 |
< |
pot, f, do_pot) |
1011 |
< |
endif |
1012 |
< |
|
1013 |
< |
endif |
1014 |
< |
|
887 |
< |
if (FF_uses_dipoles .and. SIM_uses_dipoles) then |
888 |
< |
|
889 |
< |
if ( PropertyMap(me_i)%is_Dipole .and. PropertyMap(me_j)%is_Dipole) then |
890 |
< |
call do_dipole_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
891 |
< |
pot, u_l, f, t, do_pot) |
892 |
< |
if (FF_uses_RF .and. SIM_uses_RF) then |
893 |
< |
call accumulate_rf(i, j, r, u_l, sw) |
894 |
< |
call rf_correct_forces(i, j, d, r, u_l, sw, f, fpair) |
895 |
< |
endif |
1005 |
> |
|
1006 |
> |
if ( iand(iHash, ELECTROSTATIC_PAIR).ne.0 ) then |
1007 |
> |
call doElectrostaticPair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1008 |
> |
pot, eFrame, f, t, do_pot) |
1009 |
> |
|
1010 |
> |
if (FF_uses_RF .and. SIM_uses_RF) then |
1011 |
> |
|
1012 |
> |
! CHECK ME (RF needs to know about all electrostatic types) |
1013 |
> |
call accumulate_rf(i, j, r, eFrame, sw) |
1014 |
> |
call rf_correct_forces(i, j, d, r, eFrame, sw, f, fpair) |
1015 |
|
endif |
1016 |
|
|
1017 |
|
endif |
1018 |
|
|
1019 |
< |
if (FF_uses_Sticky .and. SIM_uses_sticky) then |
1019 |
> |
if ( iand(iHash, STICKY_PAIR).ne.0 ) then |
1020 |
> |
call do_sticky_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1021 |
> |
pot, A, f, t, do_pot) |
1022 |
> |
endif |
1023 |
|
|
1024 |
< |
if ( PropertyMap(me_i)%is_Sticky .and. PropertyMap(me_j)%is_Sticky) then |
1025 |
< |
call do_sticky_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1026 |
< |
pot, A, f, t, do_pot) |
905 |
< |
endif |
906 |
< |
|
1024 |
> |
if ( iand(iHash, STICKYPOWER_PAIR).ne.0 ) then |
1025 |
> |
call do_sticky_power_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1026 |
> |
pot, A, f, t, do_pot) |
1027 |
|
endif |
1028 |
|
|
1029 |
< |
|
1030 |
< |
if (FF_uses_GayBerne .and. SIM_uses_GayBerne) then |
1031 |
< |
|
912 |
< |
if ( PropertyMap(me_i)%is_GayBerne .and. & |
913 |
< |
PropertyMap(me_j)%is_GayBerne) then |
914 |
< |
call do_gb_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
915 |
< |
pot, u_l, f, t, do_pot) |
916 |
< |
endif |
917 |
< |
|
1029 |
> |
if ( iand(iHash, GAYBERNE_PAIR).ne.0 ) then |
1030 |
> |
call do_gb_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1031 |
> |
pot, A, f, t, do_pot) |
1032 |
|
endif |
1033 |
|
|
1034 |
< |
if (FF_uses_EAM .and. SIM_uses_EAM) then |
1035 |
< |
|
1036 |
< |
if ( PropertyMap(me_i)%is_EAM .and. PropertyMap(me_j)%is_EAM) then |
923 |
< |
call do_eam_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, f, & |
924 |
< |
do_pot) |
925 |
< |
endif |
926 |
< |
|
1034 |
> |
if ( iand(iHash, GAYBERNE_LJ).ne.0 ) then |
1035 |
> |
! call do_gblj_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1036 |
> |
! pot, A, f, t, do_pot) |
1037 |
|
endif |
1038 |
|
|
1039 |
< |
if (FF_uses_Shapes .and. SIM_uses_Shapes) then |
1040 |
< |
if ( PropertyMap(me_i)%is_Shape .and. & |
1041 |
< |
PropertyMap(me_j)%is_Shape ) then |
932 |
< |
call do_shape_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
933 |
< |
pot, A, f, t, do_pot) |
934 |
< |
endif |
935 |
< |
|
1039 |
> |
if ( iand(iHash, EAM_PAIR).ne.0 ) then |
1040 |
> |
call do_eam_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, f, & |
1041 |
> |
do_pot) |
1042 |
|
endif |
1043 |
+ |
|
1044 |
+ |
if ( iand(iHash, SHAPE_PAIR).ne.0 ) then |
1045 |
+ |
call do_shape_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1046 |
+ |
pot, A, f, t, do_pot) |
1047 |
+ |
endif |
1048 |
+ |
|
1049 |
+ |
if ( iand(iHash, SHAPE_LJ).ne.0 ) then |
1050 |
+ |
call do_shape_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1051 |
+ |
pot, A, f, t, do_pot) |
1052 |
+ |
endif |
1053 |
|
|
1054 |
|
end subroutine do_pair |
1055 |
|
|
1056 |
|
subroutine do_prepair(i, j, rijsq, d, sw, rcijsq, dc, & |
1057 |
< |
do_pot, do_stress, u_l, A, f, t, pot) |
1057 |
> |
do_pot, do_stress, eFrame, A, f, t, pot) |
1058 |
|
|
1059 |
< |
real( kind = dp ) :: pot, sw |
1060 |
< |
real( kind = dp ), dimension(3,nLocal) :: u_l |
1061 |
< |
real (kind=dp), dimension(9,nLocal) :: A |
1062 |
< |
real (kind=dp), dimension(3,nLocal) :: f |
1063 |
< |
real (kind=dp), dimension(3,nLocal) :: t |
948 |
< |
|
949 |
< |
logical, intent(inout) :: do_pot, do_stress |
950 |
< |
integer, intent(in) :: i, j |
951 |
< |
real ( kind = dp ), intent(inout) :: rijsq, rcijsq |
952 |
< |
real ( kind = dp ) :: r, rc |
953 |
< |
real ( kind = dp ), intent(inout) :: d(3), dc(3) |
954 |
< |
|
955 |
< |
logical :: is_EAM_i, is_EAM_j |
956 |
< |
|
957 |
< |
integer :: me_i, me_j |
958 |
< |
|
1059 |
> |
real( kind = dp ) :: pot, sw |
1060 |
> |
real( kind = dp ), dimension(9,nLocal) :: eFrame |
1061 |
> |
real (kind=dp), dimension(9,nLocal) :: A |
1062 |
> |
real (kind=dp), dimension(3,nLocal) :: f |
1063 |
> |
real (kind=dp), dimension(3,nLocal) :: t |
1064 |
|
|
1065 |
< |
r = sqrt(rijsq) |
1066 |
< |
if (SIM_uses_molecular_cutoffs) then |
1067 |
< |
rc = sqrt(rcijsq) |
1068 |
< |
else |
1069 |
< |
rc = r |
965 |
< |
endif |
966 |
< |
|
1065 |
> |
logical, intent(inout) :: do_pot, do_stress |
1066 |
> |
integer, intent(in) :: i, j |
1067 |
> |
real ( kind = dp ), intent(inout) :: rijsq, rcijsq |
1068 |
> |
real ( kind = dp ) :: r, rc |
1069 |
> |
real ( kind = dp ), intent(inout) :: d(3), dc(3) |
1070 |
|
|
1071 |
+ |
integer :: me_i, me_j, iHash |
1072 |
+ |
|
1073 |
|
#ifdef IS_MPI |
1074 |
< |
me_i = atid_row(i) |
1075 |
< |
me_j = atid_col(j) |
1074 |
> |
me_i = atid_row(i) |
1075 |
> |
me_j = atid_col(j) |
1076 |
|
#else |
1077 |
< |
me_i = atid(i) |
1078 |
< |
me_j = atid(j) |
1077 |
> |
me_i = atid(i) |
1078 |
> |
me_j = atid(j) |
1079 |
|
#endif |
1080 |
< |
|
1081 |
< |
if (FF_uses_EAM .and. SIM_uses_EAM) then |
1082 |
< |
|
1083 |
< |
if (PropertyMap(me_i)%is_EAM .and. PropertyMap(me_j)%is_EAM) & |
1084 |
< |
call calc_EAM_prepair_rho(i, j, d, r, rijsq ) |
1085 |
< |
|
1086 |
< |
endif |
1087 |
< |
|
1088 |
< |
end subroutine do_prepair |
1089 |
< |
|
1090 |
< |
|
1091 |
< |
subroutine do_preforce(nlocal,pot) |
1092 |
< |
integer :: nlocal |
1093 |
< |
real( kind = dp ) :: pot |
1094 |
< |
|
1095 |
< |
if (FF_uses_EAM .and. SIM_uses_EAM) then |
1096 |
< |
call calc_EAM_preforce_Frho(nlocal,pot) |
1097 |
< |
endif |
1098 |
< |
|
1099 |
< |
|
1100 |
< |
end subroutine do_preforce |
1101 |
< |
|
1102 |
< |
|
1103 |
< |
subroutine get_interatomic_vector(q_i, q_j, d, r_sq) |
1104 |
< |
|
1105 |
< |
real (kind = dp), dimension(3) :: q_i |
1106 |
< |
real (kind = dp), dimension(3) :: q_j |
1107 |
< |
real ( kind = dp ), intent(out) :: r_sq |
1108 |
< |
real( kind = dp ) :: d(3), scaled(3) |
1109 |
< |
integer i |
1110 |
< |
|
1111 |
< |
d(1:3) = q_j(1:3) - q_i(1:3) |
1112 |
< |
|
1113 |
< |
! Wrap back into periodic box if necessary |
1114 |
< |
if ( SIM_uses_PBC ) then |
1115 |
< |
|
1116 |
< |
if( .not.boxIsOrthorhombic ) then |
1117 |
< |
! calc the scaled coordinates. |
1118 |
< |
|
1119 |
< |
scaled = matmul(HmatInv, d) |
1120 |
< |
|
1121 |
< |
! wrap the scaled coordinates |
1122 |
< |
|
1123 |
< |
scaled = scaled - anint(scaled) |
1124 |
< |
|
1125 |
< |
|
1126 |
< |
! calc the wrapped real coordinates from the wrapped scaled |
1127 |
< |
! coordinates |
1128 |
< |
|
1129 |
< |
d = matmul(Hmat,scaled) |
1130 |
< |
|
1131 |
< |
else |
1132 |
< |
! calc the scaled coordinates. |
1133 |
< |
|
1134 |
< |
do i = 1, 3 |
1135 |
< |
scaled(i) = d(i) * HmatInv(i,i) |
1136 |
< |
|
1137 |
< |
! wrap the scaled coordinates |
1138 |
< |
|
1139 |
< |
scaled(i) = scaled(i) - anint(scaled(i)) |
1140 |
< |
|
1141 |
< |
! calc the wrapped real coordinates from the wrapped scaled |
1142 |
< |
! coordinates |
1143 |
< |
|
1144 |
< |
d(i) = scaled(i)*Hmat(i,i) |
1145 |
< |
enddo |
1146 |
< |
endif |
1147 |
< |
|
1148 |
< |
endif |
1149 |
< |
|
1150 |
< |
r_sq = dot_product(d,d) |
1151 |
< |
|
1152 |
< |
end subroutine get_interatomic_vector |
1153 |
< |
|
1154 |
< |
subroutine zero_work_arrays() |
1050 |
< |
|
1080 |
> |
|
1081 |
> |
iHash = InteractionHash(me_i, me_j) |
1082 |
> |
|
1083 |
> |
if ( iand(iHash, EAM_PAIR).ne.0 ) then |
1084 |
> |
call calc_EAM_prepair_rho(i, j, d, r, rijsq ) |
1085 |
> |
endif |
1086 |
> |
|
1087 |
> |
end subroutine do_prepair |
1088 |
> |
|
1089 |
> |
|
1090 |
> |
subroutine do_preforce(nlocal,pot) |
1091 |
> |
integer :: nlocal |
1092 |
> |
real( kind = dp ) :: pot |
1093 |
> |
|
1094 |
> |
if (FF_uses_EAM .and. SIM_uses_EAM) then |
1095 |
> |
call calc_EAM_preforce_Frho(nlocal,pot) |
1096 |
> |
endif |
1097 |
> |
|
1098 |
> |
|
1099 |
> |
end subroutine do_preforce |
1100 |
> |
|
1101 |
> |
|
1102 |
> |
subroutine get_interatomic_vector(q_i, q_j, d, r_sq) |
1103 |
> |
|
1104 |
> |
real (kind = dp), dimension(3) :: q_i |
1105 |
> |
real (kind = dp), dimension(3) :: q_j |
1106 |
> |
real ( kind = dp ), intent(out) :: r_sq |
1107 |
> |
real( kind = dp ) :: d(3), scaled(3) |
1108 |
> |
integer i |
1109 |
> |
|
1110 |
> |
d(1:3) = q_j(1:3) - q_i(1:3) |
1111 |
> |
|
1112 |
> |
! Wrap back into periodic box if necessary |
1113 |
> |
if ( SIM_uses_PBC ) then |
1114 |
> |
|
1115 |
> |
if( .not.boxIsOrthorhombic ) then |
1116 |
> |
! calc the scaled coordinates. |
1117 |
> |
|
1118 |
> |
scaled = matmul(HmatInv, d) |
1119 |
> |
|
1120 |
> |
! wrap the scaled coordinates |
1121 |
> |
|
1122 |
> |
scaled = scaled - anint(scaled) |
1123 |
> |
|
1124 |
> |
|
1125 |
> |
! calc the wrapped real coordinates from the wrapped scaled |
1126 |
> |
! coordinates |
1127 |
> |
|
1128 |
> |
d = matmul(Hmat,scaled) |
1129 |
> |
|
1130 |
> |
else |
1131 |
> |
! calc the scaled coordinates. |
1132 |
> |
|
1133 |
> |
do i = 1, 3 |
1134 |
> |
scaled(i) = d(i) * HmatInv(i,i) |
1135 |
> |
|
1136 |
> |
! wrap the scaled coordinates |
1137 |
> |
|
1138 |
> |
scaled(i) = scaled(i) - anint(scaled(i)) |
1139 |
> |
|
1140 |
> |
! calc the wrapped real coordinates from the wrapped scaled |
1141 |
> |
! coordinates |
1142 |
> |
|
1143 |
> |
d(i) = scaled(i)*Hmat(i,i) |
1144 |
> |
enddo |
1145 |
> |
endif |
1146 |
> |
|
1147 |
> |
endif |
1148 |
> |
|
1149 |
> |
r_sq = dot_product(d,d) |
1150 |
> |
|
1151 |
> |
end subroutine get_interatomic_vector |
1152 |
> |
|
1153 |
> |
subroutine zero_work_arrays() |
1154 |
> |
|
1155 |
|
#ifdef IS_MPI |
1052 |
– |
|
1053 |
– |
q_Row = 0.0_dp |
1054 |
– |
q_Col = 0.0_dp |
1156 |
|
|
1157 |
< |
q_group_Row = 0.0_dp |
1158 |
< |
q_group_Col = 0.0_dp |
1159 |
< |
|
1160 |
< |
u_l_Row = 0.0_dp |
1161 |
< |
u_l_Col = 0.0_dp |
1162 |
< |
|
1163 |
< |
A_Row = 0.0_dp |
1164 |
< |
A_Col = 0.0_dp |
1165 |
< |
|
1166 |
< |
f_Row = 0.0_dp |
1167 |
< |
f_Col = 0.0_dp |
1168 |
< |
f_Temp = 0.0_dp |
1169 |
< |
|
1170 |
< |
t_Row = 0.0_dp |
1171 |
< |
t_Col = 0.0_dp |
1172 |
< |
t_Temp = 0.0_dp |
1173 |
< |
|
1174 |
< |
pot_Row = 0.0_dp |
1175 |
< |
pot_Col = 0.0_dp |
1176 |
< |
pot_Temp = 0.0_dp |
1177 |
< |
|
1178 |
< |
rf_Row = 0.0_dp |
1179 |
< |
rf_Col = 0.0_dp |
1180 |
< |
rf_Temp = 0.0_dp |
1181 |
< |
|
1157 |
> |
q_Row = 0.0_dp |
1158 |
> |
q_Col = 0.0_dp |
1159 |
> |
|
1160 |
> |
q_group_Row = 0.0_dp |
1161 |
> |
q_group_Col = 0.0_dp |
1162 |
> |
|
1163 |
> |
eFrame_Row = 0.0_dp |
1164 |
> |
eFrame_Col = 0.0_dp |
1165 |
> |
|
1166 |
> |
A_Row = 0.0_dp |
1167 |
> |
A_Col = 0.0_dp |
1168 |
> |
|
1169 |
> |
f_Row = 0.0_dp |
1170 |
> |
f_Col = 0.0_dp |
1171 |
> |
f_Temp = 0.0_dp |
1172 |
> |
|
1173 |
> |
t_Row = 0.0_dp |
1174 |
> |
t_Col = 0.0_dp |
1175 |
> |
t_Temp = 0.0_dp |
1176 |
> |
|
1177 |
> |
pot_Row = 0.0_dp |
1178 |
> |
pot_Col = 0.0_dp |
1179 |
> |
pot_Temp = 0.0_dp |
1180 |
> |
|
1181 |
> |
rf_Row = 0.0_dp |
1182 |
> |
rf_Col = 0.0_dp |
1183 |
> |
rf_Temp = 0.0_dp |
1184 |
> |
|
1185 |
|
#endif |
1186 |
< |
|
1187 |
< |
if (FF_uses_EAM .and. SIM_uses_EAM) then |
1188 |
< |
call clean_EAM() |
1189 |
< |
endif |
1190 |
< |
|
1191 |
< |
rf = 0.0_dp |
1192 |
< |
tau_Temp = 0.0_dp |
1193 |
< |
virial_Temp = 0.0_dp |
1194 |
< |
end subroutine zero_work_arrays |
1195 |
< |
|
1196 |
< |
function skipThisPair(atom1, atom2) result(skip_it) |
1197 |
< |
integer, intent(in) :: atom1 |
1198 |
< |
integer, intent(in), optional :: atom2 |
1199 |
< |
logical :: skip_it |
1200 |
< |
integer :: unique_id_1, unique_id_2 |
1201 |
< |
integer :: me_i,me_j |
1202 |
< |
integer :: i |
1203 |
< |
|
1204 |
< |
skip_it = .false. |
1205 |
< |
|
1206 |
< |
!! there are a number of reasons to skip a pair or a particle |
1207 |
< |
!! mostly we do this to exclude atoms who are involved in short |
1208 |
< |
!! range interactions (bonds, bends, torsions), but we also need |
1209 |
< |
!! to exclude some overcounted interactions that result from |
1210 |
< |
!! the parallel decomposition |
1211 |
< |
|
1186 |
> |
|
1187 |
> |
if (FF_uses_EAM .and. SIM_uses_EAM) then |
1188 |
> |
call clean_EAM() |
1189 |
> |
endif |
1190 |
> |
|
1191 |
> |
rf = 0.0_dp |
1192 |
> |
tau_Temp = 0.0_dp |
1193 |
> |
virial_Temp = 0.0_dp |
1194 |
> |
end subroutine zero_work_arrays |
1195 |
> |
|
1196 |
> |
function skipThisPair(atom1, atom2) result(skip_it) |
1197 |
> |
integer, intent(in) :: atom1 |
1198 |
> |
integer, intent(in), optional :: atom2 |
1199 |
> |
logical :: skip_it |
1200 |
> |
integer :: unique_id_1, unique_id_2 |
1201 |
> |
integer :: me_i,me_j |
1202 |
> |
integer :: i |
1203 |
> |
|
1204 |
> |
skip_it = .false. |
1205 |
> |
|
1206 |
> |
!! there are a number of reasons to skip a pair or a particle |
1207 |
> |
!! mostly we do this to exclude atoms who are involved in short |
1208 |
> |
!! range interactions (bonds, bends, torsions), but we also need |
1209 |
> |
!! to exclude some overcounted interactions that result from |
1210 |
> |
!! the parallel decomposition |
1211 |
> |
|
1212 |
|
#ifdef IS_MPI |
1213 |
< |
!! in MPI, we have to look up the unique IDs for each atom |
1214 |
< |
unique_id_1 = AtomRowToGlobal(atom1) |
1213 |
> |
!! in MPI, we have to look up the unique IDs for each atom |
1214 |
> |
unique_id_1 = AtomRowToGlobal(atom1) |
1215 |
|
#else |
1216 |
< |
!! in the normal loop, the atom numbers are unique |
1217 |
< |
unique_id_1 = atom1 |
1216 |
> |
!! in the normal loop, the atom numbers are unique |
1217 |
> |
unique_id_1 = atom1 |
1218 |
|
#endif |
1219 |
< |
|
1220 |
< |
!! We were called with only one atom, so just check the global exclude |
1221 |
< |
!! list for this atom |
1222 |
< |
if (.not. present(atom2)) then |
1223 |
< |
do i = 1, nExcludes_global |
1224 |
< |
if (excludesGlobal(i) == unique_id_1) then |
1225 |
< |
skip_it = .true. |
1226 |
< |
return |
1227 |
< |
end if |
1228 |
< |
end do |
1229 |
< |
return |
1230 |
< |
end if |
1231 |
< |
|
1219 |
> |
|
1220 |
> |
!! We were called with only one atom, so just check the global exclude |
1221 |
> |
!! list for this atom |
1222 |
> |
if (.not. present(atom2)) then |
1223 |
> |
do i = 1, nExcludes_global |
1224 |
> |
if (excludesGlobal(i) == unique_id_1) then |
1225 |
> |
skip_it = .true. |
1226 |
> |
return |
1227 |
> |
end if |
1228 |
> |
end do |
1229 |
> |
return |
1230 |
> |
end if |
1231 |
> |
|
1232 |
|
#ifdef IS_MPI |
1233 |
< |
unique_id_2 = AtomColToGlobal(atom2) |
1233 |
> |
unique_id_2 = AtomColToGlobal(atom2) |
1234 |
|
#else |
1235 |
< |
unique_id_2 = atom2 |
1235 |
> |
unique_id_2 = atom2 |
1236 |
|
#endif |
1237 |
< |
|
1237 |
> |
|
1238 |
|
#ifdef IS_MPI |
1239 |
< |
!! this situation should only arise in MPI simulations |
1240 |
< |
if (unique_id_1 == unique_id_2) then |
1241 |
< |
skip_it = .true. |
1242 |
< |
return |
1243 |
< |
end if |
1244 |
< |
|
1245 |
< |
!! this prevents us from doing the pair on multiple processors |
1246 |
< |
if (unique_id_1 < unique_id_2) then |
1247 |
< |
if (mod(unique_id_1 + unique_id_2,2) == 0) then |
1248 |
< |
skip_it = .true. |
1249 |
< |
return |
1250 |
< |
endif |
1251 |
< |
else |
1252 |
< |
if (mod(unique_id_1 + unique_id_2,2) == 1) then |
1253 |
< |
skip_it = .true. |
1254 |
< |
return |
1255 |
< |
endif |
1256 |
< |
endif |
1239 |
> |
!! this situation should only arise in MPI simulations |
1240 |
> |
if (unique_id_1 == unique_id_2) then |
1241 |
> |
skip_it = .true. |
1242 |
> |
return |
1243 |
> |
end if |
1244 |
> |
|
1245 |
> |
!! this prevents us from doing the pair on multiple processors |
1246 |
> |
if (unique_id_1 < unique_id_2) then |
1247 |
> |
if (mod(unique_id_1 + unique_id_2,2) == 0) then |
1248 |
> |
skip_it = .true. |
1249 |
> |
return |
1250 |
> |
endif |
1251 |
> |
else |
1252 |
> |
if (mod(unique_id_1 + unique_id_2,2) == 1) then |
1253 |
> |
skip_it = .true. |
1254 |
> |
return |
1255 |
> |
endif |
1256 |
> |
endif |
1257 |
|
#endif |
1258 |
< |
|
1259 |
< |
!! the rest of these situations can happen in all simulations: |
1260 |
< |
do i = 1, nExcludes_global |
1261 |
< |
if ((excludesGlobal(i) == unique_id_1) .or. & |
1262 |
< |
(excludesGlobal(i) == unique_id_2)) then |
1263 |
< |
skip_it = .true. |
1264 |
< |
return |
1265 |
< |
endif |
1266 |
< |
enddo |
1267 |
< |
|
1268 |
< |
do i = 1, nSkipsForAtom(atom1) |
1269 |
< |
if (skipsForAtom(atom1, i) .eq. unique_id_2) then |
1270 |
< |
skip_it = .true. |
1271 |
< |
return |
1272 |
< |
endif |
1273 |
< |
end do |
1274 |
< |
|
1275 |
< |
return |
1276 |
< |
end function skipThisPair |
1277 |
< |
|
1278 |
< |
function FF_UsesDirectionalAtoms() result(doesit) |
1279 |
< |
logical :: doesit |
1280 |
< |
doesit = FF_uses_DirectionalAtoms .or. FF_uses_Dipoles .or. & |
1281 |
< |
FF_uses_Sticky .or. FF_uses_GayBerne .or. FF_uses_Shapes |
1282 |
< |
end function FF_UsesDirectionalAtoms |
1283 |
< |
|
1284 |
< |
function FF_RequiresPrepairCalc() result(doesit) |
1285 |
< |
logical :: doesit |
1286 |
< |
doesit = FF_uses_EAM |
1287 |
< |
end function FF_RequiresPrepairCalc |
1288 |
< |
|
1289 |
< |
function FF_RequiresPostpairCalc() result(doesit) |
1290 |
< |
logical :: doesit |
1291 |
< |
doesit = FF_uses_RF |
1292 |
< |
end function FF_RequiresPostpairCalc |
1189 |
< |
|
1258 |
> |
|
1259 |
> |
!! the rest of these situations can happen in all simulations: |
1260 |
> |
do i = 1, nExcludes_global |
1261 |
> |
if ((excludesGlobal(i) == unique_id_1) .or. & |
1262 |
> |
(excludesGlobal(i) == unique_id_2)) then |
1263 |
> |
skip_it = .true. |
1264 |
> |
return |
1265 |
> |
endif |
1266 |
> |
enddo |
1267 |
> |
|
1268 |
> |
do i = 1, nSkipsForAtom(atom1) |
1269 |
> |
if (skipsForAtom(atom1, i) .eq. unique_id_2) then |
1270 |
> |
skip_it = .true. |
1271 |
> |
return |
1272 |
> |
endif |
1273 |
> |
end do |
1274 |
> |
|
1275 |
> |
return |
1276 |
> |
end function skipThisPair |
1277 |
> |
|
1278 |
> |
function FF_UsesDirectionalAtoms() result(doesit) |
1279 |
> |
logical :: doesit |
1280 |
> |
doesit = FF_uses_DirectionalAtoms |
1281 |
> |
end function FF_UsesDirectionalAtoms |
1282 |
> |
|
1283 |
> |
function FF_RequiresPrepairCalc() result(doesit) |
1284 |
> |
logical :: doesit |
1285 |
> |
doesit = FF_uses_EAM |
1286 |
> |
end function FF_RequiresPrepairCalc |
1287 |
> |
|
1288 |
> |
function FF_RequiresPostpairCalc() result(doesit) |
1289 |
> |
logical :: doesit |
1290 |
> |
doesit = FF_uses_RF |
1291 |
> |
end function FF_RequiresPostpairCalc |
1292 |
> |
|
1293 |
|
#ifdef PROFILE |
1294 |
< |
function getforcetime() result(totalforcetime) |
1295 |
< |
real(kind=dp) :: totalforcetime |
1296 |
< |
totalforcetime = forcetime |
1297 |
< |
end function getforcetime |
1294 |
> |
function getforcetime() result(totalforcetime) |
1295 |
> |
real(kind=dp) :: totalforcetime |
1296 |
> |
totalforcetime = forcetime |
1297 |
> |
end function getforcetime |
1298 |
|
#endif |
1196 |
– |
|
1197 |
– |
!! This cleans componets of force arrays belonging only to fortran |
1299 |
|
|
1300 |
< |
subroutine add_stress_tensor(dpair, fpair) |
1200 |
< |
|
1201 |
< |
real( kind = dp ), dimension(3), intent(in) :: dpair, fpair |
1202 |
< |
|
1203 |
< |
! because the d vector is the rj - ri vector, and |
1204 |
< |
! because fx, fy, fz are the force on atom i, we need a |
1205 |
< |
! negative sign here: |
1206 |
< |
|
1207 |
< |
tau_Temp(1) = tau_Temp(1) - dpair(1) * fpair(1) |
1208 |
< |
tau_Temp(2) = tau_Temp(2) - dpair(1) * fpair(2) |
1209 |
< |
tau_Temp(3) = tau_Temp(3) - dpair(1) * fpair(3) |
1210 |
< |
tau_Temp(4) = tau_Temp(4) - dpair(2) * fpair(1) |
1211 |
< |
tau_Temp(5) = tau_Temp(5) - dpair(2) * fpair(2) |
1212 |
< |
tau_Temp(6) = tau_Temp(6) - dpair(2) * fpair(3) |
1213 |
< |
tau_Temp(7) = tau_Temp(7) - dpair(3) * fpair(1) |
1214 |
< |
tau_Temp(8) = tau_Temp(8) - dpair(3) * fpair(2) |
1215 |
< |
tau_Temp(9) = tau_Temp(9) - dpair(3) * fpair(3) |
1216 |
< |
|
1217 |
< |
virial_Temp = virial_Temp + & |
1218 |
< |
(tau_Temp(1) + tau_Temp(5) + tau_Temp(9)) |
1219 |
< |
|
1220 |
< |
end subroutine add_stress_tensor |
1221 |
< |
|
1222 |
< |
end module doForces |
1300 |
> |
!! This cleans componets of force arrays belonging only to fortran |
1301 |
|
|
1302 |
< |
!! Interfaces for C programs to module.... |
1302 |
> |
subroutine add_stress_tensor(dpair, fpair) |
1303 |
|
|
1304 |
< |
subroutine initFortranFF(use_RF_c, thisStat) |
1227 |
< |
use doForces, ONLY: init_FF |
1228 |
< |
logical, intent(in) :: use_RF_c |
1304 |
> |
real( kind = dp ), dimension(3), intent(in) :: dpair, fpair |
1305 |
|
|
1306 |
< |
integer, intent(out) :: thisStat |
1307 |
< |
call init_FF(use_RF_c, thisStat) |
1306 |
> |
! because the d vector is the rj - ri vector, and |
1307 |
> |
! because fx, fy, fz are the force on atom i, we need a |
1308 |
> |
! negative sign here: |
1309 |
|
|
1310 |
< |
end subroutine initFortranFF |
1310 |
> |
tau_Temp(1) = tau_Temp(1) - dpair(1) * fpair(1) |
1311 |
> |
tau_Temp(2) = tau_Temp(2) - dpair(1) * fpair(2) |
1312 |
> |
tau_Temp(3) = tau_Temp(3) - dpair(1) * fpair(3) |
1313 |
> |
tau_Temp(4) = tau_Temp(4) - dpair(2) * fpair(1) |
1314 |
> |
tau_Temp(5) = tau_Temp(5) - dpair(2) * fpair(2) |
1315 |
> |
tau_Temp(6) = tau_Temp(6) - dpair(2) * fpair(3) |
1316 |
> |
tau_Temp(7) = tau_Temp(7) - dpair(3) * fpair(1) |
1317 |
> |
tau_Temp(8) = tau_Temp(8) - dpair(3) * fpair(2) |
1318 |
> |
tau_Temp(9) = tau_Temp(9) - dpair(3) * fpair(3) |
1319 |
|
|
1320 |
< |
subroutine doForceloop(q, q_group, A, u_l, f, t, tau, pot, & |
1321 |
< |
do_pot_c, do_stress_c, error) |
1237 |
< |
|
1238 |
< |
use definitions, ONLY: dp |
1239 |
< |
use simulation |
1240 |
< |
use doForces, ONLY: do_force_loop |
1241 |
< |
!! Position array provided by C, dimensioned by getNlocal |
1242 |
< |
real ( kind = dp ), dimension(3, nLocal) :: q |
1243 |
< |
!! molecular center-of-mass position array |
1244 |
< |
real ( kind = dp ), dimension(3, nGroups) :: q_group |
1245 |
< |
!! Rotation Matrix for each long range particle in simulation. |
1246 |
< |
real( kind = dp), dimension(9, nLocal) :: A |
1247 |
< |
!! Unit vectors for dipoles (lab frame) |
1248 |
< |
real( kind = dp ), dimension(3,nLocal) :: u_l |
1249 |
< |
!! Force array provided by C, dimensioned by getNlocal |
1250 |
< |
real ( kind = dp ), dimension(3,nLocal) :: f |
1251 |
< |
!! Torsion array provided by C, dimensioned by getNlocal |
1252 |
< |
real( kind = dp ), dimension(3,nLocal) :: t |
1320 |
> |
virial_Temp = virial_Temp + & |
1321 |
> |
(tau_Temp(1) + tau_Temp(5) + tau_Temp(9)) |
1322 |
|
|
1323 |
< |
!! Stress Tensor |
1324 |
< |
real( kind = dp), dimension(9) :: tau |
1325 |
< |
real ( kind = dp ) :: pot |
1257 |
< |
logical ( kind = 2) :: do_pot_c, do_stress_c |
1258 |
< |
integer :: error |
1259 |
< |
|
1260 |
< |
call do_force_loop(q, q_group, A, u_l, f, t, tau, pot, & |
1261 |
< |
do_pot_c, do_stress_c, error) |
1262 |
< |
|
1263 |
< |
end subroutine doForceloop |
1323 |
> |
end subroutine add_stress_tensor |
1324 |
> |
|
1325 |
> |
end module doForces |