4 |
|
|
5 |
|
!! @author Charles F. Vardeman II |
6 |
|
!! @author Matthew Meineke |
7 |
< |
!! @version $Id: do_Forces.F90,v 1.6 2003-03-31 22:09:39 chuckv Exp $, $Date: 2003-03-31 22:09:39 $, $Name: not supported by cvs2svn $, $Revision: 1.6 $ |
7 |
> |
!! @version $Id: do_Forces.F90,v 1.28 2003-08-08 21:22:37 chuckv Exp $, $Date: 2003-08-08 21:22:37 $, $Name: not supported by cvs2svn $, $Revision: 1.28 $ |
8 |
|
|
9 |
|
module do_Forces |
10 |
|
use force_globals |
17 |
|
use dipole_dipole |
18 |
|
use reaction_field |
19 |
|
use gb_pair |
20 |
+ |
use vector_class |
21 |
+ |
use eam |
22 |
+ |
use status |
23 |
|
#ifdef IS_MPI |
24 |
|
use mpiSimulation |
25 |
|
#endif |
30 |
|
#define __FORTRAN90 |
31 |
|
#include "fForceField.h" |
32 |
|
|
33 |
< |
logical, save :: do_forces_initialized = .false. |
33 |
> |
logical, save :: do_forces_initialized = .false., haveRlist = .false. |
34 |
> |
logical, save :: havePolicies = .false. |
35 |
|
logical, save :: FF_uses_LJ |
36 |
|
logical, save :: FF_uses_sticky |
37 |
|
logical, save :: FF_uses_dipoles |
39 |
|
logical, save :: FF_uses_GB |
40 |
|
logical, save :: FF_uses_EAM |
41 |
|
|
42 |
+ |
real(kind=dp), save :: rlist, rlistsq |
43 |
+ |
|
44 |
|
public :: init_FF |
45 |
|
public :: do_force_loop |
46 |
+ |
public :: setRlistDF |
47 |
|
|
48 |
|
contains |
49 |
|
|
50 |
+ |
subroutine setRlistDF( this_rlist ) |
51 |
+ |
|
52 |
+ |
real(kind=dp) :: this_rlist |
53 |
+ |
|
54 |
+ |
rlist = this_rlist |
55 |
+ |
rlistsq = rlist * rlist |
56 |
+ |
|
57 |
+ |
haveRlist = .true. |
58 |
+ |
if( havePolicies ) do_forces_initialized = .true. |
59 |
+ |
|
60 |
+ |
end subroutine setRlistDF |
61 |
+ |
|
62 |
|
subroutine init_FF(LJMIXPOLICY, use_RF_c, thisStat) |
63 |
|
|
64 |
|
integer, intent(in) :: LJMIXPOLICY |
106 |
|
!! check to make sure the FF_uses_RF setting makes sense |
107 |
|
|
108 |
|
if (FF_uses_dipoles) then |
90 |
– |
rrf = getRrf() |
91 |
– |
rt = getRt() |
92 |
– |
call initialize_dipole(rrf, rt) |
109 |
|
if (FF_uses_RF) then |
110 |
|
dielect = getDielect() |
111 |
< |
call initialize_rf(rrf, rt, dielect) |
111 |
> |
call initialize_rf(dielect) |
112 |
|
endif |
113 |
|
else |
114 |
|
if (FF_uses_RF) then |
116 |
|
thisStat = -1 |
117 |
|
return |
118 |
|
endif |
119 |
< |
endif |
119 |
> |
endif |
120 |
|
|
121 |
|
if (FF_uses_LJ) then |
122 |
|
|
107 |
– |
call getRcut(rcut) |
108 |
– |
|
123 |
|
select case (LJMIXPOLICY) |
124 |
|
case (LB_MIXING_RULE) |
125 |
< |
call init_lj_FF(LB_MIXING_RULE, rcut, my_status) |
125 |
> |
call init_lj_FF(LB_MIXING_RULE, my_status) |
126 |
|
case (EXPLICIT_MIXING_RULE) |
127 |
< |
call init_lj_FF(EXPLICIT_MIXING_RULE, rcut, my_status) |
127 |
> |
call init_lj_FF(EXPLICIT_MIXING_RULE, my_status) |
128 |
|
case default |
129 |
|
write(default_error,*) 'unknown LJ Mixing Policy!' |
130 |
|
thisStat = -1 |
143 |
|
return |
144 |
|
end if |
145 |
|
endif |
146 |
+ |
|
147 |
+ |
|
148 |
+ |
if (FF_uses_EAM) then |
149 |
+ |
call init_EAM_FF(my_status) |
150 |
+ |
if (my_status /= 0) then |
151 |
+ |
thisStat = -1 |
152 |
+ |
return |
153 |
+ |
end if |
154 |
+ |
endif |
155 |
+ |
|
156 |
+ |
|
157 |
|
|
158 |
|
if (FF_uses_GB) then |
159 |
|
call check_gb_pair_FF(my_status) |
165 |
|
|
166 |
|
if (FF_uses_GB .and. FF_uses_LJ) then |
167 |
|
endif |
168 |
+ |
if (.not. do_forces_initialized) then |
169 |
+ |
!! Create neighbor lists |
170 |
+ |
call expandNeighborList(getNlocal(), my_status) |
171 |
+ |
if (my_Status /= 0) then |
172 |
+ |
write(default_error,*) "SimSetup: ExpandNeighborList returned error." |
173 |
+ |
thisStat = -1 |
174 |
+ |
return |
175 |
+ |
endif |
176 |
+ |
endif |
177 |
+ |
|
178 |
|
|
179 |
+ |
havePolicies = .true. |
180 |
+ |
if( haveRlist ) do_forces_initialized = .true. |
181 |
|
|
145 |
– |
do_forces_initialized = .true. |
146 |
– |
|
182 |
|
end subroutine init_FF |
183 |
|
|
184 |
|
|
203 |
|
logical :: do_pot |
204 |
|
logical :: do_stress |
205 |
|
#ifdef IS_MPI |
206 |
< |
real( kind = DP ) :: pot_local = 0.0_dp |
206 |
> |
real( kind = DP ) :: pot_local |
207 |
|
integer :: nrow |
208 |
|
integer :: ncol |
209 |
|
#endif |
212 |
|
logical :: update_nlist |
213 |
|
integer :: i, j, jbeg, jend, jnab |
214 |
|
integer :: nlist |
215 |
< |
real( kind = DP ) :: rijsq, rlistsq, rcutsq, rlist, rcut |
215 |
> |
real( kind = DP ) :: rijsq |
216 |
|
real(kind=dp),dimension(3) :: d |
217 |
|
real(kind=dp) :: rfpot, mu_i, virial |
218 |
|
integer :: me_i |
221 |
|
integer :: listerror, error |
222 |
|
integer :: localError |
223 |
|
|
224 |
+ |
real(kind=dp) :: listSkin = 1.0 |
225 |
+ |
|
226 |
+ |
|
227 |
|
!! initialize local variables |
228 |
|
|
229 |
|
#ifdef IS_MPI |
230 |
+ |
pot_local = 0.0_dp |
231 |
|
nlocal = getNlocal() |
232 |
|
nrow = getNrow(plan_row) |
233 |
|
ncol = getNcol(plan_col) |
236 |
|
natoms = nlocal |
237 |
|
#endif |
238 |
|
|
200 |
– |
call getRcut(rcut,rc2=rcutsq) |
201 |
– |
call getRlist(rlist,rlistsq) |
202 |
– |
|
239 |
|
call check_initialization(localError) |
240 |
|
if ( localError .ne. 0 ) then |
241 |
+ |
call handleError("do_force_loop","Not Initialized") |
242 |
|
error = -1 |
243 |
|
return |
244 |
|
end if |
247 |
|
do_pot = do_pot_c |
248 |
|
do_stress = do_stress_c |
249 |
|
|
250 |
+ |
|
251 |
|
! Gather all information needed by all force loops: |
252 |
|
|
253 |
|
#ifdef IS_MPI |
264 |
|
endif |
265 |
|
|
266 |
|
#endif |
267 |
< |
|
267 |
> |
|
268 |
|
if (FF_RequiresPrepairCalc() .and. SimRequiresPrepairCalc()) then |
269 |
|
!! See if we need to update neighbor lists |
270 |
< |
call checkNeighborList(nlocal, q, rcut, rlist, update_nlist) |
270 |
> |
call checkNeighborList(nlocal, q, listSkin, update_nlist) |
271 |
|
!! if_mpi_gather_stuff_for_prepair |
272 |
|
!! do_prepair_loop_if_needed |
273 |
|
!! if_mpi_scatter_stuff_from_prepair |
274 |
|
!! if_mpi_gather_stuff_from_prepair_to_main_loop |
275 |
< |
else |
276 |
< |
!! See if we need to update neighbor lists |
277 |
< |
call checkNeighborList(nlocal, q, rcut, rlist, update_nlist) |
275 |
> |
|
276 |
> |
!--------------------PREFORCE LOOP----------->>>>>>>>>>>>>>>>>>>>>>>>>>> |
277 |
> |
#ifdef IS_MPI |
278 |
> |
|
279 |
> |
if (update_nlist) then |
280 |
> |
|
281 |
> |
!! save current configuration, construct neighbor list, |
282 |
> |
!! and calculate forces |
283 |
> |
call saveNeighborList(nlocal, q) |
284 |
> |
|
285 |
> |
neighborListSize = size(list) |
286 |
> |
nlist = 0 |
287 |
> |
|
288 |
> |
do i = 1, nrow |
289 |
> |
point(i) = nlist + 1 |
290 |
> |
|
291 |
> |
prepair_inner: do j = 1, ncol |
292 |
> |
|
293 |
> |
if (skipThisPair(i,j)) cycle prepair_inner |
294 |
> |
|
295 |
> |
call get_interatomic_vector(q_Row(:,i), q_Col(:,j), d, rijsq) |
296 |
> |
|
297 |
> |
if (rijsq < rlistsq) then |
298 |
> |
|
299 |
> |
nlist = nlist + 1 |
300 |
> |
|
301 |
> |
if (nlist > neighborListSize) then |
302 |
> |
call expandNeighborList(nlocal, listerror) |
303 |
> |
if (listerror /= 0) then |
304 |
> |
error = -1 |
305 |
> |
write(DEFAULT_ERROR,*) "ERROR: nlist > list size and max allocations exceeded." |
306 |
> |
return |
307 |
> |
end if |
308 |
> |
neighborListSize = size(list) |
309 |
> |
endif |
310 |
> |
|
311 |
> |
list(nlist) = j |
312 |
> |
call do_prepair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t, pot_local) |
313 |
> |
endif |
314 |
> |
enddo prepair_inner |
315 |
> |
enddo |
316 |
> |
|
317 |
> |
point(nrow + 1) = nlist + 1 |
318 |
> |
|
319 |
> |
else !! (of update_check) |
320 |
> |
|
321 |
> |
! use the list to find the neighbors |
322 |
> |
do i = 1, nrow |
323 |
> |
JBEG = POINT(i) |
324 |
> |
JEND = POINT(i+1) - 1 |
325 |
> |
! check thiat molecule i has neighbors |
326 |
> |
if (jbeg .le. jend) then |
327 |
> |
|
328 |
> |
do jnab = jbeg, jend |
329 |
> |
j = list(jnab) |
330 |
> |
|
331 |
> |
call get_interatomic_vector(q_Row(:,i), q_Col(:,j), d, rijsq) |
332 |
> |
call do_prepair(i, j, rijsq, d, do_pot, do_stress, & |
333 |
> |
u_l, A, f, t, pot_local) |
334 |
> |
|
335 |
> |
enddo |
336 |
> |
endif |
337 |
> |
enddo |
338 |
|
endif |
339 |
|
|
340 |
+ |
#else |
341 |
+ |
|
342 |
+ |
if (update_nlist) then |
343 |
+ |
|
344 |
+ |
! save current configuration, contruct neighbor list, |
345 |
+ |
! and calculate forces |
346 |
+ |
call saveNeighborList(natoms, q) |
347 |
+ |
|
348 |
+ |
neighborListSize = size(list) |
349 |
+ |
|
350 |
+ |
nlist = 0 |
351 |
+ |
|
352 |
+ |
do i = 1, natoms-1 |
353 |
+ |
point(i) = nlist + 1 |
354 |
+ |
|
355 |
+ |
prepair_inner: do j = i+1, natoms |
356 |
+ |
|
357 |
+ |
if (skipThisPair(i,j)) cycle prepair_inner |
358 |
+ |
|
359 |
+ |
call get_interatomic_vector(q(:,i), q(:,j), d, rijsq) |
360 |
+ |
|
361 |
+ |
|
362 |
+ |
if (rijsq < rlistsq) then |
363 |
+ |
|
364 |
+ |
|
365 |
+ |
nlist = nlist + 1 |
366 |
+ |
|
367 |
+ |
if (nlist > neighborListSize) then |
368 |
+ |
call expandNeighborList(natoms, listerror) |
369 |
+ |
if (listerror /= 0) then |
370 |
+ |
error = -1 |
371 |
+ |
write(DEFAULT_ERROR,*) "ERROR: nlist > list size and max allocations exceeded." |
372 |
+ |
return |
373 |
+ |
end if |
374 |
+ |
neighborListSize = size(list) |
375 |
+ |
endif |
376 |
+ |
|
377 |
+ |
list(nlist) = j |
378 |
+ |
|
379 |
+ |
call do_prepair(i, j, rijsq, d, do_pot, do_stress, & |
380 |
+ |
u_l, A, f, t, pot) |
381 |
+ |
|
382 |
+ |
endif |
383 |
+ |
enddo prepair_inner |
384 |
+ |
enddo |
385 |
+ |
|
386 |
+ |
point(natoms) = nlist + 1 |
387 |
+ |
|
388 |
+ |
else !! (update) |
389 |
+ |
|
390 |
+ |
! use the list to find the neighbors |
391 |
+ |
do i = 1, natoms-1 |
392 |
+ |
JBEG = POINT(i) |
393 |
+ |
JEND = POINT(i+1) - 1 |
394 |
+ |
! check thiat molecule i has neighbors |
395 |
+ |
if (jbeg .le. jend) then |
396 |
+ |
|
397 |
+ |
do jnab = jbeg, jend |
398 |
+ |
j = list(jnab) |
399 |
+ |
|
400 |
+ |
call get_interatomic_vector(q(:,i), q(:,j), d, rijsq) |
401 |
+ |
call do_prepair(i, j, rijsq, d, do_pot, do_stress, & |
402 |
+ |
u_l, A, f, t, pot) |
403 |
+ |
|
404 |
+ |
enddo |
405 |
+ |
endif |
406 |
+ |
enddo |
407 |
+ |
endif |
408 |
+ |
#endif |
409 |
+ |
!! Do rest of preforce calculations |
410 |
+ |
!! do necessary preforce calculations |
411 |
+ |
call do_preforce(nlocal,pot) |
412 |
+ |
! we have already updated the neighbor list set it to false... |
413 |
+ |
update_nlist = .false. |
414 |
+ |
else |
415 |
+ |
!! See if we need to update neighbor lists for non pre-pair |
416 |
+ |
call checkNeighborList(nlocal, q, listSkin, update_nlist) |
417 |
+ |
endif |
418 |
+ |
|
419 |
+ |
|
420 |
+ |
|
421 |
+ |
|
422 |
+ |
|
423 |
+ |
!---------------------------------MAIN Pair LOOP->>>>>>>>>>>>>>>>>>>>>>>>>>>> |
424 |
+ |
|
425 |
+ |
|
426 |
+ |
|
427 |
+ |
|
428 |
+ |
|
429 |
|
#ifdef IS_MPI |
430 |
|
|
431 |
|
if (update_nlist) then |
432 |
|
|
433 |
|
!! save current configuration, construct neighbor list, |
434 |
|
!! and calculate forces |
435 |
< |
call saveNeighborList(q) |
435 |
> |
call saveNeighborList(nlocal, q) |
436 |
|
|
437 |
|
neighborListSize = size(list) |
438 |
|
nlist = 0 |
446 |
|
|
447 |
|
call get_interatomic_vector(q_Row(:,i), q_Col(:,j), d, rijsq) |
448 |
|
|
449 |
< |
if (rijsq < rlistsq) then |
449 |
> |
if (rijsq < rlistsq) then |
450 |
|
|
451 |
|
nlist = nlist + 1 |
452 |
|
|
462 |
|
|
463 |
|
list(nlist) = j |
464 |
|
|
465 |
< |
if (rijsq < rcutsq) then |
466 |
< |
call do_pair(i, j, rijsq, d, do_pot, do_stress, & |
467 |
< |
u_l, A, f, t,pot) |
281 |
< |
endif |
465 |
> |
call do_pair(i, j, rijsq, d, do_pot, do_stress, & |
466 |
> |
u_l, A, f, t, pot_local) |
467 |
> |
|
468 |
|
endif |
469 |
|
enddo inner |
470 |
|
enddo |
485 |
|
|
486 |
|
call get_interatomic_vector(q_Row(:,i), q_Col(:,j), d, rijsq) |
487 |
|
call do_pair(i, j, rijsq, d, do_pot, do_stress, & |
488 |
< |
u_l, A, f, t,pot) |
488 |
> |
u_l, A, f, t, pot_local) |
489 |
|
|
490 |
|
enddo |
491 |
|
endif |
498 |
|
|
499 |
|
! save current configuration, contruct neighbor list, |
500 |
|
! and calculate forces |
501 |
< |
call saveNeighborList(q) |
501 |
> |
call saveNeighborList(natoms, q) |
502 |
|
|
503 |
|
neighborListSize = size(list) |
504 |
|
|
514 |
|
call get_interatomic_vector(q(:,i), q(:,j), d, rijsq) |
515 |
|
|
516 |
|
|
517 |
< |
if (rijsq < rlistsq) then |
517 |
> |
if (rijsq < rlistsq) then |
518 |
|
|
519 |
|
nlist = nlist + 1 |
520 |
|
|
530 |
|
|
531 |
|
list(nlist) = j |
532 |
|
|
533 |
< |
if (rijsq < rcutsq) then |
534 |
< |
call do_pair(i, j, rijsq, d, do_pot, do_stress, & |
535 |
< |
u_l, A, f, t,pot) |
350 |
< |
endif |
533 |
> |
call do_pair(i, j, rijsq, d, do_pot, do_stress, & |
534 |
> |
u_l, A, f, t, pot) |
535 |
> |
|
536 |
|
endif |
537 |
|
enddo inner |
538 |
|
enddo |
553 |
|
|
554 |
|
call get_interatomic_vector(q(:,i), q(:,j), d, rijsq) |
555 |
|
call do_pair(i, j, rijsq, d, do_pot, do_stress, & |
556 |
< |
u_l, A, f, t,pot) |
556 |
> |
u_l, A, f, t, pot) |
557 |
|
|
558 |
|
enddo |
559 |
|
endif |
657 |
|
#ifdef IS_MPI |
658 |
|
|
659 |
|
if (do_pot) then |
660 |
< |
pot = pot_local |
660 |
> |
pot = pot + pot_local |
661 |
|
!! we assume the c code will do the allreduce to get the total potential |
662 |
|
!! we could do it right here if we needed to... |
663 |
|
endif |
664 |
|
|
665 |
|
if (do_stress) then |
666 |
< |
call mpi_allreduce(tau, tau_Temp,9,mpi_double_precision,mpi_sum, & |
666 |
> |
call mpi_allreduce(tau_Temp, tau, 9,mpi_double_precision,mpi_sum, & |
667 |
|
mpi_comm_world,mpi_err) |
668 |
< |
call mpi_allreduce(virial, virial_Temp,1,mpi_double_precision,mpi_sum, & |
668 |
> |
call mpi_allreduce(virial_Temp, virial,1,mpi_double_precision,mpi_sum, & |
669 |
|
mpi_comm_world,mpi_err) |
670 |
|
endif |
671 |
|
|
680 |
|
|
681 |
|
end subroutine do_force_loop |
682 |
|
|
683 |
< |
subroutine do_pair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t,pot) |
683 |
> |
subroutine do_pair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t, pot) |
684 |
|
|
685 |
|
real( kind = dp ) :: pot |
686 |
< |
real( kind = dp ), dimension(:,:) :: u_l |
687 |
< |
real (kind=dp), dimension(:,:) :: A |
688 |
< |
real (kind=dp), dimension(:,:) :: f |
689 |
< |
real (kind=dp), dimension(:,:) :: t |
686 |
> |
real( kind = dp ), dimension(3,getNlocal()) :: u_l |
687 |
> |
real (kind=dp), dimension(9,getNlocal()) :: A |
688 |
> |
real (kind=dp), dimension(3,getNlocal()) :: f |
689 |
> |
real (kind=dp), dimension(3,getNlocal()) :: t |
690 |
|
|
691 |
|
logical, intent(inout) :: do_pot, do_stress |
692 |
|
integer, intent(in) :: i, j |
696 |
|
logical :: is_LJ_i, is_LJ_j |
697 |
|
logical :: is_DP_i, is_DP_j |
698 |
|
logical :: is_GB_i, is_GB_j |
699 |
+ |
logical :: is_EAM_i,is_EAM_j |
700 |
|
logical :: is_Sticky_i, is_Sticky_j |
701 |
|
integer :: me_i, me_j |
702 |
|
|
703 |
|
r = sqrt(rijsq) |
704 |
|
|
705 |
|
#ifdef IS_MPI |
706 |
+ |
if (tagRow(i) .eq. tagColumn(j)) then |
707 |
+ |
write(0,*) 'do_pair is doing', i , j, tagRow(i), tagColumn(j) |
708 |
+ |
endif |
709 |
|
|
710 |
|
me_i = atid_row(i) |
711 |
|
me_j = atid_col(j) |
764 |
|
endif |
765 |
|
endif |
766 |
|
|
767 |
+ |
|
768 |
+ |
|
769 |
+ |
if (FF_uses_EAM .and. SimUsesEAM()) then |
770 |
+ |
call getElementProperty(atypes, me_i, "is_EAM", is_EAM_i) |
771 |
+ |
call getElementProperty(atypes, me_j, "is_EAM", is_EAM_j) |
772 |
+ |
|
773 |
+ |
if ( is_EAM_i .and. is_EAM_j ) & |
774 |
+ |
call do_eam_pair(i, j, d, r, rijsq, pot, f, do_pot, do_stress) |
775 |
+ |
endif |
776 |
+ |
|
777 |
+ |
|
778 |
+ |
|
779 |
+ |
|
780 |
|
end subroutine do_pair |
781 |
+ |
|
782 |
+ |
|
783 |
+ |
|
784 |
+ |
subroutine do_prepair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t, pot) |
785 |
+ |
real( kind = dp ) :: pot |
786 |
+ |
real( kind = dp ), dimension(3,getNlocal()) :: u_l |
787 |
+ |
real (kind=dp), dimension(9,getNlocal()) :: A |
788 |
+ |
real (kind=dp), dimension(3,getNlocal()) :: f |
789 |
+ |
real (kind=dp), dimension(3,getNlocal()) :: t |
790 |
+ |
|
791 |
+ |
logical, intent(inout) :: do_pot, do_stress |
792 |
+ |
integer, intent(in) :: i, j |
793 |
+ |
real ( kind = dp ), intent(inout) :: rijsq |
794 |
+ |
real ( kind = dp ) :: r |
795 |
+ |
real ( kind = dp ), intent(inout) :: d(3) |
796 |
+ |
|
797 |
+ |
logical :: is_EAM_i, is_EAM_j |
798 |
+ |
|
799 |
+ |
integer :: me_i, me_j |
800 |
+ |
|
801 |
+ |
r = sqrt(rijsq) |
802 |
+ |
|
803 |
+ |
|
804 |
+ |
#ifdef IS_MPI |
805 |
+ |
if (tagRow(i) .eq. tagColumn(j)) then |
806 |
+ |
write(0,*) 'do_pair is doing', i , j, tagRow(i), tagColumn(j) |
807 |
+ |
endif |
808 |
+ |
|
809 |
+ |
me_i = atid_row(i) |
810 |
+ |
me_j = atid_col(j) |
811 |
+ |
|
812 |
+ |
#else |
813 |
+ |
|
814 |
+ |
me_i = atid(i) |
815 |
+ |
me_j = atid(j) |
816 |
+ |
|
817 |
+ |
#endif |
818 |
+ |
|
819 |
+ |
if (FF_uses_EAM .and. SimUsesEAM()) then |
820 |
+ |
call getElementProperty(atypes, me_i, "is_EAM", is_EAM_i) |
821 |
+ |
call getElementProperty(atypes, me_j, "is_EAM", is_EAM_j) |
822 |
+ |
|
823 |
+ |
if ( is_EAM_i .and. is_EAM_j ) & |
824 |
+ |
call calc_EAM_prepair_rho(i, j, d, r, rijsq ) |
825 |
+ |
endif |
826 |
|
|
827 |
+ |
end subroutine do_prepair |
828 |
|
|
829 |
+ |
|
830 |
+ |
|
831 |
+ |
|
832 |
+ |
subroutine do_preforce(nlocal,pot) |
833 |
+ |
integer :: nlocal |
834 |
+ |
real( kind = dp ) :: pot |
835 |
+ |
|
836 |
+ |
if (FF_uses_EAM .and. SimUsesEAM()) then |
837 |
+ |
call calc_EAM_preforce_Frho(nlocal,pot) |
838 |
+ |
endif |
839 |
+ |
|
840 |
+ |
|
841 |
+ |
end subroutine do_preforce |
842 |
+ |
|
843 |
+ |
|
844 |
|
subroutine get_interatomic_vector(q_i, q_j, d, r_sq) |
845 |
|
|
846 |
|
real (kind = dp), dimension(3) :: q_i |
847 |
|
real (kind = dp), dimension(3) :: q_j |
848 |
|
real ( kind = dp ), intent(out) :: r_sq |
849 |
< |
real( kind = dp ) :: d(3) |
850 |
< |
real( kind = dp ) :: d_old(3) |
851 |
< |
d(1:3) = q_i(1:3) - q_j(1:3) |
852 |
< |
d_old = d |
849 |
> |
real( kind = dp ) :: d(3), scaled(3) |
850 |
> |
integer i |
851 |
> |
|
852 |
> |
d(1:3) = q_j(1:3) - q_i(1:3) |
853 |
> |
|
854 |
|
! Wrap back into periodic box if necessary |
855 |
|
if ( SimUsesPBC() ) then |
856 |
|
|
857 |
< |
d(1:3) = d(1:3) - box(1:3) * sign(1.0_dp,d(1:3)) * & |
858 |
< |
int(abs(d(1:3)/box(1:3)) + 0.5_dp) |
857 |
> |
if( .not.boxIsOrthorhombic ) then |
858 |
> |
! calc the scaled coordinates. |
859 |
> |
|
860 |
> |
scaled = matmul(HmatInv, d) |
861 |
> |
|
862 |
> |
! wrap the scaled coordinates |
863 |
> |
|
864 |
> |
scaled = scaled - anint(scaled) |
865 |
> |
|
866 |
> |
|
867 |
> |
! calc the wrapped real coordinates from the wrapped scaled |
868 |
> |
! coordinates |
869 |
> |
|
870 |
> |
d = matmul(Hmat,scaled) |
871 |
> |
|
872 |
> |
else |
873 |
> |
! calc the scaled coordinates. |
874 |
> |
|
875 |
> |
do i = 1, 3 |
876 |
> |
scaled(i) = d(i) * HmatInv(i,i) |
877 |
> |
|
878 |
> |
! wrap the scaled coordinates |
879 |
> |
|
880 |
> |
scaled(i) = scaled(i) - anint(scaled(i)) |
881 |
> |
|
882 |
> |
! calc the wrapped real coordinates from the wrapped scaled |
883 |
> |
! coordinates |
884 |
> |
|
885 |
> |
d(i) = scaled(i)*Hmat(i,i) |
886 |
> |
enddo |
887 |
> |
endif |
888 |
|
|
889 |
|
endif |
890 |
+ |
|
891 |
|
r_sq = dot_product(d,d) |
892 |
< |
|
892 |
> |
|
893 |
|
end subroutine get_interatomic_vector |
894 |
< |
|
894 |
> |
|
895 |
|
subroutine check_initialization(error) |
896 |
|
integer, intent(out) :: error |
897 |
|
|
898 |
|
error = 0 |
899 |
|
! Make sure we are properly initialized. |
900 |
|
if (.not. do_forces_initialized) then |
901 |
+ |
write(*,*) "Forces not initialized" |
902 |
|
error = -1 |
903 |
|
return |
904 |
|
endif |
946 |
|
|
947 |
|
#endif |
948 |
|
|
949 |
+ |
|
950 |
+ |
if (FF_uses_EAM .and. SimUsesEAM()) then |
951 |
+ |
call clean_EAM() |
952 |
+ |
endif |
953 |
+ |
|
954 |
+ |
|
955 |
+ |
|
956 |
+ |
|
957 |
+ |
|
958 |
|
rf = 0.0_dp |
959 |
|
tau_Temp = 0.0_dp |
960 |
|
virial_Temp = 0.0_dp |
657 |
– |
|
961 |
|
end subroutine zero_work_arrays |
962 |
|
|
963 |
|
function skipThisPair(atom1, atom2) result(skip_it) |
1001 |
|
#else |
1002 |
|
unique_id_2 = atom2 |
1003 |
|
#endif |
1004 |
< |
|
1004 |
> |
|
1005 |
|
#ifdef IS_MPI |
1006 |
|
!! this situation should only arise in MPI simulations |
1007 |
|
if (unique_id_1 == unique_id_2) then |
1011 |
|
|
1012 |
|
!! this prevents us from doing the pair on multiple processors |
1013 |
|
if (unique_id_1 < unique_id_2) then |
1014 |
< |
if (mod(unique_id_1 + unique_id_2,2) == 0) skip_it = .true. |
1015 |
< |
return |
1014 |
> |
if (mod(unique_id_1 + unique_id_2,2) == 0) then |
1015 |
> |
skip_it = .true. |
1016 |
> |
return |
1017 |
> |
endif |
1018 |
|
else |
1019 |
< |
if (mod(unique_id_1 + unique_id_2,2) == 1) skip_it = .true. |
1020 |
< |
return |
1019 |
> |
if (mod(unique_id_1 + unique_id_2,2) == 1) then |
1020 |
> |
skip_it = .true. |
1021 |
> |
return |
1022 |
> |
endif |
1023 |
|
endif |
1024 |
|
#endif |
1025 |
< |
|
1025 |
> |
|
1026 |
|
!! the rest of these situations can happen in all simulations: |
1027 |
|
do i = 1, nExcludes_global |
1028 |
|
if ((excludesGlobal(i) == unique_id_1) .or. & |
1031 |
|
return |
1032 |
|
endif |
1033 |
|
enddo |
1034 |
< |
|
1034 |
> |
|
1035 |
|
do i = 1, nExcludes_local |
1036 |
|
if (excludesLocal(1,i) == unique_id_1) then |
1037 |
|
if (excludesLocal(2,i) == unique_id_2) then |
1067 |
|
doesit = FF_uses_RF |
1068 |
|
end function FF_RequiresPostpairCalc |
1069 |
|
|
1070 |
+ |
!! This cleans componets of force arrays belonging only to fortran |
1071 |
+ |
|
1072 |
|
end module do_Forces |