4 |
|
|
5 |
|
!! @author Charles F. Vardeman II |
6 |
|
!! @author Matthew Meineke |
7 |
< |
!! @version $Id: do_Forces.F90,v 1.40 2003-12-19 20:36:35 mmeineke Exp $, $Date: 2003-12-19 20:36:35 $, $Name: not supported by cvs2svn $, $Revision: 1.40 $ |
7 |
> |
!! @version $Id: do_Forces.F90,v 1.51 2004-04-24 04:31:36 tim Exp $, $Date: 2004-04-24 04:31:36 $, $Name: not supported by cvs2svn $, $Revision: 1.51 $ |
8 |
|
|
9 |
|
module do_Forces |
10 |
|
use force_globals |
15 |
|
use lj |
16 |
|
use sticky_pair |
17 |
|
use dipole_dipole |
18 |
+ |
use charge_charge |
19 |
|
use reaction_field |
20 |
|
use gb_pair |
21 |
|
use vector_class |
31 |
|
#define __FORTRAN90 |
32 |
|
#include "fForceField.h" |
33 |
|
|
34 |
< |
logical, save :: do_forces_initialized = .false., haveRlist = .false. |
34 |
> |
logical, save :: haveRlist = .false. |
35 |
> |
logical, save :: haveNeighborList = .false. |
36 |
|
logical, save :: havePolicies = .false. |
37 |
+ |
logical, save :: haveSIMvariables = .false. |
38 |
+ |
logical, save :: havePropertyMap = .false. |
39 |
+ |
logical, save :: haveSaneForceField = .false. |
40 |
|
logical, save :: FF_uses_LJ |
41 |
|
logical, save :: FF_uses_sticky |
42 |
+ |
logical, save :: FF_uses_charges |
43 |
|
logical, save :: FF_uses_dipoles |
44 |
|
logical, save :: FF_uses_RF |
45 |
|
logical, save :: FF_uses_GB |
46 |
|
logical, save :: FF_uses_EAM |
47 |
+ |
logical, save :: SIM_uses_LJ |
48 |
+ |
logical, save :: SIM_uses_sticky |
49 |
+ |
logical, save :: SIM_uses_charges |
50 |
+ |
logical, save :: SIM_uses_dipoles |
51 |
+ |
logical, save :: SIM_uses_RF |
52 |
+ |
logical, save :: SIM_uses_GB |
53 |
+ |
logical, save :: SIM_uses_EAM |
54 |
+ |
logical, save :: SIM_requires_postpair_calc |
55 |
+ |
logical, save :: SIM_requires_prepair_calc |
56 |
+ |
logical, save :: SIM_uses_directional_atoms |
57 |
+ |
logical, save :: SIM_uses_PBC |
58 |
|
|
59 |
|
real(kind=dp), save :: rlist, rlistsq |
60 |
|
|
62 |
|
public :: do_force_loop |
63 |
|
public :: setRlistDF |
64 |
|
|
65 |
+ |
|
66 |
|
#ifdef PROFILE |
67 |
|
public :: getforcetime |
68 |
|
real, save :: forceTime = 0 |
70 |
|
integer :: nLoops |
71 |
|
#endif |
72 |
|
|
73 |
+ |
type :: Properties |
74 |
+ |
logical :: is_lj = .false. |
75 |
+ |
logical :: is_sticky = .false. |
76 |
+ |
logical :: is_dp = .false. |
77 |
+ |
logical :: is_gb = .false. |
78 |
+ |
logical :: is_eam = .false. |
79 |
+ |
logical :: is_charge = .false. |
80 |
+ |
real(kind=DP) :: charge = 0.0_DP |
81 |
+ |
real(kind=DP) :: dipole_moment = 0.0_DP |
82 |
+ |
end type Properties |
83 |
+ |
|
84 |
+ |
type(Properties), dimension(:),allocatable :: PropertyMap |
85 |
+ |
|
86 |
|
contains |
87 |
|
|
88 |
|
subroutine setRlistDF( this_rlist ) |
93 |
|
rlistsq = rlist * rlist |
94 |
|
|
95 |
|
haveRlist = .true. |
65 |
– |
if( havePolicies ) do_forces_initialized = .true. |
96 |
|
|
97 |
|
end subroutine setRlistDF |
98 |
+ |
|
99 |
+ |
subroutine createPropertyMap(status) |
100 |
+ |
integer :: nAtypes |
101 |
+ |
integer :: status |
102 |
+ |
integer :: i |
103 |
+ |
logical :: thisProperty |
104 |
+ |
real (kind=DP) :: thisDPproperty |
105 |
+ |
|
106 |
+ |
status = 0 |
107 |
+ |
|
108 |
+ |
nAtypes = getSize(atypes) |
109 |
+ |
|
110 |
+ |
if (nAtypes == 0) then |
111 |
+ |
status = -1 |
112 |
+ |
return |
113 |
+ |
end if |
114 |
+ |
|
115 |
+ |
if (.not. allocated(PropertyMap)) then |
116 |
+ |
allocate(PropertyMap(nAtypes)) |
117 |
+ |
endif |
118 |
+ |
|
119 |
+ |
do i = 1, nAtypes |
120 |
+ |
call getElementProperty(atypes, i, "is_LJ", thisProperty) |
121 |
+ |
PropertyMap(i)%is_LJ = thisProperty |
122 |
+ |
|
123 |
+ |
call getElementProperty(atypes, i, "is_Charge", thisProperty) |
124 |
+ |
PropertyMap(i)%is_Charge = thisProperty |
125 |
+ |
|
126 |
+ |
if (thisProperty) then |
127 |
+ |
call getElementProperty(atypes, i, "charge", thisDPproperty) |
128 |
+ |
PropertyMap(i)%charge = thisDPproperty |
129 |
+ |
endif |
130 |
+ |
|
131 |
+ |
call getElementProperty(atypes, i, "is_DP", thisProperty) |
132 |
+ |
PropertyMap(i)%is_DP = thisProperty |
133 |
+ |
|
134 |
+ |
if (thisProperty) then |
135 |
+ |
call getElementProperty(atypes, i, "dipole_moment", thisDPproperty) |
136 |
+ |
PropertyMap(i)%dipole_moment = thisDPproperty |
137 |
+ |
endif |
138 |
+ |
|
139 |
+ |
call getElementProperty(atypes, i, "is_Sticky", thisProperty) |
140 |
+ |
PropertyMap(i)%is_Sticky = thisProperty |
141 |
+ |
call getElementProperty(atypes, i, "is_GB", thisProperty) |
142 |
+ |
PropertyMap(i)%is_GB = thisProperty |
143 |
+ |
call getElementProperty(atypes, i, "is_EAM", thisProperty) |
144 |
+ |
PropertyMap(i)%is_EAM = thisProperty |
145 |
+ |
end do |
146 |
+ |
|
147 |
+ |
havePropertyMap = .true. |
148 |
+ |
|
149 |
+ |
end subroutine createPropertyMap |
150 |
+ |
|
151 |
+ |
subroutine setSimVariables() |
152 |
+ |
SIM_uses_LJ = SimUsesLJ() |
153 |
+ |
SIM_uses_sticky = SimUsesSticky() |
154 |
+ |
SIM_uses_charges = SimUsesCharges() |
155 |
+ |
SIM_uses_dipoles = SimUsesDipoles() |
156 |
+ |
SIM_uses_RF = SimUsesRF() |
157 |
+ |
SIM_uses_GB = SimUsesGB() |
158 |
+ |
SIM_uses_EAM = SimUsesEAM() |
159 |
+ |
SIM_requires_postpair_calc = SimRequiresPostpairCalc() |
160 |
+ |
SIM_requires_prepair_calc = SimRequiresPrepairCalc() |
161 |
+ |
SIM_uses_directional_atoms = SimUsesDirectionalAtoms() |
162 |
+ |
SIM_uses_PBC = SimUsesPBC() |
163 |
+ |
|
164 |
+ |
haveSIMvariables = .true. |
165 |
+ |
|
166 |
+ |
return |
167 |
+ |
end subroutine setSimVariables |
168 |
|
|
169 |
+ |
subroutine doReadyCheck(error) |
170 |
+ |
integer, intent(out) :: error |
171 |
+ |
|
172 |
+ |
integer :: myStatus |
173 |
+ |
|
174 |
+ |
error = 0 |
175 |
+ |
|
176 |
+ |
if (.not. havePropertyMap) then |
177 |
+ |
|
178 |
+ |
myStatus = 0 |
179 |
+ |
|
180 |
+ |
call createPropertyMap(myStatus) |
181 |
+ |
|
182 |
+ |
if (myStatus .ne. 0) then |
183 |
+ |
write(default_error, *) 'createPropertyMap failed in do_Forces!' |
184 |
+ |
error = -1 |
185 |
+ |
return |
186 |
+ |
endif |
187 |
+ |
endif |
188 |
+ |
|
189 |
+ |
if (.not. haveSIMvariables) then |
190 |
+ |
call setSimVariables() |
191 |
+ |
endif |
192 |
+ |
|
193 |
+ |
if (.not. haveRlist) then |
194 |
+ |
write(default_error, *) 'rList has not been set in do_Forces!' |
195 |
+ |
error = -1 |
196 |
+ |
return |
197 |
+ |
endif |
198 |
+ |
|
199 |
+ |
if (SIM_uses_LJ .and. FF_uses_LJ) then |
200 |
+ |
if (.not. havePolicies) then |
201 |
+ |
write(default_error, *) 'LJ mixing Policies have not been set in do_Forces!' |
202 |
+ |
error = -1 |
203 |
+ |
return |
204 |
+ |
endif |
205 |
+ |
endif |
206 |
+ |
|
207 |
+ |
if (.not. haveNeighborList) then |
208 |
+ |
write(default_error, *) 'neighbor list has not been initialized in do_Forces!' |
209 |
+ |
error = -1 |
210 |
+ |
return |
211 |
+ |
end if |
212 |
+ |
|
213 |
+ |
if (.not. haveSaneForceField) then |
214 |
+ |
write(default_error, *) 'Force Field is not sane in do_Forces!' |
215 |
+ |
error = -1 |
216 |
+ |
return |
217 |
+ |
end if |
218 |
+ |
|
219 |
+ |
#ifdef IS_MPI |
220 |
+ |
if (.not. isMPISimSet()) then |
221 |
+ |
write(default_error,*) "ERROR: mpiSimulation has not been initialized!" |
222 |
+ |
error = -1 |
223 |
+ |
return |
224 |
+ |
endif |
225 |
+ |
#endif |
226 |
+ |
return |
227 |
+ |
end subroutine doReadyCheck |
228 |
+ |
|
229 |
+ |
|
230 |
|
subroutine init_FF(LJMIXPOLICY, use_RF_c, thisStat) |
231 |
|
|
232 |
|
integer, intent(in) :: LJMIXPOLICY |
251 |
|
|
252 |
|
FF_uses_LJ = .false. |
253 |
|
FF_uses_sticky = .false. |
254 |
+ |
FF_uses_charges = .false. |
255 |
|
FF_uses_dipoles = .false. |
256 |
|
FF_uses_GB = .false. |
257 |
|
FF_uses_EAM = .false. |
258 |
|
|
259 |
|
call getMatchingElementList(atypes, "is_LJ", .true., nMatches, MatchList) |
260 |
|
if (nMatches .gt. 0) FF_uses_LJ = .true. |
261 |
< |
|
261 |
> |
|
262 |
> |
call getMatchingElementList(atypes, "is_Charge", .true., nMatches, MatchList) |
263 |
> |
if (nMatches .gt. 0) FF_uses_charges = .true. |
264 |
> |
|
265 |
|
call getMatchingElementList(atypes, "is_DP", .true., nMatches, MatchList) |
266 |
|
if (nMatches .gt. 0) FF_uses_dipoles = .true. |
267 |
|
|
275 |
|
call getMatchingElementList(atypes, "is_EAM", .true., nMatches, MatchList) |
276 |
|
if (nMatches .gt. 0) FF_uses_EAM = .true. |
277 |
|
|
278 |
+ |
!! Assume sanity (for the sake of argument) |
279 |
+ |
haveSaneForceField = .true. |
280 |
+ |
!! |
281 |
+ |
if (FF_uses_charges) then |
282 |
+ |
dielect = getDielect() |
283 |
+ |
call initialize_charge(dielect) |
284 |
+ |
endif |
285 |
+ |
|
286 |
+ |
|
287 |
|
!! check to make sure the FF_uses_RF setting makes sense |
288 |
|
|
289 |
|
if (FF_uses_dipoles) then |
295 |
|
if (FF_uses_RF) then |
296 |
|
write(default_error,*) 'Using Reaction Field with no dipoles? Huh?' |
297 |
|
thisStat = -1 |
298 |
+ |
haveSaneForceField = .false. |
299 |
|
return |
300 |
|
endif |
301 |
|
endif |
310 |
|
case default |
311 |
|
write(default_error,*) 'unknown LJ Mixing Policy!' |
312 |
|
thisStat = -1 |
313 |
+ |
haveSaneForceField = .false. |
314 |
|
return |
315 |
|
end select |
316 |
|
if (my_status /= 0) then |
317 |
|
thisStat = -1 |
318 |
+ |
haveSaneForceField = .false. |
319 |
|
return |
320 |
|
end if |
321 |
+ |
havePolicies = .true. |
322 |
|
endif |
323 |
|
|
324 |
|
if (FF_uses_sticky) then |
325 |
|
call check_sticky_FF(my_status) |
326 |
|
if (my_status /= 0) then |
327 |
|
thisStat = -1 |
328 |
+ |
haveSaneForceField = .false. |
329 |
|
return |
330 |
|
end if |
331 |
|
endif |
334 |
|
if (FF_uses_EAM) then |
335 |
|
call init_EAM_FF(my_status) |
336 |
|
if (my_status /= 0) then |
337 |
< |
write(*,*) "init_EAM_FF returned a bad status" |
337 |
> |
write(default_error, *) "init_EAM_FF returned a bad status" |
338 |
|
thisStat = -1 |
339 |
+ |
haveSaneForceField = .false. |
340 |
|
return |
341 |
|
end if |
342 |
|
endif |
343 |
|
|
164 |
– |
|
165 |
– |
|
344 |
|
if (FF_uses_GB) then |
345 |
|
call check_gb_pair_FF(my_status) |
346 |
|
if (my_status .ne. 0) then |
347 |
|
thisStat = -1 |
348 |
+ |
haveSaneForceField = .false. |
349 |
|
return |
350 |
|
endif |
351 |
|
endif |
352 |
|
|
353 |
|
if (FF_uses_GB .and. FF_uses_LJ) then |
354 |
|
endif |
355 |
< |
if (.not. do_forces_initialized) then |
355 |
> |
if (.not. haveNeighborList) then |
356 |
|
!! Create neighbor lists |
357 |
< |
call expandNeighborList(getNlocal(), my_status) |
357 |
> |
call expandNeighborList(nLocal, my_status) |
358 |
|
if (my_Status /= 0) then |
359 |
|
write(default_error,*) "SimSetup: ExpandNeighborList returned error." |
360 |
|
thisStat = -1 |
361 |
|
return |
362 |
|
endif |
363 |
+ |
haveNeighborList = .true. |
364 |
|
endif |
365 |
|
|
186 |
– |
|
187 |
– |
havePolicies = .true. |
188 |
– |
if( haveRlist ) do_forces_initialized = .true. |
189 |
– |
|
366 |
|
end subroutine init_FF |
367 |
|
|
368 |
|
|
371 |
|
subroutine do_force_loop(q, A, u_l, f, t, tau, pot, do_pot_c, do_stress_c, & |
372 |
|
error) |
373 |
|
!! Position array provided by C, dimensioned by getNlocal |
374 |
< |
real ( kind = dp ), dimension(3,getNlocal()) :: q |
374 |
> |
real ( kind = dp ), dimension(3,nLocal) :: q |
375 |
|
!! Rotation Matrix for each long range particle in simulation. |
376 |
< |
real( kind = dp), dimension(9,getNlocal()) :: A |
377 |
< |
!! Unit vectors for dipoles (lab frame) |
378 |
< |
real( kind = dp ), dimension(3,getNlocal()) :: u_l |
376 |
> |
real( kind = dp), dimension(9,nLocal) :: A |
377 |
> |
!! Unit vectors for dipoles (lab frame) |
378 |
> |
real( kind = dp ), dimension(3,nLocal) :: u_l |
379 |
|
!! Force array provided by C, dimensioned by getNlocal |
380 |
< |
real ( kind = dp ), dimension(3,getNlocal()) :: f |
380 |
> |
real ( kind = dp ), dimension(3,nLocal) :: f |
381 |
|
!! Torsion array provided by C, dimensioned by getNlocal |
382 |
< |
real( kind = dp ), dimension(3,getNlocal()) :: t |
382 |
> |
real( kind = dp ), dimension(3,nLocal) :: t |
383 |
> |
|
384 |
|
!! Stress Tensor |
385 |
|
real( kind = dp), dimension(9) :: tau |
386 |
|
real ( kind = dp ) :: pot |
393 |
|
integer :: ncol |
394 |
|
integer :: nprocs |
395 |
|
#endif |
219 |
– |
integer :: nlocal |
396 |
|
integer :: natoms |
397 |
|
logical :: update_nlist |
398 |
|
integer :: i, j, jbeg, jend, jnab |
400 |
|
real( kind = DP ) :: rijsq |
401 |
|
real(kind=dp),dimension(3) :: d |
402 |
|
real(kind=dp) :: rfpot, mu_i, virial |
403 |
< |
integer :: me_i |
403 |
> |
integer :: me_i, me_j |
404 |
|
logical :: is_dp_i |
405 |
|
integer :: neighborListSize |
406 |
|
integer :: listerror, error |
407 |
|
integer :: localError |
408 |
+ |
integer :: propPack_i, propPack_j |
409 |
|
|
410 |
|
real(kind=dp) :: listSkin = 1.0 |
411 |
|
|
413 |
|
|
414 |
|
#ifdef IS_MPI |
415 |
|
pot_local = 0.0_dp |
239 |
– |
nlocal = getNlocal() |
416 |
|
nrow = getNrow(plan_row) |
417 |
|
ncol = getNcol(plan_col) |
418 |
|
#else |
243 |
– |
nlocal = getNlocal() |
419 |
|
natoms = nlocal |
420 |
|
#endif |
421 |
|
|
422 |
< |
call check_initialization(localError) |
422 |
> |
call doReadyCheck(localError) |
423 |
|
if ( localError .ne. 0 ) then |
424 |
< |
call handleError("do_force_loop","Not Initialized") |
424 |
> |
call handleError("do_force_loop", "Not Initialized") |
425 |
|
error = -1 |
426 |
|
return |
427 |
|
end if |
428 |
|
call zero_work_arrays() |
429 |
|
|
430 |
+ |
|
431 |
|
do_pot = do_pot_c |
432 |
|
do_stress = do_stress_c |
433 |
|
|
258 |
– |
|
434 |
|
! Gather all information needed by all force loops: |
435 |
|
|
436 |
|
#ifdef IS_MPI |
438 |
|
call gather(q,q_Row,plan_row3d) |
439 |
|
call gather(q,q_Col,plan_col3d) |
440 |
|
|
441 |
< |
if (FF_UsesDirectionalAtoms() .and. SimUsesDirectionalAtoms()) then |
441 |
> |
if (FF_UsesDirectionalAtoms() .and. SIM_uses_directional_atoms) then |
442 |
|
call gather(u_l,u_l_Row,plan_row3d) |
443 |
|
call gather(u_l,u_l_Col,plan_col3d) |
444 |
|
|
454 |
|
nloops = nloops + 1 |
455 |
|
#endif |
456 |
|
|
457 |
< |
if (FF_RequiresPrepairCalc() .and. SimRequiresPrepairCalc()) then |
457 |
> |
if (FF_RequiresPrepairCalc() .and. SIM_requires_prepair_calc) then |
458 |
|
!! See if we need to update neighbor lists |
459 |
|
call checkNeighborList(nlocal, q, listSkin, update_nlist) |
460 |
|
!! if_mpi_gather_stuff_for_prepair |
626 |
|
nlist = 0 |
627 |
|
|
628 |
|
do i = 1, nrow |
629 |
+ |
|
630 |
|
point(i) = nlist + 1 |
631 |
|
|
632 |
|
inner: do j = 1, ncol |
775 |
|
f(1:3,i) = f(1:3,i) + f_temp(1:3,i) |
776 |
|
end do |
777 |
|
|
778 |
< |
if (FF_UsesDirectionalAtoms() .and. SimUsesDirectionalAtoms()) then |
778 |
> |
if (FF_UsesDirectionalAtoms() .and. SIM_uses_directional_atoms) then |
779 |
|
t_temp = 0.0_dp |
780 |
|
call scatter(t_Row,t_temp,plan_row3d) |
781 |
|
do i = 1,nlocal |
809 |
|
endif |
810 |
|
#endif |
811 |
|
|
812 |
< |
if (FF_RequiresPostpairCalc() .and. SimRequiresPostpairCalc()) then |
812 |
> |
if (FF_RequiresPostpairCalc() .and. SIM_requires_postpair_calc) then |
813 |
|
|
814 |
< |
if (FF_uses_RF .and. SimUsesRF()) then |
815 |
< |
|
814 |
> |
if (FF_uses_RF .and. SIM_uses_RF) then |
815 |
> |
|
816 |
|
#ifdef IS_MPI |
817 |
|
call scatter(rf_Row,rf,plan_row3d) |
818 |
|
call scatter(rf_Col,rf_Temp,plan_col3d) |
821 |
|
end do |
822 |
|
#endif |
823 |
|
|
824 |
< |
do i = 1, getNlocal() |
824 |
> |
do i = 1, nLocal |
825 |
|
|
826 |
|
rfpot = 0.0_DP |
827 |
|
#ifdef IS_MPI |
829 |
|
#else |
830 |
|
me_i = atid(i) |
831 |
|
#endif |
832 |
< |
call getElementProperty(atypes, me_i, "is_DP", is_DP_i) |
833 |
< |
if ( is_DP_i ) then |
834 |
< |
call getElementProperty(atypes, me_i, "dipole_moment", mu_i) |
832 |
> |
|
833 |
> |
if (PropertyMap(me_i)%is_DP) then |
834 |
> |
|
835 |
> |
mu_i = PropertyMap(me_i)%dipole_moment |
836 |
> |
|
837 |
|
!! The reaction field needs to include a self contribution |
838 |
|
!! to the field: |
839 |
< |
call accumulate_self_rf(i, mu_i, u_l) |
839 |
> |
call accumulate_self_rf(i, mu_i, u_l) |
840 |
|
!! Get the reaction field contribution to the |
841 |
|
!! potential and torques: |
842 |
|
call reaction_field_final(i, mu_i, u_l, rfpot, t, do_pot) |
877 |
|
#endif |
878 |
|
|
879 |
|
|
702 |
– |
|
880 |
|
end subroutine do_force_loop |
881 |
|
|
882 |
|
subroutine do_pair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t, pot) |
883 |
|
|
884 |
|
real( kind = dp ) :: pot |
885 |
< |
real( kind = dp ), dimension(3,getNlocal()) :: u_l |
886 |
< |
real (kind=dp), dimension(9,getNlocal()) :: A |
887 |
< |
real (kind=dp), dimension(3,getNlocal()) :: f |
888 |
< |
real (kind=dp), dimension(3,getNlocal()) :: t |
885 |
> |
real( kind = dp ), dimension(3,nLocal) :: u_l |
886 |
> |
real (kind=dp), dimension(9,nLocal) :: A |
887 |
> |
real (kind=dp), dimension(3,nLocal) :: f |
888 |
> |
real (kind=dp), dimension(3,nLocal) :: t |
889 |
|
|
890 |
|
logical, intent(inout) :: do_pot, do_stress |
891 |
|
integer, intent(in) :: i, j |
892 |
|
real ( kind = dp ), intent(inout) :: rijsq |
893 |
|
real ( kind = dp ) :: r |
894 |
|
real ( kind = dp ), intent(inout) :: d(3) |
718 |
– |
logical :: is_LJ_i, is_LJ_j |
719 |
– |
logical :: is_DP_i, is_DP_j |
720 |
– |
logical :: is_GB_i, is_GB_j |
721 |
– |
logical :: is_EAM_i,is_EAM_j |
722 |
– |
logical :: is_Sticky_i, is_Sticky_j |
895 |
|
integer :: me_i, me_j |
896 |
|
|
897 |
+ |
|
898 |
|
r = sqrt(rijsq) |
899 |
|
|
900 |
|
#ifdef IS_MPI |
901 |
|
if (tagRow(i) .eq. tagColumn(j)) then |
902 |
|
write(0,*) 'do_pair is doing', i , j, tagRow(i), tagColumn(j) |
903 |
|
endif |
731 |
– |
|
904 |
|
me_i = atid_row(i) |
905 |
|
me_j = atid_col(j) |
734 |
– |
|
906 |
|
#else |
736 |
– |
|
907 |
|
me_i = atid(i) |
908 |
|
me_j = atid(j) |
739 |
– |
|
909 |
|
#endif |
910 |
< |
|
911 |
< |
if (FF_uses_LJ .and. SimUsesLJ()) then |
912 |
< |
call getElementProperty(atypes, me_i, "is_LJ", is_LJ_i) |
913 |
< |
call getElementProperty(atypes, me_j, "is_LJ", is_LJ_j) |
914 |
< |
|
915 |
< |
if ( is_LJ_i .and. is_LJ_j ) & |
916 |
< |
call do_lj_pair(i, j, d, r, rijsq, pot, f, do_pot, do_stress) |
910 |
> |
|
911 |
> |
if (FF_uses_LJ .and. SIM_uses_LJ) then |
912 |
> |
|
913 |
> |
if ( PropertyMap(me_i)%is_LJ .and. PropertyMap(me_j)%is_LJ ) then |
914 |
> |
call do_lj_pair(i, j, d, r, rijsq, pot, f, do_pot, do_stress) |
915 |
> |
endif |
916 |
> |
|
917 |
|
endif |
918 |
< |
|
919 |
< |
if (FF_uses_dipoles .and. SimUsesDipoles()) then |
751 |
< |
call getElementProperty(atypes, me_i, "is_DP", is_DP_i) |
752 |
< |
call getElementProperty(atypes, me_j, "is_DP", is_DP_j) |
918 |
> |
|
919 |
> |
if (FF_uses_charges .and. SIM_uses_charges) then |
920 |
|
|
921 |
< |
if ( is_DP_i .and. is_DP_j ) then |
921 |
> |
if (PropertyMap(me_i)%is_Charge .and. PropertyMap(me_j)%is_Charge) then |
922 |
> |
call do_charge_pair(i, j, d, r, rijsq, pot, f, do_pot, do_stress) |
923 |
> |
endif |
924 |
> |
|
925 |
> |
endif |
926 |
> |
|
927 |
> |
if (FF_uses_dipoles .and. SIM_uses_dipoles) then |
928 |
> |
|
929 |
> |
if ( PropertyMap(me_i)%is_DP .and. PropertyMap(me_j)%is_DP) then |
930 |
|
call do_dipole_pair(i, j, d, r, rijsq, pot, u_l, f, t, & |
931 |
|
do_pot, do_stress) |
932 |
< |
if (FF_uses_RF .and. SimUsesRF()) then |
932 |
> |
if (FF_uses_RF .and. SIM_uses_RF) then |
933 |
|
call accumulate_rf(i, j, r, u_l) |
934 |
|
call rf_correct_forces(i, j, d, r, u_l, f, do_stress) |
935 |
< |
endif |
761 |
< |
|
935 |
> |
endif |
936 |
|
endif |
937 |
+ |
|
938 |
|
endif |
939 |
|
|
940 |
< |
if (FF_uses_Sticky .and. SimUsesSticky()) then |
940 |
> |
if (FF_uses_Sticky .and. SIM_uses_sticky) then |
941 |
|
|
942 |
< |
call getElementProperty(atypes, me_i, "is_Sticky", is_Sticky_i) |
768 |
< |
call getElementProperty(atypes, me_j, "is_Sticky", is_Sticky_j) |
769 |
< |
|
770 |
< |
if ( is_Sticky_i .and. is_Sticky_j ) then |
942 |
> |
if ( PropertyMap(me_i)%is_Sticky .and. PropertyMap(me_j)%is_Sticky) then |
943 |
|
call do_sticky_pair(i, j, d, r, rijsq, A, pot, f, t, & |
944 |
|
do_pot, do_stress) |
945 |
|
endif |
946 |
+ |
|
947 |
|
endif |
948 |
|
|
949 |
|
|
950 |
< |
if (FF_uses_GB .and. SimUsesGB()) then |
778 |
< |
|
779 |
< |
|
780 |
< |
call getElementProperty(atypes, me_i, "is_GB", is_GB_i) |
781 |
< |
call getElementProperty(atypes, me_j, "is_GB", is_GB_j) |
950 |
> |
if (FF_uses_GB .and. SIM_uses_GB) then |
951 |
|
|
952 |
< |
if ( is_GB_i .and. is_GB_j ) then |
952 |
> |
if ( PropertyMap(me_i)%is_GB .and. PropertyMap(me_j)%is_GB) then |
953 |
|
call do_gb_pair(i, j, d, r, rijsq, u_l, pot, f, t, & |
954 |
|
do_pot, do_stress) |
955 |
|
endif |
956 |
+ |
|
957 |
|
endif |
958 |
< |
|
958 |
> |
|
959 |
> |
if (FF_uses_EAM .and. SIM_uses_EAM) then |
960 |
> |
|
961 |
> |
if ( PropertyMap(me_i)%is_EAM .and. PropertyMap(me_j)%is_EAM) then |
962 |
> |
call do_eam_pair(i, j, d, r, rijsq, pot, f, do_pot, do_stress) |
963 |
> |
endif |
964 |
> |
|
965 |
> |
endif |
966 |
|
|
790 |
– |
|
791 |
– |
if (FF_uses_EAM .and. SimUsesEAM()) then |
792 |
– |
call getElementProperty(atypes, me_i, "is_EAM", is_EAM_i) |
793 |
– |
call getElementProperty(atypes, me_j, "is_EAM", is_EAM_j) |
794 |
– |
|
795 |
– |
if ( is_EAM_i .and. is_EAM_j ) & |
796 |
– |
call do_eam_pair(i, j, d, r, rijsq, pot, f, do_pot, do_stress) |
797 |
– |
endif |
798 |
– |
|
799 |
– |
|
800 |
– |
|
801 |
– |
|
967 |
|
end subroutine do_pair |
968 |
|
|
969 |
|
|
970 |
|
|
971 |
|
subroutine do_prepair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t, pot) |
972 |
|
real( kind = dp ) :: pot |
973 |
< |
real( kind = dp ), dimension(3,getNlocal()) :: u_l |
974 |
< |
real (kind=dp), dimension(9,getNlocal()) :: A |
975 |
< |
real (kind=dp), dimension(3,getNlocal()) :: f |
976 |
< |
real (kind=dp), dimension(3,getNlocal()) :: t |
973 |
> |
real( kind = dp ), dimension(3,nLocal) :: u_l |
974 |
> |
real (kind=dp), dimension(9,nLocal) :: A |
975 |
> |
real (kind=dp), dimension(3,nLocal) :: f |
976 |
> |
real (kind=dp), dimension(3,nLocal) :: t |
977 |
|
|
978 |
|
logical, intent(inout) :: do_pot, do_stress |
979 |
|
integer, intent(in) :: i, j |
1003 |
|
|
1004 |
|
#endif |
1005 |
|
|
1006 |
< |
if (FF_uses_EAM .and. SimUsesEAM()) then |
1007 |
< |
call getElementProperty(atypes, me_i, "is_EAM", is_EAM_i) |
1008 |
< |
call getElementProperty(atypes, me_j, "is_EAM", is_EAM_j) |
844 |
< |
|
845 |
< |
if ( is_EAM_i .and. is_EAM_j ) & |
1006 |
> |
if (FF_uses_EAM .and. SIM_uses_EAM) then |
1007 |
> |
|
1008 |
> |
if (PropertyMap(me_i)%is_EAM .and. PropertyMap(me_j)%is_EAM) & |
1009 |
|
call calc_EAM_prepair_rho(i, j, d, r, rijsq ) |
847 |
– |
endif |
1010 |
|
|
1011 |
+ |
endif |
1012 |
+ |
|
1013 |
|
end subroutine do_prepair |
1014 |
|
|
1015 |
|
|
1019 |
|
integer :: nlocal |
1020 |
|
real( kind = dp ) :: pot |
1021 |
|
|
1022 |
< |
if (FF_uses_EAM .and. SimUsesEAM()) then |
1022 |
> |
if (FF_uses_EAM .and. SIM_uses_EAM) then |
1023 |
|
call calc_EAM_preforce_Frho(nlocal,pot) |
1024 |
|
endif |
1025 |
|
|
1038 |
|
d(1:3) = q_j(1:3) - q_i(1:3) |
1039 |
|
|
1040 |
|
! Wrap back into periodic box if necessary |
1041 |
< |
if ( SimUsesPBC() ) then |
1041 |
> |
if ( SIM_uses_PBC ) then |
1042 |
|
|
1043 |
|
if( .not.boxIsOrthorhombic ) then |
1044 |
|
! calc the scaled coordinates. |
1077 |
|
r_sq = dot_product(d,d) |
1078 |
|
|
1079 |
|
end subroutine get_interatomic_vector |
916 |
– |
|
917 |
– |
subroutine check_initialization(error) |
918 |
– |
integer, intent(out) :: error |
919 |
– |
|
920 |
– |
error = 0 |
921 |
– |
! Make sure we are properly initialized. |
922 |
– |
if (.not. do_forces_initialized) then |
923 |
– |
write(*,*) "Forces not initialized" |
924 |
– |
error = -1 |
925 |
– |
return |
926 |
– |
endif |
927 |
– |
|
928 |
– |
#ifdef IS_MPI |
929 |
– |
if (.not. isMPISimSet()) then |
930 |
– |
write(default_error,*) "ERROR: mpiSimulation has not been initialized!" |
931 |
– |
error = -1 |
932 |
– |
return |
933 |
– |
endif |
934 |
– |
#endif |
935 |
– |
|
936 |
– |
return |
937 |
– |
end subroutine check_initialization |
938 |
– |
|
1080 |
|
|
1081 |
|
subroutine zero_work_arrays() |
1082 |
|
|
1110 |
|
#endif |
1111 |
|
|
1112 |
|
|
1113 |
< |
if (FF_uses_EAM .and. SimUsesEAM()) then |
1113 |
> |
if (FF_uses_EAM .and. SIM_uses_EAM) then |
1114 |
|
call clean_EAM() |
1115 |
|
endif |
1116 |
|
|