45 |
|
|
46 |
|
!! @author Charles F. Vardeman II |
47 |
|
!! @author Matthew Meineke |
48 |
< |
!! @version $Id: doForces.F90,v 1.66 2005-11-02 20:35:34 chrisfen Exp $, $Date: 2005-11-02 20:35:34 $, $Name: not supported by cvs2svn $, $Revision: 1.66 $ |
48 |
> |
!! @version $Id: doForces.F90,v 1.87 2007-04-20 18:15:46 chrisfen Exp $, $Date: 2007-04-20 18:15:46 $, $Name: not supported by cvs2svn $, $Revision: 1.87 $ |
49 |
|
|
50 |
|
|
51 |
|
module doForces |
62 |
|
use shapes |
63 |
|
use vector_class |
64 |
|
use eam |
65 |
+ |
use suttonchen |
66 |
|
use status |
67 |
|
#ifdef IS_MPI |
68 |
|
use mpiSimulation |
72 |
|
PRIVATE |
73 |
|
|
74 |
|
#define __FORTRAN90 |
74 |
– |
#include "UseTheForce/fSwitchingFunction.h" |
75 |
|
#include "UseTheForce/fCutoffPolicy.h" |
76 |
|
#include "UseTheForce/DarkSide/fInteractionMap.h" |
77 |
|
#include "UseTheForce/DarkSide/fElectrostaticSummationMethod.h" |
78 |
|
|
79 |
– |
|
79 |
|
INTEGER, PARAMETER:: PREPAIR_LOOP = 1 |
80 |
|
INTEGER, PARAMETER:: PAIR_LOOP = 2 |
81 |
|
|
85 |
|
logical, save :: haveInteractionHash = .false. |
86 |
|
logical, save :: haveGtypeCutoffMap = .false. |
87 |
|
logical, save :: haveDefaultCutoffs = .false. |
88 |
< |
logical, save :: haveRlist = .false. |
88 |
> |
logical, save :: haveSkinThickness = .false. |
89 |
> |
logical, save :: haveElectrostaticSummationMethod = .false. |
90 |
> |
logical, save :: haveCutoffPolicy = .false. |
91 |
> |
logical, save :: VisitCutoffsAfterComputing = .false. |
92 |
> |
logical, save :: do_box_dipole = .false. |
93 |
|
|
94 |
|
logical, save :: FF_uses_DirectionalAtoms |
95 |
|
logical, save :: FF_uses_Dipoles |
96 |
|
logical, save :: FF_uses_GayBerne |
97 |
|
logical, save :: FF_uses_EAM |
98 |
+ |
logical, save :: FF_uses_SC |
99 |
+ |
logical, save :: FF_uses_MEAM |
100 |
+ |
|
101 |
|
|
102 |
|
logical, save :: SIM_uses_DirectionalAtoms |
103 |
|
logical, save :: SIM_uses_EAM |
104 |
+ |
logical, save :: SIM_uses_SC |
105 |
+ |
logical, save :: SIM_uses_MEAM |
106 |
|
logical, save :: SIM_requires_postpair_calc |
107 |
|
logical, save :: SIM_requires_prepair_calc |
108 |
|
logical, save :: SIM_uses_PBC |
109 |
+ |
logical, save :: SIM_uses_AtomicVirial |
110 |
|
|
111 |
|
integer, save :: electrostaticSummationMethod |
112 |
+ |
integer, save :: cutoffPolicy = TRADITIONAL_CUTOFF_POLICY |
113 |
|
|
114 |
+ |
real(kind=dp), save :: defaultRcut, defaultRsw, largestRcut |
115 |
+ |
real(kind=dp), save :: skinThickness |
116 |
+ |
logical, save :: defaultDoShiftPot |
117 |
+ |
logical, save :: defaultDoShiftFrc |
118 |
+ |
|
119 |
|
public :: init_FF |
120 |
< |
public :: setDefaultCutoffs |
120 |
> |
public :: setCutoffs |
121 |
> |
public :: cWasLame |
122 |
> |
public :: setElectrostaticMethod |
123 |
> |
public :: setBoxDipole |
124 |
> |
public :: getBoxDipole |
125 |
> |
public :: setCutoffPolicy |
126 |
> |
public :: setSkinThickness |
127 |
|
public :: do_force_loop |
107 |
– |
public :: createInteractionHash |
108 |
– |
public :: createGtypeCutoffMap |
109 |
– |
public :: getStickyCut |
110 |
– |
public :: getStickyPowerCut |
111 |
– |
public :: getGayBerneCut |
112 |
– |
public :: getEAMCut |
113 |
– |
public :: getShapeCut |
128 |
|
|
129 |
|
#ifdef PROFILE |
130 |
|
public :: getforcetime |
152 |
|
end type gtypeCutoffs |
153 |
|
type(gtypeCutoffs), dimension(:,:), allocatable :: gtypeCutoffMap |
154 |
|
|
155 |
< |
integer, save :: cutoffPolicy = TRADITIONAL_CUTOFF_POLICY |
156 |
< |
real(kind=dp),save :: defaultRcut, defaultRsw, defaultRlist |
143 |
< |
real(kind=dp),save :: listSkin |
144 |
< |
|
155 |
> |
real(kind=dp), dimension(3) :: boxDipole |
156 |
> |
|
157 |
|
contains |
158 |
|
|
159 |
< |
subroutine createInteractionHash(status) |
159 |
> |
subroutine createInteractionHash() |
160 |
|
integer :: nAtypes |
149 |
– |
integer, intent(out) :: status |
161 |
|
integer :: i |
162 |
|
integer :: j |
163 |
|
integer :: iHash |
169 |
|
logical :: i_is_GB |
170 |
|
logical :: i_is_EAM |
171 |
|
logical :: i_is_Shape |
172 |
+ |
logical :: i_is_SC |
173 |
+ |
logical :: i_is_MEAM |
174 |
|
logical :: j_is_LJ |
175 |
|
logical :: j_is_Elect |
176 |
|
logical :: j_is_Sticky |
178 |
|
logical :: j_is_GB |
179 |
|
logical :: j_is_EAM |
180 |
|
logical :: j_is_Shape |
181 |
+ |
logical :: j_is_SC |
182 |
+ |
logical :: j_is_MEAM |
183 |
|
real(kind=dp) :: myRcut |
184 |
|
|
170 |
– |
status = 0 |
171 |
– |
|
185 |
|
if (.not. associated(atypes)) then |
186 |
< |
call handleError("atype", "atypes was not present before call of createInteractionHash!") |
174 |
< |
status = -1 |
186 |
> |
call handleError("doForces", "atypes was not present before call of createInteractionHash!") |
187 |
|
return |
188 |
|
endif |
189 |
|
|
190 |
|
nAtypes = getSize(atypes) |
191 |
|
|
192 |
|
if (nAtypes == 0) then |
193 |
< |
status = -1 |
193 |
> |
call handleError("doForces", "nAtypes was zero during call of createInteractionHash!") |
194 |
|
return |
195 |
|
end if |
196 |
|
|
216 |
|
call getElementProperty(atypes, i, "is_GayBerne", i_is_GB) |
217 |
|
call getElementProperty(atypes, i, "is_EAM", i_is_EAM) |
218 |
|
call getElementProperty(atypes, i, "is_Shape", i_is_Shape) |
219 |
+ |
call getElementProperty(atypes, i, "is_SC", i_is_SC) |
220 |
+ |
call getElementProperty(atypes, i, "is_MEAM", i_is_MEAM) |
221 |
|
|
222 |
|
do j = i, nAtypes |
223 |
|
|
231 |
|
call getElementProperty(atypes, j, "is_GayBerne", j_is_GB) |
232 |
|
call getElementProperty(atypes, j, "is_EAM", j_is_EAM) |
233 |
|
call getElementProperty(atypes, j, "is_Shape", j_is_Shape) |
234 |
+ |
call getElementProperty(atypes, j, "is_SC", j_is_SC) |
235 |
+ |
call getElementProperty(atypes, j, "is_MEAM", j_is_MEAM) |
236 |
|
|
237 |
|
if (i_is_LJ .and. j_is_LJ) then |
238 |
|
iHash = ior(iHash, LJ_PAIR) |
254 |
|
iHash = ior(iHash, EAM_PAIR) |
255 |
|
endif |
256 |
|
|
257 |
+ |
if (i_is_SC .and. j_is_SC) then |
258 |
+ |
iHash = ior(iHash, SC_PAIR) |
259 |
+ |
endif |
260 |
+ |
|
261 |
|
if (i_is_GB .and. j_is_GB) iHash = ior(iHash, GAYBERNE_PAIR) |
262 |
|
if (i_is_GB .and. j_is_LJ) iHash = ior(iHash, GAYBERNE_LJ) |
263 |
|
if (i_is_LJ .and. j_is_GB) iHash = ior(iHash, GAYBERNE_LJ) |
277 |
|
haveInteractionHash = .true. |
278 |
|
end subroutine createInteractionHash |
279 |
|
|
280 |
< |
subroutine createGtypeCutoffMap(stat) |
280 |
> |
subroutine createGtypeCutoffMap() |
281 |
|
|
262 |
– |
integer, intent(out), optional :: stat |
282 |
|
logical :: i_is_LJ |
283 |
|
logical :: i_is_Elect |
284 |
|
logical :: i_is_Sticky |
286 |
|
logical :: i_is_GB |
287 |
|
logical :: i_is_EAM |
288 |
|
logical :: i_is_Shape |
289 |
+ |
logical :: i_is_SC |
290 |
|
logical :: GtypeFound |
291 |
|
|
292 |
|
integer :: myStatus, nAtypes, i, j, istart, iend, jstart, jend |
294 |
|
integer :: nGroupsInRow |
295 |
|
integer :: nGroupsInCol |
296 |
|
integer :: nGroupTypesRow,nGroupTypesCol |
297 |
< |
real(kind=dp):: thisSigma, bigSigma, thisRcut, tradRcut, tol, skin |
297 |
> |
real(kind=dp):: thisSigma, bigSigma, thisRcut, tradRcut, tol |
298 |
|
real(kind=dp) :: biggestAtypeCutoff |
299 |
|
|
280 |
– |
stat = 0 |
300 |
|
if (.not. haveInteractionHash) then |
301 |
< |
call createInteractionHash(myStatus) |
283 |
< |
if (myStatus .ne. 0) then |
284 |
< |
write(default_error, *) 'createInteractionHash failed in doForces!' |
285 |
< |
stat = -1 |
286 |
< |
return |
287 |
< |
endif |
301 |
> |
call createInteractionHash() |
302 |
|
endif |
303 |
|
#ifdef IS_MPI |
304 |
|
nGroupsInRow = getNgroupsInRow(plan_group_row) |
316 |
|
call getElementProperty(atypes, i, "is_GayBerne", i_is_GB) |
317 |
|
call getElementProperty(atypes, i, "is_EAM", i_is_EAM) |
318 |
|
call getElementProperty(atypes, i, "is_Shape", i_is_Shape) |
319 |
< |
|
319 |
> |
call getElementProperty(atypes, i, "is_SC", i_is_SC) |
320 |
|
|
321 |
|
if (haveDefaultCutoffs) then |
322 |
|
atypeMaxCutoff(i) = defaultRcut |
349 |
|
thisRcut = getShapeCut(i) |
350 |
|
if (thisRCut .gt. atypeMaxCutoff(i)) atypeMaxCutoff(i) = thisRCut |
351 |
|
endif |
352 |
+ |
if (i_is_SC) then |
353 |
+ |
thisRcut = getSCCut(i) |
354 |
+ |
if (thisRCut .gt. atypeMaxCutoff(i)) atypeMaxCutoff(i) = thisRCut |
355 |
+ |
endif |
356 |
|
endif |
357 |
< |
|
340 |
< |
|
357 |
> |
|
358 |
|
if (atypeMaxCutoff(i).gt.biggestAtypeCutoff) then |
359 |
|
biggestAtypeCutoff = atypeMaxCutoff(i) |
360 |
|
endif |
361 |
|
|
362 |
|
endif |
363 |
|
enddo |
347 |
– |
|
348 |
– |
|
364 |
|
|
365 |
|
istart = 1 |
366 |
|
jstart = 1 |
404 |
|
allocate(groupToGtypeCol(jend)) |
405 |
|
end if |
406 |
|
|
407 |
< |
if(.not.associated(groupToGtypeCol)) then |
408 |
< |
allocate(groupToGtypeCol(jend)) |
407 |
> |
if(.not.associated(groupMaxCutoffCol)) then |
408 |
> |
allocate(groupMaxCutoffCol(jend)) |
409 |
|
else |
410 |
< |
deallocate(groupToGtypeCol) |
411 |
< |
allocate(groupToGtypeCol(jend)) |
410 |
> |
deallocate(groupMaxCutoffCol) |
411 |
> |
allocate(groupMaxCutoffCol(jend)) |
412 |
|
end if |
413 |
|
if(.not.associated(gtypeMaxCutoffCol)) then |
414 |
|
allocate(gtypeMaxCutoffCol(jend)) |
429 |
|
!! largest cutoff for any atypes present in this group. We also |
430 |
|
!! create gtypes at this point. |
431 |
|
|
432 |
< |
tol = 1.0d-6 |
432 |
> |
tol = 1.0e-6_dp |
433 |
|
nGroupTypesRow = 0 |
434 |
< |
|
434 |
> |
nGroupTypesCol = 0 |
435 |
|
do i = istart, iend |
436 |
|
n_in_i = groupStartRow(i+1) - groupStartRow(i) |
437 |
|
groupMaxCutoffRow(i) = 0.0_dp |
446 |
|
groupMaxCutoffRow(i)=atypeMaxCutoff(me_i) |
447 |
|
endif |
448 |
|
enddo |
434 |
– |
|
449 |
|
if (nGroupTypesRow.eq.0) then |
450 |
|
nGroupTypesRow = nGroupTypesRow + 1 |
451 |
|
gtypeMaxCutoffRow(nGroupTypesRow) = groupMaxCutoffRow(i) |
508 |
|
groupMaxCutoffCol => groupMaxCutoffRow |
509 |
|
#endif |
510 |
|
|
497 |
– |
|
498 |
– |
|
499 |
– |
|
500 |
– |
|
511 |
|
!! allocate the gtypeCutoffMap here. |
512 |
|
allocate(gtypeCutoffMap(nGroupTypesRow,nGroupTypesCol)) |
513 |
|
!! then we do a double loop over all the group TYPES to find the cutoff |
514 |
|
!! map between groups of two types |
515 |
|
tradRcut = max(maxval(gtypeMaxCutoffRow),maxval(gtypeMaxCutoffCol)) |
516 |
|
|
517 |
< |
do i = 1, nGroupTypesRow |
517 |
> |
do i = 1, nGroupTypesRow |
518 |
|
do j = 1, nGroupTypesCol |
519 |
|
|
520 |
|
select case(cutoffPolicy) |
529 |
|
return |
530 |
|
end select |
531 |
|
gtypeCutoffMap(i,j)%rcut = thisRcut |
532 |
+ |
|
533 |
+ |
if (thisRcut.gt.largestRcut) largestRcut = thisRcut |
534 |
+ |
|
535 |
|
gtypeCutoffMap(i,j)%rcutsq = thisRcut*thisRcut |
523 |
– |
skin = defaultRlist - defaultRcut |
524 |
– |
listSkin = skin ! set neighbor list skin thickness |
525 |
– |
gtypeCutoffMap(i,j)%rlistsq = (thisRcut + skin)**2 |
536 |
|
|
537 |
+ |
if (.not.haveSkinThickness) then |
538 |
+ |
skinThickness = 1.0_dp |
539 |
+ |
endif |
540 |
+ |
|
541 |
+ |
gtypeCutoffMap(i,j)%rlistsq = (thisRcut + skinThickness)**2 |
542 |
+ |
|
543 |
|
! sanity check |
544 |
|
|
545 |
|
if (haveDefaultCutoffs) then |
549 |
|
endif |
550 |
|
enddo |
551 |
|
enddo |
552 |
+ |
|
553 |
|
if(allocated(gtypeMaxCutoffRow)) deallocate(gtypeMaxCutoffRow) |
554 |
|
if(allocated(groupMaxCutoffRow)) deallocate(groupMaxCutoffRow) |
555 |
|
if(allocated(atypeMaxCutoff)) deallocate(atypeMaxCutoff) |
563 |
|
haveGtypeCutoffMap = .true. |
564 |
|
end subroutine createGtypeCutoffMap |
565 |
|
|
566 |
< |
subroutine setDefaultCutoffs(defRcut, defRsw, defRlist, cutPolicy) |
550 |
< |
real(kind=dp),intent(in) :: defRcut, defRsw, defRlist |
551 |
< |
integer, intent(in) :: cutPolicy |
566 |
> |
subroutine setCutoffs(defRcut, defRsw, defSP, defSF) |
567 |
|
|
568 |
+ |
real(kind=dp),intent(in) :: defRcut, defRsw |
569 |
+ |
logical, intent(in) :: defSP, defSF |
570 |
+ |
character(len = statusMsgSize) :: errMsg |
571 |
+ |
integer :: localError |
572 |
+ |
|
573 |
|
defaultRcut = defRcut |
574 |
|
defaultRsw = defRsw |
575 |
< |
defaultRlist = defRlist |
576 |
< |
cutoffPolicy = cutPolicy |
575 |
> |
|
576 |
> |
defaultDoShiftPot = defSP |
577 |
> |
defaultDoShiftFrc = defSF |
578 |
|
|
579 |
+ |
if (abs(defaultRcut-defaultRsw) .lt. 0.0001) then |
580 |
+ |
if (defaultDoShiftFrc) then |
581 |
+ |
write(errMsg, *) & |
582 |
+ |
'cutoffRadius and switchingRadius are set to the', newline & |
583 |
+ |
// tab, 'same value. OOPSE will use shifted force', newline & |
584 |
+ |
// tab, 'potentials instead of switching functions.' |
585 |
+ |
|
586 |
+ |
call handleInfo("setCutoffs", errMsg) |
587 |
+ |
else |
588 |
+ |
write(errMsg, *) & |
589 |
+ |
'cutoffRadius and switchingRadius are set to the', newline & |
590 |
+ |
// tab, 'same value. OOPSE will use shifted', newline & |
591 |
+ |
// tab, 'potentials instead of switching functions.' |
592 |
+ |
|
593 |
+ |
call handleInfo("setCutoffs", errMsg) |
594 |
+ |
|
595 |
+ |
defaultDoShiftPot = .true. |
596 |
+ |
endif |
597 |
+ |
|
598 |
+ |
endif |
599 |
+ |
|
600 |
+ |
localError = 0 |
601 |
+ |
call setLJDefaultCutoff( defaultRcut, defaultDoShiftPot, & |
602 |
+ |
defaultDoShiftFrc ) |
603 |
+ |
call setElectrostaticCutoffRadius( defaultRcut, defaultRsw ) |
604 |
+ |
call setCutoffEAM( defaultRcut ) |
605 |
+ |
call setCutoffSC( defaultRcut ) |
606 |
+ |
call set_switch(defaultRsw, defaultRcut) |
607 |
+ |
call setHmatDangerousRcutValue(defaultRcut) |
608 |
+ |
|
609 |
|
haveDefaultCutoffs = .true. |
610 |
< |
end subroutine setDefaultCutoffs |
610 |
> |
haveGtypeCutoffMap = .false. |
611 |
|
|
612 |
< |
subroutine setCutoffPolicy(cutPolicy) |
612 |
> |
end subroutine setCutoffs |
613 |
|
|
614 |
+ |
subroutine cWasLame() |
615 |
+ |
|
616 |
+ |
VisitCutoffsAfterComputing = .true. |
617 |
+ |
return |
618 |
+ |
|
619 |
+ |
end subroutine cWasLame |
620 |
+ |
|
621 |
+ |
subroutine setCutoffPolicy(cutPolicy) |
622 |
+ |
|
623 |
|
integer, intent(in) :: cutPolicy |
624 |
+ |
|
625 |
|
cutoffPolicy = cutPolicy |
626 |
< |
call createGtypeCutoffMap() |
626 |
> |
haveCutoffPolicy = .true. |
627 |
> |
haveGtypeCutoffMap = .false. |
628 |
> |
|
629 |
|
end subroutine setCutoffPolicy |
567 |
– |
|
630 |
|
|
631 |
< |
subroutine setSimVariables() |
570 |
< |
SIM_uses_DirectionalAtoms = SimUsesDirectionalAtoms() |
571 |
< |
SIM_uses_EAM = SimUsesEAM() |
572 |
< |
SIM_requires_postpair_calc = SimRequiresPostpairCalc() |
573 |
< |
SIM_requires_prepair_calc = SimRequiresPrepairCalc() |
574 |
< |
SIM_uses_PBC = SimUsesPBC() |
631 |
> |
subroutine setBoxDipole() |
632 |
|
|
633 |
< |
haveSIMvariables = .true. |
633 |
> |
do_box_dipole = .true. |
634 |
> |
|
635 |
> |
end subroutine setBoxDipole |
636 |
|
|
637 |
< |
return |
579 |
< |
end subroutine setSimVariables |
637 |
> |
subroutine getBoxDipole( box_dipole ) |
638 |
|
|
639 |
+ |
real(kind=dp), intent(inout), dimension(3) :: box_dipole |
640 |
+ |
|
641 |
+ |
box_dipole = boxDipole |
642 |
+ |
|
643 |
+ |
end subroutine getBoxDipole |
644 |
+ |
|
645 |
+ |
subroutine setElectrostaticMethod( thisESM ) |
646 |
+ |
|
647 |
+ |
integer, intent(in) :: thisESM |
648 |
+ |
|
649 |
+ |
electrostaticSummationMethod = thisESM |
650 |
+ |
haveElectrostaticSummationMethod = .true. |
651 |
+ |
|
652 |
+ |
end subroutine setElectrostaticMethod |
653 |
+ |
|
654 |
+ |
subroutine setSkinThickness( thisSkin ) |
655 |
+ |
|
656 |
+ |
real(kind=dp), intent(in) :: thisSkin |
657 |
+ |
|
658 |
+ |
skinThickness = thisSkin |
659 |
+ |
haveSkinThickness = .true. |
660 |
+ |
haveGtypeCutoffMap = .false. |
661 |
+ |
|
662 |
+ |
end subroutine setSkinThickness |
663 |
+ |
|
664 |
+ |
subroutine setSimVariables() |
665 |
+ |
SIM_uses_DirectionalAtoms = SimUsesDirectionalAtoms() |
666 |
+ |
SIM_uses_EAM = SimUsesEAM() |
667 |
+ |
SIM_requires_postpair_calc = SimRequiresPostpairCalc() |
668 |
+ |
SIM_requires_prepair_calc = SimRequiresPrepairCalc() |
669 |
+ |
SIM_uses_PBC = SimUsesPBC() |
670 |
+ |
SIM_uses_SC = SimUsesSC() |
671 |
+ |
SIM_uses_AtomicVirial = SimUsesAtomicVirial() |
672 |
+ |
|
673 |
+ |
haveSIMvariables = .true. |
674 |
+ |
|
675 |
+ |
return |
676 |
+ |
end subroutine setSimVariables |
677 |
+ |
|
678 |
|
subroutine doReadyCheck(error) |
679 |
|
integer, intent(out) :: error |
583 |
– |
|
680 |
|
integer :: myStatus |
681 |
|
|
682 |
|
error = 0 |
683 |
|
|
684 |
|
if (.not. haveInteractionHash) then |
685 |
< |
myStatus = 0 |
590 |
< |
call createInteractionHash(myStatus) |
591 |
< |
if (myStatus .ne. 0) then |
592 |
< |
write(default_error, *) 'createInteractionHash failed in doForces!' |
593 |
< |
error = -1 |
594 |
< |
return |
595 |
< |
endif |
685 |
> |
call createInteractionHash() |
686 |
|
endif |
687 |
|
|
688 |
|
if (.not. haveGtypeCutoffMap) then |
689 |
< |
myStatus = 0 |
690 |
< |
call createGtypeCutoffMap(myStatus) |
691 |
< |
if (myStatus .ne. 0) then |
692 |
< |
write(default_error, *) 'createGtypeCutoffMap failed in doForces!' |
693 |
< |
error = -1 |
694 |
< |
return |
695 |
< |
endif |
689 |
> |
call createGtypeCutoffMap() |
690 |
> |
endif |
691 |
> |
|
692 |
> |
if (VisitCutoffsAfterComputing) then |
693 |
> |
call set_switch(largestRcut, largestRcut) |
694 |
> |
call setHmatDangerousRcutValue(largestRcut) |
695 |
> |
call setCutoffEAM(largestRcut) |
696 |
> |
call setCutoffSC(largestRcut) |
697 |
> |
VisitCutoffsAfterComputing = .false. |
698 |
|
endif |
699 |
|
|
700 |
|
if (.not. haveSIMvariables) then |
701 |
|
call setSimVariables() |
702 |
|
endif |
703 |
|
|
612 |
– |
! if (.not. haveRlist) then |
613 |
– |
! write(default_error, *) 'rList has not been set in doForces!' |
614 |
– |
! error = -1 |
615 |
– |
! return |
616 |
– |
! endif |
617 |
– |
|
704 |
|
if (.not. haveNeighborList) then |
705 |
|
write(default_error, *) 'neighbor list has not been initialized in doForces!' |
706 |
|
error = -1 |
707 |
|
return |
708 |
|
end if |
709 |
< |
|
709 |
> |
|
710 |
|
if (.not. haveSaneForceField) then |
711 |
|
write(default_error, *) 'Force Field is not sane in doForces!' |
712 |
|
error = -1 |
713 |
|
return |
714 |
|
end if |
715 |
< |
|
715 |
> |
|
716 |
|
#ifdef IS_MPI |
717 |
|
if (.not. isMPISimSet()) then |
718 |
|
write(default_error,*) "ERROR: mpiSimulation has not been initialized!" |
724 |
|
end subroutine doReadyCheck |
725 |
|
|
726 |
|
|
727 |
< |
subroutine init_FF(thisESM, thisStat) |
727 |
> |
subroutine init_FF(thisStat) |
728 |
|
|
643 |
– |
integer, intent(in) :: thisESM |
729 |
|
integer, intent(out) :: thisStat |
730 |
|
integer :: my_status, nMatches |
731 |
|
integer, pointer :: MatchList(:) => null() |
733 |
|
!! assume things are copacetic, unless they aren't |
734 |
|
thisStat = 0 |
735 |
|
|
651 |
– |
electrostaticSummationMethod = thisESM |
652 |
– |
|
736 |
|
!! init_FF is called *after* all of the atom types have been |
737 |
|
!! defined in atype_module using the new_atype subroutine. |
738 |
|
!! |
743 |
|
FF_uses_Dipoles = .false. |
744 |
|
FF_uses_GayBerne = .false. |
745 |
|
FF_uses_EAM = .false. |
746 |
+ |
FF_uses_SC = .false. |
747 |
|
|
748 |
|
call getMatchingElementList(atypes, "is_Directional", .true., & |
749 |
|
nMatches, MatchList) |
760 |
|
call getMatchingElementList(atypes, "is_EAM", .true., nMatches, MatchList) |
761 |
|
if (nMatches .gt. 0) FF_uses_EAM = .true. |
762 |
|
|
763 |
+ |
call getMatchingElementList(atypes, "is_SC", .true., nMatches, MatchList) |
764 |
+ |
if (nMatches .gt. 0) FF_uses_SC = .true. |
765 |
|
|
766 |
+ |
|
767 |
|
haveSaneForceField = .true. |
768 |
|
|
769 |
|
if (FF_uses_EAM) then |
828 |
|
integer :: istart, iend |
829 |
|
integer :: ia, jb, atom1, atom2 |
830 |
|
integer :: nlist |
831 |
< |
real( kind = DP ) :: ratmsq, rgrpsq, rgrp, vpair, vij |
831 |
> |
real( kind = DP ) :: ratmsq, rgrpsq, rgrp, rag, vpair, vij |
832 |
|
real( kind = DP ) :: sw, dswdr, swderiv, mf |
833 |
|
real( kind = DP ) :: rVal |
834 |
< |
real(kind=dp),dimension(3) :: d_atm, d_grp, fpair, fij |
835 |
< |
real(kind=dp), dimension(3) :: fstrs, f2strs |
836 |
< |
real(kind=dp) :: rfpot, mu_i, virial |
834 |
> |
real(kind=dp),dimension(3) :: d_atm, d_grp, fpair, fij, fg, dag |
835 |
> |
real(kind=dp) :: rfpot, mu_i |
836 |
> |
real(kind=dp):: rCut |
837 |
|
integer :: me_i, me_j, n_in_i, n_in_j |
838 |
|
logical :: is_dp_i |
839 |
|
integer :: neighborListSize |
843 |
|
integer :: loopStart, loopEnd, loop |
844 |
|
integer :: iHash |
845 |
|
integer :: i1 |
759 |
– |
|
846 |
|
|
847 |
+ |
!! the variables for the box dipole moment |
848 |
+ |
#ifdef IS_MPI |
849 |
+ |
integer :: pChgCount_local |
850 |
+ |
integer :: nChgCount_local |
851 |
+ |
real(kind=dp) :: pChg_local |
852 |
+ |
real(kind=dp) :: nChg_local |
853 |
+ |
real(kind=dp), dimension(3) :: pChgPos_local |
854 |
+ |
real(kind=dp), dimension(3) :: nChgPos_local |
855 |
+ |
real(kind=dp), dimension(3) :: dipVec_local |
856 |
+ |
#endif |
857 |
+ |
integer :: pChgCount |
858 |
+ |
integer :: nChgCount |
859 |
+ |
real(kind=dp) :: pChg |
860 |
+ |
real(kind=dp) :: nChg |
861 |
+ |
real(kind=dp) :: chg_value |
862 |
+ |
real(kind=dp), dimension(3) :: pChgPos |
863 |
+ |
real(kind=dp), dimension(3) :: nChgPos |
864 |
+ |
real(kind=dp), dimension(3) :: dipVec |
865 |
+ |
real(kind=dp), dimension(3) :: chgVec |
866 |
+ |
|
867 |
+ |
!! initialize box dipole variables |
868 |
+ |
if (do_box_dipole) then |
869 |
+ |
#ifdef IS_MPI |
870 |
+ |
pChg_local = 0.0_dp |
871 |
+ |
nChg_local = 0.0_dp |
872 |
+ |
pChgCount_local = 0 |
873 |
+ |
nChgCount_local = 0 |
874 |
+ |
do i=1, 3 |
875 |
+ |
pChgPos_local = 0.0_dp |
876 |
+ |
nChgPos_local = 0.0_dp |
877 |
+ |
dipVec_local = 0.0_dp |
878 |
+ |
enddo |
879 |
+ |
#endif |
880 |
+ |
pChg = 0.0_dp |
881 |
+ |
nChg = 0.0_dp |
882 |
+ |
pChgCount = 0 |
883 |
+ |
nChgCount = 0 |
884 |
+ |
chg_value = 0.0_dp |
885 |
+ |
|
886 |
+ |
do i=1, 3 |
887 |
+ |
pChgPos(i) = 0.0_dp |
888 |
+ |
nChgPos(i) = 0.0_dp |
889 |
+ |
dipVec(i) = 0.0_dp |
890 |
+ |
chgVec(i) = 0.0_dp |
891 |
+ |
boxDipole(i) = 0.0_dp |
892 |
+ |
enddo |
893 |
+ |
endif |
894 |
+ |
|
895 |
|
!! initialize local variables |
896 |
|
|
897 |
|
#ifdef IS_MPI |
954 |
|
! (but only on the first time through): |
955 |
|
if (loop .eq. loopStart) then |
956 |
|
#ifdef IS_MPI |
957 |
< |
call checkNeighborList(nGroupsInRow, q_group_row, listSkin, & |
957 |
> |
call checkNeighborList(nGroupsInRow, q_group_row, skinThickness, & |
958 |
|
update_nlist) |
959 |
|
#else |
960 |
< |
call checkNeighborList(nGroups, q_group, listSkin, & |
960 |
> |
call checkNeighborList(nGroups, q_group, skinThickness, & |
961 |
|
update_nlist) |
962 |
|
#endif |
963 |
|
endif |
1037 |
|
|
1038 |
|
list(nlist) = j |
1039 |
|
endif |
1040 |
< |
|
1040 |
> |
|
1041 |
|
if (rgrpsq < gtypeCutoffMap(groupToGtypeRow(i),groupToGtypeCol(j))%rCutsq) then |
1042 |
|
|
1043 |
+ |
rCut = gtypeCutoffMap(groupToGtypeRow(i),groupToGtypeCol(j))%rCut |
1044 |
|
if (loop .eq. PAIR_LOOP) then |
1045 |
< |
vij = 0.0d0 |
1046 |
< |
fij(1:3) = 0.0d0 |
1045 |
> |
vij = 0.0_dp |
1046 |
> |
fij(1) = 0.0_dp |
1047 |
> |
fij(2) = 0.0_dp |
1048 |
> |
fij(3) = 0.0_dp |
1049 |
|
endif |
1050 |
|
|
1051 |
< |
call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & |
915 |
< |
in_switching_region) |
1051 |
> |
call get_switch(rgrpsq, sw, dswdr,rgrp, in_switching_region) |
1052 |
|
|
1053 |
|
n_in_j = groupStartCol(j+1) - groupStartCol(j) |
1054 |
|
|
1063 |
|
if (skipThisPair(atom1, atom2)) cycle inner |
1064 |
|
|
1065 |
|
if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then |
1066 |
< |
d_atm(1:3) = d_grp(1:3) |
1066 |
> |
d_atm(1) = d_grp(1) |
1067 |
> |
d_atm(2) = d_grp(2) |
1068 |
> |
d_atm(3) = d_grp(3) |
1069 |
|
ratmsq = rgrpsq |
1070 |
|
else |
1071 |
|
#ifdef IS_MPI |
1080 |
|
if (loop .eq. PREPAIR_LOOP) then |
1081 |
|
#ifdef IS_MPI |
1082 |
|
call do_prepair(atom1, atom2, ratmsq, d_atm, sw, & |
1083 |
< |
rgrpsq, d_grp, do_pot, do_stress, & |
1083 |
> |
rgrpsq, d_grp, rCut, do_pot, do_stress, & |
1084 |
|
eFrame, A, f, t, pot_local) |
1085 |
|
#else |
1086 |
|
call do_prepair(atom1, atom2, ratmsq, d_atm, sw, & |
1087 |
< |
rgrpsq, d_grp, do_pot, do_stress, & |
1087 |
> |
rgrpsq, d_grp, rCut, do_pot, do_stress, & |
1088 |
|
eFrame, A, f, t, pot) |
1089 |
|
#endif |
1090 |
|
else |
1091 |
|
#ifdef IS_MPI |
1092 |
|
call do_pair(atom1, atom2, ratmsq, d_atm, sw, & |
1093 |
|
do_pot, eFrame, A, f, t, pot_local, vpair, & |
1094 |
< |
fpair, d_grp, rgrp, fstrs) |
1094 |
> |
fpair, d_grp, rgrp, rCut) |
1095 |
|
#else |
1096 |
|
call do_pair(atom1, atom2, ratmsq, d_atm, sw, & |
1097 |
|
do_pot, eFrame, A, f, t, pot, vpair, fpair, & |
1098 |
< |
d_grp, rgrp, fstrs) |
1098 |
> |
d_grp, rgrp, rCut) |
1099 |
|
#endif |
962 |
– |
f2strs(1:3) = f2strs(1:3) + fstrs(1:3) |
1100 |
|
vij = vij + vpair |
1101 |
< |
fij(1:3) = fij(1:3) + fpair(1:3) |
1101 |
> |
fij(1) = fij(1) + fpair(1) |
1102 |
> |
fij(2) = fij(2) + fpair(2) |
1103 |
> |
fij(3) = fij(3) + fpair(3) |
1104 |
> |
if (do_stress) then |
1105 |
> |
call add_stress_tensor(d_atm, fpair, tau) |
1106 |
> |
endif |
1107 |
|
endif |
1108 |
|
enddo inner |
1109 |
|
enddo |
1118 |
|
do ia=groupStartRow(i), groupStartRow(i+1)-1 |
1119 |
|
atom1=groupListRow(ia) |
1120 |
|
mf = mfactRow(atom1) |
1121 |
+ |
! fg is the force on atom ia due to cutoff group's |
1122 |
+ |
! presence in switching region |
1123 |
+ |
fg = swderiv*d_grp*mf |
1124 |
|
#ifdef IS_MPI |
1125 |
< |
f_Row(1,atom1) = f_Row(1,atom1) + swderiv*d_grp(1)*mf |
1126 |
< |
f_Row(2,atom1) = f_Row(2,atom1) + swderiv*d_grp(2)*mf |
1127 |
< |
f_Row(3,atom1) = f_Row(3,atom1) + swderiv*d_grp(3)*mf |
1125 |
> |
f_Row(1,atom1) = f_Row(1,atom1) + fg(1) |
1126 |
> |
f_Row(2,atom1) = f_Row(2,atom1) + fg(2) |
1127 |
> |
f_Row(3,atom1) = f_Row(3,atom1) + fg(3) |
1128 |
|
#else |
1129 |
< |
f(1,atom1) = f(1,atom1) + swderiv*d_grp(1)*mf |
1130 |
< |
f(2,atom1) = f(2,atom1) + swderiv*d_grp(2)*mf |
1131 |
< |
f(3,atom1) = f(3,atom1) + swderiv*d_grp(3)*mf |
1129 |
> |
f(1,atom1) = f(1,atom1) + fg(1) |
1130 |
> |
f(2,atom1) = f(2,atom1) + fg(2) |
1131 |
> |
f(3,atom1) = f(3,atom1) + fg(3) |
1132 |
|
#endif |
1133 |
+ |
if (n_in_i .gt. 1) then |
1134 |
+ |
if (do_stress.and.SIM_uses_AtomicVirial) then |
1135 |
+ |
! find the distance between the atom and the center of |
1136 |
+ |
! the cutoff group: |
1137 |
+ |
#ifdef IS_MPI |
1138 |
+ |
call get_interatomic_vector(q_Row(:,atom1), & |
1139 |
+ |
q_group_Row(:,i), dag, rag) |
1140 |
+ |
#else |
1141 |
+ |
call get_interatomic_vector(q(:,atom1), & |
1142 |
+ |
q_group(:,i), dag, rag) |
1143 |
+ |
#endif |
1144 |
+ |
call add_stress_tensor(dag,fg,tau) |
1145 |
+ |
endif |
1146 |
+ |
endif |
1147 |
|
enddo |
1148 |
|
|
1149 |
|
do jb=groupStartCol(j), groupStartCol(j+1)-1 |
1150 |
|
atom2=groupListCol(jb) |
1151 |
|
mf = mfactCol(atom2) |
1152 |
+ |
! fg is the force on atom jb due to cutoff group's |
1153 |
+ |
! presence in switching region |
1154 |
+ |
fg = -swderiv*d_grp*mf |
1155 |
|
#ifdef IS_MPI |
1156 |
< |
f_Col(1,atom2) = f_Col(1,atom2) - swderiv*d_grp(1)*mf |
1157 |
< |
f_Col(2,atom2) = f_Col(2,atom2) - swderiv*d_grp(2)*mf |
1158 |
< |
f_Col(3,atom2) = f_Col(3,atom2) - swderiv*d_grp(3)*mf |
1156 |
> |
f_Col(1,atom2) = f_Col(1,atom2) + fg(1) |
1157 |
> |
f_Col(2,atom2) = f_Col(2,atom2) + fg(2) |
1158 |
> |
f_Col(3,atom2) = f_Col(3,atom2) + fg(3) |
1159 |
|
#else |
1160 |
< |
f(1,atom2) = f(1,atom2) - swderiv*d_grp(1)*mf |
1161 |
< |
f(2,atom2) = f(2,atom2) - swderiv*d_grp(2)*mf |
1162 |
< |
f(3,atom2) = f(3,atom2) - swderiv*d_grp(3)*mf |
1160 |
> |
f(1,atom2) = f(1,atom2) + fg(1) |
1161 |
> |
f(2,atom2) = f(2,atom2) + fg(2) |
1162 |
> |
f(3,atom2) = f(3,atom2) + fg(3) |
1163 |
|
#endif |
1164 |
+ |
if (n_in_j .gt. 1) then |
1165 |
+ |
if (do_stress.and.SIM_uses_AtomicVirial) then |
1166 |
+ |
! find the distance between the atom and the center of |
1167 |
+ |
! the cutoff group: |
1168 |
+ |
#ifdef IS_MPI |
1169 |
+ |
call get_interatomic_vector(q_Col(:,atom2), & |
1170 |
+ |
q_group_Col(:,j), dag, rag) |
1171 |
+ |
#else |
1172 |
+ |
call get_interatomic_vector(q(:,atom2), & |
1173 |
+ |
q_group(:,j), dag, rag) |
1174 |
+ |
#endif |
1175 |
+ |
call add_stress_tensor(dag,fg,tau) |
1176 |
+ |
endif |
1177 |
+ |
endif |
1178 |
|
enddo |
1179 |
|
endif |
1004 |
– |
|
1005 |
– |
if (do_stress) call add_stress_tensor(d_grp, fij) |
1180 |
|
endif |
1181 |
|
endif |
1182 |
|
endif |
1296 |
|
|
1297 |
|
! prevent overcounting of the skips |
1298 |
|
if (i.lt.j) then |
1299 |
< |
call get_interatomic_vector(q(:,i), & |
1300 |
< |
q(:,j), d_atm, ratmsq) |
1301 |
< |
rVal = dsqrt(ratmsq) |
1128 |
< |
call get_switch(ratmsq, sw, dswdr, rVal, group_switch, & |
1129 |
< |
in_switching_region) |
1299 |
> |
call get_interatomic_vector(q(:,i), q(:,j), d_atm, ratmsq) |
1300 |
> |
rVal = sqrt(ratmsq) |
1301 |
> |
call get_switch(ratmsq, sw, dswdr, rVal,in_switching_region) |
1302 |
|
#ifdef IS_MPI |
1303 |
|
call rf_self_excludes(i, j, sw, eFrame, d_atm, rVal, & |
1304 |
|
vpair, pot_local(ELECTROSTATIC_POT), f, t, do_pot) |
1309 |
|
endif |
1310 |
|
enddo |
1311 |
|
endif |
1312 |
+ |
|
1313 |
+ |
if (do_box_dipole) then |
1314 |
+ |
#ifdef IS_MPI |
1315 |
+ |
call accumulate_box_dipole(i, eFrame, q(:,i), pChg_local, & |
1316 |
+ |
nChg_local, pChgPos_local, nChgPos_local, dipVec_local, & |
1317 |
+ |
pChgCount_local, nChgCount_local) |
1318 |
+ |
#else |
1319 |
+ |
call accumulate_box_dipole(i, eFrame, q(:,i), pChg, nChg, & |
1320 |
+ |
pChgPos, nChgPos, dipVec, pChgCount, nChgCount) |
1321 |
+ |
#endif |
1322 |
+ |
endif |
1323 |
|
enddo |
1324 |
|
endif |
1325 |
< |
|
1325 |
> |
|
1326 |
|
#ifdef IS_MPI |
1144 |
– |
|
1327 |
|
if (do_pot) then |
1328 |
< |
call mpi_allreduce(pot_local, pot, LR_POT_TYPES,mpi_double_precision,mpi_sum, & |
1328 |
> |
#ifdef SINGLE_PRECISION |
1329 |
> |
call mpi_allreduce(pot_local, pot, LR_POT_TYPES,mpi_real,mpi_sum, & |
1330 |
|
mpi_comm_world,mpi_err) |
1331 |
+ |
#else |
1332 |
+ |
call mpi_allreduce(pot_local, pot, LR_POT_TYPES,mpi_double_precision, & |
1333 |
+ |
mpi_sum, mpi_comm_world,mpi_err) |
1334 |
+ |
#endif |
1335 |
|
endif |
1336 |
< |
|
1337 |
< |
if (do_stress) then |
1338 |
< |
call mpi_allreduce(tau_Temp, tau, 9,mpi_double_precision,mpi_sum, & |
1339 |
< |
mpi_comm_world,mpi_err) |
1340 |
< |
call mpi_allreduce(virial_Temp, virial,1,mpi_double_precision,mpi_sum, & |
1341 |
< |
mpi_comm_world,mpi_err) |
1342 |
< |
endif |
1343 |
< |
|
1336 |
> |
|
1337 |
> |
if (do_box_dipole) then |
1338 |
> |
|
1339 |
> |
#ifdef SINGLE_PRECISION |
1340 |
> |
call mpi_allreduce(pChg_local, pChg, 1, mpi_real, mpi_sum, & |
1341 |
> |
mpi_comm_world, mpi_err) |
1342 |
> |
call mpi_allreduce(nChg_local, nChg, 1, mpi_real, mpi_sum, & |
1343 |
> |
mpi_comm_world, mpi_err) |
1344 |
> |
call mpi_allreduce(pChgCount_local, pChgCount, 1, mpi_integer, mpi_sum,& |
1345 |
> |
mpi_comm_world, mpi_err) |
1346 |
> |
call mpi_allreduce(nChgCount_local, nChgCount, 1, mpi_integer, mpi_sum,& |
1347 |
> |
mpi_comm_world, mpi_err) |
1348 |
> |
call mpi_allreduce(pChgPos_local, pChgPos, 3, mpi_real, mpi_sum, & |
1349 |
> |
mpi_comm_world, mpi_err) |
1350 |
> |
call mpi_allreduce(nChgPos_local, nChgPos, 3, mpi_real, mpi_sum, & |
1351 |
> |
mpi_comm_world, mpi_err) |
1352 |
> |
call mpi_allreduce(dipVec_local, dipVec, 3, mpi_real, mpi_sum, & |
1353 |
> |
mpi_comm_world, mpi_err) |
1354 |
|
#else |
1355 |
< |
|
1356 |
< |
if (do_stress) then |
1357 |
< |
tau = tau_Temp |
1358 |
< |
virial = virial_Temp |
1355 |
> |
call mpi_allreduce(pChg_local, pChg, 1, mpi_double_precision, mpi_sum, & |
1356 |
> |
mpi_comm_world, mpi_err) |
1357 |
> |
call mpi_allreduce(nChg_local, nChg, 1, mpi_double_precision, mpi_sum, & |
1358 |
> |
mpi_comm_world, mpi_err) |
1359 |
> |
call mpi_allreduce(pChgCount_local, pChgCount, 1, mpi_integer,& |
1360 |
> |
mpi_sum, mpi_comm_world, mpi_err) |
1361 |
> |
call mpi_allreduce(nChgCount_local, nChgCount, 1, mpi_integer,& |
1362 |
> |
mpi_sum, mpi_comm_world, mpi_err) |
1363 |
> |
call mpi_allreduce(pChgPos_local, pChgPos, 3, mpi_double_precision, & |
1364 |
> |
mpi_sum, mpi_comm_world, mpi_err) |
1365 |
> |
call mpi_allreduce(nChgPos_local, nChgPos, 3, mpi_double_precision, & |
1366 |
> |
mpi_sum, mpi_comm_world, mpi_err) |
1367 |
> |
call mpi_allreduce(dipVec_local, dipVec, 3, mpi_double_precision, & |
1368 |
> |
mpi_sum, mpi_comm_world, mpi_err) |
1369 |
> |
#endif |
1370 |
> |
|
1371 |
|
endif |
1372 |
|
|
1373 |
|
#endif |
1374 |
< |
|
1374 |
> |
|
1375 |
> |
if (do_box_dipole) then |
1376 |
> |
! first load the accumulated dipole moment (if dipoles were present) |
1377 |
> |
boxDipole(1) = dipVec(1) |
1378 |
> |
boxDipole(2) = dipVec(2) |
1379 |
> |
boxDipole(3) = dipVec(3) |
1380 |
> |
|
1381 |
> |
! now include the dipole moment due to charges |
1382 |
> |
! use the lesser of the positive and negative charge totals |
1383 |
> |
if (nChg .le. pChg) then |
1384 |
> |
chg_value = nChg |
1385 |
> |
else |
1386 |
> |
chg_value = pChg |
1387 |
> |
endif |
1388 |
> |
|
1389 |
> |
! find the average positions |
1390 |
> |
if (pChgCount .gt. 0 .and. nChgCount .gt. 0) then |
1391 |
> |
pChgPos = pChgPos / pChgCount |
1392 |
> |
nChgPos = nChgPos / nChgCount |
1393 |
> |
endif |
1394 |
> |
|
1395 |
> |
! dipole is from the negative to the positive (physics notation) |
1396 |
> |
chgVec(1) = pChgPos(1) - nChgPos(1) |
1397 |
> |
chgVec(2) = pChgPos(2) - nChgPos(2) |
1398 |
> |
chgVec(3) = pChgPos(3) - nChgPos(3) |
1399 |
> |
|
1400 |
> |
boxDipole(1) = boxDipole(1) + chgVec(1) * chg_value |
1401 |
> |
boxDipole(2) = boxDipole(2) + chgVec(2) * chg_value |
1402 |
> |
boxDipole(3) = boxDipole(3) + chgVec(3) * chg_value |
1403 |
> |
|
1404 |
> |
endif |
1405 |
> |
|
1406 |
|
end subroutine do_force_loop |
1407 |
|
|
1168 |
– |
!!$ subroutine do_pair(i, j, rijsq, d, sw, do_pot, & |
1169 |
– |
!!$ eFrame, A, f, t, pot, vpair, fpair, d_grp, r_grp) |
1408 |
|
subroutine do_pair(i, j, rijsq, d, sw, do_pot, & |
1409 |
< |
eFrame, A, f, t, pot, vpair, fpair, d_grp, r_grp, fstrs) |
1409 |
> |
eFrame, A, f, t, pot, vpair, fpair, d_grp, r_grp, rCut) |
1410 |
|
|
1411 |
|
real( kind = dp ) :: vpair, sw |
1412 |
|
real( kind = dp ), dimension(LR_POT_TYPES) :: pot |
1413 |
|
real( kind = dp ), dimension(3) :: fpair |
1176 |
– |
real( kind = dp ), dimension(3) :: fstrs |
1414 |
|
real( kind = dp ), dimension(nLocal) :: mfact |
1415 |
|
real( kind = dp ), dimension(9,nLocal) :: eFrame |
1416 |
|
real( kind = dp ), dimension(9,nLocal) :: A |
1423 |
|
real ( kind = dp ), intent(inout) :: r_grp |
1424 |
|
real ( kind = dp ), intent(inout) :: d(3) |
1425 |
|
real ( kind = dp ), intent(inout) :: d_grp(3) |
1426 |
+ |
real ( kind = dp ), intent(inout) :: rCut |
1427 |
|
real ( kind = dp ) :: r |
1428 |
+ |
real ( kind = dp ) :: a_k, b_k, c_k, d_k, dx |
1429 |
|
integer :: me_i, me_j |
1430 |
+ |
integer :: k |
1431 |
|
|
1432 |
|
integer :: iHash |
1433 |
|
|
1434 |
|
r = sqrt(rijsq) |
1435 |
< |
vpair = 0.0d0 |
1436 |
< |
fpair(1:3) = 0.0d0 |
1435 |
> |
|
1436 |
> |
vpair = 0.0_dp |
1437 |
> |
fpair(1:3) = 0.0_dp |
1438 |
|
|
1439 |
|
#ifdef IS_MPI |
1440 |
|
me_i = atid_row(i) |
1447 |
|
iHash = InteractionHash(me_i, me_j) |
1448 |
|
|
1449 |
|
if ( iand(iHash, LJ_PAIR).ne.0 ) then |
1450 |
< |
call do_lj_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1450 |
> |
call do_lj_pair(i, j, d, r, rijsq, rcut, sw, vpair, fpair, & |
1451 |
|
pot(VDW_POT), f, do_pot) |
1452 |
|
endif |
1453 |
|
|
1454 |
|
if ( iand(iHash, ELECTROSTATIC_PAIR).ne.0 ) then |
1455 |
< |
!!$ call doElectrostaticPair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1456 |
< |
!!$ pot(ELECTROSTATIC_POT), eFrame, f, t, do_pot) |
1216 |
< |
call doElectrostaticPair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1217 |
< |
pot(ELECTROSTATIC_POT), eFrame, f, t, do_pot, fstrs) |
1455 |
> |
call doElectrostaticPair(i, j, d, r, rijsq, rcut, sw, vpair, fpair, & |
1456 |
> |
pot(ELECTROSTATIC_POT), eFrame, f, t, do_pot) |
1457 |
|
endif |
1458 |
|
|
1459 |
|
if ( iand(iHash, STICKY_PAIR).ne.0 ) then |
1472 |
|
endif |
1473 |
|
|
1474 |
|
if ( iand(iHash, GAYBERNE_LJ).ne.0 ) then |
1475 |
< |
call do_gb_lj_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1475 |
> |
call do_gb_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1476 |
|
pot(VDW_POT), A, f, t, do_pot) |
1477 |
|
endif |
1478 |
|
|
1490 |
|
call do_shape_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1491 |
|
pot(VDW_POT), A, f, t, do_pot) |
1492 |
|
endif |
1493 |
+ |
|
1494 |
+ |
if ( iand(iHash, SC_PAIR).ne.0 ) then |
1495 |
+ |
call do_SC_pair(i, j, d, r, rijsq, rcut, sw, vpair, fpair, & |
1496 |
+ |
pot(METALLIC_POT), f, do_pot) |
1497 |
+ |
endif |
1498 |
|
|
1499 |
|
end subroutine do_pair |
1500 |
|
|
1501 |
< |
subroutine do_prepair(i, j, rijsq, d, sw, rcijsq, dc, & |
1501 |
> |
subroutine do_prepair(i, j, rijsq, d, sw, rcijsq, dc, rCut, & |
1502 |
|
do_pot, do_stress, eFrame, A, f, t, pot) |
1503 |
|
|
1504 |
|
real( kind = dp ) :: sw |
1510 |
|
|
1511 |
|
logical, intent(inout) :: do_pot, do_stress |
1512 |
|
integer, intent(in) :: i, j |
1513 |
< |
real ( kind = dp ), intent(inout) :: rijsq, rcijsq |
1513 |
> |
real ( kind = dp ), intent(inout) :: rijsq, rcijsq, rCut |
1514 |
|
real ( kind = dp ) :: r, rc |
1515 |
|
real ( kind = dp ), intent(inout) :: d(3), dc(3) |
1516 |
|
|
1517 |
|
integer :: me_i, me_j, iHash |
1518 |
|
|
1519 |
|
r = sqrt(rijsq) |
1520 |
< |
|
1520 |
> |
|
1521 |
|
#ifdef IS_MPI |
1522 |
|
me_i = atid_row(i) |
1523 |
|
me_j = atid_col(j) |
1529 |
|
iHash = InteractionHash(me_i, me_j) |
1530 |
|
|
1531 |
|
if ( iand(iHash, EAM_PAIR).ne.0 ) then |
1532 |
< |
call calc_EAM_prepair_rho(i, j, d, r, rijsq ) |
1532 |
> |
call calc_EAM_prepair_rho(i, j, d, r, rijsq) |
1533 |
|
endif |
1534 |
+ |
|
1535 |
+ |
if ( iand(iHash, SC_PAIR).ne.0 ) then |
1536 |
+ |
call calc_SC_prepair_rho(i, j, d, r, rijsq, rcut ) |
1537 |
+ |
endif |
1538 |
|
|
1539 |
|
end subroutine do_prepair |
1540 |
|
|
1546 |
|
if (FF_uses_EAM .and. SIM_uses_EAM) then |
1547 |
|
call calc_EAM_preforce_Frho(nlocal,pot(METALLIC_POT)) |
1548 |
|
endif |
1549 |
< |
|
1550 |
< |
|
1549 |
> |
if (FF_uses_SC .and. SIM_uses_SC) then |
1550 |
> |
call calc_SC_preforce_Frho(nlocal,pot(METALLIC_POT)) |
1551 |
> |
endif |
1552 |
|
end subroutine do_preforce |
1553 |
|
|
1554 |
|
|
1560 |
|
real( kind = dp ) :: d(3), scaled(3) |
1561 |
|
integer i |
1562 |
|
|
1563 |
< |
d(1:3) = q_j(1:3) - q_i(1:3) |
1563 |
> |
d(1) = q_j(1) - q_i(1) |
1564 |
> |
d(2) = q_j(2) - q_i(2) |
1565 |
> |
d(3) = q_j(3) - q_i(3) |
1566 |
|
|
1567 |
|
! Wrap back into periodic box if necessary |
1568 |
|
if ( SIM_uses_PBC ) then |
1569 |
|
|
1570 |
|
if( .not.boxIsOrthorhombic ) then |
1571 |
|
! calc the scaled coordinates. |
1572 |
+ |
! scaled = matmul(HmatInv, d) |
1573 |
|
|
1574 |
< |
scaled = matmul(HmatInv, d) |
1575 |
< |
|
1574 |
> |
scaled(1) = HmatInv(1,1)*d(1) + HmatInv(1,2)*d(2) + HmatInv(1,3)*d(3) |
1575 |
> |
scaled(2) = HmatInv(2,1)*d(1) + HmatInv(2,2)*d(2) + HmatInv(2,3)*d(3) |
1576 |
> |
scaled(3) = HmatInv(3,1)*d(1) + HmatInv(3,2)*d(2) + HmatInv(3,3)*d(3) |
1577 |
> |
|
1578 |
|
! wrap the scaled coordinates |
1579 |
|
|
1580 |
< |
scaled = scaled - anint(scaled) |
1580 |
> |
scaled(1) = scaled(1) - anint(scaled(1), kind=dp) |
1581 |
> |
scaled(2) = scaled(2) - anint(scaled(2), kind=dp) |
1582 |
> |
scaled(3) = scaled(3) - anint(scaled(3), kind=dp) |
1583 |
|
|
1328 |
– |
|
1584 |
|
! calc the wrapped real coordinates from the wrapped scaled |
1585 |
|
! coordinates |
1586 |
+ |
! d = matmul(Hmat,scaled) |
1587 |
+ |
d(1)= Hmat(1,1)*scaled(1) + Hmat(1,2)*scaled(2) + Hmat(1,3)*scaled(3) |
1588 |
+ |
d(2)= Hmat(2,1)*scaled(1) + Hmat(2,2)*scaled(2) + Hmat(2,3)*scaled(3) |
1589 |
+ |
d(3)= Hmat(3,1)*scaled(1) + Hmat(3,2)*scaled(2) + Hmat(3,3)*scaled(3) |
1590 |
|
|
1332 |
– |
d = matmul(Hmat,scaled) |
1333 |
– |
|
1591 |
|
else |
1592 |
|
! calc the scaled coordinates. |
1593 |
|
|
1594 |
< |
do i = 1, 3 |
1595 |
< |
scaled(i) = d(i) * HmatInv(i,i) |
1594 |
> |
scaled(1) = d(1) * HmatInv(1,1) |
1595 |
> |
scaled(2) = d(2) * HmatInv(2,2) |
1596 |
> |
scaled(3) = d(3) * HmatInv(3,3) |
1597 |
> |
|
1598 |
> |
! wrap the scaled coordinates |
1599 |
> |
|
1600 |
> |
scaled(1) = scaled(1) - anint(scaled(1), kind=dp) |
1601 |
> |
scaled(2) = scaled(2) - anint(scaled(2), kind=dp) |
1602 |
> |
scaled(3) = scaled(3) - anint(scaled(3), kind=dp) |
1603 |
|
|
1604 |
< |
! wrap the scaled coordinates |
1604 |
> |
! calc the wrapped real coordinates from the wrapped scaled |
1605 |
> |
! coordinates |
1606 |
|
|
1607 |
< |
scaled(i) = scaled(i) - anint(scaled(i)) |
1607 |
> |
d(1) = scaled(1)*Hmat(1,1) |
1608 |
> |
d(2) = scaled(2)*Hmat(2,2) |
1609 |
> |
d(3) = scaled(3)*Hmat(3,3) |
1610 |
|
|
1344 |
– |
! calc the wrapped real coordinates from the wrapped scaled |
1345 |
– |
! coordinates |
1346 |
– |
|
1347 |
– |
d(i) = scaled(i)*Hmat(i,i) |
1348 |
– |
enddo |
1611 |
|
endif |
1612 |
|
|
1613 |
|
endif |
1614 |
|
|
1615 |
< |
r_sq = dot_product(d,d) |
1615 |
> |
r_sq = d(1)*d(1) + d(2)*d(2) + d(3)*d(3) |
1616 |
|
|
1617 |
|
end subroutine get_interatomic_vector |
1618 |
|
|
1650 |
|
call clean_EAM() |
1651 |
|
endif |
1652 |
|
|
1391 |
– |
tau_Temp = 0.0_dp |
1392 |
– |
virial_Temp = 0.0_dp |
1653 |
|
end subroutine zero_work_arrays |
1654 |
|
|
1655 |
|
function skipThisPair(atom1, atom2) result(skip_it) |
1741 |
|
|
1742 |
|
function FF_RequiresPrepairCalc() result(doesit) |
1743 |
|
logical :: doesit |
1744 |
< |
doesit = FF_uses_EAM |
1744 |
> |
doesit = FF_uses_EAM .or. FF_uses_SC & |
1745 |
> |
.or. FF_uses_MEAM |
1746 |
|
end function FF_RequiresPrepairCalc |
1747 |
|
|
1748 |
|
#ifdef PROFILE |
1754 |
|
|
1755 |
|
!! This cleans componets of force arrays belonging only to fortran |
1756 |
|
|
1757 |
< |
subroutine add_stress_tensor(dpair, fpair) |
1757 |
> |
subroutine add_stress_tensor(dpair, fpair, tau) |
1758 |
|
|
1759 |
|
real( kind = dp ), dimension(3), intent(in) :: dpair, fpair |
1760 |
+ |
real( kind = dp ), dimension(9), intent(inout) :: tau |
1761 |
|
|
1762 |
|
! because the d vector is the rj - ri vector, and |
1763 |
|
! because fx, fy, fz are the force on atom i, we need a |
1764 |
|
! negative sign here: |
1765 |
|
|
1766 |
< |
tau_Temp(1) = tau_Temp(1) - dpair(1) * fpair(1) |
1767 |
< |
tau_Temp(2) = tau_Temp(2) - dpair(1) * fpair(2) |
1768 |
< |
tau_Temp(3) = tau_Temp(3) - dpair(1) * fpair(3) |
1769 |
< |
tau_Temp(4) = tau_Temp(4) - dpair(2) * fpair(1) |
1770 |
< |
tau_Temp(5) = tau_Temp(5) - dpair(2) * fpair(2) |
1771 |
< |
tau_Temp(6) = tau_Temp(6) - dpair(2) * fpair(3) |
1772 |
< |
tau_Temp(7) = tau_Temp(7) - dpair(3) * fpair(1) |
1773 |
< |
tau_Temp(8) = tau_Temp(8) - dpair(3) * fpair(2) |
1774 |
< |
tau_Temp(9) = tau_Temp(9) - dpair(3) * fpair(3) |
1766 |
> |
tau(1) = tau(1) - dpair(1) * fpair(1) |
1767 |
> |
tau(2) = tau(2) - dpair(1) * fpair(2) |
1768 |
> |
tau(3) = tau(3) - dpair(1) * fpair(3) |
1769 |
> |
tau(4) = tau(4) - dpair(2) * fpair(1) |
1770 |
> |
tau(5) = tau(5) - dpair(2) * fpair(2) |
1771 |
> |
tau(6) = tau(6) - dpair(2) * fpair(3) |
1772 |
> |
tau(7) = tau(7) - dpair(3) * fpair(1) |
1773 |
> |
tau(8) = tau(8) - dpair(3) * fpair(2) |
1774 |
> |
tau(9) = tau(9) - dpair(3) * fpair(3) |
1775 |
|
|
1514 |
– |
virial_Temp = virial_Temp + & |
1515 |
– |
(tau_Temp(1) + tau_Temp(5) + tau_Temp(9)) |
1516 |
– |
|
1776 |
|
end subroutine add_stress_tensor |
1777 |
|
|
1778 |
|
end module doForces |