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.5 2004-10-26 22:24:44 gezelter Exp $, $Date: 2004-10-26 22:24:44 $, $Name: not supported by cvs2svn $, $Revision: 1.5 $ |
48 |
> |
!! @version $Id: doForces.F90,v 1.27 2005-08-09 19:40:56 chuckv Exp $, $Date: 2005-08-09 19:40:56 $, $Name: not supported by cvs2svn $, $Revision: 1.27 $ |
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/DarkSide/fInteractionMap.h" |
77 |
|
|
78 |
|
INTEGER, PARAMETER:: PREPAIR_LOOP = 1 |
79 |
|
INTEGER, PARAMETER:: PAIR_LOOP = 2 |
81 |
|
logical, save :: haveRlist = .false. |
82 |
|
logical, save :: haveNeighborList = .false. |
83 |
|
logical, save :: haveSIMvariables = .false. |
42 |
– |
logical, save :: havePropertyMap = .false. |
84 |
|
logical, save :: haveSaneForceField = .false. |
85 |
< |
|
85 |
> |
logical, save :: haveInteractionMap = .false. |
86 |
> |
|
87 |
|
logical, save :: FF_uses_DirectionalAtoms |
88 |
|
logical, save :: FF_uses_LennardJones |
89 |
< |
logical, save :: FF_uses_Electrostatic |
90 |
< |
logical, save :: FF_uses_charges |
91 |
< |
logical, save :: FF_uses_dipoles |
92 |
< |
logical, save :: FF_uses_sticky |
89 |
> |
logical, save :: FF_uses_Electrostatics |
90 |
> |
logical, save :: FF_uses_Charges |
91 |
> |
logical, save :: FF_uses_Dipoles |
92 |
> |
logical, save :: FF_uses_Quadrupoles |
93 |
> |
logical, save :: FF_uses_Sticky |
94 |
> |
logical, save :: FF_uses_StickyPower |
95 |
|
logical, save :: FF_uses_GayBerne |
96 |
|
logical, save :: FF_uses_EAM |
97 |
|
logical, save :: FF_uses_Shapes |
103 |
|
logical, save :: SIM_uses_Electrostatics |
104 |
|
logical, save :: SIM_uses_Charges |
105 |
|
logical, save :: SIM_uses_Dipoles |
106 |
+ |
logical, save :: SIM_uses_Quadrupoles |
107 |
|
logical, save :: SIM_uses_Sticky |
108 |
+ |
logical, save :: SIM_uses_StickyPower |
109 |
|
logical, save :: SIM_uses_GayBerne |
110 |
|
logical, save :: SIM_uses_EAM |
111 |
|
logical, save :: SIM_uses_Shapes |
116 |
|
logical, save :: SIM_uses_PBC |
117 |
|
logical, save :: SIM_uses_molecular_cutoffs |
118 |
|
|
73 |
– |
real(kind=dp), save :: rlist, rlistsq |
119 |
|
|
120 |
|
public :: init_FF |
121 |
|
public :: do_force_loop |
122 |
< |
public :: setRlistDF |
122 |
> |
! public :: setRlistDF |
123 |
> |
!public :: addInteraction |
124 |
> |
!public :: setInteractionHash |
125 |
> |
!public :: getInteractionHash |
126 |
> |
public :: createInteractionMap |
127 |
> |
public :: createGroupCutoffs |
128 |
|
|
129 |
|
#ifdef PROFILE |
130 |
|
public :: getforcetime |
132 |
|
real :: forceTimeInitial, forceTimeFinal |
133 |
|
integer :: nLoops |
134 |
|
#endif |
135 |
+ |
|
136 |
+ |
!! Variables for cutoff mapping and interaction mapping |
137 |
+ |
! Bit hash to determine pair-pair interactions. |
138 |
+ |
integer, dimension(:,:),allocatable :: InteractionHash |
139 |
+ |
!! Cuttoffs in OOPSE are handled on a Group-Group pair basis. |
140 |
+ |
! Largest cutoff for atypes for all potentials |
141 |
+ |
real(kind=dp), dimension(:), allocatable :: atypeMaxCuttoff |
142 |
+ |
! Largest cutoff for groups |
143 |
+ |
real(kind=dp), dimension(:), allocatable :: groupMaxCutoff |
144 |
+ |
! Group to Gtype transformation Map |
145 |
+ |
integer,dimension(:), allocatable :: groupToGtype |
146 |
+ |
! Group Type Max Cutoff |
147 |
+ |
real(kind=dp), dimension(:), allocatable :: gtypeMaxCutoff |
148 |
+ |
! GroupType definition |
149 |
+ |
type ::gtype |
150 |
+ |
real(kind=dp) :: rcut ! Group Cutoff |
151 |
+ |
real(kind=dp) :: rcutsq ! Group Cutoff Squared |
152 |
+ |
real(kind=dp) :: rlistsq ! List cutoff Squared |
153 |
+ |
end type gtype |
154 |
|
|
155 |
< |
type :: Properties |
156 |
< |
logical :: is_Directional = .false. |
88 |
< |
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 |
< |
|
155 |
> |
type(gtype), dimension(:,:), allocatable :: gtypeCutoffMap |
156 |
> |
|
157 |
|
contains |
158 |
|
|
159 |
< |
subroutine setRlistDF( this_rlist ) |
160 |
< |
|
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) |
159 |
> |
|
160 |
> |
subroutine createInteractionMap(status) |
161 |
|
integer :: nAtypes |
162 |
< |
integer :: status |
162 |
> |
integer, intent(out) :: status |
163 |
|
integer :: i |
164 |
< |
logical :: thisProperty |
165 |
< |
real (kind=DP) :: thisDPproperty |
164 |
> |
integer :: j |
165 |
> |
integer :: ihash |
166 |
> |
real(kind=dp) :: myRcut |
167 |
> |
!! Test Types |
168 |
> |
logical :: i_is_LJ |
169 |
> |
logical :: i_is_Elect |
170 |
> |
logical :: i_is_Sticky |
171 |
> |
logical :: i_is_StickyP |
172 |
> |
logical :: i_is_GB |
173 |
> |
logical :: i_is_EAM |
174 |
> |
logical :: i_is_Shape |
175 |
> |
logical :: j_is_LJ |
176 |
> |
logical :: j_is_Elect |
177 |
> |
logical :: j_is_Sticky |
178 |
> |
logical :: j_is_StickyP |
179 |
> |
logical :: j_is_GB |
180 |
> |
logical :: j_is_EAM |
181 |
> |
logical :: j_is_Shape |
182 |
> |
|
183 |
> |
status = 0 |
184 |
|
|
185 |
< |
status = 0 |
186 |
< |
|
185 |
> |
if (.not. associated(atypes)) then |
186 |
> |
call handleError("atype", "atypes was not present before call of createDefaultInteractionHash!") |
187 |
> |
status = -1 |
188 |
> |
return |
189 |
> |
endif |
190 |
> |
|
191 |
|
nAtypes = getSize(atypes) |
192 |
< |
|
192 |
> |
|
193 |
|
if (nAtypes == 0) then |
194 |
|
status = -1 |
195 |
|
return |
196 |
|
end if |
129 |
– |
|
130 |
– |
if (.not. allocated(PropertyMap)) then |
131 |
– |
allocate(PropertyMap(nAtypes)) |
132 |
– |
endif |
197 |
|
|
198 |
+ |
if (.not. allocated(InteractionHash)) then |
199 |
+ |
allocate(InteractionHash(nAtypes,nAtypes)) |
200 |
+ |
endif |
201 |
+ |
|
202 |
|
do i = 1, nAtypes |
203 |
< |
call getElementProperty(atypes, i, "is_Directional", thisProperty) |
204 |
< |
PropertyMap(i)%is_Directional = thisProperty |
203 |
> |
call getElementProperty(atypes, i, "is_LennardJones", i_is_LJ) |
204 |
> |
call getElementProperty(atypes, i, "is_Electrostatic", i_is_Elect) |
205 |
> |
call getElementProperty(atypes, i, "is_Sticky", i_is_Sticky) |
206 |
> |
call getElementProperty(atypes, i, "is_StickyPower", i_is_StickyP) |
207 |
> |
call getElementProperty(atypes, i, "is_GayBerne", i_is_GB) |
208 |
> |
call getElementProperty(atypes, i, "is_EAM", i_is_EAM) |
209 |
> |
call getElementProperty(atypes, i, "is_Shape", i_is_Shape) |
210 |
|
|
211 |
< |
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 |
211 |
> |
do j = i, nAtypes |
212 |
|
|
213 |
< |
call getElementProperty(atypes, i, "is_Charge", thisProperty) |
214 |
< |
PropertyMap(i)%is_Charge = thisProperty |
146 |
< |
|
147 |
< |
call getElementProperty(atypes, i, "is_Dipole", thisProperty) |
148 |
< |
PropertyMap(i)%is_Dipole = thisProperty |
213 |
> |
iHash = 0 |
214 |
> |
myRcut = 0.0_dp |
215 |
|
|
216 |
< |
call getElementProperty(atypes, i, "is_Sticky", thisProperty) |
217 |
< |
PropertyMap(i)%is_Sticky = thisProperty |
216 |
> |
call getElementProperty(atypes, j, "is_LennardJones", j_is_LJ) |
217 |
> |
call getElementProperty(atypes, j, "is_Electrostatic", j_is_Elect) |
218 |
> |
call getElementProperty(atypes, j, "is_Sticky", j_is_Sticky) |
219 |
> |
call getElementProperty(atypes, j, "is_StickyPower", j_is_StickyP) |
220 |
> |
call getElementProperty(atypes, j, "is_GayBerne", j_is_GB) |
221 |
> |
call getElementProperty(atypes, j, "is_EAM", j_is_EAM) |
222 |
> |
call getElementProperty(atypes, j, "is_Shape", j_is_Shape) |
223 |
|
|
224 |
< |
call getElementProperty(atypes, i, "is_GayBerne", thisProperty) |
225 |
< |
PropertyMap(i)%is_GayBerne = thisProperty |
224 |
> |
if (i_is_LJ .and. j_is_LJ) then |
225 |
> |
iHash = ior(iHash, LJ_PAIR) |
226 |
> |
endif |
227 |
> |
|
228 |
> |
if (i_is_Elect .and. j_is_Elect) then |
229 |
> |
iHash = ior(iHash, ELECTROSTATIC_PAIR) |
230 |
> |
endif |
231 |
> |
|
232 |
> |
if (i_is_Sticky .and. j_is_Sticky) then |
233 |
> |
iHash = ior(iHash, STICKY_PAIR) |
234 |
> |
endif |
235 |
|
|
236 |
< |
call getElementProperty(atypes, i, "is_EAM", thisProperty) |
237 |
< |
PropertyMap(i)%is_EAM = thisProperty |
236 |
> |
if (i_is_StickyP .and. j_is_StickyP) then |
237 |
> |
iHash = ior(iHash, STICKYPOWER_PAIR) |
238 |
> |
endif |
239 |
|
|
240 |
< |
call getElementProperty(atypes, i, "is_Shape", thisProperty) |
241 |
< |
PropertyMap(i)%is_Shape = thisProperty |
240 |
> |
if (i_is_EAM .and. j_is_EAM) then |
241 |
> |
iHash = ior(iHash, EAM_PAIR) |
242 |
> |
endif |
243 |
|
|
244 |
< |
call getElementProperty(atypes, i, "is_FLARB", thisProperty) |
245 |
< |
PropertyMap(i)%is_FLARB = thisProperty |
244 |
> |
if (i_is_GB .and. j_is_GB) iHash = ior(iHash, GAYBERNE_PAIR) |
245 |
> |
if (i_is_GB .and. j_is_LJ) iHash = ior(iHash, GAYBERNE_LJ) |
246 |
> |
if (i_is_LJ .and. j_is_GB) iHash = ior(iHash, GAYBERNE_LJ) |
247 |
> |
|
248 |
> |
if (i_is_Shape .and. j_is_Shape) iHash = ior(iHash, SHAPE_PAIR) |
249 |
> |
if (i_is_Shape .and. j_is_LJ) iHash = ior(iHash, SHAPE_LJ) |
250 |
> |
if (i_is_LJ .and. j_is_Shape) iHash = ior(iHash, SHAPE_LJ) |
251 |
> |
|
252 |
> |
|
253 |
> |
InteractionHash(i,j) = iHash |
254 |
> |
InteractionHash(j,i) = iHash |
255 |
> |
|
256 |
> |
end do |
257 |
> |
|
258 |
|
end do |
259 |
|
|
260 |
< |
havePropertyMap = .true. |
260 |
> |
haveInteractionMap = .true. |
261 |
> |
end subroutine createInteractionMap |
262 |
|
|
263 |
< |
end subroutine createPropertyMap |
263 |
> |
subroutine createGroupCutoffs(skinThickness,defaultrList,stat) |
264 |
> |
real(kind=dp), intent(in), optional :: defaultRList |
265 |
> |
real(kind-dp), intent(in), :: skinThickenss |
266 |
> |
! Query each potential and return the cutoff for that potential. We |
267 |
> |
! build the neighbor list based on the largest cutoff value for that |
268 |
> |
! atype. Each potential can decide whether to calculate the force for |
269 |
> |
! that atype based upon it's own cutoff. |
270 |
> |
|
271 |
|
|
272 |
+ |
real(kind=dp), intent(in), optional :: defaultRCut, defaultSkinThickness |
273 |
+ |
|
274 |
+ |
integer :: iMap |
275 |
+ |
integer :: map_i,map_j |
276 |
+ |
real(kind=dp) :: thisRCut = 0.0_dp |
277 |
+ |
real(kind=dp) :: actualCutoff = 0.0_dp |
278 |
+ |
integer, intent(out) :: stat |
279 |
+ |
integer :: nAtypes |
280 |
+ |
integer :: myStatus |
281 |
+ |
|
282 |
+ |
stat = 0 |
283 |
+ |
if (.not. haveInteractionMap) then |
284 |
+ |
|
285 |
+ |
call createInteractionMap(myStatus) |
286 |
+ |
|
287 |
+ |
if (myStatus .ne. 0) then |
288 |
+ |
write(default_error, *) 'createInteractionMap failed in doForces!' |
289 |
+ |
stat = -1 |
290 |
+ |
return |
291 |
+ |
endif |
292 |
+ |
endif |
293 |
+ |
|
294 |
+ |
nAtypes = getSize(atypes) |
295 |
+ |
!! If we pass a default rcut, set all atypes to that cutoff distance |
296 |
+ |
if(present(defaultRList)) then |
297 |
+ |
InteractionMap(:,:)%rCut = defaultRCut |
298 |
+ |
InteractionMap(:,:)%rCutSq = defaultRCut*defaultRCut |
299 |
+ |
InteractionMap(:,:)%rListSq = (defaultRCut+defaultSkinThickness)**2 |
300 |
+ |
haveRlist = .true. |
301 |
+ |
return |
302 |
+ |
end if |
303 |
+ |
|
304 |
+ |
do map_i = 1,nAtypes |
305 |
+ |
do map_j = map_i,nAtypes |
306 |
+ |
iMap = InteractionMap(map_i, map_j)%InteractionHash |
307 |
+ |
|
308 |
+ |
if ( iand(iMap, LJ_PAIR).ne.0 ) then |
309 |
+ |
! thisRCut = getLJCutOff(map_i,map_j) |
310 |
+ |
if (thisRcut > actualCutoff) actualCutoff = thisRcut |
311 |
+ |
endif |
312 |
+ |
|
313 |
+ |
if ( iand(iMap, ELECTROSTATIC_PAIR).ne.0 ) then |
314 |
+ |
! thisRCut = getElectrostaticCutOff(map_i,map_j) |
315 |
+ |
if (thisRcut > actualCutoff) actualCutoff = thisRcut |
316 |
+ |
endif |
317 |
+ |
|
318 |
+ |
if ( iand(iMap, STICKY_PAIR).ne.0 ) then |
319 |
+ |
! thisRCut = getStickyCutOff(map_i,map_j) |
320 |
+ |
if (thisRcut > actualCutoff) actualCutoff = thisRcut |
321 |
+ |
endif |
322 |
+ |
|
323 |
+ |
if ( iand(iMap, STICKYPOWER_PAIR).ne.0 ) then |
324 |
+ |
! thisRCut = getStickyPowerCutOff(map_i,map_j) |
325 |
+ |
if (thisRcut > actualCutoff) actualCutoff = thisRcut |
326 |
+ |
endif |
327 |
+ |
|
328 |
+ |
if ( iand(iMap, GAYBERNE_PAIR).ne.0 ) then |
329 |
+ |
! thisRCut = getGayberneCutOff(map_i,map_j) |
330 |
+ |
if (thisRcut > actualCutoff) actualCutoff = thisRcut |
331 |
+ |
endif |
332 |
+ |
|
333 |
+ |
if ( iand(iMap, GAYBERNE_LJ).ne.0 ) then |
334 |
+ |
! thisRCut = getGaybrneLJCutOff(map_i,map_j) |
335 |
+ |
if (thisRcut > actualCutoff) actualCutoff = thisRcut |
336 |
+ |
endif |
337 |
+ |
|
338 |
+ |
if ( iand(iMap, EAM_PAIR).ne.0 ) then |
339 |
+ |
! thisRCut = getEAMCutOff(map_i,map_j) |
340 |
+ |
if (thisRcut > actualCutoff) actualCutoff = thisRcut |
341 |
+ |
endif |
342 |
+ |
|
343 |
+ |
if ( iand(iMap, SHAPE_PAIR).ne.0 ) then |
344 |
+ |
! thisRCut = getShapeCutOff(map_i,map_j) |
345 |
+ |
if (thisRcut > actualCutoff) actualCutoff = thisRcut |
346 |
+ |
endif |
347 |
+ |
|
348 |
+ |
if ( iand(iMap, SHAPE_LJ).ne.0 ) then |
349 |
+ |
! thisRCut = getShapeLJCutOff(map_i,map_j) |
350 |
+ |
if (thisRcut > actualCutoff) actualCutoff = thisRcut |
351 |
+ |
endif |
352 |
+ |
InteractionMap(map_i, map_j)%rCut = actualCutoff |
353 |
+ |
InteractionMap(map_i, map_j)%rCutSq = actualCutoff * actualCutoff |
354 |
+ |
InteractionMap(map_i, map_j)%rListSq = (actualCutoff + skinThickness)**2 |
355 |
+ |
|
356 |
+ |
InteractionMap(map_j, map_i)%rCut = InteractionMap(map_i, map_j)%rCut |
357 |
+ |
InteractionMap(map_j, map_i)%rCutSq = InteractionMap(map_i, map_j)%rCutSq |
358 |
+ |
InteractionMap(map_j, map_i)%rListSq = InteractionMap(map_i, map_j)%rListSq |
359 |
+ |
end do |
360 |
+ |
end do |
361 |
+ |
! now the groups |
362 |
+ |
|
363 |
+ |
|
364 |
+ |
|
365 |
+ |
haveRlist = .true. |
366 |
+ |
end subroutine createGroupCutoffs |
367 |
+ |
|
368 |
|
subroutine setSimVariables() |
369 |
|
SIM_uses_DirectionalAtoms = SimUsesDirectionalAtoms() |
370 |
|
SIM_uses_LennardJones = SimUsesLennardJones() |
372 |
|
SIM_uses_Charges = SimUsesCharges() |
373 |
|
SIM_uses_Dipoles = SimUsesDipoles() |
374 |
|
SIM_uses_Sticky = SimUsesSticky() |
375 |
+ |
SIM_uses_StickyPower = SimUsesStickyPower() |
376 |
|
SIM_uses_GayBerne = SimUsesGayBerne() |
377 |
|
SIM_uses_EAM = SimUsesEAM() |
378 |
|
SIM_uses_Shapes = SimUsesShapes() |
393 |
|
integer :: myStatus |
394 |
|
|
395 |
|
error = 0 |
197 |
– |
|
198 |
– |
if (.not. havePropertyMap) then |
396 |
|
|
397 |
< |
myStatus = 0 |
398 |
< |
|
399 |
< |
call createPropertyMap(myStatus) |
400 |
< |
|
397 |
> |
if (.not. haveInteractionMap) then |
398 |
> |
|
399 |
> |
myStatus = 0 |
400 |
> |
call createInteractionMap(myStatus) |
401 |
> |
|
402 |
|
if (myStatus .ne. 0) then |
403 |
< |
write(default_error, *) 'createPropertyMap failed in doForces!' |
403 |
> |
write(default_error, *) 'createInteractionMap failed in doForces!' |
404 |
|
error = -1 |
405 |
|
return |
406 |
|
endif |
437 |
|
#endif |
438 |
|
return |
439 |
|
end subroutine doReadyCheck |
242 |
– |
|
440 |
|
|
441 |
+ |
|
442 |
|
subroutine init_FF(use_RF_c, thisStat) |
443 |
|
|
444 |
|
logical, intent(in) :: use_RF_c |
453 |
|
|
454 |
|
!! Fortran's version of a cast: |
455 |
|
FF_uses_RF = use_RF_c |
456 |
< |
|
456 |
> |
|
457 |
|
!! init_FF is called *after* all of the atom types have been |
458 |
|
!! defined in atype_module using the new_atype subroutine. |
459 |
|
!! |
460 |
|
!! this will scan through the known atypes and figure out what |
461 |
|
!! interactions are used by the force field. |
462 |
< |
|
462 |
> |
|
463 |
|
FF_uses_DirectionalAtoms = .false. |
464 |
|
FF_uses_LennardJones = .false. |
465 |
< |
FF_uses_Electrostatic = .false. |
465 |
> |
FF_uses_Electrostatics = .false. |
466 |
|
FF_uses_Charges = .false. |
467 |
|
FF_uses_Dipoles = .false. |
468 |
|
FF_uses_Sticky = .false. |
469 |
+ |
FF_uses_StickyPower = .false. |
470 |
|
FF_uses_GayBerne = .false. |
471 |
|
FF_uses_EAM = .false. |
472 |
|
FF_uses_Shapes = .false. |
473 |
|
FF_uses_FLARB = .false. |
474 |
< |
|
474 |
> |
|
475 |
|
call getMatchingElementList(atypes, "is_Directional", .true., & |
476 |
|
nMatches, MatchList) |
477 |
|
if (nMatches .gt. 0) FF_uses_DirectionalAtoms = .true. |
479 |
|
call getMatchingElementList(atypes, "is_LennardJones", .true., & |
480 |
|
nMatches, MatchList) |
481 |
|
if (nMatches .gt. 0) FF_uses_LennardJones = .true. |
482 |
< |
|
482 |
> |
|
483 |
|
call getMatchingElementList(atypes, "is_Electrostatic", .true., & |
484 |
|
nMatches, MatchList) |
485 |
|
if (nMatches .gt. 0) then |
486 |
< |
FF_uses_Electrostatic = .true. |
486 |
> |
FF_uses_Electrostatics = .true. |
487 |
|
endif |
488 |
|
|
489 |
|
call getMatchingElementList(atypes, "is_Charge", .true., & |
490 |
|
nMatches, MatchList) |
491 |
|
if (nMatches .gt. 0) then |
492 |
< |
FF_uses_charges = .true. |
493 |
< |
FF_uses_electrostatic = .true. |
492 |
> |
FF_uses_Charges = .true. |
493 |
> |
FF_uses_Electrostatics = .true. |
494 |
|
endif |
495 |
< |
|
495 |
> |
|
496 |
|
call getMatchingElementList(atypes, "is_Dipole", .true., & |
497 |
|
nMatches, MatchList) |
498 |
|
if (nMatches .gt. 0) then |
499 |
< |
FF_uses_dipoles = .true. |
500 |
< |
FF_uses_electrostatic = .true. |
499 |
> |
FF_uses_Dipoles = .true. |
500 |
> |
FF_uses_Electrostatics = .true. |
501 |
|
FF_uses_DirectionalAtoms = .true. |
502 |
|
endif |
503 |
< |
|
503 |
> |
|
504 |
> |
call getMatchingElementList(atypes, "is_Quadrupole", .true., & |
505 |
> |
nMatches, MatchList) |
506 |
> |
if (nMatches .gt. 0) then |
507 |
> |
FF_uses_Quadrupoles = .true. |
508 |
> |
FF_uses_Electrostatics = .true. |
509 |
> |
FF_uses_DirectionalAtoms = .true. |
510 |
> |
endif |
511 |
> |
|
512 |
|
call getMatchingElementList(atypes, "is_Sticky", .true., nMatches, & |
513 |
|
MatchList) |
514 |
|
if (nMatches .gt. 0) then |
515 |
|
FF_uses_Sticky = .true. |
516 |
|
FF_uses_DirectionalAtoms = .true. |
517 |
|
endif |
518 |
+ |
|
519 |
+ |
call getMatchingElementList(atypes, "is_StickyPower", .true., nMatches, & |
520 |
+ |
MatchList) |
521 |
+ |
if (nMatches .gt. 0) then |
522 |
+ |
FF_uses_StickyPower = .true. |
523 |
+ |
FF_uses_DirectionalAtoms = .true. |
524 |
+ |
endif |
525 |
|
|
526 |
|
call getMatchingElementList(atypes, "is_GayBerne", .true., & |
527 |
|
nMatches, MatchList) |
529 |
|
FF_uses_GayBerne = .true. |
530 |
|
FF_uses_DirectionalAtoms = .true. |
531 |
|
endif |
532 |
< |
|
532 |
> |
|
533 |
|
call getMatchingElementList(atypes, "is_EAM", .true., nMatches, MatchList) |
534 |
|
if (nMatches .gt. 0) FF_uses_EAM = .true. |
535 |
< |
|
535 |
> |
|
536 |
|
call getMatchingElementList(atypes, "is_Shape", .true., & |
537 |
|
nMatches, MatchList) |
538 |
|
if (nMatches .gt. 0) then |
546 |
|
|
547 |
|
!! Assume sanity (for the sake of argument) |
548 |
|
haveSaneForceField = .true. |
549 |
< |
|
549 |
> |
|
550 |
|
!! check to make sure the FF_uses_RF setting makes sense |
551 |
< |
|
551 |
> |
|
552 |
|
if (FF_uses_dipoles) then |
553 |
|
if (FF_uses_RF) then |
554 |
|
dielect = getDielect() |
561 |
|
haveSaneForceField = .false. |
562 |
|
return |
563 |
|
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 |
564 |
|
endif |
565 |
|
|
566 |
+ |
!sticky module does not contain check_sticky_FF anymore |
567 |
+ |
!if (FF_uses_sticky) then |
568 |
+ |
! call check_sticky_FF(my_status) |
569 |
+ |
! if (my_status /= 0) then |
570 |
+ |
! thisStat = -1 |
571 |
+ |
! haveSaneForceField = .false. |
572 |
+ |
! return |
573 |
+ |
! end if |
574 |
+ |
!endif |
575 |
+ |
|
576 |
|
if (FF_uses_EAM) then |
577 |
< |
call init_EAM_FF(my_status) |
577 |
> |
call init_EAM_FF(my_status) |
578 |
|
if (my_status /= 0) then |
579 |
|
write(default_error, *) "init_EAM_FF returned a bad status" |
580 |
|
thisStat = -1 |
594 |
|
|
595 |
|
if (FF_uses_GayBerne .and. FF_uses_LennardJones) then |
596 |
|
endif |
597 |
< |
|
597 |
> |
|
598 |
|
if (.not. haveNeighborList) then |
599 |
|
!! Create neighbor lists |
600 |
|
call expandNeighborList(nLocal, my_status) |
604 |
|
return |
605 |
|
endif |
606 |
|
haveNeighborList = .true. |
607 |
< |
endif |
608 |
< |
|
607 |
> |
endif |
608 |
> |
|
609 |
|
end subroutine init_FF |
395 |
– |
|
610 |
|
|
611 |
+ |
|
612 |
|
!! Does force loop over i,j pairs. Calls do_pair to calculates forces. |
613 |
|
!-------------------------------------------------------------> |
614 |
< |
subroutine do_force_loop(q, q_group, A, u_l, f, t, tau, pot, & |
614 |
> |
subroutine do_force_loop(q, q_group, A, eFrame, f, t, tau, pot, & |
615 |
|
do_pot_c, do_stress_c, error) |
616 |
|
!! Position array provided by C, dimensioned by getNlocal |
617 |
|
real ( kind = dp ), dimension(3, nLocal) :: q |
620 |
|
!! Rotation Matrix for each long range particle in simulation. |
621 |
|
real( kind = dp), dimension(9, nLocal) :: A |
622 |
|
!! Unit vectors for dipoles (lab frame) |
623 |
< |
real( kind = dp ), dimension(3,nLocal) :: u_l |
623 |
> |
real( kind = dp ), dimension(9,nLocal) :: eFrame |
624 |
|
!! Force array provided by C, dimensioned by getNlocal |
625 |
|
real ( kind = dp ), dimension(3,nLocal) :: f |
626 |
|
!! Torsion array provided by C, dimensioned by getNlocal |
658 |
|
integer :: localError |
659 |
|
integer :: propPack_i, propPack_j |
660 |
|
integer :: loopStart, loopEnd, loop |
661 |
< |
|
661 |
> |
integer :: iMap |
662 |
|
real(kind=dp) :: listSkin = 1.0 |
663 |
< |
|
663 |
> |
|
664 |
|
!! initialize local variables |
665 |
< |
|
665 |
> |
|
666 |
|
#ifdef IS_MPI |
667 |
|
pot_local = 0.0_dp |
668 |
|
nAtomsInRow = getNatomsInRow(plan_atom_row) |
672 |
|
#else |
673 |
|
natoms = nlocal |
674 |
|
#endif |
675 |
< |
|
675 |
> |
|
676 |
|
call doReadyCheck(localError) |
677 |
|
if ( localError .ne. 0 ) then |
678 |
|
call handleError("do_force_loop", "Not Initialized") |
680 |
|
return |
681 |
|
end if |
682 |
|
call zero_work_arrays() |
683 |
< |
|
683 |
> |
|
684 |
|
do_pot = do_pot_c |
685 |
|
do_stress = do_stress_c |
686 |
< |
|
686 |
> |
|
687 |
|
! Gather all information needed by all force loops: |
688 |
< |
|
688 |
> |
|
689 |
|
#ifdef IS_MPI |
690 |
< |
|
690 |
> |
|
691 |
|
call gather(q, q_Row, plan_atom_row_3d) |
692 |
|
call gather(q, q_Col, plan_atom_col_3d) |
693 |
|
|
694 |
|
call gather(q_group, q_group_Row, plan_group_row_3d) |
695 |
|
call gather(q_group, q_group_Col, plan_group_col_3d) |
696 |
< |
|
696 |
> |
|
697 |
|
if (FF_UsesDirectionalAtoms() .and. SIM_uses_DirectionalAtoms) then |
698 |
< |
call gather(u_l, u_l_Row, plan_atom_row_3d) |
699 |
< |
call gather(u_l, u_l_Col, plan_atom_col_3d) |
700 |
< |
|
698 |
> |
call gather(eFrame, eFrame_Row, plan_atom_row_rotation) |
699 |
> |
call gather(eFrame, eFrame_Col, plan_atom_col_rotation) |
700 |
> |
|
701 |
|
call gather(A, A_Row, plan_atom_row_rotation) |
702 |
|
call gather(A, A_Col, plan_atom_col_rotation) |
703 |
|
endif |
704 |
< |
|
704 |
> |
|
705 |
|
#endif |
706 |
< |
|
706 |
> |
|
707 |
|
!! Begin force loop timing: |
708 |
|
#ifdef PROFILE |
709 |
|
call cpu_time(forceTimeInitial) |
710 |
|
nloops = nloops + 1 |
711 |
|
#endif |
712 |
< |
|
712 |
> |
|
713 |
|
loopEnd = PAIR_LOOP |
714 |
|
if (FF_RequiresPrepairCalc() .and. SIM_requires_prepair_calc) then |
715 |
|
loopStart = PREPAIR_LOOP |
724 |
|
if (loop .eq. loopStart) then |
725 |
|
#ifdef IS_MPI |
726 |
|
call checkNeighborList(nGroupsInRow, q_group_row, listSkin, & |
727 |
< |
update_nlist) |
727 |
> |
update_nlist) |
728 |
|
#else |
729 |
|
call checkNeighborList(nGroups, q_group, listSkin, & |
730 |
< |
update_nlist) |
730 |
> |
update_nlist) |
731 |
|
#endif |
732 |
|
endif |
733 |
< |
|
733 |
> |
|
734 |
|
if (update_nlist) then |
735 |
|
!! save current configuration and construct neighbor list |
736 |
|
#ifdef IS_MPI |
741 |
|
neighborListSize = size(list) |
742 |
|
nlist = 0 |
743 |
|
endif |
744 |
< |
|
744 |
> |
|
745 |
|
istart = 1 |
746 |
|
#ifdef IS_MPI |
747 |
|
iend = nGroupsInRow |
750 |
|
#endif |
751 |
|
outer: do i = istart, iend |
752 |
|
|
753 |
+ |
#ifdef IS_MPI |
754 |
+ |
me_i = atid_row(i) |
755 |
+ |
#else |
756 |
+ |
me_i = atid(i) |
757 |
+ |
#endif |
758 |
+ |
|
759 |
|
if (update_nlist) point(i) = nlist + 1 |
760 |
< |
|
760 |
> |
|
761 |
|
n_in_i = groupStartRow(i+1) - groupStartRow(i) |
762 |
< |
|
762 |
> |
|
763 |
|
if (update_nlist) then |
764 |
|
#ifdef IS_MPI |
765 |
|
jstart = 1 |
774 |
|
! make sure group i has neighbors |
775 |
|
if (jstart .gt. jend) cycle outer |
776 |
|
endif |
777 |
< |
|
777 |
> |
|
778 |
|
do jnab = jstart, jend |
779 |
|
if (update_nlist) then |
780 |
|
j = jnab |
783 |
|
endif |
784 |
|
|
785 |
|
#ifdef IS_MPI |
786 |
+ |
me_j = atid_col(j) |
787 |
|
call get_interatomic_vector(q_group_Row(:,i), & |
788 |
|
q_group_Col(:,j), d_grp, rgrpsq) |
789 |
|
#else |
790 |
+ |
me_j = atid(j) |
791 |
|
call get_interatomic_vector(q_group(:,i), & |
792 |
|
q_group(:,j), d_grp, rgrpsq) |
793 |
|
#endif |
794 |
|
|
795 |
< |
if (rgrpsq < rlistsq) then |
795 |
> |
if (rgrpsq < InteractionMap(me_i,me_j)%rListsq) then |
796 |
|
if (update_nlist) then |
797 |
|
nlist = nlist + 1 |
798 |
< |
|
798 |
> |
|
799 |
|
if (nlist > neighborListSize) then |
800 |
|
#ifdef IS_MPI |
801 |
|
call expandNeighborList(nGroupsInRow, listerror) |
809 |
|
end if |
810 |
|
neighborListSize = size(list) |
811 |
|
endif |
812 |
< |
|
812 |
> |
|
813 |
|
list(nlist) = j |
814 |
|
endif |
815 |
< |
|
815 |
> |
|
816 |
|
if (loop .eq. PAIR_LOOP) then |
817 |
|
vij = 0.0d0 |
818 |
|
fij(1:3) = 0.0d0 |
819 |
|
endif |
820 |
< |
|
820 |
> |
|
821 |
|
call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & |
822 |
|
in_switching_region) |
823 |
< |
|
823 |
> |
|
824 |
|
n_in_j = groupStartCol(j+1) - groupStartCol(j) |
825 |
< |
|
825 |
> |
|
826 |
|
do ia = groupStartRow(i), groupStartRow(i+1)-1 |
827 |
< |
|
827 |
> |
|
828 |
|
atom1 = groupListRow(ia) |
829 |
< |
|
829 |
> |
|
830 |
|
inner: do jb = groupStartCol(j), groupStartCol(j+1)-1 |
831 |
< |
|
831 |
> |
|
832 |
|
atom2 = groupListCol(jb) |
833 |
< |
|
833 |
> |
|
834 |
|
if (skipThisPair(atom1, atom2)) cycle inner |
835 |
|
|
836 |
|
if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then |
850 |
|
#ifdef IS_MPI |
851 |
|
call do_prepair(atom1, atom2, ratmsq, d_atm, sw, & |
852 |
|
rgrpsq, d_grp, do_pot, do_stress, & |
853 |
< |
u_l, A, f, t, pot_local) |
853 |
> |
eFrame, A, f, t, pot_local) |
854 |
|
#else |
855 |
|
call do_prepair(atom1, atom2, ratmsq, d_atm, sw, & |
856 |
|
rgrpsq, d_grp, do_pot, do_stress, & |
857 |
< |
u_l, A, f, t, pot) |
857 |
> |
eFrame, A, f, t, pot) |
858 |
|
#endif |
859 |
|
else |
860 |
|
#ifdef IS_MPI |
861 |
|
call do_pair(atom1, atom2, ratmsq, d_atm, sw, & |
862 |
|
do_pot, & |
863 |
< |
u_l, A, f, t, pot_local, vpair, fpair) |
863 |
> |
eFrame, A, f, t, pot_local, vpair, fpair) |
864 |
|
#else |
865 |
|
call do_pair(atom1, atom2, ratmsq, d_atm, sw, & |
866 |
|
do_pot, & |
867 |
< |
u_l, A, f, t, pot, vpair, fpair) |
867 |
> |
eFrame, A, f, t, pot, vpair, fpair) |
868 |
|
#endif |
869 |
|
|
870 |
|
vij = vij + vpair |
872 |
|
endif |
873 |
|
enddo inner |
874 |
|
enddo |
875 |
< |
|
875 |
> |
|
876 |
|
if (loop .eq. PAIR_LOOP) then |
877 |
|
if (in_switching_region) then |
878 |
|
swderiv = vij*dswdr/rgrp |
879 |
|
fij(1) = fij(1) + swderiv*d_grp(1) |
880 |
|
fij(2) = fij(2) + swderiv*d_grp(2) |
881 |
|
fij(3) = fij(3) + swderiv*d_grp(3) |
882 |
< |
|
882 |
> |
|
883 |
|
do ia=groupStartRow(i), groupStartRow(i+1)-1 |
884 |
|
atom1=groupListRow(ia) |
885 |
|
mf = mfactRow(atom1) |
893 |
|
f(3,atom1) = f(3,atom1) + swderiv*d_grp(3)*mf |
894 |
|
#endif |
895 |
|
enddo |
896 |
< |
|
896 |
> |
|
897 |
|
do jb=groupStartCol(j), groupStartCol(j+1)-1 |
898 |
|
atom2=groupListCol(jb) |
899 |
|
mf = mfactCol(atom2) |
908 |
|
#endif |
909 |
|
enddo |
910 |
|
endif |
911 |
< |
|
911 |
> |
|
912 |
|
if (do_stress) call add_stress_tensor(d_grp, fij) |
913 |
|
endif |
914 |
|
end if |
915 |
|
enddo |
916 |
|
enddo outer |
917 |
< |
|
917 |
> |
|
918 |
|
if (update_nlist) then |
919 |
|
#ifdef IS_MPI |
920 |
|
point(nGroupsInRow + 1) = nlist + 1 |
928 |
|
update_nlist = .false. |
929 |
|
endif |
930 |
|
endif |
931 |
< |
|
931 |
> |
|
932 |
|
if (loop .eq. PREPAIR_LOOP) then |
933 |
|
call do_preforce(nlocal, pot) |
934 |
|
endif |
935 |
< |
|
935 |
> |
|
936 |
|
enddo |
937 |
< |
|
937 |
> |
|
938 |
|
!! Do timing |
939 |
|
#ifdef PROFILE |
940 |
|
call cpu_time(forceTimeFinal) |
941 |
|
forceTime = forceTime + forceTimeFinal - forceTimeInitial |
942 |
|
#endif |
943 |
< |
|
943 |
> |
|
944 |
|
#ifdef IS_MPI |
945 |
|
!!distribute forces |
946 |
< |
|
946 |
> |
|
947 |
|
f_temp = 0.0_dp |
948 |
|
call scatter(f_Row,f_temp,plan_atom_row_3d) |
949 |
|
do i = 1,nlocal |
950 |
|
f(1:3,i) = f(1:3,i) + f_temp(1:3,i) |
951 |
|
end do |
952 |
< |
|
952 |
> |
|
953 |
|
f_temp = 0.0_dp |
954 |
|
call scatter(f_Col,f_temp,plan_atom_col_3d) |
955 |
|
do i = 1,nlocal |
956 |
|
f(1:3,i) = f(1:3,i) + f_temp(1:3,i) |
957 |
|
end do |
958 |
< |
|
958 |
> |
|
959 |
|
if (FF_UsesDirectionalAtoms() .and. SIM_uses_DirectionalAtoms) then |
960 |
|
t_temp = 0.0_dp |
961 |
|
call scatter(t_Row,t_temp,plan_atom_row_3d) |
964 |
|
end do |
965 |
|
t_temp = 0.0_dp |
966 |
|
call scatter(t_Col,t_temp,plan_atom_col_3d) |
967 |
< |
|
967 |
> |
|
968 |
|
do i = 1,nlocal |
969 |
|
t(1:3,i) = t(1:3,i) + t_temp(1:3,i) |
970 |
|
end do |
971 |
|
endif |
972 |
< |
|
972 |
> |
|
973 |
|
if (do_pot) then |
974 |
|
! scatter/gather pot_row into the members of my column |
975 |
|
call scatter(pot_Row, pot_Temp, plan_atom_row) |
976 |
< |
|
976 |
> |
|
977 |
|
! scatter/gather pot_local into all other procs |
978 |
|
! add resultant to get total pot |
979 |
|
do i = 1, nlocal |
980 |
|
pot_local = pot_local + pot_Temp(i) |
981 |
|
enddo |
982 |
< |
|
982 |
> |
|
983 |
|
pot_Temp = 0.0_DP |
984 |
< |
|
984 |
> |
|
985 |
|
call scatter(pot_Col, pot_Temp, plan_atom_col) |
986 |
|
do i = 1, nlocal |
987 |
|
pot_local = pot_local + pot_Temp(i) |
988 |
|
enddo |
989 |
< |
|
989 |
> |
|
990 |
|
endif |
991 |
|
#endif |
992 |
< |
|
992 |
> |
|
993 |
|
if (FF_RequiresPostpairCalc() .and. SIM_requires_postpair_calc) then |
994 |
< |
|
994 |
> |
|
995 |
|
if (FF_uses_RF .and. SIM_uses_RF) then |
996 |
< |
|
996 |
> |
|
997 |
|
#ifdef IS_MPI |
998 |
|
call scatter(rf_Row,rf,plan_atom_row_3d) |
999 |
|
call scatter(rf_Col,rf_Temp,plan_atom_col_3d) |
1001 |
|
rf(1:3,i) = rf(1:3,i) + rf_Temp(1:3,i) |
1002 |
|
end do |
1003 |
|
#endif |
1004 |
< |
|
1004 |
> |
|
1005 |
|
do i = 1, nLocal |
1006 |
< |
|
1006 |
> |
|
1007 |
|
rfpot = 0.0_DP |
1008 |
|
#ifdef IS_MPI |
1009 |
|
me_i = atid_row(i) |
1010 |
|
#else |
1011 |
|
me_i = atid(i) |
1012 |
|
#endif |
1013 |
+ |
iMap = InteractionHash(me_i,me_j) |
1014 |
|
|
1015 |
< |
if (PropertyMap(me_i)%is_Dipole) then |
1016 |
< |
|
1015 |
> |
if ( iand(iMap, ELECTROSTATIC_PAIR).ne.0 ) then |
1016 |
> |
|
1017 |
|
mu_i = getDipoleMoment(me_i) |
1018 |
< |
|
1018 |
> |
|
1019 |
|
!! The reaction field needs to include a self contribution |
1020 |
|
!! to the field: |
1021 |
< |
call accumulate_self_rf(i, mu_i, u_l) |
1021 |
> |
call accumulate_self_rf(i, mu_i, eFrame) |
1022 |
|
!! Get the reaction field contribution to the |
1023 |
|
!! potential and torques: |
1024 |
< |
call reaction_field_final(i, mu_i, u_l, rfpot, t, do_pot) |
1024 |
> |
call reaction_field_final(i, mu_i, eFrame, rfpot, t, do_pot) |
1025 |
|
#ifdef IS_MPI |
1026 |
|
pot_local = pot_local + rfpot |
1027 |
|
#else |
1028 |
|
pot = pot + rfpot |
1029 |
< |
|
1029 |
> |
|
1030 |
|
#endif |
1031 |
< |
endif |
1031 |
> |
endif |
1032 |
|
enddo |
1033 |
|
endif |
1034 |
|
endif |
1035 |
< |
|
1036 |
< |
|
1035 |
> |
|
1036 |
> |
|
1037 |
|
#ifdef IS_MPI |
1038 |
< |
|
1038 |
> |
|
1039 |
|
if (do_pot) then |
1040 |
|
pot = pot + pot_local |
1041 |
|
!! we assume the c code will do the allreduce to get the total potential |
1042 |
|
!! we could do it right here if we needed to... |
1043 |
|
endif |
1044 |
< |
|
1044 |
> |
|
1045 |
|
if (do_stress) then |
1046 |
|
call mpi_allreduce(tau_Temp, tau, 9,mpi_double_precision,mpi_sum, & |
1047 |
|
mpi_comm_world,mpi_err) |
1048 |
|
call mpi_allreduce(virial_Temp, virial,1,mpi_double_precision,mpi_sum, & |
1049 |
|
mpi_comm_world,mpi_err) |
1050 |
|
endif |
1051 |
< |
|
1051 |
> |
|
1052 |
|
#else |
1053 |
< |
|
1053 |
> |
|
1054 |
|
if (do_stress) then |
1055 |
|
tau = tau_Temp |
1056 |
|
virial = virial_Temp |
1057 |
|
endif |
1058 |
< |
|
1058 |
> |
|
1059 |
|
#endif |
1060 |
< |
|
1060 |
> |
|
1061 |
|
end subroutine do_force_loop |
1062 |
< |
|
1062 |
> |
|
1063 |
|
subroutine do_pair(i, j, rijsq, d, sw, do_pot, & |
1064 |
< |
u_l, A, f, t, pot, vpair, fpair) |
1064 |
> |
eFrame, A, f, t, pot, vpair, fpair) |
1065 |
|
|
1066 |
|
real( kind = dp ) :: pot, vpair, sw |
1067 |
|
real( kind = dp ), dimension(3) :: fpair |
1068 |
|
real( kind = dp ), dimension(nLocal) :: mfact |
1069 |
< |
real( kind = dp ), dimension(3,nLocal) :: u_l |
1069 |
> |
real( kind = dp ), dimension(9,nLocal) :: eFrame |
1070 |
|
real( kind = dp ), dimension(9,nLocal) :: A |
1071 |
|
real( kind = dp ), dimension(3,nLocal) :: f |
1072 |
|
real( kind = dp ), dimension(3,nLocal) :: t |
1076 |
|
real ( kind = dp ), intent(inout) :: rijsq |
1077 |
|
real ( kind = dp ) :: r |
1078 |
|
real ( kind = dp ), intent(inout) :: d(3) |
1079 |
+ |
real ( kind = dp ) :: ebalance |
1080 |
|
integer :: me_i, me_j |
1081 |
|
|
1082 |
+ |
integer :: iMap |
1083 |
+ |
|
1084 |
|
r = sqrt(rijsq) |
1085 |
|
vpair = 0.0d0 |
1086 |
|
fpair(1:3) = 0.0d0 |
1092 |
|
me_i = atid(i) |
1093 |
|
me_j = atid(j) |
1094 |
|
#endif |
1095 |
< |
|
1096 |
< |
if (FF_uses_LennardJones .and. SIM_uses_LennardJones) then |
1097 |
< |
|
1098 |
< |
if ( PropertyMap(me_i)%is_LennardJones .and. & |
1099 |
< |
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 |
< |
|
1095 |
> |
|
1096 |
> |
iMap = InteractionMap(me_i, me_j)%InteractionHash |
1097 |
> |
|
1098 |
> |
if ( iand(iMap, LJ_PAIR).ne.0 ) then |
1099 |
> |
call do_lj_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, f, do_pot) |
1100 |
|
endif |
1101 |
< |
|
1102 |
< |
if (FF_uses_charges .and. SIM_uses_charges) then |
1103 |
< |
|
1104 |
< |
if (PropertyMap(me_i)%is_Charge .and. PropertyMap(me_j)%is_Charge) then |
1105 |
< |
call do_charge_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1106 |
< |
pot, f, do_pot) |
1101 |
> |
|
1102 |
> |
if ( iand(iMap, ELECTROSTATIC_PAIR).ne.0 ) then |
1103 |
> |
call doElectrostaticPair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1104 |
> |
pot, eFrame, f, t, do_pot) |
1105 |
> |
|
1106 |
> |
if (FF_uses_RF .and. SIM_uses_RF) then |
1107 |
> |
|
1108 |
> |
! CHECK ME (RF needs to know about all electrostatic types) |
1109 |
> |
call accumulate_rf(i, j, r, eFrame, sw) |
1110 |
> |
call rf_correct_forces(i, j, d, r, eFrame, sw, f, fpair) |
1111 |
|
endif |
1112 |
< |
|
1112 |
> |
|
1113 |
|
endif |
886 |
– |
|
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 |
896 |
– |
endif |
1114 |
|
|
1115 |
+ |
if ( iand(iMap, STICKY_PAIR).ne.0 ) then |
1116 |
+ |
call do_sticky_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1117 |
+ |
pot, A, f, t, do_pot) |
1118 |
|
endif |
1119 |
|
|
1120 |
< |
if (FF_uses_Sticky .and. SIM_uses_sticky) then |
1121 |
< |
|
1122 |
< |
if ( PropertyMap(me_i)%is_Sticky .and. PropertyMap(me_j)%is_Sticky) then |
903 |
< |
call do_sticky_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
904 |
< |
pot, A, f, t, do_pot) |
905 |
< |
endif |
906 |
< |
|
1120 |
> |
if ( iand(iMap, STICKYPOWER_PAIR).ne.0 ) then |
1121 |
> |
call do_sticky_power_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1122 |
> |
pot, A, f, t, do_pot) |
1123 |
|
endif |
1124 |
|
|
1125 |
< |
|
1126 |
< |
if (FF_uses_GayBerne .and. SIM_uses_GayBerne) then |
1127 |
< |
|
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 |
< |
|
1125 |
> |
if ( iand(iMap, GAYBERNE_PAIR).ne.0 ) then |
1126 |
> |
call do_gb_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1127 |
> |
pot, A, f, t, do_pot) |
1128 |
|
endif |
1129 |
|
|
1130 |
< |
if (FF_uses_EAM .and. SIM_uses_EAM) then |
1131 |
< |
|
1132 |
< |
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 |
< |
|
1130 |
> |
if ( iand(iMap, GAYBERNE_LJ).ne.0 ) then |
1131 |
> |
! call do_gblj_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1132 |
> |
! pot, A, f, t, do_pot) |
1133 |
|
endif |
1134 |
|
|
1135 |
< |
if (FF_uses_Shapes .and. SIM_uses_Shapes) then |
1136 |
< |
|
1137 |
< |
if ( PropertyMap(me_i)%is_Shape .and. & |
932 |
< |
PropertyMap(me_j)%is_Shape ) then |
933 |
< |
call do_shape_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
934 |
< |
pot, A, f, t, do_pot) |
935 |
< |
endif |
936 |
< |
|
1135 |
> |
if ( iand(iMap, EAM_PAIR).ne.0 ) then |
1136 |
> |
call do_eam_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, f, & |
1137 |
> |
do_pot) |
1138 |
|
endif |
1139 |
+ |
|
1140 |
+ |
if ( iand(iMap, SHAPE_PAIR).ne.0 ) then |
1141 |
+ |
call do_shape_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1142 |
+ |
pot, A, f, t, do_pot) |
1143 |
+ |
endif |
1144 |
+ |
|
1145 |
+ |
if ( iand(iMap, SHAPE_LJ).ne.0 ) then |
1146 |
+ |
call do_shape_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1147 |
+ |
pot, A, f, t, do_pot) |
1148 |
+ |
endif |
1149 |
|
|
1150 |
|
end subroutine do_pair |
1151 |
|
|
1152 |
|
subroutine do_prepair(i, j, rijsq, d, sw, rcijsq, dc, & |
1153 |
< |
do_pot, do_stress, u_l, A, f, t, pot) |
1153 |
> |
do_pot, do_stress, eFrame, A, f, t, pot) |
1154 |
|
|
1155 |
< |
real( kind = dp ) :: pot, sw |
1156 |
< |
real( kind = dp ), dimension(3,nLocal) :: u_l |
1157 |
< |
real (kind=dp), dimension(9,nLocal) :: A |
1158 |
< |
real (kind=dp), dimension(3,nLocal) :: f |
1159 |
< |
real (kind=dp), dimension(3,nLocal) :: t |
949 |
< |
|
950 |
< |
logical, intent(inout) :: do_pot, do_stress |
951 |
< |
integer, intent(in) :: i, j |
952 |
< |
real ( kind = dp ), intent(inout) :: rijsq, rcijsq |
953 |
< |
real ( kind = dp ) :: r, rc |
954 |
< |
real ( kind = dp ), intent(inout) :: d(3), dc(3) |
955 |
< |
|
956 |
< |
logical :: is_EAM_i, is_EAM_j |
957 |
< |
|
958 |
< |
integer :: me_i, me_j |
959 |
< |
|
1155 |
> |
real( kind = dp ) :: pot, sw |
1156 |
> |
real( kind = dp ), dimension(9,nLocal) :: eFrame |
1157 |
> |
real (kind=dp), dimension(9,nLocal) :: A |
1158 |
> |
real (kind=dp), dimension(3,nLocal) :: f |
1159 |
> |
real (kind=dp), dimension(3,nLocal) :: t |
1160 |
|
|
1161 |
< |
r = sqrt(rijsq) |
1162 |
< |
if (SIM_uses_molecular_cutoffs) then |
1163 |
< |
rc = sqrt(rcijsq) |
1164 |
< |
else |
1165 |
< |
rc = r |
966 |
< |
endif |
967 |
< |
|
1161 |
> |
logical, intent(inout) :: do_pot, do_stress |
1162 |
> |
integer, intent(in) :: i, j |
1163 |
> |
real ( kind = dp ), intent(inout) :: rijsq, rcijsq |
1164 |
> |
real ( kind = dp ) :: r, rc |
1165 |
> |
real ( kind = dp ), intent(inout) :: d(3), dc(3) |
1166 |
|
|
1167 |
+ |
integer :: me_i, me_j, iMap |
1168 |
+ |
|
1169 |
|
#ifdef IS_MPI |
1170 |
< |
me_i = atid_row(i) |
1171 |
< |
me_j = atid_col(j) |
1170 |
> |
me_i = atid_row(i) |
1171 |
> |
me_j = atid_col(j) |
1172 |
|
#else |
1173 |
< |
me_i = atid(i) |
1174 |
< |
me_j = atid(j) |
1173 |
> |
me_i = atid(i) |
1174 |
> |
me_j = atid(j) |
1175 |
|
#endif |
976 |
– |
|
977 |
– |
if (FF_uses_EAM .and. SIM_uses_EAM) then |
978 |
– |
|
979 |
– |
if (PropertyMap(me_i)%is_EAM .and. PropertyMap(me_j)%is_EAM) & |
980 |
– |
call calc_EAM_prepair_rho(i, j, d, r, rijsq ) |
981 |
– |
|
982 |
– |
endif |
983 |
– |
|
984 |
– |
end subroutine do_prepair |
985 |
– |
|
986 |
– |
|
987 |
– |
subroutine do_preforce(nlocal,pot) |
988 |
– |
integer :: nlocal |
989 |
– |
real( kind = dp ) :: pot |
990 |
– |
|
991 |
– |
if (FF_uses_EAM .and. SIM_uses_EAM) then |
992 |
– |
call calc_EAM_preforce_Frho(nlocal,pot) |
993 |
– |
endif |
994 |
– |
|
995 |
– |
|
996 |
– |
end subroutine do_preforce |
997 |
– |
|
998 |
– |
|
999 |
– |
subroutine get_interatomic_vector(q_i, q_j, d, r_sq) |
1000 |
– |
|
1001 |
– |
real (kind = dp), dimension(3) :: q_i |
1002 |
– |
real (kind = dp), dimension(3) :: q_j |
1003 |
– |
real ( kind = dp ), intent(out) :: r_sq |
1004 |
– |
real( kind = dp ) :: d(3), scaled(3) |
1005 |
– |
integer i |
1006 |
– |
|
1007 |
– |
d(1:3) = q_j(1:3) - q_i(1:3) |
1008 |
– |
|
1009 |
– |
! Wrap back into periodic box if necessary |
1010 |
– |
if ( SIM_uses_PBC ) then |
1011 |
– |
|
1012 |
– |
if( .not.boxIsOrthorhombic ) then |
1013 |
– |
! calc the scaled coordinates. |
1014 |
– |
|
1015 |
– |
scaled = matmul(HmatInv, d) |
1016 |
– |
|
1017 |
– |
! wrap the scaled coordinates |
1018 |
– |
|
1019 |
– |
scaled = scaled - anint(scaled) |
1020 |
– |
|
1021 |
– |
|
1022 |
– |
! calc the wrapped real coordinates from the wrapped scaled |
1023 |
– |
! coordinates |
1024 |
– |
|
1025 |
– |
d = matmul(Hmat,scaled) |
1026 |
– |
|
1027 |
– |
else |
1028 |
– |
! calc the scaled coordinates. |
1029 |
– |
|
1030 |
– |
do i = 1, 3 |
1031 |
– |
scaled(i) = d(i) * HmatInv(i,i) |
1032 |
– |
|
1033 |
– |
! wrap the scaled coordinates |
1034 |
– |
|
1035 |
– |
scaled(i) = scaled(i) - anint(scaled(i)) |
1036 |
– |
|
1037 |
– |
! calc the wrapped real coordinates from the wrapped scaled |
1038 |
– |
! coordinates |
1039 |
– |
|
1040 |
– |
d(i) = scaled(i)*Hmat(i,i) |
1041 |
– |
enddo |
1042 |
– |
endif |
1043 |
– |
|
1044 |
– |
endif |
1045 |
– |
|
1046 |
– |
r_sq = dot_product(d,d) |
1047 |
– |
|
1048 |
– |
end subroutine get_interatomic_vector |
1049 |
– |
|
1050 |
– |
subroutine zero_work_arrays() |
1051 |
– |
|
1052 |
– |
#ifdef IS_MPI |
1053 |
– |
|
1054 |
– |
q_Row = 0.0_dp |
1055 |
– |
q_Col = 0.0_dp |
1176 |
|
|
1177 |
< |
q_group_Row = 0.0_dp |
1178 |
< |
q_group_Col = 0.0_dp |
1179 |
< |
|
1180 |
< |
u_l_Row = 0.0_dp |
1181 |
< |
u_l_Col = 0.0_dp |
1182 |
< |
|
1183 |
< |
A_Row = 0.0_dp |
1184 |
< |
A_Col = 0.0_dp |
1185 |
< |
|
1186 |
< |
f_Row = 0.0_dp |
1187 |
< |
f_Col = 0.0_dp |
1188 |
< |
f_Temp = 0.0_dp |
1189 |
< |
|
1190 |
< |
t_Row = 0.0_dp |
1191 |
< |
t_Col = 0.0_dp |
1192 |
< |
t_Temp = 0.0_dp |
1193 |
< |
|
1194 |
< |
pot_Row = 0.0_dp |
1195 |
< |
pot_Col = 0.0_dp |
1196 |
< |
pot_Temp = 0.0_dp |
1197 |
< |
|
1198 |
< |
rf_Row = 0.0_dp |
1199 |
< |
rf_Col = 0.0_dp |
1200 |
< |
rf_Temp = 0.0_dp |
1201 |
< |
|
1202 |
< |
#endif |
1203 |
< |
|
1204 |
< |
if (FF_uses_EAM .and. SIM_uses_EAM) then |
1205 |
< |
call clean_EAM() |
1206 |
< |
endif |
1207 |
< |
|
1208 |
< |
rf = 0.0_dp |
1209 |
< |
tau_Temp = 0.0_dp |
1210 |
< |
virial_Temp = 0.0_dp |
1211 |
< |
end subroutine zero_work_arrays |
1212 |
< |
|
1213 |
< |
function skipThisPair(atom1, atom2) result(skip_it) |
1214 |
< |
integer, intent(in) :: atom1 |
1215 |
< |
integer, intent(in), optional :: atom2 |
1216 |
< |
logical :: skip_it |
1217 |
< |
integer :: unique_id_1, unique_id_2 |
1218 |
< |
integer :: me_i,me_j |
1219 |
< |
integer :: i |
1220 |
< |
|
1221 |
< |
skip_it = .false. |
1222 |
< |
|
1223 |
< |
!! there are a number of reasons to skip a pair or a particle |
1224 |
< |
!! mostly we do this to exclude atoms who are involved in short |
1225 |
< |
!! range interactions (bonds, bends, torsions), but we also need |
1226 |
< |
!! to exclude some overcounted interactions that result from |
1227 |
< |
!! the parallel decomposition |
1228 |
< |
|
1177 |
> |
iMap = InteractionMap(me_i, me_j)%InteractionHash |
1178 |
> |
|
1179 |
> |
if ( iand(iMap, EAM_PAIR).ne.0 ) then |
1180 |
> |
call calc_EAM_prepair_rho(i, j, d, r, rijsq ) |
1181 |
> |
endif |
1182 |
> |
|
1183 |
> |
end subroutine do_prepair |
1184 |
> |
|
1185 |
> |
|
1186 |
> |
subroutine do_preforce(nlocal,pot) |
1187 |
> |
integer :: nlocal |
1188 |
> |
real( kind = dp ) :: pot |
1189 |
> |
|
1190 |
> |
if (FF_uses_EAM .and. SIM_uses_EAM) then |
1191 |
> |
call calc_EAM_preforce_Frho(nlocal,pot) |
1192 |
> |
endif |
1193 |
> |
|
1194 |
> |
|
1195 |
> |
end subroutine do_preforce |
1196 |
> |
|
1197 |
> |
|
1198 |
> |
subroutine get_interatomic_vector(q_i, q_j, d, r_sq) |
1199 |
> |
|
1200 |
> |
real (kind = dp), dimension(3) :: q_i |
1201 |
> |
real (kind = dp), dimension(3) :: q_j |
1202 |
> |
real ( kind = dp ), intent(out) :: r_sq |
1203 |
> |
real( kind = dp ) :: d(3), scaled(3) |
1204 |
> |
integer i |
1205 |
> |
|
1206 |
> |
d(1:3) = q_j(1:3) - q_i(1:3) |
1207 |
> |
|
1208 |
> |
! Wrap back into periodic box if necessary |
1209 |
> |
if ( SIM_uses_PBC ) then |
1210 |
> |
|
1211 |
> |
if( .not.boxIsOrthorhombic ) then |
1212 |
> |
! calc the scaled coordinates. |
1213 |
> |
|
1214 |
> |
scaled = matmul(HmatInv, d) |
1215 |
> |
|
1216 |
> |
! wrap the scaled coordinates |
1217 |
> |
|
1218 |
> |
scaled = scaled - anint(scaled) |
1219 |
> |
|
1220 |
> |
|
1221 |
> |
! calc the wrapped real coordinates from the wrapped scaled |
1222 |
> |
! coordinates |
1223 |
> |
|
1224 |
> |
d = matmul(Hmat,scaled) |
1225 |
> |
|
1226 |
> |
else |
1227 |
> |
! calc the scaled coordinates. |
1228 |
> |
|
1229 |
> |
do i = 1, 3 |
1230 |
> |
scaled(i) = d(i) * HmatInv(i,i) |
1231 |
> |
|
1232 |
> |
! wrap the scaled coordinates |
1233 |
> |
|
1234 |
> |
scaled(i) = scaled(i) - anint(scaled(i)) |
1235 |
> |
|
1236 |
> |
! calc the wrapped real coordinates from the wrapped scaled |
1237 |
> |
! coordinates |
1238 |
> |
|
1239 |
> |
d(i) = scaled(i)*Hmat(i,i) |
1240 |
> |
enddo |
1241 |
> |
endif |
1242 |
> |
|
1243 |
> |
endif |
1244 |
> |
|
1245 |
> |
r_sq = dot_product(d,d) |
1246 |
> |
|
1247 |
> |
end subroutine get_interatomic_vector |
1248 |
> |
|
1249 |
> |
subroutine zero_work_arrays() |
1250 |
> |
|
1251 |
|
#ifdef IS_MPI |
1252 |
< |
!! in MPI, we have to look up the unique IDs for each atom |
1253 |
< |
unique_id_1 = AtomRowToGlobal(atom1) |
1254 |
< |
#else |
1255 |
< |
!! in the normal loop, the atom numbers are unique |
1256 |
< |
unique_id_1 = atom1 |
1252 |
> |
|
1253 |
> |
q_Row = 0.0_dp |
1254 |
> |
q_Col = 0.0_dp |
1255 |
> |
|
1256 |
> |
q_group_Row = 0.0_dp |
1257 |
> |
q_group_Col = 0.0_dp |
1258 |
> |
|
1259 |
> |
eFrame_Row = 0.0_dp |
1260 |
> |
eFrame_Col = 0.0_dp |
1261 |
> |
|
1262 |
> |
A_Row = 0.0_dp |
1263 |
> |
A_Col = 0.0_dp |
1264 |
> |
|
1265 |
> |
f_Row = 0.0_dp |
1266 |
> |
f_Col = 0.0_dp |
1267 |
> |
f_Temp = 0.0_dp |
1268 |
> |
|
1269 |
> |
t_Row = 0.0_dp |
1270 |
> |
t_Col = 0.0_dp |
1271 |
> |
t_Temp = 0.0_dp |
1272 |
> |
|
1273 |
> |
pot_Row = 0.0_dp |
1274 |
> |
pot_Col = 0.0_dp |
1275 |
> |
pot_Temp = 0.0_dp |
1276 |
> |
|
1277 |
> |
rf_Row = 0.0_dp |
1278 |
> |
rf_Col = 0.0_dp |
1279 |
> |
rf_Temp = 0.0_dp |
1280 |
> |
|
1281 |
|
#endif |
1282 |
< |
|
1283 |
< |
!! We were called with only one atom, so just check the global exclude |
1284 |
< |
!! list for this atom |
1285 |
< |
if (.not. present(atom2)) then |
1286 |
< |
do i = 1, nExcludes_global |
1287 |
< |
if (excludesGlobal(i) == unique_id_1) then |
1288 |
< |
skip_it = .true. |
1289 |
< |
return |
1290 |
< |
end if |
1291 |
< |
end do |
1292 |
< |
return |
1293 |
< |
end if |
1294 |
< |
|
1282 |
> |
|
1283 |
> |
if (FF_uses_EAM .and. SIM_uses_EAM) then |
1284 |
> |
call clean_EAM() |
1285 |
> |
endif |
1286 |
> |
|
1287 |
> |
rf = 0.0_dp |
1288 |
> |
tau_Temp = 0.0_dp |
1289 |
> |
virial_Temp = 0.0_dp |
1290 |
> |
end subroutine zero_work_arrays |
1291 |
> |
|
1292 |
> |
function skipThisPair(atom1, atom2) result(skip_it) |
1293 |
> |
integer, intent(in) :: atom1 |
1294 |
> |
integer, intent(in), optional :: atom2 |
1295 |
> |
logical :: skip_it |
1296 |
> |
integer :: unique_id_1, unique_id_2 |
1297 |
> |
integer :: me_i,me_j |
1298 |
> |
integer :: i |
1299 |
> |
|
1300 |
> |
skip_it = .false. |
1301 |
> |
|
1302 |
> |
!! there are a number of reasons to skip a pair or a particle |
1303 |
> |
!! mostly we do this to exclude atoms who are involved in short |
1304 |
> |
!! range interactions (bonds, bends, torsions), but we also need |
1305 |
> |
!! to exclude some overcounted interactions that result from |
1306 |
> |
!! the parallel decomposition |
1307 |
> |
|
1308 |
|
#ifdef IS_MPI |
1309 |
< |
unique_id_2 = AtomColToGlobal(atom2) |
1309 |
> |
!! in MPI, we have to look up the unique IDs for each atom |
1310 |
> |
unique_id_1 = AtomRowToGlobal(atom1) |
1311 |
|
#else |
1312 |
< |
unique_id_2 = atom2 |
1312 |
> |
!! in the normal loop, the atom numbers are unique |
1313 |
> |
unique_id_1 = atom1 |
1314 |
|
#endif |
1315 |
< |
|
1315 |
> |
|
1316 |
> |
!! We were called with only one atom, so just check the global exclude |
1317 |
> |
!! list for this atom |
1318 |
> |
if (.not. present(atom2)) then |
1319 |
> |
do i = 1, nExcludes_global |
1320 |
> |
if (excludesGlobal(i) == unique_id_1) then |
1321 |
> |
skip_it = .true. |
1322 |
> |
return |
1323 |
> |
end if |
1324 |
> |
end do |
1325 |
> |
return |
1326 |
> |
end if |
1327 |
> |
|
1328 |
|
#ifdef IS_MPI |
1329 |
< |
!! this situation should only arise in MPI simulations |
1330 |
< |
if (unique_id_1 == unique_id_2) then |
1331 |
< |
skip_it = .true. |
1139 |
< |
return |
1140 |
< |
end if |
1141 |
< |
|
1142 |
< |
!! this prevents us from doing the pair on multiple processors |
1143 |
< |
if (unique_id_1 < unique_id_2) then |
1144 |
< |
if (mod(unique_id_1 + unique_id_2,2) == 0) then |
1145 |
< |
skip_it = .true. |
1146 |
< |
return |
1147 |
< |
endif |
1148 |
< |
else |
1149 |
< |
if (mod(unique_id_1 + unique_id_2,2) == 1) then |
1150 |
< |
skip_it = .true. |
1151 |
< |
return |
1152 |
< |
endif |
1153 |
< |
endif |
1329 |
> |
unique_id_2 = AtomColToGlobal(atom2) |
1330 |
> |
#else |
1331 |
> |
unique_id_2 = atom2 |
1332 |
|
#endif |
1333 |
< |
|
1334 |
< |
!! the rest of these situations can happen in all simulations: |
1335 |
< |
do i = 1, nExcludes_global |
1336 |
< |
if ((excludesGlobal(i) == unique_id_1) .or. & |
1337 |
< |
(excludesGlobal(i) == unique_id_2)) then |
1338 |
< |
skip_it = .true. |
1339 |
< |
return |
1340 |
< |
endif |
1341 |
< |
enddo |
1342 |
< |
|
1343 |
< |
do i = 1, nSkipsForAtom(atom1) |
1344 |
< |
if (skipsForAtom(atom1, i) .eq. unique_id_2) then |
1345 |
< |
skip_it = .true. |
1346 |
< |
return |
1347 |
< |
endif |
1348 |
< |
end do |
1349 |
< |
|
1350 |
< |
return |
1351 |
< |
end function skipThisPair |
1352 |
< |
|
1353 |
< |
function FF_UsesDirectionalAtoms() result(doesit) |
1354 |
< |
logical :: doesit |
1355 |
< |
doesit = FF_uses_DirectionalAtoms .or. FF_uses_Dipoles .or. & |
1356 |
< |
FF_uses_Sticky .or. FF_uses_GayBerne .or. FF_uses_Shapes |
1357 |
< |
end function FF_UsesDirectionalAtoms |
1358 |
< |
|
1359 |
< |
function FF_RequiresPrepairCalc() result(doesit) |
1360 |
< |
logical :: doesit |
1361 |
< |
doesit = FF_uses_EAM |
1362 |
< |
end function FF_RequiresPrepairCalc |
1363 |
< |
|
1364 |
< |
function FF_RequiresPostpairCalc() result(doesit) |
1365 |
< |
logical :: doesit |
1366 |
< |
doesit = FF_uses_RF |
1367 |
< |
end function FF_RequiresPostpairCalc |
1368 |
< |
|
1333 |
> |
|
1334 |
> |
#ifdef IS_MPI |
1335 |
> |
!! this situation should only arise in MPI simulations |
1336 |
> |
if (unique_id_1 == unique_id_2) then |
1337 |
> |
skip_it = .true. |
1338 |
> |
return |
1339 |
> |
end if |
1340 |
> |
|
1341 |
> |
!! this prevents us from doing the pair on multiple processors |
1342 |
> |
if (unique_id_1 < unique_id_2) then |
1343 |
> |
if (mod(unique_id_1 + unique_id_2,2) == 0) then |
1344 |
> |
skip_it = .true. |
1345 |
> |
return |
1346 |
> |
endif |
1347 |
> |
else |
1348 |
> |
if (mod(unique_id_1 + unique_id_2,2) == 1) then |
1349 |
> |
skip_it = .true. |
1350 |
> |
return |
1351 |
> |
endif |
1352 |
> |
endif |
1353 |
> |
#endif |
1354 |
> |
|
1355 |
> |
!! the rest of these situations can happen in all simulations: |
1356 |
> |
do i = 1, nExcludes_global |
1357 |
> |
if ((excludesGlobal(i) == unique_id_1) .or. & |
1358 |
> |
(excludesGlobal(i) == unique_id_2)) then |
1359 |
> |
skip_it = .true. |
1360 |
> |
return |
1361 |
> |
endif |
1362 |
> |
enddo |
1363 |
> |
|
1364 |
> |
do i = 1, nSkipsForAtom(atom1) |
1365 |
> |
if (skipsForAtom(atom1, i) .eq. unique_id_2) then |
1366 |
> |
skip_it = .true. |
1367 |
> |
return |
1368 |
> |
endif |
1369 |
> |
end do |
1370 |
> |
|
1371 |
> |
return |
1372 |
> |
end function skipThisPair |
1373 |
> |
|
1374 |
> |
function FF_UsesDirectionalAtoms() result(doesit) |
1375 |
> |
logical :: doesit |
1376 |
> |
doesit = FF_uses_DirectionalAtoms .or. FF_uses_Dipoles .or. & |
1377 |
> |
FF_uses_Quadrupoles .or. FF_uses_Sticky .or. & |
1378 |
> |
FF_uses_StickyPower .or. FF_uses_GayBerne .or. FF_uses_Shapes |
1379 |
> |
end function FF_UsesDirectionalAtoms |
1380 |
> |
|
1381 |
> |
function FF_RequiresPrepairCalc() result(doesit) |
1382 |
> |
logical :: doesit |
1383 |
> |
doesit = FF_uses_EAM |
1384 |
> |
end function FF_RequiresPrepairCalc |
1385 |
> |
|
1386 |
> |
function FF_RequiresPostpairCalc() result(doesit) |
1387 |
> |
logical :: doesit |
1388 |
> |
doesit = FF_uses_RF |
1389 |
> |
end function FF_RequiresPostpairCalc |
1390 |
> |
|
1391 |
|
#ifdef PROFILE |
1392 |
< |
function getforcetime() result(totalforcetime) |
1393 |
< |
real(kind=dp) :: totalforcetime |
1394 |
< |
totalforcetime = forcetime |
1395 |
< |
end function getforcetime |
1392 |
> |
function getforcetime() result(totalforcetime) |
1393 |
> |
real(kind=dp) :: totalforcetime |
1394 |
> |
totalforcetime = forcetime |
1395 |
> |
end function getforcetime |
1396 |
|
#endif |
1197 |
– |
|
1198 |
– |
!! This cleans componets of force arrays belonging only to fortran |
1397 |
|
|
1398 |
< |
subroutine add_stress_tensor(dpair, fpair) |
1201 |
< |
|
1202 |
< |
real( kind = dp ), dimension(3), intent(in) :: dpair, fpair |
1203 |
< |
|
1204 |
< |
! because the d vector is the rj - ri vector, and |
1205 |
< |
! because fx, fy, fz are the force on atom i, we need a |
1206 |
< |
! negative sign here: |
1207 |
< |
|
1208 |
< |
tau_Temp(1) = tau_Temp(1) - dpair(1) * fpair(1) |
1209 |
< |
tau_Temp(2) = tau_Temp(2) - dpair(1) * fpair(2) |
1210 |
< |
tau_Temp(3) = tau_Temp(3) - dpair(1) * fpair(3) |
1211 |
< |
tau_Temp(4) = tau_Temp(4) - dpair(2) * fpair(1) |
1212 |
< |
tau_Temp(5) = tau_Temp(5) - dpair(2) * fpair(2) |
1213 |
< |
tau_Temp(6) = tau_Temp(6) - dpair(2) * fpair(3) |
1214 |
< |
tau_Temp(7) = tau_Temp(7) - dpair(3) * fpair(1) |
1215 |
< |
tau_Temp(8) = tau_Temp(8) - dpair(3) * fpair(2) |
1216 |
< |
tau_Temp(9) = tau_Temp(9) - dpair(3) * fpair(3) |
1217 |
< |
|
1218 |
< |
virial_Temp = virial_Temp + & |
1219 |
< |
(tau_Temp(1) + tau_Temp(5) + tau_Temp(9)) |
1220 |
< |
|
1221 |
< |
end subroutine add_stress_tensor |
1222 |
< |
|
1223 |
< |
end module doForces |
1398 |
> |
!! This cleans componets of force arrays belonging only to fortran |
1399 |
|
|
1400 |
< |
!! Interfaces for C programs to module.... |
1400 |
> |
subroutine add_stress_tensor(dpair, fpair) |
1401 |
|
|
1402 |
< |
subroutine initFortranFF(use_RF_c, thisStat) |
1228 |
< |
use doForces, ONLY: init_FF |
1229 |
< |
logical, intent(in) :: use_RF_c |
1402 |
> |
real( kind = dp ), dimension(3), intent(in) :: dpair, fpair |
1403 |
|
|
1404 |
< |
integer, intent(out) :: thisStat |
1405 |
< |
call init_FF(use_RF_c, thisStat) |
1404 |
> |
! because the d vector is the rj - ri vector, and |
1405 |
> |
! because fx, fy, fz are the force on atom i, we need a |
1406 |
> |
! negative sign here: |
1407 |
|
|
1408 |
< |
end subroutine initFortranFF |
1408 |
> |
tau_Temp(1) = tau_Temp(1) - dpair(1) * fpair(1) |
1409 |
> |
tau_Temp(2) = tau_Temp(2) - dpair(1) * fpair(2) |
1410 |
> |
tau_Temp(3) = tau_Temp(3) - dpair(1) * fpair(3) |
1411 |
> |
tau_Temp(4) = tau_Temp(4) - dpair(2) * fpair(1) |
1412 |
> |
tau_Temp(5) = tau_Temp(5) - dpair(2) * fpair(2) |
1413 |
> |
tau_Temp(6) = tau_Temp(6) - dpair(2) * fpair(3) |
1414 |
> |
tau_Temp(7) = tau_Temp(7) - dpair(3) * fpair(1) |
1415 |
> |
tau_Temp(8) = tau_Temp(8) - dpair(3) * fpair(2) |
1416 |
> |
tau_Temp(9) = tau_Temp(9) - dpair(3) * fpair(3) |
1417 |
|
|
1418 |
< |
subroutine doForceloop(q, q_group, A, u_l, f, t, tau, pot, & |
1419 |
< |
do_pot_c, do_stress_c, error) |
1238 |
< |
|
1239 |
< |
use definitions, ONLY: dp |
1240 |
< |
use simulation |
1241 |
< |
use doForces, ONLY: do_force_loop |
1242 |
< |
!! Position array provided by C, dimensioned by getNlocal |
1243 |
< |
real ( kind = dp ), dimension(3, nLocal) :: q |
1244 |
< |
!! molecular center-of-mass position array |
1245 |
< |
real ( kind = dp ), dimension(3, nGroups) :: q_group |
1246 |
< |
!! Rotation Matrix for each long range particle in simulation. |
1247 |
< |
real( kind = dp), dimension(9, nLocal) :: A |
1248 |
< |
!! Unit vectors for dipoles (lab frame) |
1249 |
< |
real( kind = dp ), dimension(3,nLocal) :: u_l |
1250 |
< |
!! Force array provided by C, dimensioned by getNlocal |
1251 |
< |
real ( kind = dp ), dimension(3,nLocal) :: f |
1252 |
< |
!! Torsion array provided by C, dimensioned by getNlocal |
1253 |
< |
real( kind = dp ), dimension(3,nLocal) :: t |
1418 |
> |
virial_Temp = virial_Temp + & |
1419 |
> |
(tau_Temp(1) + tau_Temp(5) + tau_Temp(9)) |
1420 |
|
|
1421 |
< |
!! Stress Tensor |
1422 |
< |
real( kind = dp), dimension(9) :: tau |
1423 |
< |
real ( kind = dp ) :: pot |
1258 |
< |
logical ( kind = 2) :: do_pot_c, do_stress_c |
1259 |
< |
integer :: error |
1260 |
< |
|
1261 |
< |
call do_force_loop(q, q_group, A, u_l, f, t, tau, pot, & |
1262 |
< |
do_pot_c, do_stress_c, error) |
1263 |
< |
|
1264 |
< |
end subroutine doForceloop |
1421 |
> |
end subroutine add_stress_tensor |
1422 |
> |
|
1423 |
> |
end module doForces |