58 |
|
#define __FORTRAN90 |
59 |
|
#include "UseTheForce/DarkSide/fInteractionMap.h" |
60 |
|
#include "UseTheForce/DarkSide/fElectrostaticSummationMethod.h" |
61 |
+ |
#include "UseTheForce/DarkSide/fElectrostaticScreeningMethod.h" |
62 |
|
|
63 |
|
|
64 |
|
!! these prefactors convert the multipole interactions into kcal / mol |
75 |
|
!! This unit is also known affectionately as an esu centi-barn. |
76 |
|
real(kind=dp), parameter :: pre14 = 69.13373_dp |
77 |
|
|
78 |
< |
!! variables to handle different summation methods for long-range electrostatics: |
78 |
> |
!! variables to handle different summation methods for long-range |
79 |
> |
!! electrostatics: |
80 |
|
integer, save :: summationMethod = NONE |
81 |
+ |
integer, save :: screeningMethod = UNDAMPED |
82 |
|
logical, save :: summationMethodChecked = .false. |
83 |
|
real(kind=DP), save :: defaultCutoff = 0.0_DP |
84 |
|
real(kind=DP), save :: defaultCutoff2 = 0.0_DP |
85 |
|
logical, save :: haveDefaultCutoff = .false. |
86 |
|
real(kind=DP), save :: dampingAlpha = 0.0_DP |
87 |
+ |
real(kind=DP), save :: alpha2 = 0.0_DP |
88 |
|
logical, save :: haveDampingAlpha = .false. |
89 |
|
real(kind=DP), save :: dielectric = 1.0_DP |
90 |
|
logical, save :: haveDielectric = .false. |
87 |
– |
real(kind=DP), save :: constERFC = 0.0_DP |
91 |
|
real(kind=DP), save :: constEXP = 0.0_DP |
89 |
– |
logical, save :: haveDWAconstants = .false. |
92 |
|
real(kind=dp), save :: rcuti = 0.0_DP |
93 |
|
real(kind=dp), save :: rcuti2 = 0.0_DP |
94 |
|
real(kind=dp), save :: rcuti3 = 0.0_DP |
99 |
|
real(kind=dp), save :: rt = 1.0_DP |
100 |
|
real(kind=dp), save :: rrfsq = 1.0_DP |
101 |
|
real(kind=dp), save :: preRF = 0.0_DP |
102 |
< |
logical, save :: preRFCalculated = .false. |
103 |
< |
|
102 |
> |
real(kind=dp), save :: preRF2 = 0.0_DP |
103 |
> |
real(kind=dp), save :: f0 = 1.0_DP |
104 |
> |
real(kind=dp), save :: f1 = 1.0_DP |
105 |
> |
real(kind=dp), save :: f2 = 0.0_DP |
106 |
> |
real(kind=dp), save :: f0c = 1.0_DP |
107 |
> |
real(kind=dp), save :: f1c = 1.0_DP |
108 |
> |
real(kind=dp), save :: f2c = 0.0_DP |
109 |
> |
|
110 |
|
#ifdef __IFC |
111 |
|
! error function for ifc version > 7. |
112 |
|
double precision, external :: derfc |
113 |
|
#endif |
114 |
|
|
115 |
|
public :: setElectrostaticSummationMethod |
116 |
+ |
public :: setScreeningMethod |
117 |
|
public :: setElectrostaticCutoffRadius |
118 |
< |
public :: setDampedWolfAlpha |
118 |
> |
public :: setDampingAlpha |
119 |
|
public :: setReactionFieldDielectric |
111 |
– |
public :: setReactionFieldPrefactor |
120 |
|
public :: newElectrostaticType |
121 |
|
public :: setCharge |
122 |
|
public :: setDipoleMoment |
125 |
|
public :: doElectrostaticPair |
126 |
|
public :: getCharge |
127 |
|
public :: getDipoleMoment |
120 |
– |
public :: pre22 |
128 |
|
public :: destroyElectrostaticTypes |
129 |
< |
public :: accumulate_rf |
130 |
< |
public :: accumulate_self_rf |
124 |
< |
public :: reaction_field_final |
125 |
< |
public :: rf_correct_forces |
129 |
> |
public :: self_self |
130 |
> |
public :: rf_self_excludes |
131 |
|
|
132 |
|
type :: Electrostatic |
133 |
|
integer :: c_ident |
157 |
|
|
158 |
|
end subroutine setElectrostaticSummationMethod |
159 |
|
|
160 |
+ |
subroutine setScreeningMethod(the_SM) |
161 |
+ |
integer, intent(in) :: the_SM |
162 |
+ |
screeningMethod = the_SM |
163 |
+ |
end subroutine setScreeningMethod |
164 |
+ |
|
165 |
|
subroutine setElectrostaticCutoffRadius(thisRcut, thisRsw) |
166 |
|
real(kind=dp), intent(in) :: thisRcut |
167 |
|
real(kind=dp), intent(in) :: thisRsw |
171 |
|
haveDefaultCutoff = .true. |
172 |
|
end subroutine setElectrostaticCutoffRadius |
173 |
|
|
174 |
< |
subroutine setDampedWolfAlpha(thisAlpha) |
174 |
> |
subroutine setDampingAlpha(thisAlpha) |
175 |
|
real(kind=dp), intent(in) :: thisAlpha |
176 |
|
dampingAlpha = thisAlpha |
177 |
+ |
alpha2 = dampingAlpha*dampingAlpha |
178 |
|
haveDampingAlpha = .true. |
179 |
< |
end subroutine setDampedWolfAlpha |
179 |
> |
end subroutine setDampingAlpha |
180 |
|
|
181 |
|
subroutine setReactionFieldDielectric(thisDielectric) |
182 |
|
real(kind=dp), intent(in) :: thisDielectric |
183 |
|
dielectric = thisDielectric |
184 |
|
haveDielectric = .true. |
185 |
|
end subroutine setReactionFieldDielectric |
175 |
– |
|
176 |
– |
subroutine setReactionFieldPrefactor |
177 |
– |
if (haveDefaultCutoff .and. haveDielectric) then |
178 |
– |
defaultCutoff2 = defaultCutoff*defaultCutoff |
179 |
– |
preRF = pre22 * 2.0d0*(dielectric-1.0d0) / & |
180 |
– |
((2.0d0*dielectric+1.0d0)*defaultCutoff2*defaultCutoff) |
181 |
– |
preRFCalculated = .true. |
182 |
– |
else if (.not.haveDefaultCutoff) then |
183 |
– |
call handleError("setReactionFieldPrefactor", "Default cutoff not set") |
184 |
– |
else |
185 |
– |
call handleError("setReactionFieldPrefactor", "Dielectric not set") |
186 |
– |
endif |
187 |
– |
end subroutine setReactionFieldPrefactor |
186 |
|
|
187 |
|
subroutine newElectrostaticType(c_ident, is_Charge, is_Dipole, & |
188 |
|
is_SplitDipole, is_Quadrupole, is_Tap, status) |
405 |
|
rcuti3 = rcuti2*rcuti |
406 |
|
rcuti4 = rcuti2*rcuti2 |
407 |
|
|
408 |
< |
if (summationMethod .eq. DAMPED_WOLF) then |
409 |
< |
if (.not.haveDWAconstants) then |
410 |
< |
|
411 |
< |
if (.not.haveDampingAlpha) then |
412 |
< |
call handleError("checkSummationMethod", "no Damping Alpha set!") |
413 |
< |
endif |
414 |
< |
|
417 |
< |
if (.not.haveDefaultCutoff) then |
418 |
< |
call handleError("checkSummationMethod", "no Default Cutoff set!") |
419 |
< |
endif |
420 |
< |
|
421 |
< |
constEXP = exp(-dampingAlpha*dampingAlpha*defaultCutoff*defaultCutoff) |
422 |
< |
constERFC = derfc(dampingAlpha*defaultCutoff) |
423 |
< |
invRootPi = 0.56418958354775628695d0 |
424 |
< |
alphaPi = 2*dampingAlpha*invRootPi |
425 |
< |
|
426 |
< |
haveDWAconstants = .true. |
408 |
> |
if (screeningMethod .eq. DAMPED) then |
409 |
> |
if (.not.haveDampingAlpha) then |
410 |
> |
call handleError("checkSummationMethod", "no Damping Alpha set!") |
411 |
> |
endif |
412 |
> |
|
413 |
> |
if (.not.haveDefaultCutoff) then |
414 |
> |
call handleError("checkSummationMethod", "no Default Cutoff set!") |
415 |
|
endif |
416 |
+ |
|
417 |
+ |
constEXP = exp(-alpha2*defaultCutoff*defaultCutoff) |
418 |
+ |
invRootPi = 0.56418958354775628695d0 |
419 |
+ |
alphaPi = 2.0d0*dampingAlpha*invRootPi |
420 |
+ |
f0c = derfc(dampingAlpha*defaultCutoff) |
421 |
+ |
f1c = alphaPi*defaultCutoff*constEXP + f0c |
422 |
+ |
f2c = alphaPi*2.0d0*alpha2*constEXP*rcuti2 |
423 |
+ |
|
424 |
|
endif |
425 |
|
|
426 |
|
if (summationMethod .eq. REACTION_FIELD) then |
427 |
< |
if (.not.haveDielectric) then |
428 |
< |
call handleError("checkSummationMethod", "no reaction field Dielectric set!") |
427 |
> |
if (haveDielectric) then |
428 |
> |
defaultCutoff2 = defaultCutoff*defaultCutoff |
429 |
> |
preRF = (dielectric-1.0d0) / & |
430 |
> |
((2.0d0*dielectric+1.0d0)*defaultCutoff2*defaultCutoff) |
431 |
> |
preRF2 = 2.0d0*preRF |
432 |
> |
else |
433 |
> |
call handleError("checkSummationMethod", "Dielectric not set") |
434 |
|
endif |
435 |
+ |
|
436 |
|
endif |
437 |
|
|
438 |
|
summationMethodChecked = .true. |
439 |
|
end subroutine checkSummationMethod |
440 |
|
|
441 |
|
|
440 |
– |
|
442 |
|
subroutine doElectrostaticPair(atom1, atom2, d, rij, r2, sw, & |
443 |
|
vpair, fpair, pot, eFrame, f, t, do_pot) |
444 |
|
|
450 |
|
real(kind=dp), intent(in) :: rij, r2, sw |
451 |
|
real(kind=dp), intent(in), dimension(3) :: d |
452 |
|
real(kind=dp), intent(inout) :: vpair |
453 |
< |
real(kind=dp), intent(inout), dimension(3) :: fpair |
453 |
> |
real(kind=dp), intent(inout), dimension(3) :: fpair |
454 |
|
|
455 |
|
real( kind = dp ) :: pot |
456 |
|
real( kind = dp ), dimension(9,nLocal) :: eFrame |
457 |
|
real( kind = dp ), dimension(3,nLocal) :: f |
458 |
+ |
real( kind = dp ), dimension(3,nLocal) :: felec |
459 |
|
real( kind = dp ), dimension(3,nLocal) :: t |
460 |
|
|
461 |
|
real (kind = dp), dimension(3) :: ux_i, uy_i, uz_i |
473 |
|
real (kind=dp) :: cx_i, cy_i, cz_i |
474 |
|
real (kind=dp) :: cx_j, cy_j, cz_j |
475 |
|
real (kind=dp) :: cx2, cy2, cz2 |
476 |
< |
real (kind=dp) :: ct_i, ct_j, ct_ij, a1 |
476 |
> |
real (kind=dp) :: ct_i, ct_j, ct_ij, a0, a1 |
477 |
|
real (kind=dp) :: riji, ri, ri2, ri3, ri4 |
478 |
|
real (kind=dp) :: pref, vterm, epot, dudr, vterm1, vterm2 |
479 |
|
real (kind=dp) :: xhat, yhat, zhat |
480 |
|
real (kind=dp) :: dudx, dudy, dudz |
481 |
|
real (kind=dp) :: scale, sc2, bigR |
482 |
< |
real (kind=dp) :: varERFC, varEXP |
483 |
< |
real (kind=dp) :: limScale |
482 |
> |
real (kind=dp) :: varEXP |
483 |
> |
real (kind=dp) :: pot_term |
484 |
> |
real (kind=dp) :: preVal, rfVal |
485 |
|
|
486 |
|
if (.not.allocated(ElectrostaticMap)) then |
487 |
|
call handleError("electrostatic", "no ElectrostaticMap was present before first call of do_electrostatic_pair!") |
490 |
|
|
491 |
|
if (.not.summationMethodChecked) then |
492 |
|
call checkSummationMethod() |
490 |
– |
|
493 |
|
endif |
494 |
|
|
493 |
– |
|
495 |
|
#ifdef IS_MPI |
496 |
|
me1 = atid_Row(atom1) |
497 |
|
me2 = atid_Col(atom2) |
500 |
|
me2 = atid(atom2) |
501 |
|
#endif |
502 |
|
|
503 |
+ |
!!$ if (rij .ge. defaultCutoff) then |
504 |
+ |
!!$ write(*,*) 'warning: rij = ', rij, ' rcut = ', defaultCutoff, ' sw = ', sw |
505 |
+ |
!!$ endif |
506 |
+ |
|
507 |
|
!! some variables we'll need independent of electrostatic type: |
508 |
|
|
509 |
|
riji = 1.0d0 / rij |
646 |
|
if (i_is_Charge) then |
647 |
|
|
648 |
|
if (j_is_Charge) then |
649 |
+ |
if (screeningMethod .eq. DAMPED) then |
650 |
+ |
f0 = derfc(dampingAlpha*rij) |
651 |
+ |
varEXP = exp(-alpha2*rij*rij) |
652 |
+ |
f1 = alphaPi*rij*varEXP + f0 |
653 |
+ |
endif |
654 |
|
|
655 |
< |
if (summationMethod .eq. UNDAMPED_WOLF) then |
655 |
> |
preVal = pre11 * q_i * q_j |
656 |
|
|
657 |
< |
vterm = pre11 * q_i * q_j * (riji - rcuti) |
658 |
< |
vpair = vpair + vterm |
649 |
< |
epot = epot + sw*vterm |
657 |
> |
if (summationMethod .eq. SHIFTED_POTENTIAL) then |
658 |
> |
vterm = preVal * (riji*f0 - rcuti*f0c) |
659 |
|
|
660 |
< |
dudr = -sw*pre11*q_i*q_j * (riji*riji-rcuti2)*riji |
661 |
< |
|
662 |
< |
dudx = dudx + dudr * d(1) |
663 |
< |
dudy = dudy + dudr * d(2) |
664 |
< |
dudz = dudz + dudr * d(3) |
656 |
< |
|
657 |
< |
elseif (summationMethod .eq. DAMPED_WOLF) then |
658 |
< |
|
659 |
< |
varERFC = derfc(dampingAlpha*rij) |
660 |
< |
varEXP = exp(-dampingAlpha*dampingAlpha*rij*rij) |
661 |
< |
vterm = pre11 * q_i * q_j * (varERFC*riji - constERFC*rcuti) |
662 |
< |
vpair = vpair + vterm |
663 |
< |
epot = epot + sw*vterm |
660 |
> |
dudr = -sw * preVal * riji * riji * f1 |
661 |
> |
|
662 |
> |
elseif (summationMethod .eq. SHIFTED_FORCE) then |
663 |
> |
vterm = preVal * ( riji*f0 - rcuti*f0c + & |
664 |
> |
f1c*rcuti2*(rij-defaultCutoff) ) |
665 |
|
|
666 |
< |
dudr = -sw*pre11*q_i*q_j * ( riji*((varERFC*riji*riji & |
667 |
< |
+ alphaPi*varEXP) & |
668 |
< |
- (constERFC*rcuti2 & |
669 |
< |
+ alphaPi*constEXP)) ) |
666 |
> |
dudr = -sw*preVal * (riji*riji*f1 - rcuti2*f1c) |
667 |
> |
|
668 |
> |
elseif (summationMethod .eq. REACTION_FIELD) then |
669 |
> |
rfVal = preRF*rij*rij |
670 |
> |
vterm = preVal * ( riji + rfVal ) |
671 |
|
|
672 |
< |
dudx = dudx + dudr * d(1) |
673 |
< |
dudy = dudy + dudr * d(2) |
672 |
< |
dudz = dudz + dudr * d(3) |
673 |
< |
|
672 |
> |
dudr = sw * preVal * ( 2.0d0*rfVal - riji )*riji |
673 |
> |
|
674 |
|
else |
675 |
< |
|
676 |
< |
vterm = pre11 * q_i * q_j * riji |
677 |
< |
vpair = vpair + vterm |
678 |
< |
epot = epot + sw*vterm |
675 |
> |
vterm = preVal * riji*f0 |
676 |
|
|
677 |
< |
dudr = - sw * vterm * riji |
678 |
< |
|
682 |
< |
dudx = dudx + dudr * xhat |
683 |
< |
dudy = dudy + dudr * yhat |
684 |
< |
dudz = dudz + dudr * zhat |
685 |
< |
|
677 |
> |
dudr = - sw * preVal * riji*riji*f1 |
678 |
> |
|
679 |
|
endif |
680 |
|
|
681 |
+ |
vpair = vpair + vterm |
682 |
+ |
epot = epot + sw*vterm |
683 |
+ |
|
684 |
+ |
dudx = dudx + dudr * xhat |
685 |
+ |
dudy = dudy + dudr * yhat |
686 |
+ |
dudz = dudz + dudr * zhat |
687 |
+ |
|
688 |
|
endif |
689 |
|
|
690 |
|
if (j_is_Dipole) then |
691 |
|
|
692 |
|
pref = pre12 * q_i * mu_j |
693 |
|
|
694 |
< |
if (summationMethod .eq. UNDAMPED_WOLF) then |
694 |
> |
if (summationMethod .eq. REACTION_FIELD) then |
695 |
|
ri2 = riji * riji |
696 |
|
ri3 = ri2 * riji |
697 |
< |
|
698 |
< |
pref = pre12 * q_i * mu_j |
699 |
< |
vterm = - pref * ct_j * (ri2 - rcuti2) |
697 |
> |
|
698 |
> |
vterm = - pref * ct_j * ( ri2 - preRF2*rij ) |
699 |
|
vpair = vpair + vterm |
700 |
|
epot = epot + sw*vterm |
701 |
|
|
703 |
|
!! r_j - r_i and the charge-dipole potential takes the origin |
704 |
|
!! as the point dipole, which is atom j in this case. |
705 |
|
|
706 |
< |
dudx = dudx - sw*pref * ( ri3*( uz_j(1) - 3.0d0*ct_j*xhat) & |
707 |
< |
- rcuti3*( uz_j(1) - 3.0d0*ct_j*d(1)*rcuti ) ) |
708 |
< |
dudy = dudy - sw*pref * ( ri3*( uz_j(2) - 3.0d0*ct_j*yhat) & |
709 |
< |
- rcuti3*( uz_j(2) - 3.0d0*ct_j*d(2)*rcuti ) ) |
710 |
< |
dudz = dudz - sw*pref * ( ri3*( uz_j(3) - 3.0d0*ct_j*zhat) & |
711 |
< |
- rcuti3*( uz_j(3) - 3.0d0*ct_j*d(3)*rcuti ) ) |
712 |
< |
|
713 |
< |
duduz_j(1) = duduz_j(1) - sw*pref*( ri2*xhat - d(1)*rcuti3 ) |
714 |
< |
duduz_j(2) = duduz_j(2) - sw*pref*( ri2*yhat - d(2)*rcuti3 ) |
716 |
< |
duduz_j(3) = duduz_j(3) - sw*pref*( ri2*zhat - d(3)*rcuti3 ) |
706 |
> |
dudx = dudx - sw*pref*( ri3*(uz_j(1) - 3.0d0*ct_j*xhat) - & |
707 |
> |
preRF2*uz_j(1) ) |
708 |
> |
dudy = dudy - sw*pref*( ri3*(uz_j(2) - 3.0d0*ct_j*yhat) - & |
709 |
> |
preRF2*uz_j(2) ) |
710 |
> |
dudz = dudz - sw*pref*( ri3*(uz_j(3) - 3.0d0*ct_j*zhat) - & |
711 |
> |
preRF2*uz_j(3) ) |
712 |
> |
duduz_j(1) = duduz_j(1) - sw*pref * xhat * ( ri2 - preRF2*rij ) |
713 |
> |
duduz_j(2) = duduz_j(2) - sw*pref * yhat * ( ri2 - preRF2*rij ) |
714 |
> |
duduz_j(3) = duduz_j(3) - sw*pref * zhat * ( ri2 - preRF2*rij ) |
715 |
|
|
716 |
|
else |
717 |
|
if (j_is_SplitDipole) then |
727 |
|
ri3 = ri2 * ri |
728 |
|
sc2 = scale * scale |
729 |
|
|
732 |
– |
pref = pre12 * q_i * mu_j |
730 |
|
vterm = - pref * ct_j * ri2 * scale |
731 |
|
vpair = vpair + vterm |
732 |
|
epot = epot + sw*vterm |
754 |
|
cy2 = cy_j * cy_j |
755 |
|
cz2 = cz_j * cz_j |
756 |
|
|
757 |
< |
if (summationMethod .eq. UNDAMPED_WOLF) then |
758 |
< |
pref = pre14 * q_i / 3.0_dp |
759 |
< |
vterm1 = pref * ri3*( qxx_j * (3.0_dp*cx2 - 1.0_dp) + & |
760 |
< |
qyy_j * (3.0_dp*cy2 - 1.0_dp) + & |
761 |
< |
qzz_j * (3.0_dp*cz2 - 1.0_dp) ) |
762 |
< |
vterm2 = pref * rcuti3*( qxx_j * (3.0_dp*cx2 - 1.0_dp) + & |
766 |
< |
qyy_j * (3.0_dp*cy2 - 1.0_dp) + & |
767 |
< |
qzz_j * (3.0_dp*cz2 - 1.0_dp) ) |
768 |
< |
vpair = vpair + ( vterm1 - vterm2 ) |
769 |
< |
epot = epot + sw*( vterm1 - vterm2 ) |
770 |
< |
|
771 |
< |
dudx = dudx - (5.0_dp * & |
772 |
< |
(vterm1*riji*xhat - vterm2*rcuti2*d(1))) + sw*pref * ( & |
773 |
< |
(ri4 - rcuti4)*(qxx_j*(6.0_dp*cx_j*ux_j(1)) - & |
774 |
< |
qxx_j*2.0_dp*(xhat - rcuti*d(1))) + & |
775 |
< |
(ri4 - rcuti4)*(qyy_j*(6.0_dp*cy_j*uy_j(1)) - & |
776 |
< |
qyy_j*2.0_dp*(xhat - rcuti*d(1))) + & |
777 |
< |
(ri4 - rcuti4)*(qzz_j*(6.0_dp*cz_j*uz_j(1)) - & |
778 |
< |
qzz_j*2.0_dp*(xhat - rcuti*d(1))) ) |
779 |
< |
dudy = dudy - (5.0_dp * & |
780 |
< |
(vterm1*riji*yhat - vterm2*rcuti2*d(2))) + sw*pref * ( & |
781 |
< |
(ri4 - rcuti4)*(qxx_j*(6.0_dp*cx_j*ux_j(2)) - & |
782 |
< |
qxx_j*2.0_dp*(yhat - rcuti*d(2))) + & |
783 |
< |
(ri4 - rcuti4)*(qyy_j*(6.0_dp*cy_j*uy_j(2)) - & |
784 |
< |
qyy_j*2.0_dp*(yhat - rcuti*d(2))) + & |
785 |
< |
(ri4 - rcuti4)*(qzz_j*(6.0_dp*cz_j*uz_j(2)) - & |
786 |
< |
qzz_j*2.0_dp*(yhat - rcuti*d(2))) ) |
787 |
< |
dudz = dudz - (5.0_dp * & |
788 |
< |
(vterm1*riji*zhat - vterm2*rcuti2*d(3))) + sw*pref * ( & |
789 |
< |
(ri4 - rcuti4)*(qxx_j*(6.0_dp*cx_j*ux_j(3)) - & |
790 |
< |
qxx_j*2.0_dp*(zhat - rcuti*d(3))) + & |
791 |
< |
(ri4 - rcuti4)*(qyy_j*(6.0_dp*cy_j*uy_j(3)) - & |
792 |
< |
qyy_j*2.0_dp*(zhat - rcuti*d(3))) + & |
793 |
< |
(ri4 - rcuti4)*(qzz_j*(6.0_dp*cz_j*uz_j(3)) - & |
794 |
< |
qzz_j*2.0_dp*(zhat - rcuti*d(3))) ) |
795 |
< |
|
796 |
< |
dudux_j(1) = dudux_j(1) + sw*pref*(ri3*(qxx_j*6.0_dp*cx_j*xhat) -& |
797 |
< |
rcuti4*(qxx_j*6.0_dp*cx_j*d(1))) |
798 |
< |
dudux_j(2) = dudux_j(2) + sw*pref*(ri3*(qxx_j*6.0_dp*cx_j*yhat) -& |
799 |
< |
rcuti4*(qxx_j*6.0_dp*cx_j*d(2))) |
800 |
< |
dudux_j(3) = dudux_j(3) + sw*pref*(ri3*(qxx_j*6.0_dp*cx_j*zhat) -& |
801 |
< |
rcuti4*(qxx_j*6.0_dp*cx_j*d(3))) |
802 |
< |
|
803 |
< |
duduy_j(1) = duduy_j(1) + sw*pref*(ri3*(qyy_j*6.0_dp*cy_j*xhat) -& |
804 |
< |
rcuti4*(qyy_j*6.0_dp*cx_j*d(1))) |
805 |
< |
duduy_j(2) = duduy_j(2) + sw*pref*(ri3*(qyy_j*6.0_dp*cy_j*yhat) -& |
806 |
< |
rcuti4*(qyy_j*6.0_dp*cx_j*d(2))) |
807 |
< |
duduy_j(3) = duduy_j(3) + sw*pref*(ri3*(qyy_j*6.0_dp*cy_j*zhat) -& |
808 |
< |
rcuti4*(qyy_j*6.0_dp*cx_j*d(3))) |
809 |
< |
|
810 |
< |
duduz_j(1) = duduz_j(1) + sw*pref*(ri3*(qzz_j*6.0_dp*cz_j*xhat) -& |
811 |
< |
rcuti4*(qzz_j*6.0_dp*cx_j*d(1))) |
812 |
< |
duduz_j(2) = duduz_j(2) + sw*pref*(ri3*(qzz_j*6.0_dp*cz_j*yhat) -& |
813 |
< |
rcuti4*(qzz_j*6.0_dp*cx_j*d(2))) |
814 |
< |
duduz_j(3) = duduz_j(3) + sw*pref*(ri3*(qzz_j*6.0_dp*cz_j*zhat) -& |
815 |
< |
rcuti4*(qzz_j*6.0_dp*cx_j*d(3))) |
816 |
< |
|
817 |
< |
else |
818 |
< |
pref = pre14 * q_i / 3.0_dp |
819 |
< |
vterm = pref * ri3 * (qxx_j * (3.0_dp*cx2 - 1.0_dp) + & |
820 |
< |
qyy_j * (3.0_dp*cy2 - 1.0_dp) + & |
821 |
< |
qzz_j * (3.0_dp*cz2 - 1.0_dp)) |
822 |
< |
vpair = vpair + vterm |
823 |
< |
epot = epot + sw*vterm |
824 |
< |
|
825 |
< |
dudx = dudx - 5.0_dp*sw*vterm*riji*xhat + sw*pref * ri4 * ( & |
826 |
< |
qxx_j*(6.0_dp*cx_j*ux_j(1) - 2.0_dp*xhat) + & |
827 |
< |
qyy_j*(6.0_dp*cy_j*uy_j(1) - 2.0_dp*xhat) + & |
828 |
< |
qzz_j*(6.0_dp*cz_j*uz_j(1) - 2.0_dp*xhat) ) |
829 |
< |
dudy = dudy - 5.0_dp*sw*vterm*riji*yhat + sw*pref * ri4 * ( & |
830 |
< |
qxx_j*(6.0_dp*cx_j*ux_j(2) - 2.0_dp*yhat) + & |
831 |
< |
qyy_j*(6.0_dp*cy_j*uy_j(2) - 2.0_dp*yhat) + & |
832 |
< |
qzz_j*(6.0_dp*cz_j*uz_j(2) - 2.0_dp*yhat) ) |
833 |
< |
dudz = dudz - 5.0_dp*sw*vterm*riji*zhat + sw*pref * ri4 * ( & |
834 |
< |
qxx_j*(6.0_dp*cx_j*ux_j(3) - 2.0_dp*zhat) + & |
835 |
< |
qyy_j*(6.0_dp*cy_j*uy_j(3) - 2.0_dp*zhat) + & |
836 |
< |
qzz_j*(6.0_dp*cz_j*uz_j(3) - 2.0_dp*zhat) ) |
837 |
< |
|
838 |
< |
dudux_j(1) = dudux_j(1) + sw*pref * ri3*(qxx_j*6.0_dp*cx_j*xhat) |
839 |
< |
dudux_j(2) = dudux_j(2) + sw*pref * ri3*(qxx_j*6.0_dp*cx_j*yhat) |
840 |
< |
dudux_j(3) = dudux_j(3) + sw*pref * ri3*(qxx_j*6.0_dp*cx_j*zhat) |
841 |
< |
|
842 |
< |
duduy_j(1) = duduy_j(1) + sw*pref * ri3*(qyy_j*6.0_dp*cy_j*xhat) |
843 |
< |
duduy_j(2) = duduy_j(2) + sw*pref * ri3*(qyy_j*6.0_dp*cy_j*yhat) |
844 |
< |
duduy_j(3) = duduy_j(3) + sw*pref * ri3*(qyy_j*6.0_dp*cy_j*zhat) |
845 |
< |
|
846 |
< |
duduz_j(1) = duduz_j(1) + sw*pref * ri3*(qzz_j*6.0_dp*cz_j*xhat) |
847 |
< |
duduz_j(2) = duduz_j(2) + sw*pref * ri3*(qzz_j*6.0_dp*cz_j*yhat) |
848 |
< |
duduz_j(3) = duduz_j(3) + sw*pref * ri3*(qzz_j*6.0_dp*cz_j*zhat) |
757 |
> |
pref = pre14 * q_i / 3.0_dp |
758 |
> |
vterm = pref * ri3 * (qxx_j * (3.0_dp*cx2 - 1.0_dp) + & |
759 |
> |
qyy_j * (3.0_dp*cy2 - 1.0_dp) + & |
760 |
> |
qzz_j * (3.0_dp*cz2 - 1.0_dp)) |
761 |
> |
vpair = vpair + vterm |
762 |
> |
epot = epot + sw*vterm |
763 |
|
|
764 |
< |
endif |
764 |
> |
dudx = dudx - 5.0_dp*sw*vterm*riji*xhat + sw*pref * ri4 * ( & |
765 |
> |
qxx_j*(6.0_dp*cx_j*ux_j(1) - 2.0_dp*xhat) + & |
766 |
> |
qyy_j*(6.0_dp*cy_j*uy_j(1) - 2.0_dp*xhat) + & |
767 |
> |
qzz_j*(6.0_dp*cz_j*uz_j(1) - 2.0_dp*xhat) ) |
768 |
> |
dudy = dudy - 5.0_dp*sw*vterm*riji*yhat + sw*pref * ri4 * ( & |
769 |
> |
qxx_j*(6.0_dp*cx_j*ux_j(2) - 2.0_dp*yhat) + & |
770 |
> |
qyy_j*(6.0_dp*cy_j*uy_j(2) - 2.0_dp*yhat) + & |
771 |
> |
qzz_j*(6.0_dp*cz_j*uz_j(2) - 2.0_dp*yhat) ) |
772 |
> |
dudz = dudz - 5.0_dp*sw*vterm*riji*zhat + sw*pref * ri4 * ( & |
773 |
> |
qxx_j*(6.0_dp*cx_j*ux_j(3) - 2.0_dp*zhat) + & |
774 |
> |
qyy_j*(6.0_dp*cy_j*uy_j(3) - 2.0_dp*zhat) + & |
775 |
> |
qzz_j*(6.0_dp*cz_j*uz_j(3) - 2.0_dp*zhat) ) |
776 |
> |
|
777 |
> |
dudux_j(1) = dudux_j(1) + sw*pref * ri3*(qxx_j*6.0_dp*cx_j*xhat) |
778 |
> |
dudux_j(2) = dudux_j(2) + sw*pref * ri3*(qxx_j*6.0_dp*cx_j*yhat) |
779 |
> |
dudux_j(3) = dudux_j(3) + sw*pref * ri3*(qxx_j*6.0_dp*cx_j*zhat) |
780 |
> |
|
781 |
> |
duduy_j(1) = duduy_j(1) + sw*pref * ri3*(qyy_j*6.0_dp*cy_j*xhat) |
782 |
> |
duduy_j(2) = duduy_j(2) + sw*pref * ri3*(qyy_j*6.0_dp*cy_j*yhat) |
783 |
> |
duduy_j(3) = duduy_j(3) + sw*pref * ri3*(qyy_j*6.0_dp*cy_j*zhat) |
784 |
> |
|
785 |
> |
duduz_j(1) = duduz_j(1) + sw*pref * ri3*(qzz_j*6.0_dp*cz_j*xhat) |
786 |
> |
duduz_j(2) = duduz_j(2) + sw*pref * ri3*(qzz_j*6.0_dp*cz_j*yhat) |
787 |
> |
duduz_j(3) = duduz_j(3) + sw*pref * ri3*(qzz_j*6.0_dp*cz_j*zhat) |
788 |
> |
|
789 |
|
endif |
790 |
|
endif |
791 |
< |
|
791 |
> |
|
792 |
|
if (i_is_Dipole) then |
793 |
|
|
794 |
|
if (j_is_Charge) then |
795 |
|
|
796 |
|
pref = pre12 * q_j * mu_i |
797 |
|
|
798 |
< |
if (summationMethod .eq. UNDAMPED_WOLF) then |
798 |
> |
if (summationMethod .eq. SHIFTED_POTENTIAL) then |
799 |
|
ri2 = riji * riji |
800 |
|
ri3 = ri2 * riji |
801 |
+ |
|
802 |
+ |
pot_term = ri2 - rcuti2 |
803 |
+ |
vterm = pref * ct_i * pot_term |
804 |
+ |
vpair = vpair + vterm |
805 |
+ |
epot = epot + sw*vterm |
806 |
+ |
|
807 |
+ |
dudx = dudx + sw*pref * ( ri3*(uz_i(1)-3.0d0*ct_i*xhat) ) |
808 |
+ |
dudy = dudy + sw*pref * ( ri3*(uz_i(2)-3.0d0*ct_i*yhat) ) |
809 |
+ |
dudz = dudz + sw*pref * ( ri3*(uz_i(3)-3.0d0*ct_i*zhat) ) |
810 |
+ |
|
811 |
+ |
duduz_i(1) = duduz_i(1) + sw*pref * xhat * pot_term |
812 |
+ |
duduz_i(2) = duduz_i(2) + sw*pref * yhat * pot_term |
813 |
+ |
duduz_i(3) = duduz_i(3) + sw*pref * zhat * pot_term |
814 |
|
|
815 |
< |
pref = pre12 * q_j * mu_i |
816 |
< |
vterm = pref * ct_i * (ri2 - rcuti2) |
815 |
> |
elseif (summationMethod .eq. SHIFTED_FORCE) then |
816 |
> |
ri2 = riji * riji |
817 |
> |
ri3 = ri2 * riji |
818 |
> |
|
819 |
> |
pot_term = ri2 - rcuti2 + 2.0d0*rcuti3*( rij - defaultCutoff ) |
820 |
> |
vterm = pref * ct_i * pot_term |
821 |
|
vpair = vpair + vterm |
822 |
|
epot = epot + sw*vterm |
823 |
|
|
824 |
< |
!! this has a + sign in the () because the rij vector is |
825 |
< |
!! r_j - r_i and the charge-dipole potential takes the origin |
826 |
< |
!! as the point dipole, which is atom j in this case. |
824 |
> |
dudx = dudx + sw*pref * ( (ri3-rcuti3)*(uz_i(1)-3.0d0*ct_i*xhat) ) |
825 |
> |
dudy = dudy + sw*pref * ( (ri3-rcuti3)*(uz_i(2)-3.0d0*ct_i*yhat) ) |
826 |
> |
dudz = dudz + sw*pref * ( (ri3-rcuti3)*(uz_i(3)-3.0d0*ct_i*zhat) ) |
827 |
|
|
828 |
< |
dudx = dudx + sw*pref * ( ri3*( uz_i(1) - 3.0d0*ct_i*xhat) & |
829 |
< |
- rcuti3*( uz_i(1) - 3.0d0*ct_i*d(1)*rcuti ) ) |
830 |
< |
dudy = dudy + sw*pref * ( ri3*( uz_i(2) - 3.0d0*ct_i*yhat) & |
831 |
< |
- rcuti3*( uz_i(2) - 3.0d0*ct_i*d(2)*rcuti ) ) |
832 |
< |
dudz = dudz + sw*pref * ( ri3*( uz_i(3) - 3.0d0*ct_i*zhat) & |
833 |
< |
- rcuti3*( uz_i(3) - 3.0d0*ct_i*d(3)*rcuti ) ) |
828 |
> |
duduz_i(1) = duduz_i(1) + sw*pref * xhat * pot_term |
829 |
> |
duduz_i(2) = duduz_i(2) + sw*pref * yhat * pot_term |
830 |
> |
duduz_i(3) = duduz_i(3) + sw*pref * zhat * pot_term |
831 |
> |
|
832 |
> |
elseif (summationMethod .eq. REACTION_FIELD) then |
833 |
> |
ri2 = riji * riji |
834 |
> |
ri3 = ri2 * riji |
835 |
> |
|
836 |
> |
vterm = pref * ct_i * ( ri2 - preRF2*rij ) |
837 |
> |
vpair = vpair + vterm |
838 |
> |
epot = epot + sw*vterm |
839 |
|
|
840 |
< |
duduz_i(1) = duduz_i(1) - sw*pref*( ri2*xhat - d(1)*rcuti3 ) |
841 |
< |
duduz_i(2) = duduz_i(2) - sw*pref*( ri2*yhat - d(2)*rcuti3 ) |
842 |
< |
duduz_i(3) = duduz_i(3) - sw*pref*( ri2*zhat - d(3)*rcuti3 ) |
840 |
> |
dudx = dudx + sw*pref * ( ri3*(uz_i(1) - 3.0d0*ct_i*xhat) - & |
841 |
> |
preRF2*uz_i(1) ) |
842 |
> |
dudy = dudy + sw*pref * ( ri3*(uz_i(2) - 3.0d0*ct_i*yhat) - & |
843 |
> |
preRF2*uz_i(2) ) |
844 |
> |
dudz = dudz + sw*pref * ( ri3*(uz_i(3) - 3.0d0*ct_i*zhat) - & |
845 |
> |
preRF2*uz_i(3) ) |
846 |
> |
|
847 |
> |
duduz_i(1) = duduz_i(1) + sw*pref * xhat * ( ri2 - preRF2*rij ) |
848 |
> |
duduz_i(2) = duduz_i(2) + sw*pref * yhat * ( ri2 - preRF2*rij ) |
849 |
> |
duduz_i(3) = duduz_i(3) + sw*pref * zhat * ( ri2 - preRF2*rij ) |
850 |
|
|
851 |
|
else |
852 |
|
if (i_is_SplitDipole) then |
862 |
|
ri3 = ri2 * ri |
863 |
|
sc2 = scale * scale |
864 |
|
|
898 |
– |
pref = pre12 * q_j * mu_i |
865 |
|
vterm = pref * ct_i * ri2 * scale |
866 |
|
vpair = vpair + vterm |
867 |
|
epot = epot + sw*vterm |
877 |
|
endif |
878 |
|
|
879 |
|
if (j_is_Dipole) then |
880 |
+ |
ct_ij = uz_i(1)*uz_j(1) + uz_i(2)*uz_j(2) + uz_i(3)*uz_j(3) |
881 |
+ |
|
882 |
+ |
ri2 = riji * riji |
883 |
+ |
ri3 = ri2 * riji |
884 |
+ |
ri4 = ri2 * ri2 |
885 |
+ |
|
886 |
+ |
pref = pre22 * mu_i * mu_j |
887 |
|
|
888 |
< |
if (summationMethod .eq. UNDAMPED_WOLF) then |
889 |
< |
ri2 = riji * riji |
890 |
< |
ri3 = ri2 * riji |
918 |
< |
ri4 = ri2 * ri2 |
919 |
< |
|
920 |
< |
pref = pre22 * mu_i * mu_j |
921 |
< |
vterm = pref * (ri3 - rcuti3) * (ct_ij - 3.0d0 * ct_i * ct_j) |
888 |
> |
if (summationMethod .eq. REACTION_FIELD) then |
889 |
> |
vterm = pref*( ri3*(ct_ij - 3.0d0 * ct_i * ct_j) - & |
890 |
> |
preRF2*ct_ij ) |
891 |
|
vpair = vpair + vterm |
892 |
|
epot = epot + sw*vterm |
893 |
|
|
894 |
|
a1 = 5.0d0 * ct_i * ct_j - ct_ij |
895 |
|
|
896 |
|
dudx = dudx + sw*pref*3.0d0*ri4 & |
897 |
< |
* (a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1)) & |
929 |
< |
- sw*pref*3.0d0*rcuti4 & |
930 |
< |
* (a1*rcuti*d(1)-ct_i*uz_j(1)-ct_j*uz_i(1)) |
897 |
> |
* (a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1)) |
898 |
|
dudy = dudy + sw*pref*3.0d0*ri4 & |
899 |
< |
* (a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2)) & |
933 |
< |
- sw*pref*3.0d0*rcuti4 & |
934 |
< |
* (a1*rcuti*d(2)-ct_i*uz_j(2)-ct_j*uz_i(2)) |
899 |
> |
* (a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2)) |
900 |
|
dudz = dudz + sw*pref*3.0d0*ri4 & |
901 |
< |
* (a1*zhat-ct_i*uz_j(3)-ct_j*uz_i(3)) & |
937 |
< |
- sw*pref*3.0d0*rcuti4 & |
938 |
< |
* (a1*rcuti*d(3)-ct_i*uz_j(3)-ct_j*uz_i(3)) |
901 |
> |
* (a1*zhat-ct_i*uz_j(3)-ct_j*uz_i(3)) |
902 |
|
|
903 |
|
duduz_i(1) = duduz_i(1) + sw*pref*(ri3*(uz_j(1)-3.0d0*ct_j*xhat) & |
904 |
< |
- rcuti3*(uz_j(1) - 3.0d0*ct_j*d(1)*rcuti)) |
904 |
> |
- preRF2*uz_j(1)) |
905 |
|
duduz_i(2) = duduz_i(2) + sw*pref*(ri3*(uz_j(2)-3.0d0*ct_j*yhat) & |
906 |
< |
- rcuti3*(uz_j(2) - 3.0d0*ct_j*d(2)*rcuti)) |
906 |
> |
- preRF2*uz_j(2)) |
907 |
|
duduz_i(3) = duduz_i(3) + sw*pref*(ri3*(uz_j(3)-3.0d0*ct_j*zhat) & |
908 |
< |
- rcuti3*(uz_j(3) - 3.0d0*ct_j*d(3)*rcuti)) |
908 |
> |
- preRF2*uz_j(3)) |
909 |
|
duduz_j(1) = duduz_j(1) + sw*pref*(ri3*(uz_i(1)-3.0d0*ct_i*xhat) & |
910 |
< |
- rcuti3*(uz_i(1) - 3.0d0*ct_i*d(1)*rcuti)) |
910 |
> |
- preRF2*uz_i(1)) |
911 |
|
duduz_j(2) = duduz_j(2) + sw*pref*(ri3*(uz_i(2)-3.0d0*ct_i*yhat) & |
912 |
< |
- rcuti3*(uz_i(2) - 3.0d0*ct_i*d(2)*rcuti)) |
912 |
> |
- preRF2*uz_i(2)) |
913 |
|
duduz_j(3) = duduz_j(3) + sw*pref*(ri3*(uz_i(3)-3.0d0*ct_i*zhat) & |
914 |
< |
- rcuti3*(uz_i(3) - 3.0d0*ct_i*d(3)*rcuti)) |
914 |
> |
- preRF2*uz_i(3)) |
915 |
|
|
916 |
|
else |
917 |
|
if (i_is_SplitDipole) then |
933 |
|
endif |
934 |
|
endif |
935 |
|
|
973 |
– |
ct_ij = uz_i(1)*uz_j(1) + uz_i(2)*uz_j(2) + uz_i(3)*uz_j(3) |
974 |
– |
|
975 |
– |
ri2 = ri * ri |
976 |
– |
ri3 = ri2 * ri |
977 |
– |
ri4 = ri2 * ri2 |
936 |
|
sc2 = scale * scale |
937 |
< |
|
980 |
< |
pref = pre22 * mu_i * mu_j |
937 |
> |
|
938 |
|
vterm = pref * ri3 * (ct_ij - 3.0d0 * ct_i * ct_j * sc2) |
939 |
|
vpair = vpair + vterm |
940 |
|
epot = epot + sw*vterm |
967 |
|
|
968 |
|
if (i_is_Quadrupole) then |
969 |
|
if (j_is_Charge) then |
1013 |
– |
|
970 |
|
ri2 = riji * riji |
971 |
|
ri3 = ri2 * riji |
972 |
|
ri4 = ri2 * ri2 |
974 |
|
cy2 = cy_i * cy_i |
975 |
|
cz2 = cz_i * cz_i |
976 |
|
|
977 |
< |
if (summationMethod .eq. UNDAMPED_WOLF) then |
978 |
< |
pref = pre14 * q_j / 3.0_dp |
979 |
< |
vterm1 = pref * ri3*( qxx_i * (3.0_dp*cx2 - 1.0_dp) + & |
980 |
< |
qyy_i * (3.0_dp*cy2 - 1.0_dp) + & |
981 |
< |
qzz_i * (3.0_dp*cz2 - 1.0_dp) ) |
982 |
< |
vterm2 = pref * rcuti3*( qxx_i * (3.0_dp*cx2 - 1.0_dp) + & |
983 |
< |
qyy_i * (3.0_dp*cy2 - 1.0_dp) + & |
984 |
< |
qzz_i * (3.0_dp*cz2 - 1.0_dp) ) |
985 |
< |
vpair = vpair + ( vterm1 - vterm2 ) |
986 |
< |
epot = epot + sw*( vterm1 - vterm2 ) |
987 |
< |
|
988 |
< |
dudx = dudx - sw*(5.0_dp*(vterm1*riji*xhat-vterm2*rcuti2*d(1))) +& |
989 |
< |
sw*pref * ( (ri4 - rcuti4)*(qxx_i*(6.0_dp*cx_i*ux_i(1)) - & |
990 |
< |
qxx_i*2.0_dp*(xhat - rcuti*d(1))) + & |
991 |
< |
(ri4 - rcuti4)*(qyy_i*(6.0_dp*cy_i*uy_i(1)) - & |
992 |
< |
qyy_i*2.0_dp*(xhat - rcuti*d(1))) + & |
993 |
< |
(ri4 - rcuti4)*(qzz_i*(6.0_dp*cz_i*uz_i(1)) - & |
994 |
< |
qzz_i*2.0_dp*(xhat - rcuti*d(1))) ) |
995 |
< |
dudy = dudy - sw*(5.0_dp*(vterm1*riji*yhat-vterm2*rcuti2*d(2))) +& |
996 |
< |
sw*pref * ( (ri4 - rcuti4)*(qxx_i*(6.0_dp*cx_i*ux_i(2)) - & |
997 |
< |
qxx_i*2.0_dp*(yhat - rcuti*d(2))) + & |
998 |
< |
(ri4 - rcuti4)*(qyy_i*(6.0_dp*cy_i*uy_i(2)) - & |
999 |
< |
qyy_i*2.0_dp*(yhat - rcuti*d(2))) + & |
1000 |
< |
(ri4 - rcuti4)*(qzz_i*(6.0_dp*cz_i*uz_i(2)) - & |
1001 |
< |
qzz_i*2.0_dp*(yhat - rcuti*d(2))) ) |
1002 |
< |
dudz = dudz - sw*(5.0_dp*(vterm1*riji*zhat-vterm2*rcuti2*d(3))) +& |
1003 |
< |
sw*pref * ( (ri4 - rcuti4)*(qxx_i*(6.0_dp*cx_i*ux_i(3)) - & |
1004 |
< |
qxx_i*2.0_dp*(zhat - rcuti*d(3))) + & |
1005 |
< |
(ri4 - rcuti4)*(qyy_i*(6.0_dp*cy_i*uy_i(3)) - & |
1006 |
< |
qyy_i*2.0_dp*(zhat - rcuti*d(3))) + & |
1007 |
< |
(ri4 - rcuti4)*(qzz_i*(6.0_dp*cz_i*uz_i(3)) - & |
1052 |
< |
qzz_i*2.0_dp*(zhat - rcuti*d(3))) ) |
1053 |
< |
|
1054 |
< |
dudux_i(1) = dudux_i(1) + sw*pref*(ri3*(qxx_i*6.0_dp*cx_i*xhat) -& |
1055 |
< |
rcuti4*(qxx_i*6.0_dp*cx_i*d(1))) |
1056 |
< |
dudux_i(2) = dudux_i(2) + sw*pref*(ri3*(qxx_i*6.0_dp*cx_i*yhat) -& |
1057 |
< |
rcuti4*(qxx_i*6.0_dp*cx_i*d(2))) |
1058 |
< |
dudux_i(3) = dudux_i(3) + sw*pref*(ri3*(qxx_i*6.0_dp*cx_i*zhat) -& |
1059 |
< |
rcuti4*(qxx_i*6.0_dp*cx_i*d(3))) |
1060 |
< |
|
1061 |
< |
duduy_i(1) = duduy_i(1) + sw*pref*(ri3*(qyy_i*6.0_dp*cy_i*xhat) -& |
1062 |
< |
rcuti4*(qyy_i*6.0_dp*cx_i*d(1))) |
1063 |
< |
duduy_i(2) = duduy_i(2) + sw*pref*(ri3*(qyy_i*6.0_dp*cy_i*yhat) -& |
1064 |
< |
rcuti4*(qyy_i*6.0_dp*cx_i*d(2))) |
1065 |
< |
duduy_i(3) = duduy_i(3) + sw*pref*(ri3*(qyy_i*6.0_dp*cy_i*zhat) -& |
1066 |
< |
rcuti4*(qyy_i*6.0_dp*cx_i*d(3))) |
1067 |
< |
|
1068 |
< |
duduz_i(1) = duduz_i(1) + sw*pref*(ri3*(qzz_i*6.0_dp*cz_i*xhat) -& |
1069 |
< |
rcuti4*(qzz_i*6.0_dp*cx_i*d(1))) |
1070 |
< |
duduz_i(2) = duduz_i(2) + sw*pref*(ri3*(qzz_i*6.0_dp*cz_i*yhat) -& |
1071 |
< |
rcuti4*(qzz_i*6.0_dp*cx_i*d(2))) |
1072 |
< |
duduz_i(3) = duduz_i(3) + sw*pref*(ri3*(qzz_i*6.0_dp*cz_i*zhat) -& |
1073 |
< |
rcuti4*(qzz_i*6.0_dp*cx_i*d(3))) |
977 |
> |
pref = pre14 * q_j / 3.0_dp |
978 |
> |
vterm = pref * ri3 * (qxx_i * (3.0_dp*cx2 - 1.0_dp) + & |
979 |
> |
qyy_i * (3.0_dp*cy2 - 1.0_dp) + & |
980 |
> |
qzz_i * (3.0_dp*cz2 - 1.0_dp)) |
981 |
> |
vpair = vpair + vterm |
982 |
> |
epot = epot + sw*vterm |
983 |
> |
|
984 |
> |
dudx = dudx - 5.0_dp*sw*vterm*riji*xhat + sw*pref*ri4 * ( & |
985 |
> |
qxx_i*(6.0_dp*cx_i*ux_i(1) - 2.0_dp*xhat) + & |
986 |
> |
qyy_i*(6.0_dp*cy_i*uy_i(1) - 2.0_dp*xhat) + & |
987 |
> |
qzz_i*(6.0_dp*cz_i*uz_i(1) - 2.0_dp*xhat) ) |
988 |
> |
dudy = dudy - 5.0_dp*sw*vterm*riji*yhat + sw*pref*ri4 * ( & |
989 |
> |
qxx_i*(6.0_dp*cx_i*ux_i(2) - 2.0_dp*yhat) + & |
990 |
> |
qyy_i*(6.0_dp*cy_i*uy_i(2) - 2.0_dp*yhat) + & |
991 |
> |
qzz_i*(6.0_dp*cz_i*uz_i(2) - 2.0_dp*yhat) ) |
992 |
> |
dudz = dudz - 5.0_dp*sw*vterm*riji*zhat + sw*pref*ri4 * ( & |
993 |
> |
qxx_i*(6.0_dp*cx_i*ux_i(3) - 2.0_dp*zhat) + & |
994 |
> |
qyy_i*(6.0_dp*cy_i*uy_i(3) - 2.0_dp*zhat) + & |
995 |
> |
qzz_i*(6.0_dp*cz_i*uz_i(3) - 2.0_dp*zhat) ) |
996 |
> |
|
997 |
> |
dudux_i(1) = dudux_i(1) + sw*pref*ri3*(qxx_i*6.0_dp*cx_i*xhat) |
998 |
> |
dudux_i(2) = dudux_i(2) + sw*pref*ri3*(qxx_i*6.0_dp*cx_i*yhat) |
999 |
> |
dudux_i(3) = dudux_i(3) + sw*pref*ri3*(qxx_i*6.0_dp*cx_i*zhat) |
1000 |
> |
|
1001 |
> |
duduy_i(1) = duduy_i(1) + sw*pref*ri3*(qyy_i*6.0_dp*cy_i*xhat) |
1002 |
> |
duduy_i(2) = duduy_i(2) + sw*pref*ri3*(qyy_i*6.0_dp*cy_i*yhat) |
1003 |
> |
duduy_i(3) = duduy_i(3) + sw*pref*ri3*(qyy_i*6.0_dp*cy_i*zhat) |
1004 |
> |
|
1005 |
> |
duduz_i(1) = duduz_i(1) + sw*pref*ri3*(qzz_i*6.0_dp*cz_i*xhat) |
1006 |
> |
duduz_i(2) = duduz_i(2) + sw*pref*ri3*(qzz_i*6.0_dp*cz_i*yhat) |
1007 |
> |
duduz_i(3) = duduz_i(3) + sw*pref*ri3*(qzz_i*6.0_dp*cz_i*zhat) |
1008 |
|
|
1075 |
– |
else |
1076 |
– |
pref = pre14 * q_j / 3.0_dp |
1077 |
– |
vterm = pref * ri3 * (qxx_i * (3.0_dp*cx2 - 1.0_dp) + & |
1078 |
– |
qyy_i * (3.0_dp*cy2 - 1.0_dp) + & |
1079 |
– |
qzz_i * (3.0_dp*cz2 - 1.0_dp)) |
1080 |
– |
vpair = vpair + vterm |
1081 |
– |
epot = epot + sw*vterm |
1082 |
– |
|
1083 |
– |
dudx = dudx - 5.0_dp*sw*vterm*riji*xhat + sw*pref*ri4 * ( & |
1084 |
– |
qxx_i*(6.0_dp*cx_i*ux_i(1) - 2.0_dp*xhat) + & |
1085 |
– |
qyy_i*(6.0_dp*cy_i*uy_i(1) - 2.0_dp*xhat) + & |
1086 |
– |
qzz_i*(6.0_dp*cz_i*uz_i(1) - 2.0_dp*xhat) ) |
1087 |
– |
dudy = dudy - 5.0_dp*sw*vterm*riji*yhat + sw*pref*ri4 * ( & |
1088 |
– |
qxx_i*(6.0_dp*cx_i*ux_i(2) - 2.0_dp*yhat) + & |
1089 |
– |
qyy_i*(6.0_dp*cy_i*uy_i(2) - 2.0_dp*yhat) + & |
1090 |
– |
qzz_i*(6.0_dp*cz_i*uz_i(2) - 2.0_dp*yhat) ) |
1091 |
– |
dudz = dudz - 5.0_dp*sw*vterm*riji*zhat + sw*pref*ri4 * ( & |
1092 |
– |
qxx_i*(6.0_dp*cx_i*ux_i(3) - 2.0_dp*zhat) + & |
1093 |
– |
qyy_i*(6.0_dp*cy_i*uy_i(3) - 2.0_dp*zhat) + & |
1094 |
– |
qzz_i*(6.0_dp*cz_i*uz_i(3) - 2.0_dp*zhat) ) |
1095 |
– |
|
1096 |
– |
dudux_i(1) = dudux_i(1) + sw*pref*ri3*(qxx_i*6.0_dp*cx_i*xhat) |
1097 |
– |
dudux_i(2) = dudux_i(2) + sw*pref*ri3*(qxx_i*6.0_dp*cx_i*yhat) |
1098 |
– |
dudux_i(3) = dudux_i(3) + sw*pref*ri3*(qxx_i*6.0_dp*cx_i*zhat) |
1099 |
– |
|
1100 |
– |
duduy_i(1) = duduy_i(1) + sw*pref*ri3*(qyy_i*6.0_dp*cy_i*xhat) |
1101 |
– |
duduy_i(2) = duduy_i(2) + sw*pref*ri3*(qyy_i*6.0_dp*cy_i*yhat) |
1102 |
– |
duduy_i(3) = duduy_i(3) + sw*pref*ri3*(qyy_i*6.0_dp*cy_i*zhat) |
1103 |
– |
|
1104 |
– |
duduz_i(1) = duduz_i(1) + sw*pref*ri3*(qzz_i*6.0_dp*cz_i*xhat) |
1105 |
– |
duduz_i(2) = duduz_i(2) + sw*pref*ri3*(qzz_i*6.0_dp*cz_i*yhat) |
1106 |
– |
duduz_i(3) = duduz_i(3) + sw*pref*ri3*(qzz_i*6.0_dp*cz_i*zhat) |
1107 |
– |
endif |
1009 |
|
endif |
1010 |
|
endif |
1011 |
|
|
1124 |
|
|
1125 |
|
end subroutine destroyElectrostaticTypes |
1126 |
|
|
1127 |
< |
subroutine accumulate_rf(atom1, atom2, rij, eFrame, taper) |
1127 |
> |
subroutine self_self(atom1, eFrame, mypot, t, do_pot) |
1128 |
> |
logical, intent(in) :: do_pot |
1129 |
> |
integer, intent(in) :: atom1 |
1130 |
> |
integer :: atid1 |
1131 |
> |
real(kind=dp), dimension(9,nLocal) :: eFrame |
1132 |
> |
real(kind=dp), dimension(3,nLocal) :: t |
1133 |
> |
real(kind=dp) :: mu1, c1 |
1134 |
> |
real(kind=dp) :: preVal, epot, mypot |
1135 |
> |
real(kind=dp) :: eix, eiy, eiz |
1136 |
|
|
1137 |
< |
integer, intent(in) :: atom1, atom2 |
1138 |
< |
real (kind = dp), intent(in) :: rij |
1230 |
< |
real (kind = dp), dimension(9,nLocal) :: eFrame |
1137 |
> |
! this is a local only array, so we use the local atom type id's: |
1138 |
> |
atid1 = atid(atom1) |
1139 |
|
|
1140 |
< |
integer :: me1, me2 |
1141 |
< |
real (kind = dp), intent(in) :: taper |
1142 |
< |
real (kind = dp):: mu1, mu2 |
1143 |
< |
real (kind = dp), dimension(3) :: ul1 |
1144 |
< |
real (kind = dp), dimension(3) :: ul2 |
1140 |
> |
if (.not.summationMethodChecked) then |
1141 |
> |
call checkSummationMethod() |
1142 |
> |
endif |
1143 |
> |
|
1144 |
> |
if (summationMethod .eq. REACTION_FIELD) then |
1145 |
> |
if (ElectrostaticMap(atid1)%is_Dipole) then |
1146 |
> |
mu1 = getDipoleMoment(atid1) |
1147 |
> |
|
1148 |
> |
preVal = pre22 * preRF2 * mu1*mu1 |
1149 |
> |
mypot = mypot - 0.5d0*preVal |
1150 |
> |
|
1151 |
> |
! The self-correction term adds into the reaction field vector |
1152 |
> |
|
1153 |
> |
eix = preVal * eFrame(3,atom1) |
1154 |
> |
eiy = preVal * eFrame(6,atom1) |
1155 |
> |
eiz = preVal * eFrame(9,atom1) |
1156 |
> |
|
1157 |
> |
! once again, this is self-self, so only the local arrays are needed |
1158 |
> |
! even for MPI jobs: |
1159 |
> |
|
1160 |
> |
t(1,atom1)=t(1,atom1) - eFrame(6,atom1)*eiz + & |
1161 |
> |
eFrame(9,atom1)*eiy |
1162 |
> |
t(2,atom1)=t(2,atom1) - eFrame(9,atom1)*eix + & |
1163 |
> |
eFrame(3,atom1)*eiz |
1164 |
> |
t(3,atom1)=t(3,atom1) - eFrame(3,atom1)*eiy + & |
1165 |
> |
eFrame(6,atom1)*eix |
1166 |
> |
|
1167 |
> |
endif |
1168 |
|
|
1169 |
< |
integer :: localError |
1169 |
> |
elseif (summationMethod .eq. SHIFTED_FORCE) then |
1170 |
> |
if (ElectrostaticMap(atid1)%is_Charge) then |
1171 |
> |
c1 = getCharge(atid1) |
1172 |
> |
|
1173 |
> |
if (screeningMethod .eq. DAMPED) then |
1174 |
> |
mypot = mypot - (f0c * rcuti * 0.5_dp + & |
1175 |
> |
dampingAlpha*invRootPi) * c1 * c1 |
1176 |
> |
|
1177 |
> |
else |
1178 |
> |
mypot = mypot - (rcuti * 0.5_dp * c1 * c1) |
1179 |
> |
|
1180 |
> |
endif |
1181 |
> |
endif |
1182 |
> |
endif |
1183 |
> |
|
1184 |
> |
return |
1185 |
> |
end subroutine self_self |
1186 |
|
|
1187 |
< |
#ifdef IS_MPI |
1188 |
< |
me1 = atid_Row(atom1) |
1189 |
< |
ul1(1) = eFrame_Row(3,atom1) |
1190 |
< |
ul1(2) = eFrame_Row(6,atom1) |
1191 |
< |
ul1(3) = eFrame_Row(9,atom1) |
1187 |
> |
subroutine rf_self_excludes(atom1, atom2, sw, eFrame, d, rij, vpair, myPot, & |
1188 |
> |
f, t, do_pot) |
1189 |
> |
logical, intent(in) :: do_pot |
1190 |
> |
integer, intent(in) :: atom1 |
1191 |
> |
integer, intent(in) :: atom2 |
1192 |
> |
logical :: i_is_Charge, j_is_Charge |
1193 |
> |
logical :: i_is_Dipole, j_is_Dipole |
1194 |
> |
integer :: atid1 |
1195 |
> |
integer :: atid2 |
1196 |
> |
real(kind=dp), intent(in) :: rij |
1197 |
> |
real(kind=dp), intent(in) :: sw |
1198 |
> |
real(kind=dp), intent(in), dimension(3) :: d |
1199 |
> |
real(kind=dp), intent(inout) :: vpair |
1200 |
> |
real(kind=dp), dimension(9,nLocal) :: eFrame |
1201 |
> |
real(kind=dp), dimension(3,nLocal) :: f |
1202 |
> |
real(kind=dp), dimension(3,nLocal) :: t |
1203 |
> |
real (kind = dp), dimension(3) :: duduz_i |
1204 |
> |
real (kind = dp), dimension(3) :: duduz_j |
1205 |
> |
real (kind = dp), dimension(3) :: uz_i |
1206 |
> |
real (kind = dp), dimension(3) :: uz_j |
1207 |
> |
real(kind=dp) :: q_i, q_j, mu_i, mu_j |
1208 |
> |
real(kind=dp) :: xhat, yhat, zhat |
1209 |
> |
real(kind=dp) :: ct_i, ct_j |
1210 |
> |
real(kind=dp) :: ri2, ri3, riji, vterm |
1211 |
> |
real(kind=dp) :: pref, preVal, rfVal, myPot |
1212 |
> |
real(kind=dp) :: dudx, dudy, dudz, dudr |
1213 |
|
|
1214 |
< |
me2 = atid_Col(atom2) |
1215 |
< |
ul2(1) = eFrame_Col(3,atom2) |
1216 |
< |
ul2(2) = eFrame_Col(6,atom2) |
1249 |
< |
ul2(3) = eFrame_Col(9,atom2) |
1250 |
< |
#else |
1251 |
< |
me1 = atid(atom1) |
1252 |
< |
ul1(1) = eFrame(3,atom1) |
1253 |
< |
ul1(2) = eFrame(6,atom1) |
1254 |
< |
ul1(3) = eFrame(9,atom1) |
1214 |
> |
if (.not.summationMethodChecked) then |
1215 |
> |
call checkSummationMethod() |
1216 |
> |
endif |
1217 |
|
|
1218 |
< |
me2 = atid(atom2) |
1219 |
< |
ul2(1) = eFrame(3,atom2) |
1220 |
< |
ul2(2) = eFrame(6,atom2) |
1259 |
< |
ul2(3) = eFrame(9,atom2) |
1260 |
< |
#endif |
1218 |
> |
dudx = 0.0d0 |
1219 |
> |
dudy = 0.0d0 |
1220 |
> |
dudz = 0.0d0 |
1221 |
|
|
1222 |
< |
mu1 = getDipoleMoment(me1) |
1263 |
< |
mu2 = getDipoleMoment(me2) |
1222 |
> |
riji = 1.0d0/rij |
1223 |
|
|
1224 |
< |
#ifdef IS_MPI |
1225 |
< |
rf_Row(1,atom1) = rf_Row(1,atom1) + ul2(1)*mu2*taper |
1226 |
< |
rf_Row(2,atom1) = rf_Row(2,atom1) + ul2(2)*mu2*taper |
1268 |
< |
rf_Row(3,atom1) = rf_Row(3,atom1) + ul2(3)*mu2*taper |
1224 |
> |
xhat = d(1) * riji |
1225 |
> |
yhat = d(2) * riji |
1226 |
> |
zhat = d(3) * riji |
1227 |
|
|
1228 |
< |
rf_Col(1,atom2) = rf_Col(1,atom2) + ul1(1)*mu1*taper |
1229 |
< |
rf_Col(2,atom2) = rf_Col(2,atom2) + ul1(2)*mu1*taper |
1230 |
< |
rf_Col(3,atom2) = rf_Col(3,atom2) + ul1(3)*mu1*taper |
1231 |
< |
#else |
1232 |
< |
rf(1,atom1) = rf(1,atom1) + ul2(1)*mu2*taper |
1233 |
< |
rf(2,atom1) = rf(2,atom1) + ul2(2)*mu2*taper |
1234 |
< |
rf(3,atom1) = rf(3,atom1) + ul2(3)*mu2*taper |
1228 |
> |
! this is a local only array, so we use the local atom type id's: |
1229 |
> |
atid1 = atid(atom1) |
1230 |
> |
atid2 = atid(atom2) |
1231 |
> |
i_is_Charge = ElectrostaticMap(atid1)%is_Charge |
1232 |
> |
j_is_Charge = ElectrostaticMap(atid2)%is_Charge |
1233 |
> |
i_is_Dipole = ElectrostaticMap(atid1)%is_Dipole |
1234 |
> |
j_is_Dipole = ElectrostaticMap(atid2)%is_Dipole |
1235 |
|
|
1236 |
< |
rf(1,atom2) = rf(1,atom2) + ul1(1)*mu1*taper |
1237 |
< |
rf(2,atom2) = rf(2,atom2) + ul1(2)*mu1*taper |
1238 |
< |
rf(3,atom2) = rf(3,atom2) + ul1(3)*mu1*taper |
1239 |
< |
#endif |
1240 |
< |
return |
1241 |
< |
end subroutine accumulate_rf |
1242 |
< |
|
1243 |
< |
subroutine accumulate_self_rf(atom1, mu1, eFrame) |
1244 |
< |
|
1245 |
< |
integer, intent(in) :: atom1 |
1246 |
< |
real(kind=dp), intent(in) :: mu1 |
1247 |
< |
real(kind=dp), dimension(9,nLocal) :: eFrame |
1248 |
< |
|
1249 |
< |
!! should work for both MPI and non-MPI version since this is not pairwise. |
1250 |
< |
rf(1,atom1) = rf(1,atom1) + eFrame(3,atom1)*mu1 |
1251 |
< |
rf(2,atom1) = rf(2,atom1) + eFrame(6,atom1)*mu1 |
1252 |
< |
rf(3,atom1) = rf(3,atom1) + eFrame(9,atom1)*mu1 |
1253 |
< |
|
1254 |
< |
return |
1255 |
< |
end subroutine accumulate_self_rf |
1256 |
< |
|
1257 |
< |
subroutine reaction_field_final(a1, mu1, eFrame, rfpot, t, do_pot) |
1258 |
< |
|
1259 |
< |
integer, intent(in) :: a1 |
1260 |
< |
real (kind=dp), intent(in) :: mu1 |
1261 |
< |
real (kind=dp), intent(inout) :: rfpot |
1262 |
< |
logical, intent(in) :: do_pot |
1263 |
< |
real (kind = dp), dimension(9,nLocal) :: eFrame |
1264 |
< |
real (kind = dp), dimension(3,nLocal) :: t |
1265 |
< |
|
1266 |
< |
integer :: localError |
1267 |
< |
|
1268 |
< |
if (.not.preRFCalculated) then |
1269 |
< |
call setReactionFieldPrefactor() |
1236 |
> |
if (i_is_Charge.and.j_is_Charge) then |
1237 |
> |
q_i = ElectrostaticMap(atid1)%charge |
1238 |
> |
q_j = ElectrostaticMap(atid2)%charge |
1239 |
> |
|
1240 |
> |
preVal = pre11 * q_i * q_j |
1241 |
> |
rfVal = preRF*rij*rij |
1242 |
> |
vterm = preVal * rfVal |
1243 |
> |
|
1244 |
> |
myPot = myPot + sw*vterm |
1245 |
> |
|
1246 |
> |
dudr = sw*preVal * 2.0d0*rfVal*riji |
1247 |
> |
|
1248 |
> |
dudx = dudx + dudr * xhat |
1249 |
> |
dudy = dudy + dudr * yhat |
1250 |
> |
dudz = dudz + dudr * zhat |
1251 |
> |
|
1252 |
> |
elseif (i_is_Charge.and.j_is_Dipole) then |
1253 |
> |
q_i = ElectrostaticMap(atid1)%charge |
1254 |
> |
mu_j = ElectrostaticMap(atid2)%dipole_moment |
1255 |
> |
uz_j(1) = eFrame(3,atom2) |
1256 |
> |
uz_j(2) = eFrame(6,atom2) |
1257 |
> |
uz_j(3) = eFrame(9,atom2) |
1258 |
> |
ct_j = uz_j(1)*xhat + uz_j(2)*yhat + uz_j(3)*zhat |
1259 |
> |
|
1260 |
> |
ri2 = riji * riji |
1261 |
> |
ri3 = ri2 * riji |
1262 |
> |
|
1263 |
> |
pref = pre12 * q_i * mu_j |
1264 |
> |
vterm = - pref * ct_j * ( ri2 - preRF2*rij ) |
1265 |
> |
myPot = myPot + sw*vterm |
1266 |
> |
|
1267 |
> |
dudx = dudx - sw*pref*( ri3*(uz_j(1)-3.0d0*ct_j*xhat) & |
1268 |
> |
- preRF2*uz_j(1) ) |
1269 |
> |
dudy = dudy - sw*pref*( ri3*(uz_j(2)-3.0d0*ct_j*yhat) & |
1270 |
> |
- preRF2*uz_j(2) ) |
1271 |
> |
dudz = dudz - sw*pref*( ri3*(uz_j(3)-3.0d0*ct_j*zhat) & |
1272 |
> |
- preRF2*uz_j(3) ) |
1273 |
> |
|
1274 |
> |
duduz_j(1) = duduz_j(1) - sw * pref * xhat * ( ri2 - preRF2*rij ) |
1275 |
> |
duduz_j(2) = duduz_j(2) - sw * pref * yhat * ( ri2 - preRF2*rij ) |
1276 |
> |
duduz_j(3) = duduz_j(3) - sw * pref * zhat * ( ri2 - preRF2*rij ) |
1277 |
> |
|
1278 |
> |
elseif (i_is_Dipole.and.j_is_Charge) then |
1279 |
> |
mu_i = ElectrostaticMap(atid1)%dipole_moment |
1280 |
> |
q_j = ElectrostaticMap(atid2)%charge |
1281 |
> |
uz_i(1) = eFrame(3,atom1) |
1282 |
> |
uz_i(2) = eFrame(6,atom1) |
1283 |
> |
uz_i(3) = eFrame(9,atom1) |
1284 |
> |
ct_i = uz_i(1)*xhat + uz_i(2)*yhat + uz_i(3)*zhat |
1285 |
> |
|
1286 |
> |
ri2 = riji * riji |
1287 |
> |
ri3 = ri2 * riji |
1288 |
> |
|
1289 |
> |
pref = pre12 * q_j * mu_i |
1290 |
> |
vterm = pref * ct_i * ( ri2 - preRF2*rij ) |
1291 |
> |
myPot = myPot + sw*vterm |
1292 |
> |
|
1293 |
> |
dudx = dudx + sw*pref*( ri3*(uz_i(1)-3.0d0*ct_i*xhat) & |
1294 |
> |
- preRF2*uz_i(1) ) |
1295 |
> |
dudy = dudy + sw*pref*( ri3*(uz_i(2)-3.0d0*ct_i*yhat) & |
1296 |
> |
- preRF2*uz_i(2) ) |
1297 |
> |
dudz = dudz + sw*pref*( ri3*(uz_i(3)-3.0d0*ct_i*zhat) & |
1298 |
> |
- preRF2*uz_i(3) ) |
1299 |
> |
|
1300 |
> |
duduz_i(1) = duduz_i(1) + sw * pref * xhat * ( ri2 - preRF2*rij ) |
1301 |
> |
duduz_i(2) = duduz_i(2) + sw * pref * yhat * ( ri2 - preRF2*rij ) |
1302 |
> |
duduz_i(3) = duduz_i(3) + sw * pref * zhat * ( ri2 - preRF2*rij ) |
1303 |
> |
|
1304 |
|
endif |
1305 |
+ |
|
1306 |
|
|
1307 |
< |
! compute torques on dipoles: |
1308 |
< |
! pre converts from mu in units of debye to kcal/mol |
1309 |
< |
|
1310 |
< |
! The torque contribution is dipole cross reaction_field |
1311 |
< |
|
1312 |
< |
t(1,a1) = t(1,a1) + preRF*mu1*(eFrame(6,a1)*rf(3,a1) - & |
1313 |
< |
eFrame(9,a1)*rf(2,a1)) |
1314 |
< |
t(2,a1) = t(2,a1) + preRF*mu1*(eFrame(9,a1)*rf(1,a1) - & |
1315 |
< |
eFrame(3,a1)*rf(3,a1)) |
1316 |
< |
t(3,a1) = t(3,a1) + preRF*mu1*(eFrame(3,a1)*rf(2,a1) - & |
1317 |
< |
eFrame(6,a1)*rf(1,a1)) |
1318 |
< |
|
1319 |
< |
! the potential contribution is -1/2 dipole dot reaction_field |
1320 |
< |
|
1321 |
< |
if (do_pot) then |
1322 |
< |
rfpot = rfpot - 0.5d0 * preRF * mu1 * & |
1323 |
< |
(rf(1,a1)*eFrame(3,a1) + rf(2,a1)*eFrame(6,a1) + & |
1331 |
< |
rf(3,a1)*eFrame(9,a1)) |
1307 |
> |
! accumulate the forces and torques resulting from the self term |
1308 |
> |
f(1,atom1) = f(1,atom1) + dudx |
1309 |
> |
f(2,atom1) = f(2,atom1) + dudy |
1310 |
> |
f(3,atom1) = f(3,atom1) + dudz |
1311 |
> |
|
1312 |
> |
f(1,atom2) = f(1,atom2) - dudx |
1313 |
> |
f(2,atom2) = f(2,atom2) - dudy |
1314 |
> |
f(3,atom2) = f(3,atom2) - dudz |
1315 |
> |
|
1316 |
> |
if (i_is_Dipole) then |
1317 |
> |
t(1,atom1)=t(1,atom1) - uz_i(2)*duduz_i(3) + uz_i(3)*duduz_i(2) |
1318 |
> |
t(2,atom1)=t(2,atom1) - uz_i(3)*duduz_i(1) + uz_i(1)*duduz_i(3) |
1319 |
> |
t(3,atom1)=t(3,atom1) - uz_i(1)*duduz_i(2) + uz_i(2)*duduz_i(1) |
1320 |
> |
elseif (j_is_Dipole) then |
1321 |
> |
t(1,atom2)=t(1,atom2) - uz_j(2)*duduz_j(3) + uz_j(3)*duduz_j(2) |
1322 |
> |
t(2,atom2)=t(2,atom2) - uz_j(3)*duduz_j(1) + uz_j(1)*duduz_j(3) |
1323 |
> |
t(3,atom2)=t(3,atom2) - uz_j(1)*duduz_j(2) + uz_j(2)*duduz_j(1) |
1324 |
|
endif |
1325 |
|
|
1326 |
|
return |
1327 |
< |
end subroutine reaction_field_final |
1327 |
> |
end subroutine rf_self_excludes |
1328 |
|
|
1337 |
– |
subroutine rf_correct_forces(atom1, atom2, d, rij, eFrame, taper, f, fpair) |
1338 |
– |
|
1339 |
– |
integer, intent(in) :: atom1, atom2 |
1340 |
– |
real(kind=dp), dimension(3), intent(in) :: d |
1341 |
– |
real(kind=dp), intent(in) :: rij, taper |
1342 |
– |
real( kind = dp ), dimension(9,nLocal) :: eFrame |
1343 |
– |
real( kind = dp ), dimension(3,nLocal) :: f |
1344 |
– |
real( kind = dp ), dimension(3), intent(inout) :: fpair |
1345 |
– |
|
1346 |
– |
real (kind = dp), dimension(3) :: ul1 |
1347 |
– |
real (kind = dp), dimension(3) :: ul2 |
1348 |
– |
real (kind = dp) :: dtdr |
1349 |
– |
real (kind = dp) :: dudx, dudy, dudz, u1dotu2 |
1350 |
– |
integer :: me1, me2, id1, id2 |
1351 |
– |
real (kind = dp) :: mu1, mu2 |
1352 |
– |
|
1353 |
– |
integer :: localError |
1354 |
– |
|
1355 |
– |
if (.not.preRFCalculated) then |
1356 |
– |
call setReactionFieldPrefactor() |
1357 |
– |
endif |
1358 |
– |
|
1359 |
– |
if (rij.le.rrf) then |
1360 |
– |
|
1361 |
– |
if (rij.lt.rt) then |
1362 |
– |
dtdr = 0.0d0 |
1363 |
– |
else |
1364 |
– |
! write(*,*) 'rf correct in taper region' |
1365 |
– |
dtdr = 6.0d0*(rij*rij - rij*rt - rij*rrf +rrf*rt)/((rrf-rt)**3) |
1366 |
– |
endif |
1367 |
– |
|
1368 |
– |
#ifdef IS_MPI |
1369 |
– |
me1 = atid_Row(atom1) |
1370 |
– |
ul1(1) = eFrame_Row(3,atom1) |
1371 |
– |
ul1(2) = eFrame_Row(6,atom1) |
1372 |
– |
ul1(3) = eFrame_Row(9,atom1) |
1373 |
– |
|
1374 |
– |
me2 = atid_Col(atom2) |
1375 |
– |
ul2(1) = eFrame_Col(3,atom2) |
1376 |
– |
ul2(2) = eFrame_Col(6,atom2) |
1377 |
– |
ul2(3) = eFrame_Col(9,atom2) |
1378 |
– |
#else |
1379 |
– |
me1 = atid(atom1) |
1380 |
– |
ul1(1) = eFrame(3,atom1) |
1381 |
– |
ul1(2) = eFrame(6,atom1) |
1382 |
– |
ul1(3) = eFrame(9,atom1) |
1383 |
– |
|
1384 |
– |
me2 = atid(atom2) |
1385 |
– |
ul2(1) = eFrame(3,atom2) |
1386 |
– |
ul2(2) = eFrame(6,atom2) |
1387 |
– |
ul2(3) = eFrame(9,atom2) |
1388 |
– |
#endif |
1389 |
– |
|
1390 |
– |
mu1 = getDipoleMoment(me1) |
1391 |
– |
mu2 = getDipoleMoment(me2) |
1392 |
– |
|
1393 |
– |
u1dotu2 = ul1(1)*ul2(1) + ul1(2)*ul2(2) + ul1(3)*ul2(3) |
1394 |
– |
|
1395 |
– |
dudx = - preRF*mu1*mu2*u1dotu2*dtdr*d(1)/rij |
1396 |
– |
dudy = - preRF*mu1*mu2*u1dotu2*dtdr*d(2)/rij |
1397 |
– |
dudz = - preRF*mu1*mu2*u1dotu2*dtdr*d(3)/rij |
1398 |
– |
|
1399 |
– |
#ifdef IS_MPI |
1400 |
– |
f_Row(1,atom1) = f_Row(1,atom1) + dudx |
1401 |
– |
f_Row(2,atom1) = f_Row(2,atom1) + dudy |
1402 |
– |
f_Row(3,atom1) = f_Row(3,atom1) + dudz |
1403 |
– |
|
1404 |
– |
f_Col(1,atom2) = f_Col(1,atom2) - dudx |
1405 |
– |
f_Col(2,atom2) = f_Col(2,atom2) - dudy |
1406 |
– |
f_Col(3,atom2) = f_Col(3,atom2) - dudz |
1407 |
– |
#else |
1408 |
– |
f(1,atom1) = f(1,atom1) + dudx |
1409 |
– |
f(2,atom1) = f(2,atom1) + dudy |
1410 |
– |
f(3,atom1) = f(3,atom1) + dudz |
1411 |
– |
|
1412 |
– |
f(1,atom2) = f(1,atom2) - dudx |
1413 |
– |
f(2,atom2) = f(2,atom2) - dudy |
1414 |
– |
f(3,atom2) = f(3,atom2) - dudz |
1415 |
– |
#endif |
1416 |
– |
|
1417 |
– |
#ifdef IS_MPI |
1418 |
– |
id1 = AtomRowToGlobal(atom1) |
1419 |
– |
id2 = AtomColToGlobal(atom2) |
1420 |
– |
#else |
1421 |
– |
id1 = atom1 |
1422 |
– |
id2 = atom2 |
1423 |
– |
#endif |
1424 |
– |
|
1425 |
– |
if (molMembershipList(id1) .ne. molMembershipList(id2)) then |
1426 |
– |
|
1427 |
– |
fpair(1) = fpair(1) + dudx |
1428 |
– |
fpair(2) = fpair(2) + dudy |
1429 |
– |
fpair(3) = fpair(3) + dudz |
1430 |
– |
|
1431 |
– |
endif |
1432 |
– |
|
1433 |
– |
end if |
1434 |
– |
return |
1435 |
– |
end subroutine rf_correct_forces |
1436 |
– |
|
1329 |
|
end module electrostatic_module |