47 |
|
use vector_class |
48 |
|
use simulation |
49 |
|
use status |
50 |
+ |
use interpolation |
51 |
|
#ifdef IS_MPI |
52 |
|
use mpiSimulation |
53 |
|
#endif |
55 |
|
|
56 |
|
PRIVATE |
57 |
|
|
58 |
+ |
|
59 |
|
#define __FORTRAN90 |
60 |
+ |
#include "UseTheForce/DarkSide/fInteractionMap.h" |
61 |
|
#include "UseTheForce/DarkSide/fElectrostaticSummationMethod.h" |
62 |
+ |
#include "UseTheForce/DarkSide/fElectrostaticScreeningMethod.h" |
63 |
|
|
64 |
+ |
|
65 |
|
!! these prefactors convert the multipole interactions into kcal / mol |
66 |
|
!! all were computed assuming distances are measured in angstroms |
67 |
|
!! Charge-Charge, assuming charges are measured in electrons |
76 |
|
!! This unit is also known affectionately as an esu centi-barn. |
77 |
|
real(kind=dp), parameter :: pre14 = 69.13373_dp |
78 |
|
|
79 |
< |
!! variables to handle different summation methods for long-range electrostatics: |
79 |
> |
real(kind=dp), parameter :: zero = 0.0_dp |
80 |
> |
|
81 |
> |
!! conversions for the simulation box dipole moment |
82 |
> |
real(kind=dp), parameter :: chargeToC = 1.60217733e-19_dp |
83 |
> |
real(kind=dp), parameter :: angstromToM = 1.0e-10_dp |
84 |
> |
real(kind=dp), parameter :: debyeToCm = 3.33564095198e-30_dp |
85 |
> |
|
86 |
> |
!! number of points for electrostatic splines |
87 |
> |
integer, parameter :: np = 100 |
88 |
> |
|
89 |
> |
!! variables to handle different summation methods for long-range |
90 |
> |
!! electrostatics: |
91 |
|
integer, save :: summationMethod = NONE |
92 |
+ |
integer, save :: screeningMethod = UNDAMPED |
93 |
|
logical, save :: summationMethodChecked = .false. |
94 |
|
real(kind=DP), save :: defaultCutoff = 0.0_DP |
95 |
+ |
real(kind=DP), save :: defaultCutoff2 = 0.0_DP |
96 |
|
logical, save :: haveDefaultCutoff = .false. |
97 |
|
real(kind=DP), save :: dampingAlpha = 0.0_DP |
98 |
+ |
real(kind=DP), save :: alpha2 = 0.0_DP |
99 |
+ |
real(kind=DP), save :: alpha4 = 0.0_DP |
100 |
+ |
real(kind=DP), save :: alpha6 = 0.0_DP |
101 |
+ |
real(kind=DP), save :: alpha8 = 0.0_DP |
102 |
|
logical, save :: haveDampingAlpha = .false. |
103 |
< |
real(kind=DP), save :: dielectric = 0.0_DP |
103 |
> |
real(kind=DP), save :: dielectric = 1.0_DP |
104 |
|
logical, save :: haveDielectric = .false. |
83 |
– |
real(kind=DP), save :: constERFC = 0.0_DP |
105 |
|
real(kind=DP), save :: constEXP = 0.0_DP |
106 |
< |
logical, save :: haveDWAconstants = .false. |
107 |
< |
real(kind=dp), save :: rcuti = 0.0_dp |
108 |
< |
real(kind=dp), save :: rcuti2 = 0.0_dp |
109 |
< |
real(kind=dp), save :: rcuti3 = 0.0_dp |
110 |
< |
real(kind=dp), save :: rcuti4 = 0.0_dp |
106 |
> |
real(kind=dp), save :: rcuti = 0.0_DP |
107 |
> |
real(kind=dp), save :: rcuti2 = 0.0_DP |
108 |
> |
real(kind=dp), save :: rcuti3 = 0.0_DP |
109 |
> |
real(kind=dp), save :: rcuti4 = 0.0_DP |
110 |
> |
real(kind=dp), save :: alphaPi = 0.0_DP |
111 |
> |
real(kind=dp), save :: invRootPi = 0.0_DP |
112 |
> |
real(kind=dp), save :: rrf = 1.0_DP |
113 |
> |
real(kind=dp), save :: rt = 1.0_DP |
114 |
> |
real(kind=dp), save :: rrfsq = 1.0_DP |
115 |
> |
real(kind=dp), save :: preRF = 0.0_DP |
116 |
> |
real(kind=dp), save :: preRF2 = 0.0_DP |
117 |
> |
real(kind=dp), save :: erfcVal = 1.0_DP |
118 |
> |
real(kind=dp), save :: derfcVal = 0.0_DP |
119 |
> |
type(cubicSpline), save :: erfcSpline |
120 |
> |
logical, save :: haveElectroSpline = .false. |
121 |
> |
real(kind=dp), save :: c1 = 1.0_DP |
122 |
> |
real(kind=dp), save :: c2 = 1.0_DP |
123 |
> |
real(kind=dp), save :: c3 = 0.0_DP |
124 |
> |
real(kind=dp), save :: c4 = 0.0_DP |
125 |
> |
real(kind=dp), save :: c5 = 0.0_DP |
126 |
> |
real(kind=dp), save :: c6 = 0.0_DP |
127 |
> |
real(kind=dp), save :: c1c = 1.0_DP |
128 |
> |
real(kind=dp), save :: c2c = 1.0_DP |
129 |
> |
real(kind=dp), save :: c3c = 0.0_DP |
130 |
> |
real(kind=dp), save :: c4c = 0.0_DP |
131 |
> |
real(kind=dp), save :: c5c = 0.0_DP |
132 |
> |
real(kind=dp), save :: c6c = 0.0_DP |
133 |
> |
real(kind=dp), save :: one_third = 1.0_DP / 3.0_DP |
134 |
|
|
135 |
< |
|
135 |
> |
#if defined(__IFC) || defined(__PGI) |
136 |
> |
! error function for ifc version > 7. |
137 |
> |
real(kind=dp), external :: erfc |
138 |
> |
#endif |
139 |
> |
|
140 |
|
public :: setElectrostaticSummationMethod |
141 |
+ |
public :: setScreeningMethod |
142 |
|
public :: setElectrostaticCutoffRadius |
143 |
< |
public :: setDampedWolfAlpha |
143 |
> |
public :: setDampingAlpha |
144 |
|
public :: setReactionFieldDielectric |
145 |
+ |
public :: buildElectroSpline |
146 |
|
public :: newElectrostaticType |
147 |
|
public :: setCharge |
148 |
|
public :: setDipoleMoment |
151 |
|
public :: doElectrostaticPair |
152 |
|
public :: getCharge |
153 |
|
public :: getDipoleMoment |
104 |
– |
public :: pre22 |
154 |
|
public :: destroyElectrostaticTypes |
155 |
+ |
public :: self_self |
156 |
+ |
public :: rf_self_excludes |
157 |
+ |
public :: accumulate_box_dipole |
158 |
|
|
159 |
|
type :: Electrostatic |
160 |
|
integer :: c_ident |
171 |
|
|
172 |
|
type(Electrostatic), dimension(:), allocatable :: ElectrostaticMap |
173 |
|
|
174 |
+ |
logical, save :: hasElectrostaticMap |
175 |
+ |
|
176 |
|
contains |
177 |
|
|
178 |
|
subroutine setElectrostaticSummationMethod(the_ESM) |
183 |
|
endif |
184 |
|
|
185 |
|
summationMethod = the_ESM |
186 |
+ |
|
187 |
|
end subroutine setElectrostaticSummationMethod |
188 |
|
|
189 |
< |
subroutine setElectrostaticCutoffRadius(thisRcut) |
189 |
> |
subroutine setScreeningMethod(the_SM) |
190 |
> |
integer, intent(in) :: the_SM |
191 |
> |
screeningMethod = the_SM |
192 |
> |
end subroutine setScreeningMethod |
193 |
> |
|
194 |
> |
subroutine setElectrostaticCutoffRadius(thisRcut, thisRsw) |
195 |
|
real(kind=dp), intent(in) :: thisRcut |
196 |
+ |
real(kind=dp), intent(in) :: thisRsw |
197 |
|
defaultCutoff = thisRcut |
198 |
+ |
defaultCutoff2 = defaultCutoff*defaultCutoff |
199 |
+ |
rrf = defaultCutoff |
200 |
+ |
rt = thisRsw |
201 |
|
haveDefaultCutoff = .true. |
202 |
|
end subroutine setElectrostaticCutoffRadius |
203 |
|
|
204 |
< |
subroutine setDampedWolfAlpha(thisAlpha) |
204 |
> |
subroutine setDampingAlpha(thisAlpha) |
205 |
|
real(kind=dp), intent(in) :: thisAlpha |
206 |
|
dampingAlpha = thisAlpha |
207 |
+ |
alpha2 = dampingAlpha*dampingAlpha |
208 |
+ |
alpha4 = alpha2*alpha2 |
209 |
+ |
alpha6 = alpha4*alpha2 |
210 |
+ |
alpha8 = alpha4*alpha4 |
211 |
|
haveDampingAlpha = .true. |
212 |
< |
end subroutine setDampedWolfAlpha |
212 |
> |
end subroutine setDampingAlpha |
213 |
|
|
214 |
|
subroutine setReactionFieldDielectric(thisDielectric) |
215 |
|
real(kind=dp), intent(in) :: thisDielectric |
217 |
|
haveDielectric = .true. |
218 |
|
end subroutine setReactionFieldDielectric |
219 |
|
|
220 |
+ |
subroutine buildElectroSpline() |
221 |
+ |
real( kind = dp ), dimension(np) :: xvals, yvals |
222 |
+ |
real( kind = dp ) :: dx, rmin, rval |
223 |
+ |
integer :: i |
224 |
+ |
|
225 |
+ |
rmin = 0.0_dp |
226 |
+ |
|
227 |
+ |
dx = (defaultCutoff-rmin) / dble(np-1) |
228 |
+ |
|
229 |
+ |
do i = 1, np |
230 |
+ |
rval = rmin + dble(i-1)*dx |
231 |
+ |
xvals(i) = rval |
232 |
+ |
yvals(i) = erfc(dampingAlpha*rval) |
233 |
+ |
enddo |
234 |
+ |
|
235 |
+ |
call newSpline(erfcSpline, xvals, yvals, .true.) |
236 |
+ |
|
237 |
+ |
haveElectroSpline = .true. |
238 |
+ |
end subroutine buildElectroSpline |
239 |
+ |
|
240 |
|
subroutine newElectrostaticType(c_ident, is_Charge, is_Dipole, & |
241 |
|
is_SplitDipole, is_Quadrupole, is_Tap, status) |
242 |
|
|
264 |
|
return |
265 |
|
end if |
266 |
|
|
267 |
< |
if (.not. allocated(ElectrostaticMap)) then |
180 |
< |
allocate(ElectrostaticMap(nAtypes)) |
181 |
< |
endif |
267 |
> |
allocate(ElectrostaticMap(nAtypes)) |
268 |
|
|
269 |
|
end if |
270 |
|
|
282 |
|
ElectrostaticMap(myATID)%is_Quadrupole = is_Quadrupole |
283 |
|
ElectrostaticMap(myATID)%is_Tap = is_Tap |
284 |
|
|
285 |
+ |
hasElectrostaticMap = .true. |
286 |
+ |
|
287 |
|
end subroutine newElectrostaticType |
288 |
|
|
289 |
|
subroutine setCharge(c_ident, charge, status) |
295 |
|
status = 0 |
296 |
|
myATID = getFirstMatchingElement(atypes, "c_ident", c_ident) |
297 |
|
|
298 |
< |
if (.not.allocated(ElectrostaticMap)) then |
298 |
> |
if (.not.hasElectrostaticMap) then |
299 |
|
call handleError("electrostatic", "no ElectrostaticMap was present before first call of setCharge!") |
300 |
|
status = -1 |
301 |
|
return |
325 |
|
status = 0 |
326 |
|
myATID = getFirstMatchingElement(atypes, "c_ident", c_ident) |
327 |
|
|
328 |
< |
if (.not.allocated(ElectrostaticMap)) then |
328 |
> |
if (.not.hasElectrostaticMap) then |
329 |
|
call handleError("electrostatic", "no ElectrostaticMap was present before first call of setDipoleMoment!") |
330 |
|
status = -1 |
331 |
|
return |
355 |
|
status = 0 |
356 |
|
myATID = getFirstMatchingElement(atypes, "c_ident", c_ident) |
357 |
|
|
358 |
< |
if (.not.allocated(ElectrostaticMap)) then |
358 |
> |
if (.not.hasElectrostaticMap) then |
359 |
|
call handleError("electrostatic", "no ElectrostaticMap was present before first call of setSplitDipoleDistance!") |
360 |
|
status = -1 |
361 |
|
return |
385 |
|
status = 0 |
386 |
|
myATID = getFirstMatchingElement(atypes, "c_ident", c_ident) |
387 |
|
|
388 |
< |
if (.not.allocated(ElectrostaticMap)) then |
388 |
> |
if (.not.hasElectrostaticMap) then |
389 |
|
call handleError("electrostatic", "no ElectrostaticMap was present before first call of setQuadrupoleMoments!") |
390 |
|
status = -1 |
391 |
|
return |
416 |
|
integer :: localError |
417 |
|
real(kind=dp) :: c |
418 |
|
|
419 |
< |
if (.not.allocated(ElectrostaticMap)) then |
419 |
> |
if (.not.hasElectrostaticMap) then |
420 |
|
call handleError("electrostatic", "no ElectrostaticMap was present before first call of getCharge!") |
421 |
|
return |
422 |
|
end if |
434 |
|
integer :: localError |
435 |
|
real(kind=dp) :: dm |
436 |
|
|
437 |
< |
if (.not.allocated(ElectrostaticMap)) then |
437 |
> |
if (.not.hasElectrostaticMap) then |
438 |
|
call handleError("electrostatic", "no ElectrostaticMap was present before first call of getDipoleMoment!") |
439 |
|
return |
440 |
|
end if |
453 |
|
call handleError("checkSummationMethod", "no Default Cutoff set!") |
454 |
|
endif |
455 |
|
|
456 |
< |
rcuti = 1.0d0 / defaultCutoff |
456 |
> |
rcuti = 1.0_dp / defaultCutoff |
457 |
|
rcuti2 = rcuti*rcuti |
458 |
|
rcuti3 = rcuti2*rcuti |
459 |
|
rcuti4 = rcuti2*rcuti2 |
460 |
|
|
461 |
< |
if (summationMethod .eq. DAMPED_WOLF) then |
462 |
< |
if (.not.haveDWAconstants) then |
463 |
< |
|
376 |
< |
if (.not.haveDampingAlpha) then |
377 |
< |
call handleError("checkSummationMethod", "no Damping Alpha set!") |
378 |
< |
endif |
379 |
< |
|
380 |
< |
if (.not.haveDefaultCutoff) then |
381 |
< |
call handleError("checkSummationMethod", "no Default Cutoff set!") |
382 |
< |
endif |
383 |
< |
|
384 |
< |
constEXP = exp(-dampingAlpha*dampingAlpha*defaultCutoff*defaultCutoff) |
385 |
< |
constERFC = erfc(dampingAlpha*defaultCutoff) |
386 |
< |
|
387 |
< |
haveDWAconstants = .true. |
461 |
> |
if (screeningMethod .eq. DAMPED) then |
462 |
> |
if (.not.haveDampingAlpha) then |
463 |
> |
call handleError("checkSummationMethod", "no Damping Alpha set!") |
464 |
|
endif |
465 |
+ |
|
466 |
+ |
if (.not.haveDefaultCutoff) then |
467 |
+ |
call handleError("checkSummationMethod", "no Default Cutoff set!") |
468 |
+ |
endif |
469 |
+ |
|
470 |
+ |
constEXP = exp(-alpha2*defaultCutoff2) |
471 |
+ |
invRootPi = 0.56418958354775628695_dp |
472 |
+ |
alphaPi = 2.0_dp*dampingAlpha*invRootPi |
473 |
+ |
|
474 |
+ |
c1c = erfc(dampingAlpha*defaultCutoff) * rcuti |
475 |
+ |
c2c = alphaPi*constEXP*rcuti + c1c*rcuti |
476 |
+ |
c3c = 2.0_dp*alphaPi*alpha2 + 3.0_dp*c2c*rcuti |
477 |
+ |
c4c = 4.0_dp*alphaPi*alpha4 + 5.0_dp*c3c*rcuti2 |
478 |
+ |
c5c = 8.0_dp*alphaPi*alpha6 + 7.0_dp*c4c*rcuti2 |
479 |
+ |
c6c = 16.0_dp*alphaPi*alpha8 + 9.0_dp*c5c*rcuti2 |
480 |
+ |
else |
481 |
+ |
c1c = rcuti |
482 |
+ |
c2c = c1c*rcuti |
483 |
+ |
c3c = 3.0_dp*c2c*rcuti |
484 |
+ |
c4c = 5.0_dp*c3c*rcuti2 |
485 |
+ |
c5c = 7.0_dp*c4c*rcuti2 |
486 |
+ |
c6c = 9.0_dp*c5c*rcuti2 |
487 |
|
endif |
488 |
|
|
489 |
|
if (summationMethod .eq. REACTION_FIELD) then |
490 |
< |
if (.not.haveDielectric) then |
491 |
< |
call handleError("checkSummationMethod", "no reaction field Dielectric set!") |
490 |
> |
if (haveDielectric) then |
491 |
> |
defaultCutoff2 = defaultCutoff*defaultCutoff |
492 |
> |
preRF = (dielectric-1.0_dp) / & |
493 |
> |
((2.0_dp*dielectric+1.0_dp)*defaultCutoff2*defaultCutoff) |
494 |
> |
preRF2 = 2.0_dp*preRF |
495 |
> |
else |
496 |
> |
call handleError("checkSummationMethod", "Dielectric not set") |
497 |
|
endif |
498 |
+ |
|
499 |
|
endif |
500 |
|
|
501 |
+ |
if (.not.haveElectroSpline) then |
502 |
+ |
call buildElectroSpline() |
503 |
+ |
end if |
504 |
+ |
|
505 |
|
summationMethodChecked = .true. |
506 |
|
end subroutine checkSummationMethod |
507 |
|
|
508 |
|
|
509 |
< |
|
402 |
< |
subroutine doElectrostaticPair(atom1, atom2, d, rij, r2, sw, & |
509 |
> |
subroutine doElectrostaticPair(atom1, atom2, d, rij, r2, rcut, sw, & |
510 |
|
vpair, fpair, pot, eFrame, f, t, do_pot) |
511 |
|
|
512 |
|
logical, intent(in) :: do_pot |
514 |
|
integer, intent(in) :: atom1, atom2 |
515 |
|
integer :: localError |
516 |
|
|
517 |
< |
real(kind=dp), intent(in) :: rij, r2, sw |
517 |
> |
real(kind=dp), intent(in) :: rij, r2, sw, rcut |
518 |
|
real(kind=dp), intent(in), dimension(3) :: d |
519 |
|
real(kind=dp), intent(inout) :: vpair |
520 |
< |
real(kind=dp), intent(inout), dimension(3) :: fpair |
520 |
> |
real(kind=dp), intent(inout), dimension(3) :: fpair |
521 |
|
|
522 |
< |
real( kind = dp ) :: pot, swi |
522 |
> |
real( kind = dp ) :: pot |
523 |
|
real( kind = dp ), dimension(9,nLocal) :: eFrame |
524 |
|
real( kind = dp ), dimension(3,nLocal) :: f |
525 |
+ |
real( kind = dp ), dimension(3,nLocal) :: felec |
526 |
|
real( kind = dp ), dimension(3,nLocal) :: t |
527 |
|
|
528 |
|
real (kind = dp), dimension(3) :: ux_i, uy_i, uz_i |
540 |
|
real (kind=dp) :: cx_i, cy_i, cz_i |
541 |
|
real (kind=dp) :: cx_j, cy_j, cz_j |
542 |
|
real (kind=dp) :: cx2, cy2, cz2 |
543 |
< |
real (kind=dp) :: ct_i, ct_j, ct_ij, a1 |
543 |
> |
real (kind=dp) :: ct_i, ct_j, ct_ij, a0, a1 |
544 |
|
real (kind=dp) :: riji, ri, ri2, ri3, ri4 |
545 |
|
real (kind=dp) :: pref, vterm, epot, dudr, vterm1, vterm2 |
546 |
|
real (kind=dp) :: xhat, yhat, zhat |
547 |
|
real (kind=dp) :: dudx, dudy, dudz |
548 |
< |
real (kind=dp) :: scale, sc2, bigR, switcher, dswitcher |
548 |
> |
real (kind=dp) :: scale, sc2, bigR |
549 |
> |
real (kind=dp) :: varEXP |
550 |
> |
real (kind=dp) :: pot_term |
551 |
> |
real (kind=dp) :: preVal, rfVal |
552 |
> |
real (kind=dp) :: c2ri, c3ri, c4rij |
553 |
> |
real (kind=dp) :: cti3, ctj3, ctidotj |
554 |
> |
real (kind=dp) :: preSw, preSwSc |
555 |
> |
real (kind=dp) :: xhatdot2, yhatdot2, zhatdot2 |
556 |
> |
real (kind=dp) :: xhatc4, yhatc4, zhatc4 |
557 |
|
|
442 |
– |
if (.not.allocated(ElectrostaticMap)) then |
443 |
– |
call handleError("electrostatic", "no ElectrostaticMap was present before first call of do_electrostatic_pair!") |
444 |
– |
return |
445 |
– |
end if |
446 |
– |
|
558 |
|
if (.not.summationMethodChecked) then |
559 |
|
call checkSummationMethod() |
560 |
|
endif |
561 |
|
|
451 |
– |
|
562 |
|
#ifdef IS_MPI |
563 |
|
me1 = atid_Row(atom1) |
564 |
|
me2 = atid_Col(atom2) |
569 |
|
|
570 |
|
!! some variables we'll need independent of electrostatic type: |
571 |
|
|
572 |
< |
riji = 1.0d0 / rij |
573 |
< |
|
572 |
> |
riji = 1.0_dp / rij |
573 |
> |
|
574 |
|
xhat = d(1) * riji |
575 |
|
yhat = d(2) * riji |
576 |
|
zhat = d(3) * riji |
577 |
|
|
468 |
– |
swi = 1.0d0 / sw |
469 |
– |
|
578 |
|
!! logicals |
579 |
|
i_is_Charge = ElectrostaticMap(me1)%is_Charge |
580 |
|
i_is_Dipole = ElectrostaticMap(me1)%is_Dipole |
608 |
|
if (i_is_SplitDipole) then |
609 |
|
d_i = ElectrostaticMap(me1)%split_dipole_distance |
610 |
|
endif |
611 |
< |
|
611 |
> |
duduz_i = zero |
612 |
|
endif |
613 |
|
|
614 |
|
if (i_is_Quadrupole) then |
639 |
|
cx_i = ux_i(1)*xhat + ux_i(2)*yhat + ux_i(3)*zhat |
640 |
|
cy_i = uy_i(1)*xhat + uy_i(2)*yhat + uy_i(3)*zhat |
641 |
|
cz_i = uz_i(1)*xhat + uz_i(2)*yhat + uz_i(3)*zhat |
642 |
+ |
dudux_i = zero |
643 |
+ |
duduy_i = zero |
644 |
+ |
duduz_i = zero |
645 |
|
endif |
646 |
|
|
647 |
|
if (j_is_Charge) then |
664 |
|
if (j_is_SplitDipole) then |
665 |
|
d_j = ElectrostaticMap(me2)%split_dipole_distance |
666 |
|
endif |
667 |
+ |
duduz_j = zero |
668 |
|
endif |
669 |
|
|
670 |
|
if (j_is_Quadrupole) then |
695 |
|
cx_j = ux_j(1)*xhat + ux_j(2)*yhat + ux_j(3)*zhat |
696 |
|
cy_j = uy_j(1)*xhat + uy_j(2)*yhat + uy_j(3)*zhat |
697 |
|
cz_j = uz_j(1)*xhat + uz_j(2)*yhat + uz_j(3)*zhat |
698 |
+ |
dudux_j = zero |
699 |
+ |
duduy_j = zero |
700 |
+ |
duduz_j = zero |
701 |
|
endif |
702 |
|
|
703 |
< |
!!$ switcher = 1.0d0 |
704 |
< |
!!$ dswitcher = 0.0d0 |
705 |
< |
!!$ ebalance = 0.0d0 |
706 |
< |
!!$ ! weaken the dipole interaction at close range for TAP water |
592 |
< |
!!$ if (j_is_Tap .and. i_is_Tap) then |
593 |
< |
!!$ call calc_switch(rij, mu_i, switcher, dswitcher) |
594 |
< |
!!$ endif |
595 |
< |
|
596 |
< |
epot = 0.0_dp |
597 |
< |
dudx = 0.0_dp |
598 |
< |
dudy = 0.0_dp |
599 |
< |
dudz = 0.0_dp |
703 |
> |
epot = zero |
704 |
> |
dudx = zero |
705 |
> |
dudy = zero |
706 |
> |
dudz = zero |
707 |
|
|
601 |
– |
dudux_i = 0.0_dp |
602 |
– |
duduy_i = 0.0_dp |
603 |
– |
duduz_i = 0.0_dp |
604 |
– |
|
605 |
– |
dudux_j = 0.0_dp |
606 |
– |
duduy_j = 0.0_dp |
607 |
– |
duduz_j = 0.0_dp |
608 |
– |
|
708 |
|
if (i_is_Charge) then |
709 |
|
|
710 |
|
if (j_is_Charge) then |
711 |
+ |
if (screeningMethod .eq. DAMPED) then |
712 |
+ |
! assemble the damping variables |
713 |
+ |
call lookupUniformSpline1d(erfcSpline, rij, erfcVal, derfcVal) |
714 |
+ |
c1 = erfcVal*riji |
715 |
+ |
c2 = (-derfcVal + c1)*riji |
716 |
+ |
else |
717 |
+ |
c1 = riji |
718 |
+ |
c2 = c1*riji |
719 |
+ |
endif |
720 |
|
|
721 |
< |
if (summationMethod .eq. 1) then |
614 |
< |
vterm = pre11 * q_i * q_j * (riji - rcuti) |
721 |
> |
preVal = pre11 * q_i * q_j |
722 |
|
|
723 |
< |
vpair = vpair + vterm |
724 |
< |
epot = epot + sw * vterm |
723 |
> |
if (summationMethod .eq. SHIFTED_POTENTIAL) then |
724 |
> |
vterm = preVal * (c1 - c1c) |
725 |
|
|
726 |
< |
dudr = - sw * pre11 * q_i * q_j * (riji*riji*riji - rcuti2*rcuti) |
726 |
> |
dudr = -sw * preVal * c2 |
727 |
> |
|
728 |
> |
elseif (summationMethod .eq. SHIFTED_FORCE) then |
729 |
> |
vterm = preVal * ( c1 - c1c + c2c*(rij - defaultCutoff) ) |
730 |
|
|
731 |
< |
dudx = dudx + dudr * d(1) |
732 |
< |
dudy = dudy + dudr * d(2) |
733 |
< |
dudz = dudz + dudr * d(3) |
734 |
< |
|
731 |
> |
dudr = sw * preVal * (c2c - c2) |
732 |
> |
|
733 |
> |
elseif (summationMethod .eq. REACTION_FIELD) then |
734 |
> |
rfVal = preRF*rij*rij |
735 |
> |
vterm = preVal * ( riji + rfVal ) |
736 |
> |
|
737 |
> |
dudr = sw * preVal * ( 2.0_dp*rfVal - riji )*riji |
738 |
> |
|
739 |
|
else |
740 |
< |
vterm = pre11 * q_i * q_j * riji |
627 |
< |
|
628 |
< |
vpair = vpair + vterm |
629 |
< |
epot = epot + sw * vterm |
740 |
> |
vterm = preVal * riji*erfcVal |
741 |
|
|
742 |
< |
dudr = - sw * vterm * riji |
743 |
< |
|
633 |
< |
dudx = dudx + dudr * xhat |
634 |
< |
dudy = dudy + dudr * yhat |
635 |
< |
dudz = dudz + dudr * zhat |
636 |
< |
|
742 |
> |
dudr = - sw * preVal * c2 |
743 |
> |
|
744 |
|
endif |
745 |
|
|
746 |
+ |
vpair = vpair + vterm |
747 |
+ |
epot = epot + sw*vterm |
748 |
+ |
|
749 |
+ |
dudx = dudx + dudr * xhat |
750 |
+ |
dudy = dudy + dudr * yhat |
751 |
+ |
dudz = dudz + dudr * zhat |
752 |
+ |
|
753 |
|
endif |
754 |
|
|
755 |
|
if (j_is_Dipole) then |
756 |
< |
|
757 |
< |
pref = sw * pre12 * q_i * mu_j |
756 |
> |
! pref is used by all the possible methods |
757 |
> |
pref = pre12 * q_i * mu_j |
758 |
> |
preSw = sw*pref |
759 |
|
|
760 |
< |
if (summationMethod .eq. 1) then |
760 |
> |
if (summationMethod .eq. REACTION_FIELD) then |
761 |
|
ri2 = riji * riji |
762 |
|
ri3 = ri2 * riji |
763 |
< |
|
764 |
< |
vterm = - pref * ct_j * (ri2 - rcuti2) |
765 |
< |
vpair = vpair + swi*vterm |
766 |
< |
epot = epot + vterm |
763 |
> |
|
764 |
> |
vterm = - pref * ct_j * ( ri2 - preRF2*rij ) |
765 |
> |
vpair = vpair + vterm |
766 |
> |
epot = epot + sw*vterm |
767 |
|
|
768 |
< |
!! this has a + sign in the () because the rij vector is |
769 |
< |
!! r_j - r_i and the charge-dipole potential takes the origin |
770 |
< |
!! as the point dipole, which is atom j in this case. |
771 |
< |
|
772 |
< |
dudx = dudx - pref * ( ri3*( uz_j(1) - 3.0d0*ct_j*xhat) & |
773 |
< |
- rcuti3*( uz_j(1) - 3.0d0*ct_j*d(1)*rcuti ) ) |
774 |
< |
dudy = dudy - pref * ( ri3*( uz_j(2) - 3.0d0*ct_j*yhat) & |
775 |
< |
- rcuti3*( uz_j(2) - 3.0d0*ct_j*d(2)*rcuti ) ) |
776 |
< |
dudz = dudz - pref * ( ri3*( uz_j(3) - 3.0d0*ct_j*zhat) & |
662 |
< |
- rcuti3*( uz_j(3) - 3.0d0*ct_j*d(3)*rcuti ) ) |
663 |
< |
|
664 |
< |
duduz_j(1) = duduz_j(1) - pref*( ri2*xhat - d(1)*rcuti3 ) |
665 |
< |
duduz_j(2) = duduz_j(2) - pref*( ri2*yhat - d(2)*rcuti3 ) |
666 |
< |
duduz_j(3) = duduz_j(3) - pref*( ri2*zhat - d(3)*rcuti3 ) |
768 |
> |
dudx = dudx - preSw*( ri3*(uz_j(1) - 3.0_dp*ct_j*xhat) - & |
769 |
> |
preRF2*uz_j(1) ) |
770 |
> |
dudy = dudy - preSw*( ri3*(uz_j(2) - 3.0_dp*ct_j*yhat) - & |
771 |
> |
preRF2*uz_j(2) ) |
772 |
> |
dudz = dudz - preSw*( ri3*(uz_j(3) - 3.0_dp*ct_j*zhat) - & |
773 |
> |
preRF2*uz_j(3) ) |
774 |
> |
duduz_j(1) = duduz_j(1) - preSw * xhat * ( ri2 - preRF2*rij ) |
775 |
> |
duduz_j(2) = duduz_j(2) - preSw * yhat * ( ri2 - preRF2*rij ) |
776 |
> |
duduz_j(3) = duduz_j(3) - preSw * zhat * ( ri2 - preRF2*rij ) |
777 |
|
|
778 |
|
else |
779 |
+ |
! determine the inverse r used if we have split dipoles |
780 |
|
if (j_is_SplitDipole) then |
781 |
|
BigR = sqrt(r2 + 0.25_dp * d_j * d_j) |
782 |
|
ri = 1.0_dp / BigR |
785 |
|
ri = riji |
786 |
|
scale = 1.0_dp |
787 |
|
endif |
788 |
< |
|
678 |
< |
ri2 = ri * ri |
679 |
< |
ri3 = ri2 * ri |
788 |
> |
|
789 |
|
sc2 = scale * scale |
790 |
+ |
|
791 |
+ |
if (screeningMethod .eq. DAMPED) then |
792 |
+ |
! assemble the damping variables |
793 |
+ |
call lookupUniformSpline1d(erfcSpline, rij, erfcVal, derfcVal) |
794 |
+ |
c1 = erfcVal*ri |
795 |
+ |
c2 = (-derfcVal + c1)*ri |
796 |
+ |
c3 = -2.0_dp*derfcVal*alpha2 + 3.0_dp*c2*ri |
797 |
+ |
else |
798 |
+ |
c1 = ri |
799 |
+ |
c2 = c1*ri |
800 |
+ |
c3 = 3.0_dp*c2*ri |
801 |
+ |
endif |
802 |
|
|
803 |
< |
vterm = - pref * ct_j * ri2 * scale |
804 |
< |
vpair = vpair + swi * vterm |
805 |
< |
epot = epot + vterm |
803 |
> |
c2ri = c2*ri |
804 |
> |
|
805 |
> |
! calculate the potential |
806 |
> |
pot_term = scale * c2 |
807 |
> |
vterm = -pref * ct_j * pot_term |
808 |
> |
vpair = vpair + vterm |
809 |
> |
epot = epot + sw*vterm |
810 |
|
|
811 |
< |
!! this has a + sign in the () because the rij vector is |
812 |
< |
!! r_j - r_i and the charge-dipole potential takes the origin |
813 |
< |
!! as the point dipole, which is atom j in this case. |
814 |
< |
|
815 |
< |
dudx = dudx - pref * ri3 * ( uz_j(1) - 3.0d0*ct_j*xhat*sc2) |
816 |
< |
dudy = dudy - pref * ri3 * ( uz_j(2) - 3.0d0*ct_j*yhat*sc2) |
817 |
< |
dudz = dudz - pref * ri3 * ( uz_j(3) - 3.0d0*ct_j*zhat*sc2) |
818 |
< |
|
694 |
< |
duduz_j(1) = duduz_j(1) - pref * ri2 * xhat * scale |
695 |
< |
duduz_j(2) = duduz_j(2) - pref * ri2 * yhat * scale |
696 |
< |
duduz_j(3) = duduz_j(3) - pref * ri2 * zhat * scale |
811 |
> |
! calculate derivatives for forces and torques |
812 |
> |
dudx = dudx - preSw*( uz_j(1)*c2ri - ct_j*xhat*sc2*c3 ) |
813 |
> |
dudy = dudy - preSw*( uz_j(2)*c2ri - ct_j*yhat*sc2*c3 ) |
814 |
> |
dudz = dudz - preSw*( uz_j(3)*c2ri - ct_j*zhat*sc2*c3 ) |
815 |
> |
|
816 |
> |
duduz_j(1) = duduz_j(1) - preSw * pot_term * xhat |
817 |
> |
duduz_j(2) = duduz_j(2) - preSw * pot_term * yhat |
818 |
> |
duduz_j(3) = duduz_j(3) - preSw * pot_term * zhat |
819 |
|
|
820 |
|
endif |
821 |
|
endif |
822 |
|
|
823 |
|
if (j_is_Quadrupole) then |
824 |
< |
ri2 = riji * riji |
703 |
< |
ri3 = ri2 * riji |
704 |
< |
ri4 = ri2 * ri2 |
824 |
> |
! first precalculate some necessary variables |
825 |
|
cx2 = cx_j * cx_j |
826 |
|
cy2 = cy_j * cy_j |
827 |
|
cz2 = cz_j * cz_j |
828 |
+ |
pref = pre14 * q_i * one_third |
829 |
+ |
|
830 |
+ |
if (screeningMethod .eq. DAMPED) then |
831 |
+ |
! assemble the damping variables |
832 |
+ |
call lookupUniformSpline1d(erfcSpline, rij, erfcVal, derfcVal) |
833 |
+ |
c1 = erfcVal*riji |
834 |
+ |
c2 = (-derfcVal + c1)*riji |
835 |
+ |
c3 = -2.0_dp*derfcVal*alpha2 + 3.0_dp*c2*riji |
836 |
+ |
c4 = -4.0_dp*derfcVal*alpha4 + 5.0_dp*c3*riji*riji |
837 |
+ |
else |
838 |
+ |
c1 = riji |
839 |
+ |
c2 = c1*riji |
840 |
+ |
c3 = 3.0_dp*c2*riji |
841 |
+ |
c4 = 5.0_dp*c3*riji*riji |
842 |
+ |
endif |
843 |
|
|
844 |
+ |
! precompute variables for convenience |
845 |
+ |
preSw = sw*pref |
846 |
+ |
c2ri = c2*riji |
847 |
+ |
c3ri = c3*riji |
848 |
+ |
c4rij = c4*rij |
849 |
+ |
xhatdot2 = 2.0_dp*xhat*c3 |
850 |
+ |
yhatdot2 = 2.0_dp*yhat*c3 |
851 |
+ |
zhatdot2 = 2.0_dp*zhat*c3 |
852 |
+ |
xhatc4 = xhat*c4rij |
853 |
+ |
yhatc4 = yhat*c4rij |
854 |
+ |
zhatc4 = zhat*c4rij |
855 |
|
|
856 |
< |
pref = sw * pre14 * q_i / 3.0_dp |
856 |
> |
! calculate the potential |
857 |
> |
pot_term = ( qxx_j*(cx2*c3 - c2ri) + qyy_j*(cy2*c3 - c2ri) + & |
858 |
> |
qzz_j*(cz2*c3 - c2ri) ) |
859 |
> |
vterm = pref * pot_term |
860 |
> |
vpair = vpair + vterm |
861 |
> |
epot = epot + sw*vterm |
862 |
|
|
863 |
< |
if (summationMethod .eq. 1) then |
864 |
< |
vterm1 = pref * ri3*( qxx_j * (3.0_dp*cx2 - 1.0_dp) + & |
865 |
< |
qyy_j * (3.0_dp*cy2 - 1.0_dp) + & |
866 |
< |
qzz_j * (3.0_dp*cz2 - 1.0_dp) ) |
867 |
< |
vterm2 = pref * rcuti3*( qxx_j * (3.0_dp*cx2 - 1.0_dp) + & |
868 |
< |
qyy_j * (3.0_dp*cy2 - 1.0_dp) + & |
869 |
< |
qzz_j * (3.0_dp*cz2 - 1.0_dp) ) |
870 |
< |
vpair = vpair + swi*( vterm1 - vterm2 ) |
871 |
< |
epot = epot + ( vterm1 - vterm2 ) |
872 |
< |
|
873 |
< |
dudx = dudx - (5.0_dp * & |
874 |
< |
(vterm1*riji*xhat - vterm2*rcuti2*d(1))) + pref * ( & |
875 |
< |
(ri4 - rcuti4)*(qxx_j*(6.0_dp*cx_j*ux_j(1)) - & |
725 |
< |
qxx_j*2.0_dp*(xhat - rcuti*d(1))) + & |
726 |
< |
(ri4 - rcuti4)*(qyy_j*(6.0_dp*cy_j*uy_j(1)) - & |
727 |
< |
qyy_j*2.0_dp*(xhat - rcuti*d(1))) + & |
728 |
< |
(ri4 - rcuti4)*(qzz_j*(6.0_dp*cz_j*uz_j(1)) - & |
729 |
< |
qzz_j*2.0_dp*(xhat - rcuti*d(1))) ) |
730 |
< |
dudy = dudy - (5.0_dp * & |
731 |
< |
(vterm1*riji*yhat - vterm2*rcuti2*d(2))) + pref * ( & |
732 |
< |
(ri4 - rcuti4)*(qxx_j*(6.0_dp*cx_j*ux_j(2)) - & |
733 |
< |
qxx_j*2.0_dp*(yhat - rcuti*d(2))) + & |
734 |
< |
(ri4 - rcuti4)*(qyy_j*(6.0_dp*cy_j*uy_j(2)) - & |
735 |
< |
qyy_j*2.0_dp*(yhat - rcuti*d(2))) + & |
736 |
< |
(ri4 - rcuti4)*(qzz_j*(6.0_dp*cz_j*uz_j(2)) - & |
737 |
< |
qzz_j*2.0_dp*(yhat - rcuti*d(2))) ) |
738 |
< |
dudz = dudz - (5.0_dp * & |
739 |
< |
(vterm1*riji*zhat - vterm2*rcuti2*d(3))) + pref * ( & |
740 |
< |
(ri4 - rcuti4)*(qxx_j*(6.0_dp*cx_j*ux_j(3)) - & |
741 |
< |
qxx_j*2.0_dp*(zhat - rcuti*d(3))) + & |
742 |
< |
(ri4 - rcuti4)*(qyy_j*(6.0_dp*cy_j*uy_j(3)) - & |
743 |
< |
qyy_j*2.0_dp*(zhat - rcuti*d(3))) + & |
744 |
< |
(ri4 - rcuti4)*(qzz_j*(6.0_dp*cz_j*uz_j(3)) - & |
745 |
< |
qzz_j*2.0_dp*(zhat - rcuti*d(3))) ) |
746 |
< |
|
747 |
< |
dudux_j(1) = dudux_j(1) + pref * (ri3*(qxx_j*6.0_dp*cx_j*xhat) - & |
748 |
< |
rcuti4*(qxx_j*6.0_dp*cx_j*d(1))) |
749 |
< |
dudux_j(2) = dudux_j(2) + pref * (ri3*(qxx_j*6.0_dp*cx_j*yhat) - & |
750 |
< |
rcuti4*(qxx_j*6.0_dp*cx_j*d(2))) |
751 |
< |
dudux_j(3) = dudux_j(3) + pref * (ri3*(qxx_j*6.0_dp*cx_j*zhat) - & |
752 |
< |
rcuti4*(qxx_j*6.0_dp*cx_j*d(3))) |
753 |
< |
|
754 |
< |
duduy_j(1) = duduy_j(1) + pref * (ri3*(qyy_j*6.0_dp*cy_j*xhat) - & |
755 |
< |
rcuti4*(qyy_j*6.0_dp*cx_j*d(1))) |
756 |
< |
duduy_j(2) = duduy_j(2) + pref * (ri3*(qyy_j*6.0_dp*cy_j*yhat) - & |
757 |
< |
rcuti4*(qyy_j*6.0_dp*cx_j*d(2))) |
758 |
< |
duduy_j(3) = duduy_j(3) + pref * (ri3*(qyy_j*6.0_dp*cy_j*zhat) - & |
759 |
< |
rcuti4*(qyy_j*6.0_dp*cx_j*d(3))) |
760 |
< |
|
761 |
< |
duduz_j(1) = duduz_j(1) + pref * (ri3*(qzz_j*6.0_dp*cz_j*xhat) - & |
762 |
< |
rcuti4*(qzz_j*6.0_dp*cx_j*d(1))) |
763 |
< |
duduz_j(2) = duduz_j(2) + pref * (ri3*(qzz_j*6.0_dp*cz_j*yhat) - & |
764 |
< |
rcuti4*(qzz_j*6.0_dp*cx_j*d(2))) |
765 |
< |
duduz_j(3) = duduz_j(3) + pref * (ri3*(qzz_j*6.0_dp*cz_j*zhat) - & |
766 |
< |
rcuti4*(qzz_j*6.0_dp*cx_j*d(3))) |
767 |
< |
|
768 |
< |
else |
769 |
< |
vterm = pref * ri3 * (qxx_j * (3.0_dp*cx2 - 1.0_dp) + & |
770 |
< |
qyy_j * (3.0_dp*cy2 - 1.0_dp) + & |
771 |
< |
qzz_j * (3.0_dp*cz2 - 1.0_dp)) |
772 |
< |
vpair = vpair + swi * vterm |
773 |
< |
epot = epot + vterm |
774 |
< |
|
775 |
< |
dudx = dudx - 5.0_dp*vterm*riji*xhat + pref * ri4 * ( & |
776 |
< |
qxx_j*(6.0_dp*cx_j*ux_j(1) - 2.0_dp*xhat) + & |
777 |
< |
qyy_j*(6.0_dp*cy_j*uy_j(1) - 2.0_dp*xhat) + & |
778 |
< |
qzz_j*(6.0_dp*cz_j*uz_j(1) - 2.0_dp*xhat) ) |
779 |
< |
dudy = dudy - 5.0_dp*vterm*riji*yhat + pref * ri4 * ( & |
780 |
< |
qxx_j*(6.0_dp*cx_j*ux_j(2) - 2.0_dp*yhat) + & |
781 |
< |
qyy_j*(6.0_dp*cy_j*uy_j(2) - 2.0_dp*yhat) + & |
782 |
< |
qzz_j*(6.0_dp*cz_j*uz_j(2) - 2.0_dp*yhat) ) |
783 |
< |
dudz = dudz - 5.0_dp*vterm*riji*zhat + pref * ri4 * ( & |
784 |
< |
qxx_j*(6.0_dp*cx_j*ux_j(3) - 2.0_dp*zhat) + & |
785 |
< |
qyy_j*(6.0_dp*cy_j*uy_j(3) - 2.0_dp*zhat) + & |
786 |
< |
qzz_j*(6.0_dp*cz_j*uz_j(3) - 2.0_dp*zhat) ) |
787 |
< |
|
788 |
< |
dudux_j(1) = dudux_j(1) + pref * ri3*(qxx_j*6.0_dp*cx_j*xhat) |
789 |
< |
dudux_j(2) = dudux_j(2) + pref * ri3*(qxx_j*6.0_dp*cx_j*yhat) |
790 |
< |
dudux_j(3) = dudux_j(3) + pref * ri3*(qxx_j*6.0_dp*cx_j*zhat) |
791 |
< |
|
792 |
< |
duduy_j(1) = duduy_j(1) + pref * ri3*(qyy_j*6.0_dp*cy_j*xhat) |
793 |
< |
duduy_j(2) = duduy_j(2) + pref * ri3*(qyy_j*6.0_dp*cy_j*yhat) |
794 |
< |
duduy_j(3) = duduy_j(3) + pref * ri3*(qyy_j*6.0_dp*cy_j*zhat) |
795 |
< |
|
796 |
< |
duduz_j(1) = duduz_j(1) + pref * ri3*(qzz_j*6.0_dp*cz_j*xhat) |
797 |
< |
duduz_j(2) = duduz_j(2) + pref * ri3*(qzz_j*6.0_dp*cz_j*yhat) |
798 |
< |
duduz_j(3) = duduz_j(3) + pref * ri3*(qzz_j*6.0_dp*cz_j*zhat) |
863 |
> |
! calculate derivatives for the forces and torques |
864 |
> |
dudx = dudx - preSw * ( & |
865 |
> |
qxx_j*(cx2*xhatc4 - (2.0_dp*cx_j*ux_j(1) + xhat)*c3ri) + & |
866 |
> |
qyy_j*(cy2*xhatc4 - (2.0_dp*cy_j*uy_j(1) + xhat)*c3ri) + & |
867 |
> |
qzz_j*(cz2*xhatc4 - (2.0_dp*cz_j*uz_j(1) + xhat)*c3ri) ) |
868 |
> |
dudy = dudy - preSw * ( & |
869 |
> |
qxx_j*(cx2*yhatc4 - (2.0_dp*cx_j*ux_j(2) + yhat)*c3ri) + & |
870 |
> |
qyy_j*(cy2*yhatc4 - (2.0_dp*cy_j*uy_j(2) + yhat)*c3ri) + & |
871 |
> |
qzz_j*(cz2*yhatc4 - (2.0_dp*cz_j*uz_j(2) + yhat)*c3ri) ) |
872 |
> |
dudz = dudz - preSw * ( & |
873 |
> |
qxx_j*(cx2*zhatc4 - (2.0_dp*cx_j*ux_j(3) + zhat)*c3ri) + & |
874 |
> |
qyy_j*(cy2*zhatc4 - (2.0_dp*cy_j*uy_j(3) + zhat)*c3ri) + & |
875 |
> |
qzz_j*(cz2*zhatc4 - (2.0_dp*cz_j*uz_j(3) + zhat)*c3ri) ) |
876 |
|
|
877 |
< |
endif |
877 |
> |
dudux_j(1) = dudux_j(1) + preSw*(qxx_j*cx_j*xhatdot2) |
878 |
> |
dudux_j(2) = dudux_j(2) + preSw*(qxx_j*cx_j*yhatdot2) |
879 |
> |
dudux_j(3) = dudux_j(3) + preSw*(qxx_j*cx_j*zhatdot2) |
880 |
> |
|
881 |
> |
duduy_j(1) = duduy_j(1) + preSw*(qyy_j*cy_j*xhatdot2) |
882 |
> |
duduy_j(2) = duduy_j(2) + preSw*(qyy_j*cy_j*yhatdot2) |
883 |
> |
duduy_j(3) = duduy_j(3) + preSw*(qyy_j*cy_j*zhatdot2) |
884 |
> |
|
885 |
> |
duduz_j(1) = duduz_j(1) + preSw*(qzz_j*cz_j*xhatdot2) |
886 |
> |
duduz_j(2) = duduz_j(2) + preSw*(qzz_j*cz_j*yhatdot2) |
887 |
> |
duduz_j(3) = duduz_j(3) + preSw*(qzz_j*cz_j*zhatdot2) |
888 |
> |
|
889 |
> |
|
890 |
|
endif |
891 |
|
endif |
892 |
< |
|
892 |
> |
|
893 |
|
if (i_is_Dipole) then |
894 |
|
|
895 |
|
if (j_is_Charge) then |
896 |
+ |
! variables used by all the methods |
897 |
+ |
pref = pre12 * q_j * mu_i |
898 |
+ |
preSw = sw*pref |
899 |
|
|
900 |
< |
pref = sw * pre12 * q_j * mu_i |
900 |
> |
if (summationMethod .eq. REACTION_FIELD) then |
901 |
|
|
810 |
– |
if (summationMethod .eq. 1) then |
902 |
|
ri2 = riji * riji |
903 |
|
ri3 = ri2 * riji |
904 |
|
|
905 |
< |
vterm = pref * ct_i * (ri2 - rcuti2) |
906 |
< |
vpair = vpair + swi * vterm |
907 |
< |
epot = epot + vterm |
905 |
> |
vterm = pref * ct_i * ( ri2 - preRF2*rij ) |
906 |
> |
vpair = vpair + vterm |
907 |
> |
epot = epot + sw*vterm |
908 |
|
|
909 |
< |
!! this has a + sign in the () because the rij vector is |
910 |
< |
!! r_j - r_i and the charge-dipole potential takes the origin |
911 |
< |
!! as the point dipole, which is atom j in this case. |
909 |
> |
dudx = dudx + preSw * ( ri3*(uz_i(1) - 3.0_dp*ct_i*xhat) - & |
910 |
> |
preRF2*uz_i(1) ) |
911 |
> |
dudy = dudy + preSw * ( ri3*(uz_i(2) - 3.0_dp*ct_i*yhat) - & |
912 |
> |
preRF2*uz_i(2) ) |
913 |
> |
dudz = dudz + preSw * ( ri3*(uz_i(3) - 3.0_dp*ct_i*zhat) - & |
914 |
> |
preRF2*uz_i(3) ) |
915 |
|
|
916 |
< |
dudx = dudx + pref * ( ri3*( uz_i(1) - 3.0d0*ct_i*xhat) & |
917 |
< |
- rcuti3*( uz_i(1) - 3.0d0*ct_i*d(1)*rcuti ) ) |
918 |
< |
dudy = dudy + pref * ( ri3*( uz_i(2) - 3.0d0*ct_i*yhat) & |
825 |
< |
- rcuti3*( uz_i(2) - 3.0d0*ct_i*d(2)*rcuti ) ) |
826 |
< |
dudz = dudz + pref * ( ri3*( uz_i(3) - 3.0d0*ct_i*zhat) & |
827 |
< |
- rcuti3*( uz_i(3) - 3.0d0*ct_i*d(3)*rcuti ) ) |
828 |
< |
|
829 |
< |
duduz_i(1) = duduz_i(1) - pref*( ri2*xhat - d(1)*rcuti3 ) |
830 |
< |
duduz_i(2) = duduz_i(2) - pref*( ri2*yhat - d(2)*rcuti3 ) |
831 |
< |
duduz_i(3) = duduz_i(3) - pref*( ri2*zhat - d(3)*rcuti3 ) |
916 |
> |
duduz_i(1) = duduz_i(1) + preSw * xhat * ( ri2 - preRF2*rij ) |
917 |
> |
duduz_i(2) = duduz_i(2) + preSw * yhat * ( ri2 - preRF2*rij ) |
918 |
> |
duduz_i(3) = duduz_i(3) + preSw * zhat * ( ri2 - preRF2*rij ) |
919 |
|
|
920 |
|
else |
921 |
+ |
! determine inverse r if we are using split dipoles |
922 |
|
if (i_is_SplitDipole) then |
923 |
|
BigR = sqrt(r2 + 0.25_dp * d_i * d_i) |
924 |
|
ri = 1.0_dp / BigR |
927 |
|
ri = riji |
928 |
|
scale = 1.0_dp |
929 |
|
endif |
930 |
< |
|
843 |
< |
ri2 = ri * ri |
844 |
< |
ri3 = ri2 * ri |
930 |
> |
|
931 |
|
sc2 = scale * scale |
932 |
< |
|
933 |
< |
vterm = pref * ct_i * ri2 * scale |
934 |
< |
vpair = vpair + swi * vterm |
935 |
< |
epot = epot + vterm |
936 |
< |
|
937 |
< |
dudx = dudx + pref * ri3 * ( uz_i(1) - 3.0d0 * ct_i * xhat*sc2) |
938 |
< |
dudy = dudy + pref * ri3 * ( uz_i(2) - 3.0d0 * ct_i * yhat*sc2) |
939 |
< |
dudz = dudz + pref * ri3 * ( uz_i(3) - 3.0d0 * ct_i * zhat*sc2) |
932 |
> |
|
933 |
> |
if (screeningMethod .eq. DAMPED) then |
934 |
> |
! assemble the damping variables |
935 |
> |
call lookupUniformSpline1d(erfcSpline, rij, erfcVal, derfcVal) |
936 |
> |
c1 = erfcVal*ri |
937 |
> |
c2 = (-derfcVal + c1)*ri |
938 |
> |
c3 = -2.0_dp*derfcVal*alpha2 + 3.0_dp*c2*ri |
939 |
> |
else |
940 |
> |
c1 = ri |
941 |
> |
c2 = c1*ri |
942 |
> |
c3 = 3.0_dp*c2*ri |
943 |
> |
endif |
944 |
> |
|
945 |
> |
c2ri = c2*ri |
946 |
> |
|
947 |
> |
! calculate the potential |
948 |
> |
pot_term = c2 * scale |
949 |
> |
vterm = pref * ct_i * pot_term |
950 |
> |
vpair = vpair + vterm |
951 |
> |
epot = epot + sw*vterm |
952 |
> |
|
953 |
> |
! calculate derivatives for the forces and torques |
954 |
> |
dudx = dudx + preSw * ( uz_i(1)*c2ri - ct_i*xhat*sc2*c3 ) |
955 |
> |
dudy = dudy + preSw * ( uz_i(2)*c2ri - ct_i*yhat*sc2*c3 ) |
956 |
> |
dudz = dudz + preSw * ( uz_i(3)*c2ri - ct_i*zhat*sc2*c3 ) |
957 |
> |
|
958 |
> |
duduz_i(1) = duduz_i(1) + preSw * pot_term * xhat |
959 |
> |
duduz_i(2) = duduz_i(2) + preSw * pot_term * yhat |
960 |
> |
duduz_i(3) = duduz_i(3) + preSw * pot_term * zhat |
961 |
|
|
855 |
– |
duduz_i(1) = duduz_i(1) + pref * ri2 * xhat * scale |
856 |
– |
duduz_i(2) = duduz_i(2) + pref * ri2 * yhat * scale |
857 |
– |
duduz_i(3) = duduz_i(3) + pref * ri2 * zhat * scale |
962 |
|
endif |
963 |
|
endif |
964 |
< |
|
964 |
> |
|
965 |
|
if (j_is_Dipole) then |
966 |
+ |
! variables used by all methods |
967 |
+ |
ct_ij = uz_i(1)*uz_j(1) + uz_i(2)*uz_j(2) + uz_i(3)*uz_j(3) |
968 |
+ |
pref = pre22 * mu_i * mu_j |
969 |
+ |
preSw = sw*pref |
970 |
|
|
971 |
< |
pref = sw * pre22 * mu_i * mu_j |
864 |
< |
|
865 |
< |
if (summationMethod .eq. 1) then |
971 |
> |
if (summationMethod .eq. REACTION_FIELD) then |
972 |
|
ri2 = riji * riji |
973 |
|
ri3 = ri2 * riji |
974 |
|
ri4 = ri2 * ri2 |
975 |
|
|
976 |
< |
vterm = pref * (ri3 - rcuti3) * (ct_ij - 3.0d0 * ct_i * ct_j) |
977 |
< |
vpair = vpair + swi * vterm |
978 |
< |
epot = epot + vterm |
976 |
> |
vterm = pref*( ri3*(ct_ij - 3.0_dp * ct_i * ct_j) - & |
977 |
> |
preRF2*ct_ij ) |
978 |
> |
vpair = vpair + vterm |
979 |
> |
epot = epot + sw*vterm |
980 |
|
|
981 |
< |
a1 = 5.0d0 * ct_i * ct_j - ct_ij |
981 |
> |
a1 = 5.0_dp * ct_i * ct_j - ct_ij |
982 |
|
|
983 |
< |
dudx = dudx + pref*3.0d0*ri4 & |
984 |
< |
*(a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1)) - & |
985 |
< |
pref*3.0d0*rcuti4*(a1*rcuti*d(1)-ct_i*uz_j(1)-ct_j*uz_i(1)) |
879 |
< |
dudy = dudy + pref*3.0d0*ri4 & |
880 |
< |
*(a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2)) - & |
881 |
< |
pref*3.0d0*rcuti4*(a1*rcuti*d(2)-ct_i*uz_j(2)-ct_j*uz_i(2)) |
882 |
< |
dudz = dudz + pref*3.0d0*ri4 & |
883 |
< |
*(a1*zhat-ct_i*uz_j(3)-ct_j*uz_i(3)) - & |
884 |
< |
pref*3.0d0*rcuti4*(a1*rcuti*d(3)-ct_i*uz_j(3)-ct_j*uz_i(3)) |
983 |
> |
dudx = dudx + preSw*3.0_dp*ri4*(a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1)) |
984 |
> |
dudy = dudy + preSw*3.0_dp*ri4*(a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2)) |
985 |
> |
dudz = dudz + preSw*3.0_dp*ri4*(a1*zhat-ct_i*uz_j(3)-ct_j*uz_i(3)) |
986 |
|
|
987 |
< |
duduz_i(1) = duduz_i(1) + pref*(ri3*(uz_j(1) - 3.0d0*ct_j*xhat) & |
988 |
< |
- rcuti3*(uz_j(1) - 3.0d0*ct_j*d(1)*rcuti)) |
989 |
< |
duduz_i(2) = duduz_i(2) + pref*(ri3*(uz_j(2) - 3.0d0*ct_j*yhat) & |
990 |
< |
- rcuti3*(uz_j(2) - 3.0d0*ct_j*d(2)*rcuti)) |
991 |
< |
duduz_i(3) = duduz_i(3) + pref*(ri3*(uz_j(3) - 3.0d0*ct_j*zhat) & |
992 |
< |
- rcuti3*(uz_j(3) - 3.0d0*ct_j*d(3)*rcuti)) |
993 |
< |
duduz_j(1) = duduz_j(1) + pref*(ri3*(uz_i(1) - 3.0d0*ct_i*xhat) & |
994 |
< |
- rcuti3*(uz_i(1) - 3.0d0*ct_i*d(1)*rcuti)) |
995 |
< |
duduz_j(2) = duduz_j(2) + pref*(ri3*(uz_i(2) - 3.0d0*ct_i*yhat) & |
996 |
< |
- rcuti3*(uz_i(2) - 3.0d0*ct_i*d(2)*rcuti)) |
997 |
< |
duduz_j(3) = duduz_j(3) + pref*(ri3*(uz_i(3) - 3.0d0*ct_i*zhat) & |
998 |
< |
- rcuti3*(uz_i(3) - 3.0d0*ct_i*d(3)*rcuti)) |
987 |
> |
duduz_i(1) = duduz_i(1) + preSw*(ri3*(uz_j(1)-3.0_dp*ct_j*xhat) & |
988 |
> |
- preRF2*uz_j(1)) |
989 |
> |
duduz_i(2) = duduz_i(2) + preSw*(ri3*(uz_j(2)-3.0_dp*ct_j*yhat) & |
990 |
> |
- preRF2*uz_j(2)) |
991 |
> |
duduz_i(3) = duduz_i(3) + preSw*(ri3*(uz_j(3)-3.0_dp*ct_j*zhat) & |
992 |
> |
- preRF2*uz_j(3)) |
993 |
> |
duduz_j(1) = duduz_j(1) + preSw*(ri3*(uz_i(1)-3.0_dp*ct_i*xhat) & |
994 |
> |
- preRF2*uz_i(1)) |
995 |
> |
duduz_j(2) = duduz_j(2) + preSw*(ri3*(uz_i(2)-3.0_dp*ct_i*yhat) & |
996 |
> |
- preRF2*uz_i(2)) |
997 |
> |
duduz_j(3) = duduz_j(3) + preSw*(ri3*(uz_i(3)-3.0_dp*ct_i*zhat) & |
998 |
> |
- preRF2*uz_i(3)) |
999 |
> |
|
1000 |
|
else |
899 |
– |
|
1001 |
|
if (i_is_SplitDipole) then |
1002 |
|
if (j_is_SplitDipole) then |
1003 |
|
BigR = sqrt(r2 + 0.25_dp * d_i * d_i + 0.25_dp * d_j * d_j) |
1016 |
|
scale = 1.0_dp |
1017 |
|
endif |
1018 |
|
endif |
1019 |
< |
|
1020 |
< |
ct_ij = uz_i(1)*uz_j(1) + uz_i(2)*uz_j(2) + uz_i(3)*uz_j(3) |
1021 |
< |
|
1022 |
< |
ri2 = ri * ri |
1023 |
< |
ri3 = ri2 * ri |
1024 |
< |
ri4 = ri2 * ri2 |
1019 |
> |
|
1020 |
> |
if (screeningMethod .eq. DAMPED) then |
1021 |
> |
! assemble the damping variables |
1022 |
> |
call lookupUniformSpline1d(erfcSpline, rij, erfcVal, derfcVal) |
1023 |
> |
c1 = erfcVal*ri |
1024 |
> |
c2 = (-derfcVal + c1)*ri |
1025 |
> |
c3 = -2.0_dp*derfcVal*alpha2 + 3.0_dp*c2*ri |
1026 |
> |
c4 = -4.0_dp*derfcVal*alpha4 + 5.0_dp*c3*ri*ri |
1027 |
> |
else |
1028 |
> |
c1 = ri |
1029 |
> |
c2 = c1*ri |
1030 |
> |
c3 = 3.0_dp*c2*ri |
1031 |
> |
c4 = 5.0_dp*c3*ri*ri |
1032 |
> |
endif |
1033 |
> |
|
1034 |
> |
! precompute variables for convenience |
1035 |
|
sc2 = scale * scale |
1036 |
+ |
cti3 = ct_i*sc2*c3 |
1037 |
+ |
ctj3 = ct_j*sc2*c3 |
1038 |
+ |
ctidotj = ct_i * ct_j * sc2 |
1039 |
+ |
preSwSc = preSw*scale |
1040 |
+ |
c2ri = c2*ri |
1041 |
+ |
c3ri = c3*ri |
1042 |
+ |
c4rij = c4*rij |
1043 |
+ |
|
1044 |
+ |
|
1045 |
+ |
! calculate the potential |
1046 |
+ |
pot_term = (ct_ij*c2ri - ctidotj*c3) |
1047 |
+ |
vterm = pref * pot_term |
1048 |
+ |
vpair = vpair + vterm |
1049 |
+ |
epot = epot + sw*vterm |
1050 |
+ |
|
1051 |
+ |
! calculate derivatives for the forces and torques |
1052 |
+ |
dudx = dudx + preSwSc * ( ctidotj*xhat*c4rij - & |
1053 |
+ |
(ct_i*uz_j(1) + ct_j*uz_i(1) + ct_ij*xhat)*c3ri ) |
1054 |
+ |
dudy = dudy + preSwSc * ( ctidotj*yhat*c4rij - & |
1055 |
+ |
(ct_i*uz_j(2) + ct_j*uz_i(2) + ct_ij*yhat)*c3ri ) |
1056 |
+ |
dudz = dudz + preSwSc * ( ctidotj*zhat*c4rij - & |
1057 |
+ |
(ct_i*uz_j(3) + ct_j*uz_i(3) + ct_ij*zhat)*c3ri ) |
1058 |
+ |
|
1059 |
+ |
duduz_i(1) = duduz_i(1) + preSw * ( uz_j(1)*c2ri - ctj3*xhat ) |
1060 |
+ |
duduz_i(2) = duduz_i(2) + preSw * ( uz_j(2)*c2ri - ctj3*yhat ) |
1061 |
+ |
duduz_i(3) = duduz_i(3) + preSw * ( uz_j(3)*c2ri - ctj3*zhat ) |
1062 |
|
|
1063 |
< |
vterm = pref * ri3 * (ct_ij - 3.0d0 * ct_i * ct_j * sc2) |
1064 |
< |
vpair = vpair + swi * vterm |
1065 |
< |
epot = epot + vterm |
1066 |
< |
|
930 |
< |
a1 = 5.0d0 * ct_i * ct_j * sc2 - ct_ij |
931 |
< |
|
932 |
< |
dudx = dudx + pref*3.0d0*ri4*scale & |
933 |
< |
*(a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1)) |
934 |
< |
dudy = dudy + pref*3.0d0*ri4*scale & |
935 |
< |
*(a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2)) |
936 |
< |
dudz = dudz + pref*3.0d0*ri4*scale & |
937 |
< |
*(a1*zhat-ct_i*uz_j(3)-ct_j*uz_i(3)) |
938 |
< |
|
939 |
< |
duduz_i(1) = duduz_i(1) + pref*ri3 & |
940 |
< |
*(uz_j(1) - 3.0d0*ct_j*xhat*sc2) |
941 |
< |
duduz_i(2) = duduz_i(2) + pref*ri3 & |
942 |
< |
*(uz_j(2) - 3.0d0*ct_j*yhat*sc2) |
943 |
< |
duduz_i(3) = duduz_i(3) + pref*ri3 & |
944 |
< |
*(uz_j(3) - 3.0d0*ct_j*zhat*sc2) |
945 |
< |
|
946 |
< |
duduz_j(1) = duduz_j(1) + pref*ri3 & |
947 |
< |
*(uz_i(1) - 3.0d0*ct_i*xhat*sc2) |
948 |
< |
duduz_j(2) = duduz_j(2) + pref*ri3 & |
949 |
< |
*(uz_i(2) - 3.0d0*ct_i*yhat*sc2) |
950 |
< |
duduz_j(3) = duduz_j(3) + pref*ri3 & |
951 |
< |
*(uz_i(3) - 3.0d0*ct_i*zhat*sc2) |
1063 |
> |
duduz_j(1) = duduz_j(1) + preSw * ( uz_i(1)*c2ri - cti3*xhat ) |
1064 |
> |
duduz_j(2) = duduz_j(2) + preSw * ( uz_i(2)*c2ri - cti3*yhat ) |
1065 |
> |
duduz_j(3) = duduz_j(3) + preSw * ( uz_i(3)*c2ri - cti3*zhat ) |
1066 |
> |
|
1067 |
|
endif |
1068 |
|
endif |
1069 |
|
endif |
1070 |
|
|
1071 |
|
if (i_is_Quadrupole) then |
1072 |
|
if (j_is_Charge) then |
1073 |
< |
|
1074 |
< |
ri2 = riji * riji |
1075 |
< |
ri3 = ri2 * riji |
1076 |
< |
ri4 = ri2 * ri2 |
1073 |
> |
if (screeningMethod .eq. DAMPED) then |
1074 |
> |
! assemble the damping variables |
1075 |
> |
call lookupUniformSpline1d(erfcSpline, rij, erfcVal, derfcVal) |
1076 |
> |
c1 = erfcVal*riji |
1077 |
> |
c2 = (-derfcVal + c1)*riji |
1078 |
> |
c3 = -2.0_dp*derfcVal*alpha2 + 3.0_dp*c2*riji |
1079 |
> |
c4 = -4.0_dp*derfcVal*alpha4 + 5.0_dp*c3*riji*riji |
1080 |
> |
else |
1081 |
> |
c1 = riji |
1082 |
> |
c2 = c1*riji |
1083 |
> |
c3 = 3.0_dp*c2*riji |
1084 |
> |
c4 = 5.0_dp*c3*riji*riji |
1085 |
> |
endif |
1086 |
> |
|
1087 |
> |
! precompute some variables |
1088 |
|
cx2 = cx_i * cx_i |
1089 |
|
cy2 = cy_i * cy_i |
1090 |
|
cz2 = cz_i * cz_i |
1091 |
+ |
pref = pre14 * q_j * one_third |
1092 |
|
|
1093 |
< |
pref = sw * pre14 * q_j / 3.0_dp |
1093 |
> |
! calculate the potential |
1094 |
> |
pot_term = ( qxx_i * (cx2*c3 - c2ri) + qyy_i * (cy2*c3 - c2ri) + & |
1095 |
> |
qzz_i * (cz2*c3 - c2ri) ) |
1096 |
|
|
1097 |
< |
if (summationMethod .eq. 1) then |
1098 |
< |
vterm1 = pref * ri3*( qxx_i * (3.0_dp*cx2 - 1.0_dp) + & |
1099 |
< |
qyy_i * (3.0_dp*cy2 - 1.0_dp) + & |
1100 |
< |
qzz_i * (3.0_dp*cz2 - 1.0_dp) ) |
1101 |
< |
vterm2 = pref * rcuti3*( qxx_i * (3.0_dp*cx2 - 1.0_dp) + & |
1102 |
< |
qyy_i * (3.0_dp*cy2 - 1.0_dp) + & |
1103 |
< |
qzz_i * (3.0_dp*cz2 - 1.0_dp) ) |
1104 |
< |
vpair = vpair + swi * ( vterm1 - vterm2 ) |
1105 |
< |
epot = epot + ( vterm1 - vterm2 ) |
1106 |
< |
|
1107 |
< |
dudx = dudx - (5.0_dp*(vterm1*riji*xhat - vterm2*rcuti2*d(1))) + & |
1108 |
< |
pref * ( (ri4 - rcuti4)*(qxx_i*(6.0_dp*cx_i*ux_i(1)) - & |
1109 |
< |
qxx_i*2.0_dp*(xhat - rcuti*d(1))) + & |
1110 |
< |
(ri4 - rcuti4)*(qyy_i*(6.0_dp*cy_i*uy_i(1)) - & |
1111 |
< |
qyy_i*2.0_dp*(xhat - rcuti*d(1))) + & |
983 |
< |
(ri4 - rcuti4)*(qzz_i*(6.0_dp*cz_i*uz_i(1)) - & |
984 |
< |
qzz_i*2.0_dp*(xhat - rcuti*d(1))) ) |
985 |
< |
dudy = dudy - (5.0_dp*(vterm1*riji*yhat - vterm2*rcuti2*d(2))) + & |
986 |
< |
pref * ( (ri4 - rcuti4)*(qxx_i*(6.0_dp*cx_i*ux_i(2)) - & |
987 |
< |
qxx_i*2.0_dp*(yhat - rcuti*d(2))) + & |
988 |
< |
(ri4 - rcuti4)*(qyy_i*(6.0_dp*cy_i*uy_i(2)) - & |
989 |
< |
qyy_i*2.0_dp*(yhat - rcuti*d(2))) + & |
990 |
< |
(ri4 - rcuti4)*(qzz_i*(6.0_dp*cz_i*uz_i(2)) - & |
991 |
< |
qzz_i*2.0_dp*(yhat - rcuti*d(2))) ) |
992 |
< |
dudz = dudz - (5.0_dp*(vterm1*riji*zhat - vterm2*rcuti2*d(3))) + & |
993 |
< |
pref * ( (ri4 - rcuti4)*(qxx_i*(6.0_dp*cx_i*ux_i(3)) - & |
994 |
< |
qxx_i*2.0_dp*(zhat - rcuti*d(3))) + & |
995 |
< |
(ri4 - rcuti4)*(qyy_i*(6.0_dp*cy_i*uy_i(3)) - & |
996 |
< |
qyy_i*2.0_dp*(zhat - rcuti*d(3))) + & |
997 |
< |
(ri4 - rcuti4)*(qzz_i*(6.0_dp*cz_i*uz_i(3)) - & |
998 |
< |
qzz_i*2.0_dp*(zhat - rcuti*d(3))) ) |
999 |
< |
|
1000 |
< |
dudux_i(1) = dudux_i(1) + pref * (ri3*(qxx_i*6.0_dp*cx_i*xhat) - & |
1001 |
< |
rcuti4*(qxx_i*6.0_dp*cx_i*d(1))) |
1002 |
< |
dudux_i(2) = dudux_i(2) + pref * (ri3*(qxx_i*6.0_dp*cx_i*yhat) - & |
1003 |
< |
rcuti4*(qxx_i*6.0_dp*cx_i*d(2))) |
1004 |
< |
dudux_i(3) = dudux_i(3) + pref * (ri3*(qxx_i*6.0_dp*cx_i*zhat) - & |
1005 |
< |
rcuti4*(qxx_i*6.0_dp*cx_i*d(3))) |
1006 |
< |
|
1007 |
< |
duduy_i(1) = duduy_i(1) + pref * (ri3*(qyy_i*6.0_dp*cy_i*xhat) - & |
1008 |
< |
rcuti4*(qyy_i*6.0_dp*cx_i*d(1))) |
1009 |
< |
duduy_i(2) = duduy_i(2) + pref * (ri3*(qyy_i*6.0_dp*cy_i*yhat) - & |
1010 |
< |
rcuti4*(qyy_i*6.0_dp*cx_i*d(2))) |
1011 |
< |
duduy_i(3) = duduy_i(3) + pref * (ri3*(qyy_i*6.0_dp*cy_i*zhat) - & |
1012 |
< |
rcuti4*(qyy_i*6.0_dp*cx_i*d(3))) |
1013 |
< |
|
1014 |
< |
duduz_i(1) = duduz_i(1) + pref * (ri3*(qzz_i*6.0_dp*cz_i*xhat) - & |
1015 |
< |
rcuti4*(qzz_i*6.0_dp*cx_i*d(1))) |
1016 |
< |
duduz_i(2) = duduz_i(2) + pref * (ri3*(qzz_i*6.0_dp*cz_i*yhat) - & |
1017 |
< |
rcuti4*(qzz_i*6.0_dp*cx_i*d(2))) |
1018 |
< |
duduz_i(3) = duduz_i(3) + pref * (ri3*(qzz_i*6.0_dp*cz_i*zhat) - & |
1019 |
< |
rcuti4*(qzz_i*6.0_dp*cx_i*d(3))) |
1097 |
> |
vterm = pref * pot_term |
1098 |
> |
vpair = vpair + vterm |
1099 |
> |
epot = epot + sw*vterm |
1100 |
> |
|
1101 |
> |
! precompute variables for convenience |
1102 |
> |
preSw = sw*pref |
1103 |
> |
c2ri = c2*riji |
1104 |
> |
c3ri = c3*riji |
1105 |
> |
c4rij = c4*rij |
1106 |
> |
xhatdot2 = 2.0_dp*xhat*c3 |
1107 |
> |
yhatdot2 = 2.0_dp*yhat*c3 |
1108 |
> |
zhatdot2 = 2.0_dp*zhat*c3 |
1109 |
> |
xhatc4 = xhat*c4rij |
1110 |
> |
yhatc4 = yhat*c4rij |
1111 |
> |
zhatc4 = zhat*c4rij |
1112 |
|
|
1113 |
< |
else |
1114 |
< |
vterm = pref * ri3 * (qxx_i * (3.0_dp*cx2 - 1.0_dp) + & |
1115 |
< |
qyy_i * (3.0_dp*cy2 - 1.0_dp) + & |
1116 |
< |
qzz_i * (3.0_dp*cz2 - 1.0_dp)) |
1117 |
< |
vpair = vpair + swi * vterm |
1118 |
< |
epot = epot + vterm |
1119 |
< |
|
1120 |
< |
dudx = dudx - 5.0_dp*vterm*riji*xhat + pref * ri4 * ( & |
1121 |
< |
qxx_i*(6.0_dp*cx_i*ux_i(1) - 2.0_dp*xhat) + & |
1122 |
< |
qyy_i*(6.0_dp*cy_i*uy_i(1) - 2.0_dp*xhat) + & |
1123 |
< |
qzz_i*(6.0_dp*cz_i*uz_i(1) - 2.0_dp*xhat) ) |
1124 |
< |
dudy = dudy - 5.0_dp*vterm*riji*yhat + pref * ri4 * ( & |
1125 |
< |
qxx_i*(6.0_dp*cx_i*ux_i(2) - 2.0_dp*yhat) + & |
1126 |
< |
qyy_i*(6.0_dp*cy_i*uy_i(2) - 2.0_dp*yhat) + & |
1127 |
< |
qzz_i*(6.0_dp*cz_i*uz_i(2) - 2.0_dp*yhat) ) |
1128 |
< |
dudz = dudz - 5.0_dp*vterm*riji*zhat + pref * ri4 * ( & |
1129 |
< |
qxx_i*(6.0_dp*cx_i*ux_i(3) - 2.0_dp*zhat) + & |
1130 |
< |
qyy_i*(6.0_dp*cy_i*uy_i(3) - 2.0_dp*zhat) + & |
1131 |
< |
qzz_i*(6.0_dp*cz_i*uz_i(3) - 2.0_dp*zhat) ) |
1132 |
< |
|
1133 |
< |
dudux_i(1) = dudux_i(1) + pref * ri3*(qxx_i*6.0_dp*cx_i*xhat) |
1134 |
< |
dudux_i(2) = dudux_i(2) + pref * ri3*(qxx_i*6.0_dp*cx_i*yhat) |
1135 |
< |
dudux_i(3) = dudux_i(3) + pref * ri3*(qxx_i*6.0_dp*cx_i*zhat) |
1136 |
< |
|
1137 |
< |
duduy_i(1) = duduy_i(1) + pref * ri3*(qyy_i*6.0_dp*cy_i*xhat) |
1046 |
< |
duduy_i(2) = duduy_i(2) + pref * ri3*(qyy_i*6.0_dp*cy_i*yhat) |
1047 |
< |
duduy_i(3) = duduy_i(3) + pref * ri3*(qyy_i*6.0_dp*cy_i*zhat) |
1048 |
< |
|
1049 |
< |
duduz_i(1) = duduz_i(1) + pref * ri3*(qzz_i*6.0_dp*cz_i*xhat) |
1050 |
< |
duduz_i(2) = duduz_i(2) + pref * ri3*(qzz_i*6.0_dp*cz_i*yhat) |
1051 |
< |
duduz_i(3) = duduz_i(3) + pref * ri3*(qzz_i*6.0_dp*cz_i*zhat) |
1052 |
< |
endif |
1113 |
> |
! calculate the derivatives for the forces and torques |
1114 |
> |
dudx = dudx - preSw * ( & |
1115 |
> |
qxx_i*(cx2*xhatc4 - (2.0_dp*cx_i*ux_i(1) + xhat)*c3ri) + & |
1116 |
> |
qyy_i*(cy2*xhatc4 - (2.0_dp*cy_i*uy_i(1) + xhat)*c3ri) + & |
1117 |
> |
qzz_i*(cz2*xhatc4 - (2.0_dp*cz_i*uz_i(1) + xhat)*c3ri) ) |
1118 |
> |
dudy = dudy - preSw * ( & |
1119 |
> |
qxx_i*(cx2*yhatc4 - (2.0_dp*cx_i*ux_i(2) + yhat)*c3ri) + & |
1120 |
> |
qyy_i*(cy2*yhatc4 - (2.0_dp*cy_i*uy_i(2) + yhat)*c3ri) + & |
1121 |
> |
qzz_i*(cz2*yhatc4 - (2.0_dp*cz_i*uz_i(2) + yhat)*c3ri) ) |
1122 |
> |
dudz = dudz - preSw * ( & |
1123 |
> |
qxx_i*(cx2*zhatc4 - (2.0_dp*cx_i*ux_i(3) + zhat)*c3ri) + & |
1124 |
> |
qyy_i*(cy2*zhatc4 - (2.0_dp*cy_i*uy_i(3) + zhat)*c3ri) + & |
1125 |
> |
qzz_i*(cz2*zhatc4 - (2.0_dp*cz_i*uz_i(3) + zhat)*c3ri) ) |
1126 |
> |
|
1127 |
> |
dudux_i(1) = dudux_i(1) + preSw*(qxx_i*cx_i*xhatdot2) |
1128 |
> |
dudux_i(2) = dudux_i(2) + preSw*(qxx_i*cx_i*yhatdot2) |
1129 |
> |
dudux_i(3) = dudux_i(3) + preSw*(qxx_i*cx_i*zhatdot2) |
1130 |
> |
|
1131 |
> |
duduy_i(1) = duduy_i(1) + preSw*(qyy_i*cy_i*xhatdot2) |
1132 |
> |
duduy_i(2) = duduy_i(2) + preSw*(qyy_i*cy_i*yhatdot2) |
1133 |
> |
duduy_i(3) = duduy_i(3) + preSw*(qyy_i*cy_i*zhatdot2) |
1134 |
> |
|
1135 |
> |
duduz_i(1) = duduz_i(1) + preSw*(qzz_i*cz_i*xhatdot2) |
1136 |
> |
duduz_i(2) = duduz_i(2) + preSw*(qzz_i*cz_i*yhatdot2) |
1137 |
> |
duduz_i(3) = duduz_i(3) + preSw*(qzz_i*cz_i*zhatdot2) |
1138 |
|
endif |
1139 |
|
endif |
1140 |
|
|
1141 |
|
|
1142 |
|
if (do_pot) then |
1143 |
|
#ifdef IS_MPI |
1144 |
< |
pot_row(atom1) = pot_row(atom1) + 0.5d0*epot |
1145 |
< |
pot_col(atom2) = pot_col(atom2) + 0.5d0*epot |
1144 |
> |
pot_row(ELECTROSTATIC_POT,atom1) = pot_row(ELECTROSTATIC_POT,atom1) + 0.5_dp*epot |
1145 |
> |
pot_col(ELECTROSTATIC_POT,atom2) = pot_col(ELECTROSTATIC_POT,atom2) + 0.5_dp*epot |
1146 |
|
#else |
1147 |
|
pot = pot + epot |
1148 |
|
#endif |
1247 |
|
return |
1248 |
|
end subroutine doElectrostaticPair |
1249 |
|
|
1250 |
< |
!! calculates the switching functions and their derivatives for a given |
1166 |
< |
subroutine calc_switch(r, mu, scale, dscale) |
1250 |
> |
subroutine destroyElectrostaticTypes() |
1251 |
|
|
1252 |
< |
real (kind=dp), intent(in) :: r, mu |
1169 |
< |
real (kind=dp), intent(inout) :: scale, dscale |
1170 |
< |
real (kind=dp) :: rl, ru, mulow, minRatio, temp, scaleVal |
1252 |
> |
if(allocated(ElectrostaticMap)) deallocate(ElectrostaticMap) |
1253 |
|
|
1254 |
< |
! distances must be in angstroms |
1255 |
< |
rl = 2.75d0 |
1256 |
< |
ru = 3.75d0 |
1257 |
< |
mulow = 0.0d0 !3.3856d0 ! 1.84 * 1.84 |
1258 |
< |
minRatio = mulow / (mu*mu) |
1259 |
< |
scaleVal = 1.0d0 - minRatio |
1254 |
> |
end subroutine destroyElectrostaticTypes |
1255 |
> |
|
1256 |
> |
subroutine self_self(atom1, eFrame, mypot, t, do_pot) |
1257 |
> |
logical, intent(in) :: do_pot |
1258 |
> |
integer, intent(in) :: atom1 |
1259 |
> |
integer :: atid1 |
1260 |
> |
real(kind=dp), dimension(9,nLocal) :: eFrame |
1261 |
> |
real(kind=dp), dimension(3,nLocal) :: t |
1262 |
> |
real(kind=dp) :: mu1, chg1 |
1263 |
> |
real(kind=dp) :: preVal, epot, mypot |
1264 |
> |
real(kind=dp) :: eix, eiy, eiz |
1265 |
> |
|
1266 |
> |
! this is a local only array, so we use the local atom type id's: |
1267 |
> |
atid1 = atid(atom1) |
1268 |
> |
|
1269 |
> |
if (.not.summationMethodChecked) then |
1270 |
> |
call checkSummationMethod() |
1271 |
> |
endif |
1272 |
|
|
1273 |
< |
if (r.lt.rl) then |
1274 |
< |
scale = minRatio |
1275 |
< |
dscale = 0.0d0 |
1276 |
< |
elseif (r.gt.ru) then |
1277 |
< |
scale = 1.0d0 |
1278 |
< |
dscale = 0.0d0 |
1279 |
< |
else |
1280 |
< |
scale = 1.0d0 - scaleVal*((ru + 2.0d0*r - 3.0d0*rl) * (ru-r)**2) & |
1281 |
< |
/ ((ru - rl)**3) |
1282 |
< |
dscale = -scaleVal * 6.0d0 * (r-ru)*(r-rl)/((ru - rl)**3) |
1273 |
> |
if (summationMethod .eq. REACTION_FIELD) then |
1274 |
> |
if (ElectrostaticMap(atid1)%is_Dipole) then |
1275 |
> |
mu1 = getDipoleMoment(atid1) |
1276 |
> |
|
1277 |
> |
preVal = pre22 * preRF2 * mu1*mu1 |
1278 |
> |
mypot = mypot - 0.5_dp*preVal |
1279 |
> |
|
1280 |
> |
! The self-correction term adds into the reaction field vector |
1281 |
> |
|
1282 |
> |
eix = preVal * eFrame(3,atom1) |
1283 |
> |
eiy = preVal * eFrame(6,atom1) |
1284 |
> |
eiz = preVal * eFrame(9,atom1) |
1285 |
> |
|
1286 |
> |
! once again, this is self-self, so only the local arrays are needed |
1287 |
> |
! even for MPI jobs: |
1288 |
> |
|
1289 |
> |
t(1,atom1)=t(1,atom1) - eFrame(6,atom1)*eiz + & |
1290 |
> |
eFrame(9,atom1)*eiy |
1291 |
> |
t(2,atom1)=t(2,atom1) - eFrame(9,atom1)*eix + & |
1292 |
> |
eFrame(3,atom1)*eiz |
1293 |
> |
t(3,atom1)=t(3,atom1) - eFrame(3,atom1)*eiy + & |
1294 |
> |
eFrame(6,atom1)*eix |
1295 |
> |
|
1296 |
> |
endif |
1297 |
> |
|
1298 |
> |
elseif ( (summationMethod .eq. SHIFTED_FORCE) .or. & |
1299 |
> |
(summationMethod .eq. SHIFTED_POTENTIAL) ) then |
1300 |
> |
if (ElectrostaticMap(atid1)%is_Charge) then |
1301 |
> |
chg1 = getCharge(atid1) |
1302 |
> |
|
1303 |
> |
if (screeningMethod .eq. DAMPED) then |
1304 |
> |
mypot = mypot - (c1c * 0.5_dp + & |
1305 |
> |
dampingAlpha*invRootPi) * chg1 * chg1 |
1306 |
> |
|
1307 |
> |
else |
1308 |
> |
mypot = mypot - (rcuti * 0.5_dp * chg1 * chg1) |
1309 |
> |
|
1310 |
> |
endif |
1311 |
> |
endif |
1312 |
|
endif |
1313 |
< |
|
1313 |
> |
|
1314 |
|
return |
1315 |
< |
end subroutine calc_switch |
1315 |
> |
end subroutine self_self |
1316 |
|
|
1317 |
< |
subroutine destroyElectrostaticTypes() |
1317 |
> |
subroutine rf_self_excludes(atom1, atom2, sw, eFrame, d, rij, vpair, myPot, & |
1318 |
> |
f, t, do_pot) |
1319 |
> |
logical, intent(in) :: do_pot |
1320 |
> |
integer, intent(in) :: atom1 |
1321 |
> |
integer, intent(in) :: atom2 |
1322 |
> |
logical :: i_is_Charge, j_is_Charge |
1323 |
> |
logical :: i_is_Dipole, j_is_Dipole |
1324 |
> |
integer :: atid1 |
1325 |
> |
integer :: atid2 |
1326 |
> |
real(kind=dp), intent(in) :: rij |
1327 |
> |
real(kind=dp), intent(in) :: sw |
1328 |
> |
real(kind=dp), intent(in), dimension(3) :: d |
1329 |
> |
real(kind=dp), intent(inout) :: vpair |
1330 |
> |
real(kind=dp), dimension(9,nLocal) :: eFrame |
1331 |
> |
real(kind=dp), dimension(3,nLocal) :: f |
1332 |
> |
real(kind=dp), dimension(3,nLocal) :: t |
1333 |
> |
real (kind = dp), dimension(3) :: duduz_i |
1334 |
> |
real (kind = dp), dimension(3) :: duduz_j |
1335 |
> |
real (kind = dp), dimension(3) :: uz_i |
1336 |
> |
real (kind = dp), dimension(3) :: uz_j |
1337 |
> |
real(kind=dp) :: q_i, q_j, mu_i, mu_j |
1338 |
> |
real(kind=dp) :: xhat, yhat, zhat |
1339 |
> |
real(kind=dp) :: ct_i, ct_j |
1340 |
> |
real(kind=dp) :: ri2, ri3, riji, vterm |
1341 |
> |
real(kind=dp) :: pref, preVal, rfVal, myPot |
1342 |
> |
real(kind=dp) :: dudx, dudy, dudz, dudr |
1343 |
|
|
1344 |
< |
if(allocated(ElectrostaticMap)) deallocate(ElectrostaticMap) |
1344 |
> |
if (.not.summationMethodChecked) then |
1345 |
> |
call checkSummationMethod() |
1346 |
> |
endif |
1347 |
|
|
1348 |
< |
end subroutine destroyElectrostaticTypes |
1348 |
> |
dudx = zero |
1349 |
> |
dudy = zero |
1350 |
> |
dudz = zero |
1351 |
|
|
1352 |
+ |
riji = 1.0_dp/rij |
1353 |
+ |
|
1354 |
+ |
xhat = d(1) * riji |
1355 |
+ |
yhat = d(2) * riji |
1356 |
+ |
zhat = d(3) * riji |
1357 |
+ |
|
1358 |
+ |
! this is a local only array, so we use the local atom type id's: |
1359 |
+ |
atid1 = atid(atom1) |
1360 |
+ |
atid2 = atid(atom2) |
1361 |
+ |
i_is_Charge = ElectrostaticMap(atid1)%is_Charge |
1362 |
+ |
j_is_Charge = ElectrostaticMap(atid2)%is_Charge |
1363 |
+ |
i_is_Dipole = ElectrostaticMap(atid1)%is_Dipole |
1364 |
+ |
j_is_Dipole = ElectrostaticMap(atid2)%is_Dipole |
1365 |
+ |
|
1366 |
+ |
if (i_is_Charge.and.j_is_Charge) then |
1367 |
+ |
q_i = ElectrostaticMap(atid1)%charge |
1368 |
+ |
q_j = ElectrostaticMap(atid2)%charge |
1369 |
+ |
|
1370 |
+ |
preVal = pre11 * q_i * q_j |
1371 |
+ |
rfVal = preRF*rij*rij |
1372 |
+ |
vterm = preVal * rfVal |
1373 |
+ |
|
1374 |
+ |
myPot = myPot + sw*vterm |
1375 |
+ |
|
1376 |
+ |
dudr = sw*preVal * 2.0_dp*rfVal*riji |
1377 |
+ |
|
1378 |
+ |
dudx = dudx + dudr * xhat |
1379 |
+ |
dudy = dudy + dudr * yhat |
1380 |
+ |
dudz = dudz + dudr * zhat |
1381 |
+ |
|
1382 |
+ |
elseif (i_is_Charge.and.j_is_Dipole) then |
1383 |
+ |
q_i = ElectrostaticMap(atid1)%charge |
1384 |
+ |
mu_j = ElectrostaticMap(atid2)%dipole_moment |
1385 |
+ |
uz_j(1) = eFrame(3,atom2) |
1386 |
+ |
uz_j(2) = eFrame(6,atom2) |
1387 |
+ |
uz_j(3) = eFrame(9,atom2) |
1388 |
+ |
ct_j = uz_j(1)*xhat + uz_j(2)*yhat + uz_j(3)*zhat |
1389 |
+ |
|
1390 |
+ |
ri2 = riji * riji |
1391 |
+ |
ri3 = ri2 * riji |
1392 |
+ |
|
1393 |
+ |
pref = pre12 * q_i * mu_j |
1394 |
+ |
vterm = - pref * ct_j * ( ri2 - preRF2*rij ) |
1395 |
+ |
myPot = myPot + sw*vterm |
1396 |
+ |
|
1397 |
+ |
dudx = dudx - sw*pref*( ri3*(uz_j(1)-3.0_dp*ct_j*xhat) & |
1398 |
+ |
- preRF2*uz_j(1) ) |
1399 |
+ |
dudy = dudy - sw*pref*( ri3*(uz_j(2)-3.0_dp*ct_j*yhat) & |
1400 |
+ |
- preRF2*uz_j(2) ) |
1401 |
+ |
dudz = dudz - sw*pref*( ri3*(uz_j(3)-3.0_dp*ct_j*zhat) & |
1402 |
+ |
- preRF2*uz_j(3) ) |
1403 |
+ |
|
1404 |
+ |
duduz_j(1) = duduz_j(1) - sw * pref * xhat * ( ri2 - preRF2*rij ) |
1405 |
+ |
duduz_j(2) = duduz_j(2) - sw * pref * yhat * ( ri2 - preRF2*rij ) |
1406 |
+ |
duduz_j(3) = duduz_j(3) - sw * pref * zhat * ( ri2 - preRF2*rij ) |
1407 |
+ |
|
1408 |
+ |
elseif (i_is_Dipole.and.j_is_Charge) then |
1409 |
+ |
mu_i = ElectrostaticMap(atid1)%dipole_moment |
1410 |
+ |
q_j = ElectrostaticMap(atid2)%charge |
1411 |
+ |
uz_i(1) = eFrame(3,atom1) |
1412 |
+ |
uz_i(2) = eFrame(6,atom1) |
1413 |
+ |
uz_i(3) = eFrame(9,atom1) |
1414 |
+ |
ct_i = uz_i(1)*xhat + uz_i(2)*yhat + uz_i(3)*zhat |
1415 |
+ |
|
1416 |
+ |
ri2 = riji * riji |
1417 |
+ |
ri3 = ri2 * riji |
1418 |
+ |
|
1419 |
+ |
pref = pre12 * q_j * mu_i |
1420 |
+ |
vterm = pref * ct_i * ( ri2 - preRF2*rij ) |
1421 |
+ |
myPot = myPot + sw*vterm |
1422 |
+ |
|
1423 |
+ |
dudx = dudx + sw*pref*( ri3*(uz_i(1)-3.0_dp*ct_i*xhat) & |
1424 |
+ |
- preRF2*uz_i(1) ) |
1425 |
+ |
dudy = dudy + sw*pref*( ri3*(uz_i(2)-3.0_dp*ct_i*yhat) & |
1426 |
+ |
- preRF2*uz_i(2) ) |
1427 |
+ |
dudz = dudz + sw*pref*( ri3*(uz_i(3)-3.0_dp*ct_i*zhat) & |
1428 |
+ |
- preRF2*uz_i(3) ) |
1429 |
+ |
|
1430 |
+ |
duduz_i(1) = duduz_i(1) + sw * pref * xhat * ( ri2 - preRF2*rij ) |
1431 |
+ |
duduz_i(2) = duduz_i(2) + sw * pref * yhat * ( ri2 - preRF2*rij ) |
1432 |
+ |
duduz_i(3) = duduz_i(3) + sw * pref * zhat * ( ri2 - preRF2*rij ) |
1433 |
+ |
|
1434 |
+ |
endif |
1435 |
+ |
|
1436 |
+ |
|
1437 |
+ |
! accumulate the forces and torques resulting from the self term |
1438 |
+ |
f(1,atom1) = f(1,atom1) + dudx |
1439 |
+ |
f(2,atom1) = f(2,atom1) + dudy |
1440 |
+ |
f(3,atom1) = f(3,atom1) + dudz |
1441 |
+ |
|
1442 |
+ |
f(1,atom2) = f(1,atom2) - dudx |
1443 |
+ |
f(2,atom2) = f(2,atom2) - dudy |
1444 |
+ |
f(3,atom2) = f(3,atom2) - dudz |
1445 |
+ |
|
1446 |
+ |
if (i_is_Dipole) then |
1447 |
+ |
t(1,atom1)=t(1,atom1) - uz_i(2)*duduz_i(3) + uz_i(3)*duduz_i(2) |
1448 |
+ |
t(2,atom1)=t(2,atom1) - uz_i(3)*duduz_i(1) + uz_i(1)*duduz_i(3) |
1449 |
+ |
t(3,atom1)=t(3,atom1) - uz_i(1)*duduz_i(2) + uz_i(2)*duduz_i(1) |
1450 |
+ |
elseif (j_is_Dipole) then |
1451 |
+ |
t(1,atom2)=t(1,atom2) - uz_j(2)*duduz_j(3) + uz_j(3)*duduz_j(2) |
1452 |
+ |
t(2,atom2)=t(2,atom2) - uz_j(3)*duduz_j(1) + uz_j(1)*duduz_j(3) |
1453 |
+ |
t(3,atom2)=t(3,atom2) - uz_j(1)*duduz_j(2) + uz_j(2)*duduz_j(1) |
1454 |
+ |
endif |
1455 |
+ |
|
1456 |
+ |
return |
1457 |
+ |
end subroutine rf_self_excludes |
1458 |
+ |
|
1459 |
+ |
subroutine accumulate_box_dipole(atom1, eFrame, d, pChg, nChg, pChgPos, & |
1460 |
+ |
nChgPos, dipVec, pChgCount, nChgCount) |
1461 |
+ |
integer, intent(in) :: atom1 |
1462 |
+ |
logical :: i_is_Charge |
1463 |
+ |
logical :: i_is_Dipole |
1464 |
+ |
integer :: atid1 |
1465 |
+ |
integer :: pChgCount |
1466 |
+ |
integer :: nChgCount |
1467 |
+ |
real(kind=dp), intent(in), dimension(3) :: d |
1468 |
+ |
real(kind=dp), dimension(9,nLocal) :: eFrame |
1469 |
+ |
real(kind=dp) :: pChg |
1470 |
+ |
real(kind=dp) :: nChg |
1471 |
+ |
real(kind=dp), dimension(3) :: pChgPos |
1472 |
+ |
real(kind=dp), dimension(3) :: nChgPos |
1473 |
+ |
real(kind=dp), dimension(3) :: dipVec |
1474 |
+ |
real(kind=dp), dimension(3) :: uz_i |
1475 |
+ |
real(kind=dp), dimension(3) :: pos |
1476 |
+ |
real(kind=dp) :: q_i, mu_i |
1477 |
+ |
real(kind=dp) :: pref, preVal |
1478 |
+ |
|
1479 |
+ |
if (.not.summationMethodChecked) then |
1480 |
+ |
call checkSummationMethod() |
1481 |
+ |
endif |
1482 |
+ |
|
1483 |
+ |
! this is a local only array, so we use the local atom type id's: |
1484 |
+ |
atid1 = atid(atom1) |
1485 |
+ |
i_is_Charge = ElectrostaticMap(atid1)%is_Charge |
1486 |
+ |
i_is_Dipole = ElectrostaticMap(atid1)%is_Dipole |
1487 |
+ |
|
1488 |
+ |
if (i_is_Charge) then |
1489 |
+ |
q_i = ElectrostaticMap(atid1)%charge |
1490 |
+ |
! convert to the proper units |
1491 |
+ |
q_i = q_i * chargeToC |
1492 |
+ |
pos = d * angstromToM |
1493 |
+ |
|
1494 |
+ |
if (q_i.le.0.0_dp) then |
1495 |
+ |
nChg = nChg - q_i |
1496 |
+ |
nChgPos(1) = nChgPos(1) + pos(1) |
1497 |
+ |
nChgPos(2) = nChgPos(2) + pos(2) |
1498 |
+ |
nChgPos(3) = nChgPos(3) + pos(3) |
1499 |
+ |
nChgCount = nChgCount + 1 |
1500 |
+ |
|
1501 |
+ |
else |
1502 |
+ |
pChg = pChg + q_i |
1503 |
+ |
pChgPos(1) = pChgPos(1) + pos(1) |
1504 |
+ |
pChgPos(2) = pChgPos(2) + pos(2) |
1505 |
+ |
pChgPos(3) = pChgPos(3) + pos(3) |
1506 |
+ |
pChgCount = pChgCount + 1 |
1507 |
+ |
|
1508 |
+ |
endif |
1509 |
+ |
|
1510 |
+ |
endif |
1511 |
+ |
|
1512 |
+ |
if (i_is_Dipole) then |
1513 |
+ |
mu_i = ElectrostaticMap(atid1)%dipole_moment |
1514 |
+ |
uz_i(1) = eFrame(3,atom1) |
1515 |
+ |
uz_i(2) = eFrame(6,atom1) |
1516 |
+ |
uz_i(3) = eFrame(9,atom1) |
1517 |
+ |
! convert to the proper units |
1518 |
+ |
mu_i = mu_i * debyeToCm |
1519 |
+ |
|
1520 |
+ |
dipVec(1) = dipVec(1) + uz_i(1)*mu_i |
1521 |
+ |
dipVec(2) = dipVec(2) + uz_i(2)*mu_i |
1522 |
+ |
dipVec(3) = dipVec(3) + uz_i(3)*mu_i |
1523 |
+ |
|
1524 |
+ |
endif |
1525 |
+ |
|
1526 |
+ |
return |
1527 |
+ |
end subroutine accumulate_box_dipole |
1528 |
+ |
|
1529 |
|
end module electrostatic_module |