45 |
|
|
46 |
|
!! @author Charles F. Vardeman II |
47 |
|
!! @author Matthew Meineke |
48 |
< |
!! @version $Id: doForces.F90,v 1.52 2005-10-10 21:34:54 chuckv Exp $, $Date: 2005-10-10 21:34:54 $, $Name: not supported by cvs2svn $, $Revision: 1.52 $ |
48 |
> |
!! @version $Id: doForces.F90,v 1.68 2005-11-15 16:01:06 chuckv Exp $, $Date: 2005-11-15 16:01:06 $, $Name: not supported by cvs2svn $, $Revision: 1.68 $ |
49 |
|
|
50 |
|
|
51 |
|
module doForces |
58 |
|
use lj |
59 |
|
use sticky |
60 |
|
use electrostatic_module |
61 |
< |
use reaction_field_module |
62 |
< |
use gb_pair |
61 |
> |
use gayberne |
62 |
|
use shapes |
63 |
|
use vector_class |
64 |
|
use eam |
65 |
+ |
use suttonchen |
66 |
|
use status |
67 |
|
#ifdef IS_MPI |
68 |
|
use mpiSimulation |
93 |
|
logical, save :: FF_uses_Dipoles |
94 |
|
logical, save :: FF_uses_GayBerne |
95 |
|
logical, save :: FF_uses_EAM |
96 |
+ |
logical, save :: FF_uses_SC |
97 |
+ |
logical, save :: FF_uses_MEAM |
98 |
+ |
|
99 |
|
|
100 |
|
logical, save :: SIM_uses_DirectionalAtoms |
101 |
|
logical, save :: SIM_uses_EAM |
102 |
+ |
logical, save :: SIM_uses_SC |
103 |
+ |
logical, save :: SIM_uses_MEAM |
104 |
|
logical, save :: SIM_requires_postpair_calc |
105 |
|
logical, save :: SIM_requires_prepair_calc |
106 |
|
logical, save :: SIM_uses_PBC |
164 |
|
logical :: i_is_GB |
165 |
|
logical :: i_is_EAM |
166 |
|
logical :: i_is_Shape |
167 |
+ |
logical :: i_is_SC |
168 |
+ |
logical :: i_is_MEAM |
169 |
|
logical :: j_is_LJ |
170 |
|
logical :: j_is_Elect |
171 |
|
logical :: j_is_Sticky |
173 |
|
logical :: j_is_GB |
174 |
|
logical :: j_is_EAM |
175 |
|
logical :: j_is_Shape |
176 |
+ |
logical :: j_is_SC |
177 |
+ |
logical :: j_is_MEAM |
178 |
|
real(kind=dp) :: myRcut |
179 |
|
|
180 |
+ |
|
181 |
|
status = 0 |
182 |
|
|
183 |
|
if (.not. associated(atypes)) then |
194 |
|
end if |
195 |
|
|
196 |
|
if (.not. allocated(InteractionHash)) then |
197 |
+ |
allocate(InteractionHash(nAtypes,nAtypes)) |
198 |
+ |
else |
199 |
+ |
deallocate(InteractionHash) |
200 |
|
allocate(InteractionHash(nAtypes,nAtypes)) |
201 |
|
endif |
202 |
|
|
203 |
|
if (.not. allocated(atypeMaxCutoff)) then |
204 |
|
allocate(atypeMaxCutoff(nAtypes)) |
205 |
+ |
else |
206 |
+ |
deallocate(atypeMaxCutoff) |
207 |
+ |
allocate(atypeMaxCutoff(nAtypes)) |
208 |
|
endif |
209 |
|
|
210 |
|
do i = 1, nAtypes |
215 |
|
call getElementProperty(atypes, i, "is_GayBerne", i_is_GB) |
216 |
|
call getElementProperty(atypes, i, "is_EAM", i_is_EAM) |
217 |
|
call getElementProperty(atypes, i, "is_Shape", i_is_Shape) |
218 |
+ |
call getElementProperty(atypes, i, "is_SC", i_is_SC) |
219 |
+ |
call getElementProperty(atypes, i, "is_MEAM", i_is_MEAM) |
220 |
|
|
221 |
|
do j = i, nAtypes |
222 |
|
|
230 |
|
call getElementProperty(atypes, j, "is_GayBerne", j_is_GB) |
231 |
|
call getElementProperty(atypes, j, "is_EAM", j_is_EAM) |
232 |
|
call getElementProperty(atypes, j, "is_Shape", j_is_Shape) |
233 |
+ |
call getElementProperty(atypes, j, "is_SC", j_is_SC) |
234 |
+ |
call getElementProperty(atypes, j, "is_MEAM", j_is_MEAM) |
235 |
|
|
236 |
|
if (i_is_LJ .and. j_is_LJ) then |
237 |
|
iHash = ior(iHash, LJ_PAIR) |
253 |
|
iHash = ior(iHash, EAM_PAIR) |
254 |
|
endif |
255 |
|
|
256 |
+ |
if (i_is_SC .and. j_is_SC) then |
257 |
+ |
iHash = ior(iHash, SC_PAIR) |
258 |
+ |
endif |
259 |
+ |
|
260 |
|
if (i_is_GB .and. j_is_GB) iHash = ior(iHash, GAYBERNE_PAIR) |
261 |
|
if (i_is_GB .and. j_is_LJ) iHash = ior(iHash, GAYBERNE_LJ) |
262 |
|
if (i_is_LJ .and. j_is_GB) iHash = ior(iHash, GAYBERNE_LJ) |
588 |
|
subroutine setSimVariables() |
589 |
|
SIM_uses_DirectionalAtoms = SimUsesDirectionalAtoms() |
590 |
|
SIM_uses_EAM = SimUsesEAM() |
591 |
+ |
SIM_uses_SC = SimUsesSC() |
592 |
|
SIM_requires_postpair_calc = SimRequiresPostpairCalc() |
593 |
|
SIM_requires_prepair_calc = SimRequiresPrepairCalc() |
594 |
|
SIM_uses_PBC = SimUsesPBC() |
664 |
|
integer, intent(out) :: thisStat |
665 |
|
integer :: my_status, nMatches |
666 |
|
integer, pointer :: MatchList(:) => null() |
642 |
– |
real(kind=dp) :: rcut, rrf, rt, dielect |
667 |
|
|
668 |
|
!! assume things are copacetic, unless they aren't |
669 |
|
thisStat = 0 |
698 |
|
|
699 |
|
|
700 |
|
haveSaneForceField = .true. |
677 |
– |
|
678 |
– |
!! check to make sure the reaction field setting makes sense |
679 |
– |
|
680 |
– |
if (FF_uses_Dipoles) then |
681 |
– |
if (electrostaticSummationMethod == REACTION_FIELD) then |
682 |
– |
dielect = getDielect() |
683 |
– |
call initialize_rf(dielect) |
684 |
– |
endif |
685 |
– |
else |
686 |
– |
if (electrostaticSummationMethod == REACTION_FIELD) then |
687 |
– |
write(default_error,*) 'Using Reaction Field with no dipoles? Huh?' |
688 |
– |
thisStat = -1 |
689 |
– |
haveSaneForceField = .false. |
690 |
– |
return |
691 |
– |
endif |
692 |
– |
endif |
701 |
|
|
702 |
|
if (FF_uses_EAM) then |
703 |
|
call init_EAM_FF(my_status) |
709 |
|
end if |
710 |
|
endif |
711 |
|
|
704 |
– |
if (FF_uses_GayBerne) then |
705 |
– |
call check_gb_pair_FF(my_status) |
706 |
– |
if (my_status .ne. 0) then |
707 |
– |
thisStat = -1 |
708 |
– |
haveSaneForceField = .false. |
709 |
– |
return |
710 |
– |
endif |
711 |
– |
endif |
712 |
– |
|
712 |
|
if (.not. haveNeighborList) then |
713 |
|
!! Create neighbor lists |
714 |
|
call expandNeighborList(nLocal, my_status) |
742 |
|
|
743 |
|
!! Stress Tensor |
744 |
|
real( kind = dp), dimension(9) :: tau |
745 |
< |
real ( kind = dp ) :: pot |
745 |
> |
real ( kind = dp ),dimension(LR_POT_TYPES) :: pot |
746 |
|
logical ( kind = 2) :: do_pot_c, do_stress_c |
747 |
|
logical :: do_pot |
748 |
|
logical :: do_stress |
749 |
|
logical :: in_switching_region |
750 |
|
#ifdef IS_MPI |
751 |
< |
real( kind = DP ) :: pot_local |
751 |
> |
real( kind = DP ), dimension(LR_POT_TYPES) :: pot_local |
752 |
|
integer :: nAtomsInRow |
753 |
|
integer :: nAtomsInCol |
754 |
|
integer :: nprocs |
763 |
|
integer :: nlist |
764 |
|
real( kind = DP ) :: ratmsq, rgrpsq, rgrp, vpair, vij |
765 |
|
real( kind = DP ) :: sw, dswdr, swderiv, mf |
766 |
+ |
real( kind = DP ) :: rVal |
767 |
|
real(kind=dp),dimension(3) :: d_atm, d_grp, fpair, fij |
768 |
|
real(kind=dp) :: rfpot, mu_i, virial |
769 |
|
integer :: me_i, me_j, n_in_i, n_in_j |
774 |
|
integer :: propPack_i, propPack_j |
775 |
|
integer :: loopStart, loopEnd, loop |
776 |
|
integer :: iHash |
777 |
+ |
integer :: i1 |
778 |
|
|
779 |
|
|
780 |
|
!! initialize local variables |
922 |
|
|
923 |
|
list(nlist) = j |
924 |
|
endif |
925 |
< |
|
926 |
< |
if (loop .eq. PAIR_LOOP) then |
926 |
< |
vij = 0.0d0 |
927 |
< |
fij(1:3) = 0.0d0 |
928 |
< |
endif |
929 |
< |
|
930 |
< |
call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & |
931 |
< |
in_switching_region) |
925 |
> |
|
926 |
> |
if (rgrpsq < gtypeCutoffMap(groupToGtypeRow(i),groupToGtypeCol(j))%rCutsq) then |
927 |
|
|
928 |
< |
n_in_j = groupStartCol(j+1) - groupStartCol(j) |
929 |
< |
|
930 |
< |
do ia = groupStartRow(i), groupStartRow(i+1)-1 |
931 |
< |
|
932 |
< |
atom1 = groupListRow(ia) |
933 |
< |
|
934 |
< |
inner: do jb = groupStartCol(j), groupStartCol(j+1)-1 |
935 |
< |
|
936 |
< |
atom2 = groupListCol(jb) |
937 |
< |
|
938 |
< |
if (skipThisPair(atom1, atom2)) cycle inner |
939 |
< |
|
940 |
< |
if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then |
941 |
< |
d_atm(1:3) = d_grp(1:3) |
942 |
< |
ratmsq = rgrpsq |
943 |
< |
else |
928 |
> |
if (loop .eq. PAIR_LOOP) then |
929 |
> |
vij = 0.0d0 |
930 |
> |
fij(1:3) = 0.0d0 |
931 |
> |
endif |
932 |
> |
|
933 |
> |
call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & |
934 |
> |
in_switching_region) |
935 |
> |
|
936 |
> |
n_in_j = groupStartCol(j+1) - groupStartCol(j) |
937 |
> |
|
938 |
> |
do ia = groupStartRow(i), groupStartRow(i+1)-1 |
939 |
> |
|
940 |
> |
atom1 = groupListRow(ia) |
941 |
> |
|
942 |
> |
inner: do jb = groupStartCol(j), groupStartCol(j+1)-1 |
943 |
> |
|
944 |
> |
atom2 = groupListCol(jb) |
945 |
> |
|
946 |
> |
if (skipThisPair(atom1, atom2)) cycle inner |
947 |
> |
|
948 |
> |
if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then |
949 |
> |
d_atm(1:3) = d_grp(1:3) |
950 |
> |
ratmsq = rgrpsq |
951 |
> |
else |
952 |
|
#ifdef IS_MPI |
953 |
< |
call get_interatomic_vector(q_Row(:,atom1), & |
954 |
< |
q_Col(:,atom2), d_atm, ratmsq) |
953 |
> |
call get_interatomic_vector(q_Row(:,atom1), & |
954 |
> |
q_Col(:,atom2), d_atm, ratmsq) |
955 |
|
#else |
956 |
< |
call get_interatomic_vector(q(:,atom1), & |
957 |
< |
q(:,atom2), d_atm, ratmsq) |
956 |
> |
call get_interatomic_vector(q(:,atom1), & |
957 |
> |
q(:,atom2), d_atm, ratmsq) |
958 |
|
#endif |
959 |
< |
endif |
960 |
< |
|
961 |
< |
if (loop .eq. PREPAIR_LOOP) then |
959 |
> |
endif |
960 |
> |
|
961 |
> |
if (loop .eq. PREPAIR_LOOP) then |
962 |
|
#ifdef IS_MPI |
963 |
< |
call do_prepair(atom1, atom2, ratmsq, d_atm, sw, & |
964 |
< |
rgrpsq, d_grp, do_pot, do_stress, & |
965 |
< |
eFrame, A, f, t, pot_local) |
963 |
> |
call do_prepair(atom1, atom2, ratmsq, d_atm, sw, & |
964 |
> |
rgrpsq, d_grp, do_pot, do_stress, & |
965 |
> |
eFrame, A, f, t, pot_local) |
966 |
|
#else |
967 |
< |
call do_prepair(atom1, atom2, ratmsq, d_atm, sw, & |
968 |
< |
rgrpsq, d_grp, do_pot, do_stress, & |
969 |
< |
eFrame, A, f, t, pot) |
967 |
> |
call do_prepair(atom1, atom2, ratmsq, d_atm, sw, & |
968 |
> |
rgrpsq, d_grp, do_pot, do_stress, & |
969 |
> |
eFrame, A, f, t, pot) |
970 |
|
#endif |
971 |
< |
else |
971 |
> |
else |
972 |
|
#ifdef IS_MPI |
973 |
< |
call do_pair(atom1, atom2, ratmsq, d_atm, sw, & |
974 |
< |
do_pot, & |
975 |
< |
eFrame, A, f, t, pot_local, vpair, fpair) |
973 |
> |
call do_pair(atom1, atom2, ratmsq, d_atm, sw, & |
974 |
> |
do_pot, eFrame, A, f, t, pot_local, vpair, & |
975 |
> |
fpair, d_grp, rgrp) |
976 |
|
#else |
977 |
< |
call do_pair(atom1, atom2, ratmsq, d_atm, sw, & |
978 |
< |
do_pot, & |
979 |
< |
eFrame, A, f, t, pot, vpair, fpair) |
977 |
> |
call do_pair(atom1, atom2, ratmsq, d_atm, sw, & |
978 |
> |
do_pot, eFrame, A, f, t, pot, vpair, fpair, & |
979 |
> |
d_grp, rgrp) |
980 |
|
#endif |
981 |
+ |
vij = vij + vpair |
982 |
+ |
fij(1:3) = fij(1:3) + fpair(1:3) |
983 |
+ |
endif |
984 |
+ |
enddo inner |
985 |
+ |
enddo |
986 |
|
|
987 |
< |
vij = vij + vpair |
988 |
< |
fij(1:3) = fij(1:3) + fpair(1:3) |
989 |
< |
endif |
990 |
< |
enddo inner |
991 |
< |
enddo |
992 |
< |
|
993 |
< |
if (loop .eq. PAIR_LOOP) then |
994 |
< |
if (in_switching_region) then |
995 |
< |
swderiv = vij*dswdr/rgrp |
996 |
< |
fij(1) = fij(1) + swderiv*d_grp(1) |
989 |
< |
fij(2) = fij(2) + swderiv*d_grp(2) |
990 |
< |
fij(3) = fij(3) + swderiv*d_grp(3) |
991 |
< |
|
992 |
< |
do ia=groupStartRow(i), groupStartRow(i+1)-1 |
993 |
< |
atom1=groupListRow(ia) |
994 |
< |
mf = mfactRow(atom1) |
987 |
> |
if (loop .eq. PAIR_LOOP) then |
988 |
> |
if (in_switching_region) then |
989 |
> |
swderiv = vij*dswdr/rgrp |
990 |
> |
fij(1) = fij(1) + swderiv*d_grp(1) |
991 |
> |
fij(2) = fij(2) + swderiv*d_grp(2) |
992 |
> |
fij(3) = fij(3) + swderiv*d_grp(3) |
993 |
> |
|
994 |
> |
do ia=groupStartRow(i), groupStartRow(i+1)-1 |
995 |
> |
atom1=groupListRow(ia) |
996 |
> |
mf = mfactRow(atom1) |
997 |
|
#ifdef IS_MPI |
998 |
< |
f_Row(1,atom1) = f_Row(1,atom1) + swderiv*d_grp(1)*mf |
999 |
< |
f_Row(2,atom1) = f_Row(2,atom1) + swderiv*d_grp(2)*mf |
1000 |
< |
f_Row(3,atom1) = f_Row(3,atom1) + swderiv*d_grp(3)*mf |
998 |
> |
f_Row(1,atom1) = f_Row(1,atom1) + swderiv*d_grp(1)*mf |
999 |
> |
f_Row(2,atom1) = f_Row(2,atom1) + swderiv*d_grp(2)*mf |
1000 |
> |
f_Row(3,atom1) = f_Row(3,atom1) + swderiv*d_grp(3)*mf |
1001 |
|
#else |
1002 |
< |
f(1,atom1) = f(1,atom1) + swderiv*d_grp(1)*mf |
1003 |
< |
f(2,atom1) = f(2,atom1) + swderiv*d_grp(2)*mf |
1004 |
< |
f(3,atom1) = f(3,atom1) + swderiv*d_grp(3)*mf |
1002 |
> |
f(1,atom1) = f(1,atom1) + swderiv*d_grp(1)*mf |
1003 |
> |
f(2,atom1) = f(2,atom1) + swderiv*d_grp(2)*mf |
1004 |
> |
f(3,atom1) = f(3,atom1) + swderiv*d_grp(3)*mf |
1005 |
|
#endif |
1006 |
< |
enddo |
1007 |
< |
|
1008 |
< |
do jb=groupStartCol(j), groupStartCol(j+1)-1 |
1009 |
< |
atom2=groupListCol(jb) |
1010 |
< |
mf = mfactCol(atom2) |
1006 |
> |
enddo |
1007 |
> |
|
1008 |
> |
do jb=groupStartCol(j), groupStartCol(j+1)-1 |
1009 |
> |
atom2=groupListCol(jb) |
1010 |
> |
mf = mfactCol(atom2) |
1011 |
|
#ifdef IS_MPI |
1012 |
< |
f_Col(1,atom2) = f_Col(1,atom2) - swderiv*d_grp(1)*mf |
1013 |
< |
f_Col(2,atom2) = f_Col(2,atom2) - swderiv*d_grp(2)*mf |
1014 |
< |
f_Col(3,atom2) = f_Col(3,atom2) - swderiv*d_grp(3)*mf |
1012 |
> |
f_Col(1,atom2) = f_Col(1,atom2) - swderiv*d_grp(1)*mf |
1013 |
> |
f_Col(2,atom2) = f_Col(2,atom2) - swderiv*d_grp(2)*mf |
1014 |
> |
f_Col(3,atom2) = f_Col(3,atom2) - swderiv*d_grp(3)*mf |
1015 |
|
#else |
1016 |
< |
f(1,atom2) = f(1,atom2) - swderiv*d_grp(1)*mf |
1017 |
< |
f(2,atom2) = f(2,atom2) - swderiv*d_grp(2)*mf |
1018 |
< |
f(3,atom2) = f(3,atom2) - swderiv*d_grp(3)*mf |
1016 |
> |
f(1,atom2) = f(1,atom2) - swderiv*d_grp(1)*mf |
1017 |
> |
f(2,atom2) = f(2,atom2) - swderiv*d_grp(2)*mf |
1018 |
> |
f(3,atom2) = f(3,atom2) - swderiv*d_grp(3)*mf |
1019 |
|
#endif |
1020 |
< |
enddo |
1021 |
< |
endif |
1020 |
> |
enddo |
1021 |
> |
endif |
1022 |
|
|
1023 |
< |
if (do_stress) call add_stress_tensor(d_grp, fij) |
1023 |
> |
if (do_stress) call add_stress_tensor(d_grp, fij) |
1024 |
> |
endif |
1025 |
|
endif |
1026 |
< |
end if |
1026 |
> |
endif |
1027 |
|
enddo |
1028 |
< |
|
1028 |
> |
|
1029 |
|
enddo outer |
1030 |
|
|
1031 |
|
if (update_nlist) then |
1085 |
|
|
1086 |
|
if (do_pot) then |
1087 |
|
! scatter/gather pot_row into the members of my column |
1088 |
< |
call scatter(pot_Row, pot_Temp, plan_atom_row) |
1089 |
< |
|
1088 |
> |
do i = 1,LR_POT_TYPES |
1089 |
> |
call scatter(pot_Row(i,:), pot_Temp(i,:), plan_atom_row) |
1090 |
> |
end do |
1091 |
|
! scatter/gather pot_local into all other procs |
1092 |
|
! add resultant to get total pot |
1093 |
|
do i = 1, nlocal |
1094 |
< |
pot_local = pot_local + pot_Temp(i) |
1094 |
> |
pot_local(1:LR_POT_TYPES) = pot_local(1:LR_POT_TYPES) & |
1095 |
> |
+ pot_Temp(1:LR_POT_TYPES,i) |
1096 |
|
enddo |
1097 |
|
|
1098 |
|
pot_Temp = 0.0_DP |
1099 |
< |
|
1100 |
< |
call scatter(pot_Col, pot_Temp, plan_atom_col) |
1099 |
> |
do i = 1,LR_POT_TYPES |
1100 |
> |
call scatter(pot_Col(i,:), pot_Temp(i,:), plan_atom_col) |
1101 |
> |
end do |
1102 |
|
do i = 1, nlocal |
1103 |
< |
pot_local = pot_local + pot_Temp(i) |
1103 |
> |
pot_local(1:LR_POT_TYPES) = pot_local(1:LR_POT_TYPES)& |
1104 |
> |
+ pot_Temp(1:LR_POT_TYPES,i) |
1105 |
|
enddo |
1106 |
|
|
1107 |
|
endif |
1108 |
|
#endif |
1109 |
|
|
1110 |
< |
if (FF_RequiresPostpairCalc() .and. SIM_requires_postpair_calc) then |
1111 |
< |
|
1112 |
< |
if (electrostaticSummationMethod == REACTION_FIELD) then |
1110 |
> |
if (SIM_requires_postpair_calc) then |
1111 |
> |
do i = 1, nlocal |
1112 |
> |
|
1113 |
> |
! we loop only over the local atoms, so we don't need row and column |
1114 |
> |
! lookups for the types |
1115 |
> |
|
1116 |
> |
me_i = atid(i) |
1117 |
> |
|
1118 |
> |
! is the atom electrostatic? See if it would have an |
1119 |
> |
! electrostatic interaction with itself |
1120 |
> |
iHash = InteractionHash(me_i,me_i) |
1121 |
|
|
1122 |
+ |
if ( iand(iHash, ELECTROSTATIC_PAIR).ne.0 ) then |
1123 |
|
#ifdef IS_MPI |
1124 |
< |
call scatter(rf_Row,rf,plan_atom_row_3d) |
1125 |
< |
call scatter(rf_Col,rf_Temp,plan_atom_col_3d) |
1110 |
< |
do i = 1,nlocal |
1111 |
< |
rf(1:3,i) = rf(1:3,i) + rf_Temp(1:3,i) |
1112 |
< |
end do |
1113 |
< |
#endif |
1114 |
< |
|
1115 |
< |
do i = 1, nLocal |
1116 |
< |
|
1117 |
< |
rfpot = 0.0_DP |
1118 |
< |
#ifdef IS_MPI |
1119 |
< |
me_i = atid_row(i) |
1124 |
> |
call self_self(i, eFrame, pot_local(ELECTROSTATIC_POT), & |
1125 |
> |
t, do_pot) |
1126 |
|
#else |
1127 |
< |
me_i = atid(i) |
1127 |
> |
call self_self(i, eFrame, pot(ELECTROSTATIC_POT), & |
1128 |
> |
t, do_pot) |
1129 |
|
#endif |
1130 |
< |
iHash = InteractionHash(me_i,me_j) |
1130 |
> |
endif |
1131 |
> |
|
1132 |
> |
|
1133 |
> |
if (electrostaticSummationMethod.eq.REACTION_FIELD) then |
1134 |
|
|
1135 |
< |
if ( iand(iHash, ELECTROSTATIC_PAIR).ne.0 ) then |
1136 |
< |
|
1137 |
< |
mu_i = getDipoleMoment(me_i) |
1138 |
< |
|
1139 |
< |
!! The reaction field needs to include a self contribution |
1140 |
< |
!! to the field: |
1141 |
< |
call accumulate_self_rf(i, mu_i, eFrame) |
1142 |
< |
!! Get the reaction field contribution to the |
1143 |
< |
!! potential and torques: |
1144 |
< |
call reaction_field_final(i, mu_i, eFrame, rfpot, t, do_pot) |
1135 |
> |
! loop over the excludes to accumulate RF stuff we've |
1136 |
> |
! left out of the normal pair loop |
1137 |
> |
|
1138 |
> |
do i1 = 1, nSkipsForAtom(i) |
1139 |
> |
j = skipsForAtom(i, i1) |
1140 |
> |
|
1141 |
> |
! prevent overcounting of the skips |
1142 |
> |
if (i.lt.j) then |
1143 |
> |
call get_interatomic_vector(q(:,i), & |
1144 |
> |
q(:,j), d_atm, ratmsq) |
1145 |
> |
rVal = dsqrt(ratmsq) |
1146 |
> |
call get_switch(ratmsq, sw, dswdr, rVal, group_switch, & |
1147 |
> |
in_switching_region) |
1148 |
|
#ifdef IS_MPI |
1149 |
< |
pot_local = pot_local + rfpot |
1149 |
> |
call rf_self_excludes(i, j, sw, eFrame, d_atm, rVal, & |
1150 |
> |
vpair, pot_local(ELECTROSTATIC_POT), f, t, do_pot) |
1151 |
|
#else |
1152 |
< |
pot = pot + rfpot |
1153 |
< |
|
1152 |
> |
call rf_self_excludes(i, j, sw, eFrame, d_atm, rVal, & |
1153 |
> |
vpair, pot(ELECTROSTATIC_POT), f, t, do_pot) |
1154 |
|
#endif |
1155 |
< |
endif |
1156 |
< |
enddo |
1157 |
< |
endif |
1155 |
> |
endif |
1156 |
> |
enddo |
1157 |
> |
endif |
1158 |
> |
enddo |
1159 |
|
endif |
1160 |
< |
|
1146 |
< |
|
1160 |
> |
|
1161 |
|
#ifdef IS_MPI |
1162 |
< |
|
1162 |
> |
|
1163 |
|
if (do_pot) then |
1164 |
< |
pot = pot + pot_local |
1165 |
< |
!! we assume the c code will do the allreduce to get the total potential |
1152 |
< |
!! we could do it right here if we needed to... |
1164 |
> |
call mpi_allreduce(pot_local, pot, LR_POT_TYPES,mpi_double_precision,mpi_sum, & |
1165 |
> |
mpi_comm_world,mpi_err) |
1166 |
|
endif |
1167 |
< |
|
1167 |
> |
|
1168 |
|
if (do_stress) then |
1169 |
|
call mpi_allreduce(tau_Temp, tau, 9,mpi_double_precision,mpi_sum, & |
1170 |
|
mpi_comm_world,mpi_err) |
1171 |
|
call mpi_allreduce(virial_Temp, virial,1,mpi_double_precision,mpi_sum, & |
1172 |
|
mpi_comm_world,mpi_err) |
1173 |
|
endif |
1174 |
< |
|
1174 |
> |
|
1175 |
|
#else |
1176 |
< |
|
1176 |
> |
|
1177 |
|
if (do_stress) then |
1178 |
|
tau = tau_Temp |
1179 |
|
virial = virial_Temp |
1180 |
|
endif |
1181 |
< |
|
1181 |
> |
|
1182 |
|
#endif |
1183 |
< |
|
1183 |
> |
|
1184 |
|
end subroutine do_force_loop |
1185 |
|
|
1186 |
|
subroutine do_pair(i, j, rijsq, d, sw, do_pot, & |
1187 |
< |
eFrame, A, f, t, pot, vpair, fpair) |
1187 |
> |
eFrame, A, f, t, pot, vpair, fpair, d_grp, r_grp) |
1188 |
|
|
1189 |
< |
real( kind = dp ) :: pot, vpair, sw |
1189 |
> |
real( kind = dp ) :: vpair, sw |
1190 |
> |
real( kind = dp ), dimension(LR_POT_TYPES) :: pot |
1191 |
|
real( kind = dp ), dimension(3) :: fpair |
1192 |
|
real( kind = dp ), dimension(nLocal) :: mfact |
1193 |
|
real( kind = dp ), dimension(9,nLocal) :: eFrame |
1198 |
|
logical, intent(inout) :: do_pot |
1199 |
|
integer, intent(in) :: i, j |
1200 |
|
real ( kind = dp ), intent(inout) :: rijsq |
1201 |
< |
real ( kind = dp ) :: r |
1201 |
> |
real ( kind = dp ), intent(inout) :: r_grp |
1202 |
|
real ( kind = dp ), intent(inout) :: d(3) |
1203 |
+ |
real ( kind = dp ), intent(inout) :: d_grp(3) |
1204 |
+ |
real ( kind = dp ) :: r |
1205 |
|
integer :: me_i, me_j |
1206 |
|
|
1207 |
|
integer :: iHash |
1219 |
|
#endif |
1220 |
|
|
1221 |
|
iHash = InteractionHash(me_i, me_j) |
1222 |
< |
|
1222 |
> |
|
1223 |
|
if ( iand(iHash, LJ_PAIR).ne.0 ) then |
1224 |
< |
call do_lj_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, f, do_pot) |
1224 |
> |
call do_lj_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1225 |
> |
pot(VDW_POT), f, do_pot) |
1226 |
|
endif |
1227 |
< |
|
1227 |
> |
|
1228 |
|
if ( iand(iHash, ELECTROSTATIC_PAIR).ne.0 ) then |
1229 |
|
call doElectrostaticPair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1230 |
< |
pot, eFrame, f, t, do_pot) |
1214 |
< |
|
1215 |
< |
if (electrostaticSummationMethod == REACTION_FIELD) then |
1216 |
< |
|
1217 |
< |
! CHECK ME (RF needs to know about all electrostatic types) |
1218 |
< |
call accumulate_rf(i, j, r, eFrame, sw) |
1219 |
< |
call rf_correct_forces(i, j, d, r, eFrame, sw, f, fpair) |
1220 |
< |
endif |
1221 |
< |
|
1230 |
> |
pot(ELECTROSTATIC_POT), eFrame, f, t, do_pot) |
1231 |
|
endif |
1232 |
< |
|
1232 |
> |
|
1233 |
|
if ( iand(iHash, STICKY_PAIR).ne.0 ) then |
1234 |
|
call do_sticky_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1235 |
< |
pot, A, f, t, do_pot) |
1235 |
> |
pot(HB_POT), A, f, t, do_pot) |
1236 |
|
endif |
1237 |
< |
|
1237 |
> |
|
1238 |
|
if ( iand(iHash, STICKYPOWER_PAIR).ne.0 ) then |
1239 |
|
call do_sticky_power_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1240 |
< |
pot, A, f, t, do_pot) |
1240 |
> |
pot(HB_POT), A, f, t, do_pot) |
1241 |
|
endif |
1242 |
< |
|
1242 |
> |
|
1243 |
|
if ( iand(iHash, GAYBERNE_PAIR).ne.0 ) then |
1244 |
|
call do_gb_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1245 |
< |
pot, A, f, t, do_pot) |
1245 |
> |
pot(VDW_POT), A, f, t, do_pot) |
1246 |
|
endif |
1247 |
|
|
1248 |
|
if ( iand(iHash, GAYBERNE_LJ).ne.0 ) then |
1249 |
< |
! call do_gblj_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1250 |
< |
! pot, A, f, t, do_pot) |
1249 |
> |
call do_gb_lj_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1250 |
> |
pot(VDW_POT), A, f, t, do_pot) |
1251 |
|
endif |
1252 |
< |
|
1252 |
> |
|
1253 |
|
if ( iand(iHash, EAM_PAIR).ne.0 ) then |
1254 |
< |
call do_eam_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, f, & |
1255 |
< |
do_pot) |
1254 |
> |
call do_eam_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1255 |
> |
pot(METALLIC_POT), f, do_pot) |
1256 |
|
endif |
1257 |
< |
|
1257 |
> |
|
1258 |
|
if ( iand(iHash, SHAPE_PAIR).ne.0 ) then |
1259 |
|
call do_shape_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1260 |
< |
pot, A, f, t, do_pot) |
1260 |
> |
pot(VDW_POT), A, f, t, do_pot) |
1261 |
|
endif |
1262 |
< |
|
1262 |
> |
|
1263 |
|
if ( iand(iHash, SHAPE_LJ).ne.0 ) then |
1264 |
|
call do_shape_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1265 |
< |
pot, A, f, t, do_pot) |
1265 |
> |
pot(VDW_POT), A, f, t, do_pot) |
1266 |
|
endif |
1267 |
+ |
|
1268 |
+ |
if ( iand(iHash, SC_PAIR).ne.0 ) then |
1269 |
+ |
call do_SC_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1270 |
+ |
pot(METALLIC_POT), f, do_pot) |
1271 |
+ |
endif |
1272 |
+ |
|
1273 |
|
|
1274 |
+ |
|
1275 |
|
end subroutine do_pair |
1276 |
|
|
1277 |
|
subroutine do_prepair(i, j, rijsq, d, sw, rcijsq, dc, & |
1278 |
|
do_pot, do_stress, eFrame, A, f, t, pot) |
1279 |
|
|
1280 |
< |
real( kind = dp ) :: pot, sw |
1280 |
> |
real( kind = dp ) :: sw |
1281 |
> |
real( kind = dp ), dimension(LR_POT_TYPES) :: pot |
1282 |
|
real( kind = dp ), dimension(9,nLocal) :: eFrame |
1283 |
|
real (kind=dp), dimension(9,nLocal) :: A |
1284 |
|
real (kind=dp), dimension(3,nLocal) :: f |
1307 |
|
if ( iand(iHash, EAM_PAIR).ne.0 ) then |
1308 |
|
call calc_EAM_prepair_rho(i, j, d, r, rijsq ) |
1309 |
|
endif |
1310 |
+ |
|
1311 |
+ |
if ( iand(iHash, SC_PAIR).ne.0 ) then |
1312 |
+ |
call calc_SC_prepair_rho(i, j, d, r, rijsq ) |
1313 |
+ |
endif |
1314 |
|
|
1315 |
|
end subroutine do_prepair |
1316 |
|
|
1317 |
|
|
1318 |
|
subroutine do_preforce(nlocal,pot) |
1319 |
|
integer :: nlocal |
1320 |
< |
real( kind = dp ) :: pot |
1320 |
> |
real( kind = dp ),dimension(LR_POT_TYPES) :: pot |
1321 |
|
|
1322 |
|
if (FF_uses_EAM .and. SIM_uses_EAM) then |
1323 |
< |
call calc_EAM_preforce_Frho(nlocal,pot) |
1323 |
> |
call calc_EAM_preforce_Frho(nlocal,pot(METALLIC_POT)) |
1324 |
|
endif |
1325 |
+ |
if (FF_uses_SC .and. SIM_uses_SC) then |
1326 |
+ |
call calc_SC_preforce_Frho(nlocal,pot(METALLIC_POT)) |
1327 |
+ |
endif |
1328 |
|
|
1329 |
|
|
1330 |
|
end subroutine do_preforce |
1409 |
|
pot_Col = 0.0_dp |
1410 |
|
pot_Temp = 0.0_dp |
1411 |
|
|
1388 |
– |
rf_Row = 0.0_dp |
1389 |
– |
rf_Col = 0.0_dp |
1390 |
– |
rf_Temp = 0.0_dp |
1391 |
– |
|
1412 |
|
#endif |
1413 |
|
|
1414 |
|
if (FF_uses_EAM .and. SIM_uses_EAM) then |
1415 |
|
call clean_EAM() |
1416 |
|
endif |
1417 |
|
|
1398 |
– |
rf = 0.0_dp |
1418 |
|
tau_Temp = 0.0_dp |
1419 |
|
virial_Temp = 0.0_dp |
1420 |
|
end subroutine zero_work_arrays |
1508 |
|
|
1509 |
|
function FF_RequiresPrepairCalc() result(doesit) |
1510 |
|
logical :: doesit |
1511 |
< |
doesit = FF_uses_EAM |
1511 |
> |
doesit = FF_uses_EAM .or. FF_uses_SC & |
1512 |
> |
.or. FF_uses_MEAM |
1513 |
|
end function FF_RequiresPrepairCalc |
1514 |
|
|
1495 |
– |
function FF_RequiresPostpairCalc() result(doesit) |
1496 |
– |
logical :: doesit |
1497 |
– |
if (electrostaticSummationMethod == REACTION_FIELD) doesit = .true. |
1498 |
– |
end function FF_RequiresPostpairCalc |
1499 |
– |
|
1515 |
|
#ifdef PROFILE |
1516 |
|
function getforcetime() result(totalforcetime) |
1517 |
|
real(kind=dp) :: totalforcetime |