45 |
|
|
46 |
|
!! @author Charles F. Vardeman II |
47 |
|
!! @author Matthew Meineke |
48 |
< |
!! @version $Id: doForces.F90,v 1.77 2006-04-16 02:51:16 chrisfen Exp $, $Date: 2006-04-16 02:51:16 $, $Name: not supported by cvs2svn $, $Revision: 1.77 $ |
48 |
> |
!! @version $Id: doForces.F90,v 1.83 2006-06-05 18:24:45 gezelter Exp $, $Date: 2006-06-05 18:24:45 $, $Name: not supported by cvs2svn $, $Revision: 1.83 $ |
49 |
|
|
50 |
|
|
51 |
|
module doForces |
64 |
|
use eam |
65 |
|
use suttonchen |
66 |
|
use status |
67 |
– |
use interpolation |
67 |
|
#ifdef IS_MPI |
68 |
|
use mpiSimulation |
69 |
|
#endif |
72 |
|
PRIVATE |
73 |
|
|
74 |
|
#define __FORTRAN90 |
76 |
– |
#include "UseTheForce/fSwitchingFunction.h" |
75 |
|
#include "UseTheForce/fCutoffPolicy.h" |
76 |
|
#include "UseTheForce/DarkSide/fInteractionMap.h" |
77 |
|
#include "UseTheForce/DarkSide/fElectrostaticSummationMethod.h" |
80 |
– |
|
78 |
|
|
79 |
|
INTEGER, PARAMETER:: PREPAIR_LOOP = 1 |
80 |
|
INTEGER, PARAMETER:: PAIR_LOOP = 2 |
147 |
|
end type gtypeCutoffs |
148 |
|
type(gtypeCutoffs), dimension(:,:), allocatable :: gtypeCutoffMap |
149 |
|
|
150 |
+ |
|
151 |
|
contains |
152 |
|
|
153 |
|
subroutine createInteractionHash() |
423 |
|
!! largest cutoff for any atypes present in this group. We also |
424 |
|
!! create gtypes at this point. |
425 |
|
|
426 |
< |
tol = 1.0d-6 |
426 |
> |
tol = 1.0e-6_dp |
427 |
|
nGroupTypesRow = 0 |
428 |
|
nGroupTypesCol = 0 |
429 |
|
do i = istart, iend |
579 |
|
defaultDoShift = .true. |
580 |
|
|
581 |
|
endif |
582 |
< |
|
582 |
> |
|
583 |
|
localError = 0 |
584 |
|
call setLJDefaultCutoff( defaultRcut, defaultDoShift ) |
585 |
|
call setElectrostaticCutoffRadius( defaultRcut, defaultRsw ) |
586 |
< |
call setCutoffEAM( defaultRcut, localError) |
587 |
< |
if (localError /= 0) then |
588 |
< |
write(errMsg, *) 'An error has occured in setting the EAM cutoff' |
591 |
< |
call handleError("setCutoffs", errMsg) |
592 |
< |
end if |
593 |
< |
call set_switch(GROUP_SWITCH, defaultRsw, defaultRcut) |
586 |
> |
call setCutoffEAM( defaultRcut ) |
587 |
> |
call setCutoffSC( defaultRcut ) |
588 |
> |
call set_switch(defaultRsw, defaultRcut) |
589 |
|
call setHmatDangerousRcutValue(defaultRcut) |
590 |
< |
|
590 |
> |
|
591 |
|
haveDefaultCutoffs = .true. |
592 |
|
haveGtypeCutoffMap = .false. |
593 |
+ |
|
594 |
|
end subroutine setCutoffs |
595 |
|
|
596 |
|
subroutine cWasLame() |
644 |
|
|
645 |
|
subroutine doReadyCheck(error) |
646 |
|
integer, intent(out) :: error |
651 |
– |
|
647 |
|
integer :: myStatus |
648 |
|
|
649 |
|
error = 0 |
656 |
|
call createGtypeCutoffMap() |
657 |
|
endif |
658 |
|
|
664 |
– |
|
659 |
|
if (VisitCutoffsAfterComputing) then |
660 |
< |
call set_switch(GROUP_SWITCH, largestRcut, largestRcut) |
660 |
> |
call set_switch(largestRcut, largestRcut) |
661 |
|
call setHmatDangerousRcutValue(largestRcut) |
662 |
+ |
call setCutoffEAM(largestRcut) |
663 |
+ |
call setCutoffSC(largestRcut) |
664 |
+ |
VisitCutoffsAfterComputing = .false. |
665 |
|
endif |
666 |
|
|
670 |
– |
|
667 |
|
if (.not. haveSIMvariables) then |
668 |
|
call setSimVariables() |
669 |
|
endif |
670 |
|
|
675 |
– |
! if (.not. haveRlist) then |
676 |
– |
! write(default_error, *) 'rList has not been set in doForces!' |
677 |
– |
! error = -1 |
678 |
– |
! return |
679 |
– |
! endif |
680 |
– |
|
671 |
|
if (.not. haveNeighborList) then |
672 |
|
write(default_error, *) 'neighbor list has not been initialized in doForces!' |
673 |
|
error = -1 |
674 |
|
return |
675 |
|
end if |
676 |
< |
|
676 |
> |
|
677 |
|
if (.not. haveSaneForceField) then |
678 |
|
write(default_error, *) 'Force Field is not sane in doForces!' |
679 |
|
error = -1 |
680 |
|
return |
681 |
|
end if |
682 |
< |
|
682 |
> |
|
683 |
|
#ifdef IS_MPI |
684 |
|
if (.not. isMPISimSet()) then |
685 |
|
write(default_error,*) "ERROR: mpiSimulation has not been initialized!" |
957 |
|
|
958 |
|
list(nlist) = j |
959 |
|
endif |
960 |
< |
|
971 |
< |
|
972 |
< |
|
960 |
> |
|
961 |
|
if (rgrpsq < gtypeCutoffMap(groupToGtypeRow(i),groupToGtypeCol(j))%rCutsq) then |
962 |
|
|
963 |
|
rCut = gtypeCutoffMap(groupToGtypeRow(i),groupToGtypeCol(j))%rCut |
964 |
|
if (loop .eq. PAIR_LOOP) then |
965 |
< |
vij = 0.0d0 |
966 |
< |
fij(1:3) = 0.0d0 |
965 |
> |
vij = 0.0_dp |
966 |
> |
fij(1) = 0.0_dp |
967 |
> |
fij(2) = 0.0_dp |
968 |
> |
fij(3) = 0.0_dp |
969 |
|
endif |
970 |
|
|
971 |
< |
call get_switch(rgrpsq, sw, dswdr, rgrp, & |
982 |
< |
group_switch, in_switching_region) |
971 |
> |
call get_switch(rgrpsq, sw, dswdr,rgrp, in_switching_region) |
972 |
|
|
973 |
|
n_in_j = groupStartCol(j+1) - groupStartCol(j) |
974 |
|
|
983 |
|
if (skipThisPair(atom1, atom2)) cycle inner |
984 |
|
|
985 |
|
if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then |
986 |
< |
d_atm(1:3) = d_grp(1:3) |
986 |
> |
d_atm(1) = d_grp(1) |
987 |
> |
d_atm(2) = d_grp(2) |
988 |
> |
d_atm(3) = d_grp(3) |
989 |
|
ratmsq = rgrpsq |
990 |
|
else |
991 |
|
#ifdef IS_MPI |
1018 |
|
d_grp, rgrp, rCut) |
1019 |
|
#endif |
1020 |
|
vij = vij + vpair |
1021 |
< |
fij(1:3) = fij(1:3) + fpair(1:3) |
1021 |
> |
fij(1) = fij(1) + fpair(1) |
1022 |
> |
fij(2) = fij(2) + fpair(2) |
1023 |
> |
fij(3) = fij(3) + fpair(3) |
1024 |
|
endif |
1025 |
|
enddo inner |
1026 |
|
enddo |
1181 |
|
|
1182 |
|
! prevent overcounting of the skips |
1183 |
|
if (i.lt.j) then |
1184 |
< |
call get_interatomic_vector(q(:,i), & |
1185 |
< |
q(:,j), d_atm, ratmsq) |
1186 |
< |
rVal = dsqrt(ratmsq) |
1194 |
< |
call get_switch(ratmsq, sw, dswdr, rVal, group_switch, & |
1195 |
< |
in_switching_region) |
1184 |
> |
call get_interatomic_vector(q(:,i), q(:,j), d_atm, ratmsq) |
1185 |
> |
rVal = sqrt(ratmsq) |
1186 |
> |
call get_switch(ratmsq, sw, dswdr, rVal,in_switching_region) |
1187 |
|
#ifdef IS_MPI |
1188 |
|
call rf_self_excludes(i, j, sw, eFrame, d_atm, rVal, & |
1189 |
|
vpair, pot_local(ELECTROSTATIC_POT), f, t, do_pot) |
1200 |
|
#ifdef IS_MPI |
1201 |
|
|
1202 |
|
if (do_pot) then |
1203 |
+ |
#ifdef SINGLE_PRECISION |
1204 |
+ |
call mpi_allreduce(pot_local, pot, LR_POT_TYPES,mpi_real,mpi_sum, & |
1205 |
+ |
mpi_comm_world,mpi_err) |
1206 |
+ |
#else |
1207 |
|
call mpi_allreduce(pot_local, pot, LR_POT_TYPES,mpi_double_precision,mpi_sum, & |
1208 |
|
mpi_comm_world,mpi_err) |
1209 |
+ |
#endif |
1210 |
|
endif |
1211 |
|
|
1212 |
|
if (do_stress) then |
1213 |
+ |
#ifdef SINGLE_PRECISION |
1214 |
+ |
call mpi_allreduce(tau_Temp, tau, 9,mpi_real,mpi_sum, & |
1215 |
+ |
mpi_comm_world,mpi_err) |
1216 |
+ |
call mpi_allreduce(virial_Temp, virial,1,mpi_real,mpi_sum, & |
1217 |
+ |
mpi_comm_world,mpi_err) |
1218 |
+ |
#else |
1219 |
|
call mpi_allreduce(tau_Temp, tau, 9,mpi_double_precision,mpi_sum, & |
1220 |
|
mpi_comm_world,mpi_err) |
1221 |
|
call mpi_allreduce(virial_Temp, virial,1,mpi_double_precision,mpi_sum, & |
1222 |
|
mpi_comm_world,mpi_err) |
1223 |
+ |
#endif |
1224 |
|
endif |
1225 |
|
|
1226 |
|
#else |
1254 |
|
real ( kind = dp ), intent(inout) :: d_grp(3) |
1255 |
|
real ( kind = dp ), intent(inout) :: rCut |
1256 |
|
real ( kind = dp ) :: r |
1257 |
+ |
real ( kind = dp ) :: a_k, b_k, c_k, d_k, dx |
1258 |
|
integer :: me_i, me_j |
1259 |
+ |
integer :: k |
1260 |
|
|
1261 |
|
integer :: iHash |
1262 |
|
|
1263 |
|
r = sqrt(rijsq) |
1264 |
< |
vpair = 0.0d0 |
1265 |
< |
fpair(1:3) = 0.0d0 |
1264 |
> |
|
1265 |
> |
vpair = 0.0_dp |
1266 |
> |
fpair(1:3) = 0.0_dp |
1267 |
|
|
1268 |
|
#ifdef IS_MPI |
1269 |
|
me_i = atid_row(i) |
1301 |
|
endif |
1302 |
|
|
1303 |
|
if ( iand(iHash, GAYBERNE_LJ).ne.0 ) then |
1304 |
< |
call do_gb_lj_pair(i, j, d, r, rijsq, rcut, sw, vpair, fpair, & |
1304 |
> |
call do_gb_pair(i, j, d, r, rijsq, sw, vpair, fpair, & |
1305 |
|
pot(VDW_POT), A, f, t, do_pot) |
1306 |
|
endif |
1307 |
|
|
1324 |
|
call do_SC_pair(i, j, d, r, rijsq, rcut, sw, vpair, fpair, & |
1325 |
|
pot(METALLIC_POT), f, do_pot) |
1326 |
|
endif |
1321 |
– |
|
1322 |
– |
|
1327 |
|
|
1328 |
|
end subroutine do_pair |
1329 |
|
|
1346 |
|
integer :: me_i, me_j, iHash |
1347 |
|
|
1348 |
|
r = sqrt(rijsq) |
1349 |
< |
|
1349 |
> |
|
1350 |
|
#ifdef IS_MPI |
1351 |
|
me_i = atid_row(i) |
1352 |
|
me_j = atid_col(j) |
1378 |
|
if (FF_uses_SC .and. SIM_uses_SC) then |
1379 |
|
call calc_SC_preforce_Frho(nlocal,pot(METALLIC_POT)) |
1380 |
|
endif |
1377 |
– |
|
1378 |
– |
|
1381 |
|
end subroutine do_preforce |
1382 |
|
|
1383 |
|
|
1389 |
|
real( kind = dp ) :: d(3), scaled(3) |
1390 |
|
integer i |
1391 |
|
|
1392 |
< |
d(1:3) = q_j(1:3) - q_i(1:3) |
1392 |
> |
d(1) = q_j(1) - q_i(1) |
1393 |
> |
d(2) = q_j(2) - q_i(2) |
1394 |
> |
d(3) = q_j(3) - q_i(3) |
1395 |
|
|
1396 |
|
! Wrap back into periodic box if necessary |
1397 |
|
if ( SIM_uses_PBC ) then |
1398 |
|
|
1399 |
|
if( .not.boxIsOrthorhombic ) then |
1400 |
|
! calc the scaled coordinates. |
1401 |
+ |
! scaled = matmul(HmatInv, d) |
1402 |
|
|
1403 |
< |
scaled = matmul(HmatInv, d) |
1404 |
< |
|
1403 |
> |
scaled(1) = HmatInv(1,1)*d(1) + HmatInv(1,2)*d(2) + HmatInv(1,3)*d(3) |
1404 |
> |
scaled(2) = HmatInv(2,1)*d(1) + HmatInv(2,2)*d(2) + HmatInv(2,3)*d(3) |
1405 |
> |
scaled(3) = HmatInv(3,1)*d(1) + HmatInv(3,2)*d(2) + HmatInv(3,3)*d(3) |
1406 |
> |
|
1407 |
|
! wrap the scaled coordinates |
1408 |
|
|
1409 |
< |
scaled = scaled - anint(scaled) |
1410 |
< |
|
1409 |
> |
scaled(1) = scaled(1) - anint(scaled(1), kind=dp) |
1410 |
> |
scaled(2) = scaled(2) - anint(scaled(2), kind=dp) |
1411 |
> |
scaled(3) = scaled(3) - anint(scaled(3), kind=dp) |
1412 |
|
|
1413 |
|
! calc the wrapped real coordinates from the wrapped scaled |
1414 |
|
! coordinates |
1415 |
+ |
! d = matmul(Hmat,scaled) |
1416 |
+ |
d(1)= Hmat(1,1)*scaled(1) + Hmat(1,2)*scaled(2) + Hmat(1,3)*scaled(3) |
1417 |
+ |
d(2)= Hmat(2,1)*scaled(1) + Hmat(2,2)*scaled(2) + Hmat(2,3)*scaled(3) |
1418 |
+ |
d(3)= Hmat(3,1)*scaled(1) + Hmat(3,2)*scaled(2) + Hmat(3,3)*scaled(3) |
1419 |
|
|
1408 |
– |
d = matmul(Hmat,scaled) |
1409 |
– |
|
1420 |
|
else |
1421 |
|
! calc the scaled coordinates. |
1422 |
|
|
1423 |
< |
do i = 1, 3 |
1424 |
< |
scaled(i) = d(i) * HmatInv(i,i) |
1423 |
> |
scaled(1) = d(1) * HmatInv(1,1) |
1424 |
> |
scaled(2) = d(2) * HmatInv(2,2) |
1425 |
> |
scaled(3) = d(3) * HmatInv(3,3) |
1426 |
> |
|
1427 |
> |
! wrap the scaled coordinates |
1428 |
> |
|
1429 |
> |
scaled(1) = scaled(1) - anint(scaled(1), kind=dp) |
1430 |
> |
scaled(2) = scaled(2) - anint(scaled(2), kind=dp) |
1431 |
> |
scaled(3) = scaled(3) - anint(scaled(3), kind=dp) |
1432 |
|
|
1433 |
< |
! wrap the scaled coordinates |
1433 |
> |
! calc the wrapped real coordinates from the wrapped scaled |
1434 |
> |
! coordinates |
1435 |
|
|
1436 |
< |
scaled(i) = scaled(i) - anint(scaled(i)) |
1436 |
> |
d(1) = scaled(1)*Hmat(1,1) |
1437 |
> |
d(2) = scaled(2)*Hmat(2,2) |
1438 |
> |
d(3) = scaled(3)*Hmat(3,3) |
1439 |
|
|
1420 |
– |
! calc the wrapped real coordinates from the wrapped scaled |
1421 |
– |
! coordinates |
1422 |
– |
|
1423 |
– |
d(i) = scaled(i)*Hmat(i,i) |
1424 |
– |
enddo |
1440 |
|
endif |
1441 |
|
|
1442 |
|
endif |
1443 |
|
|
1444 |
< |
r_sq = dot_product(d,d) |
1444 |
> |
r_sq = d(1)*d(1) + d(2)*d(2) + d(3)*d(3) |
1445 |
|
|
1446 |
|
end subroutine get_interatomic_vector |
1447 |
|
|