ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/UseTheForce/DarkSide/electrostatic.F90
(Generate patch)

Comparing trunk/OOPSE-4/src/UseTheForce/DarkSide/electrostatic.F90 (file contents):
Revision 2402 by chrisfen, Tue Nov 1 19:09:30 2005 UTC vs.
Revision 2722 by gezelter, Thu Apr 20 18:24:24 2006 UTC

# Line 47 | Line 47 | module electrostatic_module
47    use vector_class
48    use simulation
49    use status
50 +  use interpolation
51   #ifdef IS_MPI
52    use mpiSimulation
53   #endif
# Line 58 | Line 59 | module electrostatic_module
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
68 <  real(kind=dp), parameter :: pre11 = 332.0637778_dp
68 >  real(kind=dp), parameter :: pre11 = 332.0637778d0
69    !! Charge-Dipole, assuming charges are measured in electrons, and
70    !! dipoles are measured in debyes
71 <  real(kind=dp), parameter :: pre12 = 69.13373_dp
71 >  real(kind=dp), parameter :: pre12 = 69.13373d0
72    !! Dipole-Dipole, assuming dipoles are measured in debyes
73 <  real(kind=dp), parameter :: pre22 = 14.39325_dp
73 >  real(kind=dp), parameter :: pre22 = 14.39325d0
74    !! Charge-Quadrupole, assuming charges are measured in electrons, and
75    !! quadrupoles are measured in 10^-26 esu cm^2
76    !! This unit is also known affectionately as an esu centi-barn.
77 <  real(kind=dp), parameter :: pre14 = 69.13373_dp
77 >  real(kind=dp), parameter :: pre14 = 69.13373d0
78  
79 <  !! variables to handle different summation methods for long-range electrostatics:
79 >  real(kind=dp), parameter :: zero = 0.0d0
80 >
81 >  !! variables to handle different summation methods for long-range
82 >  !! electrostatics:
83    integer, save :: summationMethod = NONE
84 +  integer, save :: screeningMethod = UNDAMPED
85    logical, save :: summationMethodChecked = .false.
86    real(kind=DP), save :: defaultCutoff = 0.0_DP
87    real(kind=DP), save :: defaultCutoff2 = 0.0_DP
88    logical, save :: haveDefaultCutoff = .false.
89    real(kind=DP), save :: dampingAlpha = 0.0_DP
90 +  real(kind=DP), save :: alpha2 = 0.0_DP
91    logical, save :: haveDampingAlpha = .false.
92    real(kind=DP), save :: dielectric = 1.0_DP
93    logical, save :: haveDielectric = .false.
87  real(kind=DP), save :: constERFC = 0.0_DP
94    real(kind=DP), save :: constEXP = 0.0_DP
95    real(kind=dp), save :: rcuti = 0.0_DP
96    real(kind=dp), save :: rcuti2 = 0.0_DP
# Line 97 | Line 103 | module electrostatic_module
103    real(kind=dp), save :: rrfsq = 1.0_DP
104    real(kind=dp), save :: preRF = 0.0_DP
105    real(kind=dp), save :: preRF2 = 0.0_DP
106 <
107 < #ifdef __IFC
106 >  real(kind=dp), save :: f0 = 1.0_DP
107 >  real(kind=dp), save :: f1 = 1.0_DP
108 >  real(kind=dp), save :: f2 = 0.0_DP
109 >  real(kind=dp), save :: f3 = 0.0_DP
110 >  real(kind=dp), save :: f4 = 0.0_DP
111 >  real(kind=dp), save :: f0c = 1.0_DP
112 >  real(kind=dp), save :: f1c = 1.0_DP
113 >  real(kind=dp), save :: f2c = 0.0_DP
114 >  real(kind=dp), save :: f3c = 0.0_DP
115 >  real(kind=dp), save :: f4c = 0.0_DP
116 >
117 > #if defined(__IFC) || defined(__PGI)
118   ! error function for ifc version > 7.
119    double precision, external :: derfc
120   #endif
121    
122    public :: setElectrostaticSummationMethod
123 +  public :: setScreeningMethod
124    public :: setElectrostaticCutoffRadius
125 <  public :: setDampedWolfAlpha
125 >  public :: setDampingAlpha
126    public :: setReactionFieldDielectric
127 +  public :: buildElectroSplines
128    public :: newElectrostaticType
129    public :: setCharge
130    public :: setDipoleMoment
# Line 119 | Line 137 | module electrostatic_module
137    public :: self_self
138    public :: rf_self_excludes
139  
140 +
141    type :: Electrostatic
142       integer :: c_ident
143       logical :: is_Charge = .false.
# Line 134 | Line 153 | contains
153  
154    type(Electrostatic), dimension(:), allocatable :: ElectrostaticMap
155  
156 +  logical, save :: hasElectrostaticMap
157 +
158   contains
159  
160    subroutine setElectrostaticSummationMethod(the_ESM)
# Line 147 | Line 168 | contains
168  
169    end subroutine setElectrostaticSummationMethod
170  
171 +  subroutine setScreeningMethod(the_SM)
172 +    integer, intent(in) :: the_SM    
173 +    screeningMethod = the_SM
174 +  end subroutine setScreeningMethod
175 +
176    subroutine setElectrostaticCutoffRadius(thisRcut, thisRsw)
177      real(kind=dp), intent(in) :: thisRcut
178      real(kind=dp), intent(in) :: thisRsw
179      defaultCutoff = thisRcut
180 +    defaultCutoff2 = defaultCutoff*defaultCutoff
181      rrf = defaultCutoff
182      rt = thisRsw
183      haveDefaultCutoff = .true.
184    end subroutine setElectrostaticCutoffRadius
185  
186 <  subroutine setDampedWolfAlpha(thisAlpha)
186 >  subroutine setDampingAlpha(thisAlpha)
187      real(kind=dp), intent(in) :: thisAlpha
188      dampingAlpha = thisAlpha
189 +    alpha2 = dampingAlpha*dampingAlpha
190      haveDampingAlpha = .true.
191 <  end subroutine setDampedWolfAlpha
191 >  end subroutine setDampingAlpha
192    
193    subroutine setReactionFieldDielectric(thisDielectric)
194      real(kind=dp), intent(in) :: thisDielectric
# Line 168 | Line 196 | contains
196      haveDielectric = .true.
197    end subroutine setReactionFieldDielectric
198  
199 +  subroutine buildElectroSplines()
200 +  end subroutine buildElectroSplines
201 +
202    subroutine newElectrostaticType(c_ident, is_Charge, is_Dipole, &
203         is_SplitDipole, is_Quadrupole, is_Tap, status)
204  
# Line 195 | Line 226 | contains
226            return
227         end if
228  
229 <       if (.not. allocated(ElectrostaticMap)) then
199 <          allocate(ElectrostaticMap(nAtypes))
200 <       endif
229 >       allocate(ElectrostaticMap(nAtypes))
230  
231      end if
232  
# Line 215 | Line 244 | contains
244      ElectrostaticMap(myATID)%is_Quadrupole = is_Quadrupole
245      ElectrostaticMap(myATID)%is_Tap = is_Tap
246  
247 +    hasElectrostaticMap = .true.
248 +
249    end subroutine newElectrostaticType
250  
251    subroutine setCharge(c_ident, charge, status)
# Line 226 | Line 257 | contains
257      status = 0
258      myATID = getFirstMatchingElement(atypes, "c_ident", c_ident)
259  
260 <    if (.not.allocated(ElectrostaticMap)) then
260 >    if (.not.hasElectrostaticMap) then
261         call handleError("electrostatic", "no ElectrostaticMap was present before first call of setCharge!")
262         status = -1
263         return
# Line 256 | Line 287 | contains
287      status = 0
288      myATID = getFirstMatchingElement(atypes, "c_ident", c_ident)
289  
290 <    if (.not.allocated(ElectrostaticMap)) then
290 >    if (.not.hasElectrostaticMap) then
291         call handleError("electrostatic", "no ElectrostaticMap was present before first call of setDipoleMoment!")
292         status = -1
293         return
# Line 286 | Line 317 | contains
317      status = 0
318      myATID = getFirstMatchingElement(atypes, "c_ident", c_ident)
319  
320 <    if (.not.allocated(ElectrostaticMap)) then
320 >    if (.not.hasElectrostaticMap) then
321         call handleError("electrostatic", "no ElectrostaticMap was present before first call of setSplitDipoleDistance!")
322         status = -1
323         return
# Line 316 | Line 347 | contains
347      status = 0
348      myATID = getFirstMatchingElement(atypes, "c_ident", c_ident)
349  
350 <    if (.not.allocated(ElectrostaticMap)) then
350 >    if (.not.hasElectrostaticMap) then
351         call handleError("electrostatic", "no ElectrostaticMap was present before first call of setQuadrupoleMoments!")
352         status = -1
353         return
# Line 347 | Line 378 | contains
378      integer :: localError
379      real(kind=dp) :: c
380  
381 <    if (.not.allocated(ElectrostaticMap)) then
381 >    if (.not.hasElectrostaticMap) then
382         call handleError("electrostatic", "no ElectrostaticMap was present before first call of getCharge!")
383         return
384      end if
# Line 365 | Line 396 | contains
396      integer :: localError
397      real(kind=dp) :: dm
398  
399 <    if (.not.allocated(ElectrostaticMap)) then
399 >    if (.not.hasElectrostaticMap) then
400         call handleError("electrostatic", "no ElectrostaticMap was present before first call of getDipoleMoment!")
401         return
402      end if
# Line 389 | Line 420 | contains
420      rcuti3 = rcuti2*rcuti
421      rcuti4 = rcuti2*rcuti2
422  
423 <    if (summationMethod .eq. DAMPED_WOLF) then
423 >    if (screeningMethod .eq. DAMPED) then
424         if (.not.haveDampingAlpha) then
425            call handleError("checkSummationMethod", "no Damping Alpha set!")
426         endif
# Line 398 | Line 429 | contains
429            call handleError("checkSummationMethod", "no Default Cutoff set!")
430         endif
431  
432 <       constEXP = exp(-dampingAlpha*dampingAlpha*defaultCutoff*defaultCutoff)
402 <       constERFC = derfc(dampingAlpha*defaultCutoff)
432 >       constEXP = exp(-alpha2*defaultCutoff2)
433         invRootPi = 0.56418958354775628695d0
434 <       alphaPi = 2*dampingAlpha*invRootPi
435 <      
434 >       alphaPi = 2.0d0*dampingAlpha*invRootPi
435 >       f0c = derfc(dampingAlpha*defaultCutoff)
436 >       f1c = alphaPi*defaultCutoff*constEXP + f0c
437 >       f2c = alphaPi*2.0d0*alpha2*constEXP
438 >       f3c = alphaPi*2.0d0*alpha2*constEXP*defaultCutoff2*defaultCutoff
439      endif
440  
441      if (summationMethod .eq. REACTION_FIELD) then
# Line 420 | Line 453 | contains
453      summationMethodChecked = .true.
454    end subroutine checkSummationMethod
455  
423 !!$
424 !!$  subroutine doElectrostaticPair(atom1, atom2, d, rij, r2, sw, &
425 !!$       vpair, fpair, pot, eFrame, f, t, do_pot)
426  subroutine doElectrostaticPair(atom1, atom2, d, rij, r2, sw, &
427       vpair, fpair, pot, eFrame, f, t, do_pot, felec)
456  
457 +  subroutine doElectrostaticPair(atom1, atom2, d, rij, r2, rcut, sw, &
458 +       vpair, fpair, pot, eFrame, f, t, do_pot)
459 +
460      logical, intent(in) :: do_pot
461  
462      integer, intent(in) :: atom1, atom2
463      integer :: localError
464  
465 <    real(kind=dp), intent(in) :: rij, r2, sw
465 >    real(kind=dp), intent(in) :: rij, r2, sw, rcut
466      real(kind=dp), intent(in), dimension(3) :: d
467      real(kind=dp), intent(inout) :: vpair
468      real(kind=dp), intent(inout), dimension(3) :: fpair    
438    real(kind=dp), intent(inout), dimension(3) :: felec
469  
470      real( kind = dp ) :: pot
471      real( kind = dp ), dimension(9,nLocal) :: eFrame
472      real( kind = dp ), dimension(3,nLocal) :: f
473 +    real( kind = dp ), dimension(3,nLocal) :: felec
474      real( kind = dp ), dimension(3,nLocal) :: t
475  
476      real (kind = dp), dimension(3) :: ux_i, uy_i, uz_i
# Line 457 | Line 488 | contains
488      real (kind=dp) :: cx_i, cy_i, cz_i
489      real (kind=dp) :: cx_j, cy_j, cz_j
490      real (kind=dp) :: cx2, cy2, cz2
491 <    real (kind=dp) :: ct_i, ct_j, ct_ij, a1
491 >    real (kind=dp) :: ct_i, ct_j, ct_ij, a0, a1
492      real (kind=dp) :: riji, ri, ri2, ri3, ri4
493      real (kind=dp) :: pref, vterm, epot, dudr, vterm1, vterm2
494      real (kind=dp) :: xhat, yhat, zhat
495      real (kind=dp) :: dudx, dudy, dudz
496      real (kind=dp) :: scale, sc2, bigR
497 <    real (kind=dp) :: varERFC, varEXP
498 <    real (kind=dp) :: limScale
497 >    real (kind=dp) :: varEXP
498 >    real (kind=dp) :: pot_term
499      real (kind=dp) :: preVal, rfVal
500 +    real (kind=dp) :: f13, f134
501  
470    if (.not.allocated(ElectrostaticMap)) then
471       call handleError("electrostatic", "no ElectrostaticMap was present before first call of do_electrostatic_pair!")
472       return
473    end if
474
502      if (.not.summationMethodChecked) then
503         call checkSummationMethod()
504      endif
# Line 525 | Line 552 | contains
552         if (i_is_SplitDipole) then
553            d_i = ElectrostaticMap(me1)%split_dipole_distance
554         endif
555 <
555 >       duduz_i = zero
556      endif
557  
558      if (i_is_Quadrupole) then
# Line 556 | Line 583 | contains
583         cx_i = ux_i(1)*xhat + ux_i(2)*yhat + ux_i(3)*zhat
584         cy_i = uy_i(1)*xhat + uy_i(2)*yhat + uy_i(3)*zhat
585         cz_i = uz_i(1)*xhat + uz_i(2)*yhat + uz_i(3)*zhat
586 +       dudux_i = zero
587 +       duduy_i = zero
588 +       duduz_i = zero
589      endif
590  
591      if (j_is_Charge) then
# Line 578 | Line 608 | contains
608         if (j_is_SplitDipole) then
609            d_j = ElectrostaticMap(me2)%split_dipole_distance
610         endif
611 +       duduz_j = zero
612      endif
613  
614      if (j_is_Quadrupole) then
# Line 608 | Line 639 | contains
639         cx_j = ux_j(1)*xhat + ux_j(2)*yhat + ux_j(3)*zhat
640         cy_j = uy_j(1)*xhat + uy_j(2)*yhat + uy_j(3)*zhat
641         cz_j = uz_j(1)*xhat + uz_j(2)*yhat + uz_j(3)*zhat
642 +       dudux_j = zero
643 +       duduy_j = zero
644 +       duduz_j = zero
645      endif
646    
647 <    epot = 0.0_dp
648 <    dudx = 0.0_dp
649 <    dudy = 0.0_dp
650 <    dudz = 0.0_dp
647 >    epot = zero
648 >    dudx = zero
649 >    dudy = zero
650 >    dudz = zero  
651  
618    dudux_i = 0.0_dp
619    duduy_i = 0.0_dp
620    duduz_i = 0.0_dp
621
622    dudux_j = 0.0_dp
623    duduy_j = 0.0_dp
624    duduz_j = 0.0_dp
625
652      if (i_is_Charge) then
653  
654         if (j_is_Charge) then
655 +          if (screeningMethod .eq. DAMPED) then
656 +             f0 = derfc(dampingAlpha*rij)
657 +             varEXP = exp(-alpha2*rij*rij)
658 +             f1 = alphaPi*rij*varEXP + f0
659 +          endif
660  
661 <          if (summationMethod .eq. UNDAMPED_WOLF) then
631 <             vterm = pre11 * q_i * q_j * (riji - rcuti)
632 <             vpair = vpair + vterm
633 <             epot = epot + sw*vterm
634 <            
635 <             dudr  = -sw*pre11*q_i*q_j * (riji*riji-rcuti2)
636 <            
637 <             dudx = dudx + dudr * xhat
638 <             dudy = dudy + dudr * yhat
639 <             dudz = dudz + dudr * zhat
661 >          preVal = pre11 * q_i * q_j
662  
663 <          elseif (summationMethod .eq. DAMPED_WOLF) then
664 <             varERFC = derfc(dampingAlpha*rij)
643 <             varEXP = exp(-dampingAlpha*dampingAlpha*rij*rij)
644 <             vterm = pre11 * q_i * q_j * (varERFC*riji - constERFC*rcuti)
645 <             vpair = vpair + vterm
646 <             epot = epot + sw*vterm
663 >          if (summationMethod .eq. SHIFTED_POTENTIAL) then
664 >             vterm = preVal * (riji*f0 - rcuti*f0c)
665              
666 <             dudr  = -sw*pre11*q_i*q_j * (((varERFC*riji*riji &
667 <                  + alphaPi*varEXP*riji) - (constERFC*rcuti2 &
668 <                  + alphaPi*constEXP*rcuti)) )
666 >             dudr  = -sw * preVal * riji * riji * f1
667 >  
668 >          elseif (summationMethod .eq. SHIFTED_FORCE) then
669 >             vterm = preVal * ( riji*f0 - rcuti*f0c + &
670 >                  f1c*rcuti2*(rij-defaultCutoff) )
671              
672 <             dudx = dudx + dudr * xhat
673 <             dudy = dudy + dudr * yhat
654 <             dudz = dudz + dudr * zhat
655 <
672 >             dudr  = -sw*preVal * (riji*riji*f1 - rcuti2*f1c)
673 >  
674            elseif (summationMethod .eq. REACTION_FIELD) then
657             preVal = pre11 * q_i * q_j
675               rfVal = preRF*rij*rij
676               vterm = preVal * ( riji + rfVal )
677              
661             vpair = vpair + vterm
662             epot = epot + sw*vterm
663            
678               dudr  = sw * preVal * ( 2.0d0*rfVal - riji )*riji
679 <            
666 <             dudx = dudx + dudr * xhat
667 <             dudy = dudy + dudr * yhat
668 <             dudz = dudz + dudr * zhat
669 <
679 >  
680            else
681 <             vterm = pre11 * q_i * q_j * riji
672 <             vpair = vpair + vterm
673 <             epot = epot + sw*vterm
681 >             vterm = preVal * riji*f0
682              
683 <             dudr  = - sw * vterm * riji
684 <            
677 <             dudx = dudx + dudr * xhat
678 <             dudy = dudy + dudr * yhat
679 <             dudz = dudz + dudr * zhat
680 <
683 >             dudr  = - sw * preVal * riji*riji*f1
684 >  
685            endif
686  
687 +          vpair = vpair + vterm
688 +          epot = epot + sw*vterm
689 +
690 +          dudx = dudx + dudr * xhat
691 +          dudy = dudy + dudr * yhat
692 +          dudz = dudz + dudr * zhat
693 +
694         endif
695  
696         if (j_is_Dipole) then
697 +          if (screeningMethod .eq. DAMPED) then
698 +             f0 = derfc(dampingAlpha*rij)
699 +             varEXP = exp(-alpha2*rij*rij)
700 +             f1 = alphaPi*rij*varEXP + f0
701 +             f3 = alphaPi*2.0d0*alpha2*varEXP*rij*rij*rij
702 +          endif
703  
704            pref = pre12 * q_i * mu_j
705  
706 <          if (summationMethod .eq. UNDAMPED_WOLF) then
690 <             ri2 = riji * riji
691 <             ri3 = ri2 * riji
692 <
693 <             pref = pre12 * q_i * mu_j
694 <             vterm = - pref * ct_j * (ri2 - rcuti2)
695 <             vpair = vpair + vterm
696 <             epot = epot + sw*vterm
697 <            
698 <             !! this has a + sign in the () because the rij vector is
699 <             !! r_j - r_i and the charge-dipole potential takes the origin
700 <             !! as the point dipole, which is atom j in this case.
701 <            
702 <             dudx = dudx - sw*pref * ( ri3*( uz_j(1) - 3.0d0*ct_j*xhat) &
703 <                  - rcuti3*( uz_j(1) - 3.0d0*ct_j*d(1)*rcuti ) )
704 <             dudy = dudy - sw*pref * ( ri3*( uz_j(2) - 3.0d0*ct_j*yhat) &
705 <                  - rcuti3*( uz_j(2) - 3.0d0*ct_j*d(2)*rcuti ) )
706 <             dudz = dudz - sw*pref * ( ri3*( uz_j(3) - 3.0d0*ct_j*zhat) &
707 <                  - rcuti3*( uz_j(3) - 3.0d0*ct_j*d(3)*rcuti ) )
708 <            
709 <             duduz_j(1) = duduz_j(1) - sw*pref*( ri2*xhat - d(1)*rcuti3 )
710 <             duduz_j(2) = duduz_j(2) - sw*pref*( ri2*yhat - d(2)*rcuti3 )
711 <             duduz_j(3) = duduz_j(3) - sw*pref*( ri2*zhat - d(3)*rcuti3 )
712 <
713 <          elseif (summationMethod .eq. REACTION_FIELD) then
706 >          if (summationMethod .eq. REACTION_FIELD) then
707               ri2 = riji * riji
708               ri3 = ri2 * riji
709      
717             pref = pre12 * q_i * mu_j
710               vterm = - pref * ct_j * ( ri2 - preRF2*rij )
711               vpair = vpair + vterm
712               epot = epot + sw*vterm
# Line 735 | Line 727 | contains
727  
728            else
729               if (j_is_SplitDipole) then
730 <                BigR = sqrt(r2 + 0.25_dp * d_j * d_j)
731 <                ri = 1.0_dp / BigR
730 >                BigR = sqrt(r2 + 0.25d0 * d_j * d_j)
731 >                ri = 1.0d0 / BigR
732                  scale = rij * ri
733               else
734                  ri = riji
735 <                scale = 1.0_dp
735 >                scale = 1.0d0
736               endif
737              
738               ri2 = ri * ri
739               ri3 = ri2 * ri
740               sc2 = scale * scale
741  
742 <             pref = pre12 * q_i * mu_j
743 <             vterm = - pref * ct_j * ri2 * scale
742 >             pot_term =  ri2 * scale * f1
743 >             vterm = - pref * ct_j * pot_term
744               vpair = vpair + vterm
745               epot = epot + sw*vterm
746              
# Line 756 | Line 748 | contains
748               !! r_j - r_i and the charge-dipole potential takes the origin
749               !! as the point dipole, which is atom j in this case.
750              
751 <             dudx = dudx - sw*pref * ri3 * ( uz_j(1) - 3.0d0*ct_j*xhat*sc2)
752 <             dudy = dudy - sw*pref * ri3 * ( uz_j(2) - 3.0d0*ct_j*yhat*sc2)
753 <             dudz = dudz - sw*pref * ri3 * ( uz_j(3) - 3.0d0*ct_j*zhat*sc2)
754 <            
755 <             duduz_j(1) = duduz_j(1) - sw*pref * ri2 * xhat * scale
756 <             duduz_j(2) = duduz_j(2) - sw*pref * ri2 * yhat * scale
757 <             duduz_j(3) = duduz_j(3) - sw*pref * ri2 * zhat * scale
751 >             dudx = dudx - sw*pref * ri3 * ( uz_j(1)*f1 - &
752 >                  ct_j*xhat*sc2*( 3.0d0*f1 + f3 ) )
753 >             dudy = dudy - sw*pref * ri3 * ( uz_j(2)*f1 - &
754 >                  ct_j*yhat*sc2*( 3.0d0*f1 + f3 ) )
755 >             dudz = dudz - sw*pref * ri3 * ( uz_j(3)*f1 - &
756 >                  ct_j*zhat*sc2*( 3.0d0*f1 + f3 ) )
757 >                          
758 >             duduz_j(1) = duduz_j(1) - sw*pref * pot_term * xhat
759 >             duduz_j(2) = duduz_j(2) - sw*pref * pot_term * yhat
760 >             duduz_j(3) = duduz_j(3) - sw*pref * pot_term * zhat
761  
762            endif
763         endif
764  
765         if (j_is_Quadrupole) then
766 +          if (screeningMethod .eq. DAMPED) then
767 +             f0 = derfc(dampingAlpha*rij)
768 +             varEXP = exp(-alpha2*rij*rij)
769 +             f1 = alphaPi*rij*varEXP + f0
770 +             f2 = alphaPi*2.0d0*alpha2*varEXP
771 +             f3 = f2*rij*rij*rij
772 +             f4 = 2.0d0*alpha2*f2*rij
773 +          endif
774 +
775            ri2 = riji * riji
776            ri3 = ri2 * riji
777            ri4 = ri2 * ri2
# Line 775 | Line 779 | contains
779            cy2 = cy_j * cy_j
780            cz2 = cz_j * cz_j
781  
782 <          if (summationMethod .eq. UNDAMPED_WOLF) then
783 <             pref =  pre14 * q_i / 3.0_dp
784 <             vterm1 = pref * ri3*( qxx_j * (3.0_dp*cx2 - 1.0_dp) + &
785 <                  qyy_j * (3.0_dp*cy2 - 1.0_dp) + &
786 <                  qzz_j * (3.0_dp*cz2 - 1.0_dp) )
787 <             vterm2 = pref * rcuti3*( qxx_j * (3.0_dp*cx2 - 1.0_dp) + &
788 <                  qyy_j * (3.0_dp*cy2 - 1.0_dp) + &
785 <                  qzz_j * (3.0_dp*cz2 - 1.0_dp) )
786 <             vpair = vpair + ( vterm1 - vterm2 )
787 <             epot = epot + sw*( vterm1 - vterm2 )
788 <            
789 <             dudx = dudx - (5.0_dp * &
790 <                  (vterm1*riji*xhat - vterm2*rcuti2*d(1))) + sw*pref * ( &
791 <                  (ri4 - rcuti4)*(qxx_j*(6.0_dp*cx_j*ux_j(1)) - &
792 <                  qxx_j*2.0_dp*(xhat - rcuti*d(1))) + &
793 <                  (ri4 - rcuti4)*(qyy_j*(6.0_dp*cy_j*uy_j(1)) - &
794 <                  qyy_j*2.0_dp*(xhat - rcuti*d(1))) + &
795 <                  (ri4 - rcuti4)*(qzz_j*(6.0_dp*cz_j*uz_j(1)) - &
796 <                  qzz_j*2.0_dp*(xhat - rcuti*d(1))) )
797 <             dudy = dudy - (5.0_dp * &
798 <                  (vterm1*riji*yhat - vterm2*rcuti2*d(2))) + sw*pref * ( &
799 <                  (ri4 - rcuti4)*(qxx_j*(6.0_dp*cx_j*ux_j(2)) - &
800 <                  qxx_j*2.0_dp*(yhat - rcuti*d(2))) + &
801 <                  (ri4 - rcuti4)*(qyy_j*(6.0_dp*cy_j*uy_j(2)) - &
802 <                  qyy_j*2.0_dp*(yhat - rcuti*d(2))) + &
803 <                  (ri4 - rcuti4)*(qzz_j*(6.0_dp*cz_j*uz_j(2)) - &
804 <                  qzz_j*2.0_dp*(yhat - rcuti*d(2))) )
805 <             dudz = dudz - (5.0_dp * &
806 <                  (vterm1*riji*zhat - vterm2*rcuti2*d(3))) + sw*pref * ( &
807 <                  (ri4 - rcuti4)*(qxx_j*(6.0_dp*cx_j*ux_j(3)) - &
808 <                  qxx_j*2.0_dp*(zhat - rcuti*d(3))) + &
809 <                  (ri4 - rcuti4)*(qyy_j*(6.0_dp*cy_j*uy_j(3)) - &
810 <                  qyy_j*2.0_dp*(zhat - rcuti*d(3))) + &
811 <                  (ri4 - rcuti4)*(qzz_j*(6.0_dp*cz_j*uz_j(3)) - &
812 <                  qzz_j*2.0_dp*(zhat - rcuti*d(3))) )
813 <            
814 <             dudux_j(1) = dudux_j(1) + sw*pref*(ri3*(qxx_j*6.0_dp*cx_j*xhat) -&
815 <                  rcuti4*(qxx_j*6.0_dp*cx_j*d(1)))
816 <             dudux_j(2) = dudux_j(2) + sw*pref*(ri3*(qxx_j*6.0_dp*cx_j*yhat) -&
817 <                  rcuti4*(qxx_j*6.0_dp*cx_j*d(2)))
818 <             dudux_j(3) = dudux_j(3) + sw*pref*(ri3*(qxx_j*6.0_dp*cx_j*zhat) -&
819 <                  rcuti4*(qxx_j*6.0_dp*cx_j*d(3)))
820 <            
821 <             duduy_j(1) = duduy_j(1) + sw*pref*(ri3*(qyy_j*6.0_dp*cy_j*xhat) -&
822 <                  rcuti4*(qyy_j*6.0_dp*cx_j*d(1)))
823 <             duduy_j(2) = duduy_j(2) + sw*pref*(ri3*(qyy_j*6.0_dp*cy_j*yhat) -&
824 <                  rcuti4*(qyy_j*6.0_dp*cx_j*d(2)))
825 <             duduy_j(3) = duduy_j(3) + sw*pref*(ri3*(qyy_j*6.0_dp*cy_j*zhat) -&
826 <                  rcuti4*(qyy_j*6.0_dp*cx_j*d(3)))
827 <            
828 <             duduz_j(1) = duduz_j(1) + sw*pref*(ri3*(qzz_j*6.0_dp*cz_j*xhat) -&
829 <                  rcuti4*(qzz_j*6.0_dp*cx_j*d(1)))
830 <             duduz_j(2) = duduz_j(2) + sw*pref*(ri3*(qzz_j*6.0_dp*cz_j*yhat) -&
831 <                  rcuti4*(qzz_j*6.0_dp*cx_j*d(2)))
832 <             duduz_j(3) = duduz_j(3) + sw*pref*(ri3*(qzz_j*6.0_dp*cz_j*zhat) -&
833 <                  rcuti4*(qzz_j*6.0_dp*cx_j*d(3)))
834 <        
835 <          else
836 <             pref =  pre14 * q_i / 3.0_dp
837 <             vterm = pref * ri3 * (qxx_j * (3.0_dp*cx2 - 1.0_dp) + &
838 <                  qyy_j * (3.0_dp*cy2 - 1.0_dp) + &
839 <                  qzz_j * (3.0_dp*cz2 - 1.0_dp))
840 <             vpair = vpair + vterm
841 <             epot = epot + sw*vterm
842 <            
843 <             dudx = dudx - 5.0_dp*sw*vterm*riji*xhat + sw*pref * ri4 * ( &
844 <                  qxx_j*(6.0_dp*cx_j*ux_j(1) - 2.0_dp*xhat) + &
845 <                  qyy_j*(6.0_dp*cy_j*uy_j(1) - 2.0_dp*xhat) + &
846 <                  qzz_j*(6.0_dp*cz_j*uz_j(1) - 2.0_dp*xhat) )
847 <             dudy = dudy - 5.0_dp*sw*vterm*riji*yhat + sw*pref * ri4 * ( &
848 <                  qxx_j*(6.0_dp*cx_j*ux_j(2) - 2.0_dp*yhat) + &
849 <                  qyy_j*(6.0_dp*cy_j*uy_j(2) - 2.0_dp*yhat) + &
850 <                  qzz_j*(6.0_dp*cz_j*uz_j(2) - 2.0_dp*yhat) )
851 <             dudz = dudz - 5.0_dp*sw*vterm*riji*zhat + sw*pref * ri4 * ( &
852 <                  qxx_j*(6.0_dp*cx_j*ux_j(3) - 2.0_dp*zhat) + &
853 <                  qyy_j*(6.0_dp*cy_j*uy_j(3) - 2.0_dp*zhat) + &
854 <                  qzz_j*(6.0_dp*cz_j*uz_j(3) - 2.0_dp*zhat) )
855 <            
856 <             dudux_j(1) = dudux_j(1) + sw*pref * ri3*(qxx_j*6.0_dp*cx_j*xhat)
857 <             dudux_j(2) = dudux_j(2) + sw*pref * ri3*(qxx_j*6.0_dp*cx_j*yhat)
858 <             dudux_j(3) = dudux_j(3) + sw*pref * ri3*(qxx_j*6.0_dp*cx_j*zhat)
859 <            
860 <             duduy_j(1) = duduy_j(1) + sw*pref * ri3*(qyy_j*6.0_dp*cy_j*xhat)
861 <             duduy_j(2) = duduy_j(2) + sw*pref * ri3*(qyy_j*6.0_dp*cy_j*yhat)
862 <             duduy_j(3) = duduy_j(3) + sw*pref * ri3*(qyy_j*6.0_dp*cy_j*zhat)
863 <            
864 <             duduz_j(1) = duduz_j(1) + sw*pref * ri3*(qzz_j*6.0_dp*cz_j*xhat)
865 <             duduz_j(2) = duduz_j(2) + sw*pref * ri3*(qzz_j*6.0_dp*cz_j*yhat)
866 <             duduz_j(3) = duduz_j(3) + sw*pref * ri3*(qzz_j*6.0_dp*cz_j*zhat)
782 >          pref =  pre14 * q_i / 3.0d0
783 >          pot_term = ri3*(qxx_j * (3.0d0*cx2 - 1.0d0) + &
784 >               qyy_j * (3.0d0*cy2 - 1.0d0) + &
785 >               qzz_j * (3.0d0*cz2 - 1.0d0))
786 >          vterm = pref * (pot_term*f1 + (qxx_j*cx2 + qyy_j*cy2 + qzz_j*cz2)*f2)
787 >          vpair = vpair + vterm
788 >          epot = epot + sw*vterm
789            
790 <          endif
790 >          dudx = dudx - sw*pref*pot_term*riji*xhat*(5.0d0*f1 + f3) + &
791 >               sw*pref*ri4 * ( &
792 >               qxx_j*(2.0d0*cx_j*ux_j(1)*(3.0d0*f1 + f3) - 2.0d0*xhat*f1) + &
793 >               qyy_j*(2.0d0*cy_j*uy_j(1)*(3.0d0*f1 + f3) - 2.0d0*xhat*f1) + &
794 >               qzz_j*(2.0d0*cz_j*uz_j(1)*(3.0d0*f1 + f3) - 2.0d0*xhat*f1) ) &
795 >               + (qxx_j*cx2 + qyy_j*cy2 + qzz_j*cz2)*f4
796 >          dudy = dudy - sw*pref*pot_term*riji*yhat*(5.0d0*f1 + f3) + &
797 >               sw*pref*ri4 * ( &
798 >               qxx_j*(2.0d0*cx_j*ux_j(2)*(3.0d0*f1 + f3) - 2.0d0*yhat*f1) + &
799 >               qyy_j*(2.0d0*cy_j*uy_j(2)*(3.0d0*f1 + f3) - 2.0d0*yhat*f1) + &
800 >               qzz_j*(2.0d0*cz_j*uz_j(2)*(3.0d0*f1 + f3) - 2.0d0*yhat*f1) ) &
801 >               + (qxx_j*cx2 + qyy_j*cy2 + qzz_j*cz2)*f4
802 >          dudz = dudz - sw*pref*pot_term*riji*zhat*(5.0d0*f1 + f3) + &
803 >               sw*pref*ri4 * ( &
804 >               qxx_j*(2.0d0*cx_j*ux_j(3)*(3.0d0*f1 + f3) - 2.0d0*zhat*f1) + &
805 >               qyy_j*(2.0d0*cy_j*uy_j(3)*(3.0d0*f1 + f3) - 2.0d0*zhat*f1) + &
806 >               qzz_j*(2.0d0*cz_j*uz_j(3)*(3.0d0*f1 + f3) - 2.0d0*zhat*f1) ) &
807 >               + (qxx_j*cx2 + qyy_j*cy2 + qzz_j*cz2)*f4
808 >          
809 >          dudux_j(1) = dudux_j(1) + sw*pref*ri3*( (qxx_j*2.0d0*cx_j*xhat) &
810 >               * (3.0d0*f1 + f3) )
811 >          dudux_j(2) = dudux_j(2) + sw*pref*ri3*( (qxx_j*2.0d0*cx_j*yhat) &
812 >               * (3.0d0*f1 + f3) )
813 >          dudux_j(3) = dudux_j(3) + sw*pref*ri3*( (qxx_j*2.0d0*cx_j*zhat) &
814 >               * (3.0d0*f1 + f3) )
815 >          
816 >          duduy_j(1) = duduy_j(1) + sw*pref*ri3*( (qyy_j*2.0d0*cy_j*xhat) &
817 >               * (3.0d0*f1 + f3) )
818 >          duduy_j(2) = duduy_j(2) + sw*pref*ri3*( (qyy_j*2.0d0*cy_j*yhat) &
819 >               * (3.0d0*f1 + f3) )
820 >          duduy_j(3) = duduy_j(3) + sw*pref*ri3*( (qyy_j*2.0d0*cy_j*zhat) &
821 >               * (3.0d0*f1 + f3) )
822 >          
823 >          duduz_j(1) = duduz_j(1) + sw*pref*ri3*( (qzz_j*2.0d0*cz_j*xhat) &
824 >               * (3.0d0*f1 + f3) )
825 >          duduz_j(2) = duduz_j(2) + sw*pref*ri3*( (qzz_j*2.0d0*cz_j*yhat) &
826 >               * (3.0d0*f1 + f3) )
827 >          duduz_j(3) = duduz_j(3) + sw*pref*ri3*( (qzz_j*2.0d0*cz_j*zhat) &
828 >               * (3.0d0*f1 + f3) )
829 >          
830         endif
831      endif
832 <
832 >    
833      if (i_is_Dipole) then
834  
835         if (j_is_Charge) then
836 +          if (screeningMethod .eq. DAMPED) then
837 +             f0 = derfc(dampingAlpha*rij)
838 +             varEXP = exp(-alpha2*rij*rij)
839 +             f1 = alphaPi*rij*varEXP + f0
840 +             f3 = alphaPi*2.0d0*alpha2*varEXP*rij*rij*rij
841 +          endif
842            
843            pref = pre12 * q_j * mu_i
844            
845 <          if (summationMethod .eq. UNDAMPED_WOLF) then
845 >          if (summationMethod .eq. SHIFTED_POTENTIAL) then
846 >             ri2 = riji * riji
847 >             ri3 = ri2 * riji
848 >            
849 >             pot_term = ri2*f1 - rcuti2*f1c
850 >             vterm = pref * ct_i * pot_term
851 >             vpair = vpair + vterm
852 >             epot = epot + sw*vterm
853 >            
854 >             dudx = dudx + sw*pref*( ri3*(uz_i(1)*f1-ct_i*xhat*(3.0d0*f1+f3)) )
855 >             dudy = dudy + sw*pref*( ri3*(uz_i(2)*f1-ct_i*yhat*(3.0d0*f1+f3)) )
856 >             dudz = dudz + sw*pref*( ri3*(uz_i(3)*f1-ct_i*zhat*(3.0d0*f1+f3)) )
857 >            
858 >             duduz_i(1) = duduz_i(1) + sw*pref * xhat * pot_term
859 >             duduz_i(2) = duduz_i(2) + sw*pref * yhat * pot_term
860 >             duduz_i(3) = duduz_i(3) + sw*pref * zhat * pot_term
861 >
862 >          elseif (summationMethod .eq. SHIFTED_FORCE) then
863               ri2 = riji * riji
864               ri3 = ri2 * riji
865  
866 <             pref = pre12 * q_j * mu_i
867 <             vterm = pref * ct_i * (ri2 - rcuti2)
866 >             !! might need a -(f1c-f0c) or dct_i/dr in the derivative term...
867 >             pot_term = ri2*f1 - rcuti2*f1c + &
868 >                  (2.0d0*rcuti3*f1c + f2c)*( rij - defaultCutoff )
869 >             vterm = pref * ct_i * pot_term
870               vpair = vpair + vterm
871               epot = epot + sw*vterm
872              
873 <             dudx = dudx + sw*pref * ( ri3*( uz_i(1) - 3.0d0*ct_i*xhat) &
874 <                  - rcuti3*( uz_i(1) - 3.0d0*ct_i*d(1)*rcuti ) )
875 <             dudy = dudy + sw*pref * ( ri3*( uz_i(2) - 3.0d0*ct_i*yhat) &
876 <                  - rcuti3*( uz_i(2) - 3.0d0*ct_i*d(2)*rcuti ) )
877 <             dudz = dudz + sw*pref * ( ri3*( uz_i(3) - 3.0d0*ct_i*zhat) &
878 <                  - rcuti3*( uz_i(3) - 3.0d0*ct_i*d(3)*rcuti ) )
873 >             dudx = dudx + sw*pref*( ri3*(uz_i(1)*f1-ct_i*xhat*(3.0d0*f1+f3)) &
874 >                  - rcuti3*(uz_i(1)*f1c-ct_i*xhat*(3.0d0*f1c+f3c)) )
875 >             dudy = dudy + sw*pref*( ri3*(uz_i(2)*f1-ct_i*yhat*(3.0d0*f1+f3)) &
876 >                  - rcuti3*(uz_i(1)*f1c-ct_i*xhat*(3.0d0*f1c+f3c)) )
877 >             dudz = dudz + sw*pref*( ri3*(uz_i(3)*f1-ct_i*zhat*(3.0d0*f1+f3)) &
878 >                  - rcuti3*(uz_i(1)*f1c-ct_i*xhat*(3.0d0*f1c+f3c)) )
879              
880 <             duduz_i(1) = duduz_i(1) + sw*pref*( ri2*xhat - d(1)*rcuti3 )
881 <             duduz_i(2) = duduz_i(2) + sw*pref*( ri2*yhat - d(2)*rcuti3 )
882 <             duduz_i(3) = duduz_i(3) + sw*pref*( ri2*zhat - d(3)*rcuti3 )
883 <
880 >             duduz_i(1) = duduz_i(1) + sw*pref * xhat * pot_term
881 >             duduz_i(2) = duduz_i(2) + sw*pref * yhat * pot_term
882 >             duduz_i(3) = duduz_i(3) + sw*pref * zhat * pot_term
883 >
884            elseif (summationMethod .eq. REACTION_FIELD) then
885               ri2 = riji * riji
886               ri3 = ri2 * riji
887  
902             pref = pre12 * q_j * mu_i
888               vterm = pref * ct_i * ( ri2 - preRF2*rij )
889               vpair = vpair + vterm
890               epot = epot + sw*vterm
# Line 917 | Line 902 | contains
902  
903            else
904               if (i_is_SplitDipole) then
905 <                BigR = sqrt(r2 + 0.25_dp * d_i * d_i)
906 <                ri = 1.0_dp / BigR
905 >                BigR = sqrt(r2 + 0.25d0 * d_i * d_i)
906 >                ri = 1.0d0 / BigR
907                  scale = rij * ri
908               else
909                  ri = riji
910 <                scale = 1.0_dp
910 >                scale = 1.0d0
911               endif
912              
913               ri2 = ri * ri
914               ri3 = ri2 * ri
915               sc2 = scale * scale
916  
917 <             pref = pre12 * q_j * mu_i
918 <             vterm = pref * ct_i * ri2 * scale
917 >             pot_term = ri2 * f1 * scale
918 >             vterm = pref * ct_i * pot_term
919               vpair = vpair + vterm
920               epot = epot + sw*vterm
921              
922 <             dudx = dudx + sw*pref * ri3 * ( uz_i(1) - 3.0d0 * ct_i * xhat*sc2)
923 <             dudy = dudy + sw*pref * ri3 * ( uz_i(2) - 3.0d0 * ct_i * yhat*sc2)
924 <             dudz = dudz + sw*pref * ri3 * ( uz_i(3) - 3.0d0 * ct_i * zhat*sc2)
922 >             dudx = dudx + sw*pref * ri3 * ( uz_i(1)*f1 - &
923 >                  ct_i*xhat*sc2*( 3.0d0*f1 + f3 ) )
924 >             dudy = dudy + sw*pref * ri3 * ( uz_i(2)*f1 - &
925 >                  ct_i*yhat*sc2*( 3.0d0*f1 + f3 ) )
926 >             dudz = dudz + sw*pref * ri3 * ( uz_i(3)*f1 - &
927 >                  ct_i*zhat*sc2*( 3.0d0*f1 + f3 ) )
928              
929 <             duduz_i(1) = duduz_i(1) + sw*pref * ri2 * xhat * scale
930 <             duduz_i(2) = duduz_i(2) + sw*pref * ri2 * yhat * scale
931 <             duduz_i(3) = duduz_i(3) + sw*pref * ri2 * zhat * scale
929 >             duduz_i(1) = duduz_i(1) + sw*pref * pot_term * xhat
930 >             duduz_i(2) = duduz_i(2) + sw*pref * pot_term * yhat
931 >             duduz_i(3) = duduz_i(3) + sw*pref * pot_term * zhat
932            endif
933         endif
934        
935         if (j_is_Dipole) then
936 +          if (screeningMethod .eq. DAMPED) then
937 +             f0 = derfc(dampingAlpha*rij)
938 +             varEXP = exp(-alpha2*rij*rij)
939 +             f1 = alphaPi*rij*varEXP + f0
940 +             f2 = alphaPi*2.0d0*alpha2*varEXP
941 +             f3 = f2*rij*rij*rij
942 +             f4 = 2.0d0*alpha2*f3*rij*rij
943 +          endif
944  
945 <          if (summationMethod .eq. UNDAMPED_WOLF) then
950 < !!$             ct_ij = uz_i(1)*uz_j(1) + uz_i(2)*uz_j(2) + uz_i(3)*uz_j(3)
951 < !!$
952 < !!$             ri2 = riji * riji
953 < !!$             ri3 = ri2 * riji
954 < !!$             ri4 = ri2 * ri2
955 < !!$
956 < !!$             pref = pre22 * mu_i * mu_j
957 < !!$             vterm = pref * (ri3 - rcuti3) * (ct_ij - 3.0d0 * ct_i * ct_j)
958 < !!$             vpair = vpair + vterm
959 < !!$             epot = epot + sw*vterm
960 < !!$            
961 < !!$             a1 = 5.0d0 * ct_i * ct_j - ct_ij
962 < !!$            
963 < !!$             dudx = dudx + sw*pref*3.0d0*( &
964 < !!$                  ri4*(a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1)) &
965 < !!$                  - rcuti4*(a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1)) )
966 < !!$             dudy = dudy + sw*pref*3.0d0*( &
967 < !!$                  ri4*(a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2)) &
968 < !!$                  - rcuti4*(a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2)) )
969 < !!$             dudz = dudz + sw*pref*3.0d0*( &
970 < !!$                  ri4*(a1*zhat-ct_i*uz_j(3)-ct_j*uz_i(3)) &
971 < !!$                  - rcuti4*(a1*zhat-ct_i*uz_j(3)-ct_j*uz_i(3)) )
972 < !!$            
973 < !!$             duduz_i(1) = duduz_i(1) + sw*pref*(ri3*(uz_j(1)-3.0d0*ct_j*xhat) &
974 < !!$                  - rcuti3*(uz_j(1) - 3.0d0*ct_j*xhat))
975 < !!$             duduz_i(2) = duduz_i(2) + sw*pref*(ri3*(uz_j(2)-3.0d0*ct_j*yhat) &
976 < !!$                  - rcuti3*(uz_j(2) - 3.0d0*ct_j*yhat))
977 < !!$             duduz_i(3) = duduz_i(3) + sw*pref*(ri3*(uz_j(3)-3.0d0*ct_j*zhat) &
978 < !!$                  - rcuti3*(uz_j(3) - 3.0d0*ct_j*zhat))
979 < !!$             duduz_j(1) = duduz_j(1) + sw*pref*(ri3*(uz_i(1)-3.0d0*ct_i*xhat) &
980 < !!$                  - rcuti3*(uz_i(1) - 3.0d0*ct_i*xhat))
981 < !!$             duduz_j(2) = duduz_j(2) + sw*pref*(ri3*(uz_i(2)-3.0d0*ct_i*yhat) &
982 < !!$                  - rcuti3*(uz_i(2) - 3.0d0*ct_i*yhat))
983 < !!$             duduz_j(3) = duduz_j(3) + sw*pref*(ri3*(uz_i(3)-3.0d0*ct_i*zhat) &
984 < !!$                  - rcuti3*(uz_i(3) - 3.0d0*ct_i*zhat))
945 >          ct_ij = uz_i(1)*uz_j(1) + uz_i(2)*uz_j(2) + uz_i(3)*uz_j(3)
946            
947 <          elseif (summationMethod .eq. DAMPED_WOLF) then
948 <             ct_ij = uz_i(1)*uz_j(1) + uz_i(2)*uz_j(2) + uz_i(3)*uz_j(3)
949 <            
950 <             ri2 = riji * riji
951 <             ri3 = ri2 * riji
991 <             ri4 = ri2 * ri2
992 <             sc2 = scale * scale
993 <            
994 <             pref = pre22 * mu_i * mu_j
995 <             vterm = pref * ri3 * (ct_ij - 3.0d0 * ct_i * ct_j)
996 <             vpair = vpair + vterm
997 <             epot = epot + sw*vterm
998 <            
999 <             a1 = 5.0d0 * ct_i * ct_j * sc2 - ct_ij
1000 <            
1001 <             dudx = dudx + sw*pref*3.0d0*ri4*(a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1))
1002 <             dudy = dudy + sw*pref*3.0d0*ri4*(a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2))
1003 <             dudz = dudz + sw*pref*3.0d0*ri4*(a1*zhat-ct_i*uz_j(3)-ct_j*uz_i(3))
1004 <            
1005 <             duduz_i(1) = duduz_i(1) + sw*pref*ri3 *(uz_j(1) - 3.0d0*ct_j*xhat)
1006 <             duduz_i(2) = duduz_i(2) + sw*pref*ri3 *(uz_j(2) - 3.0d0*ct_j*yhat)
1007 <             duduz_i(3) = duduz_i(3) + sw*pref*ri3 *(uz_j(3) - 3.0d0*ct_j*zhat)
1008 <            
1009 <             duduz_j(1) = duduz_j(1) + sw*pref*ri3 *(uz_i(1) - 3.0d0*ct_i*xhat)
1010 <             duduz_j(2) = duduz_j(2) + sw*pref*ri3 *(uz_i(2) - 3.0d0*ct_i*yhat)
1011 <             duduz_j(3) = duduz_j(3) + sw*pref*ri3 *(uz_i(3) - 3.0d0*ct_i*zhat)
1012 <            
1013 <          elseif (summationMethod .eq. REACTION_FIELD) then
1014 <             ct_ij = uz_i(1)*uz_j(1) + uz_i(2)*uz_j(2) + uz_i(3)*uz_j(3)
947 >          ri2 = riji * riji
948 >          ri3 = ri2 * riji
949 >          ri4 = ri2 * ri2
950 >          
951 >          pref = pre22 * mu_i * mu_j
952  
953 <             ri2 = riji * riji
1017 <             ri3 = ri2 * riji
1018 <             ri4 = ri2 * ri2
1019 <
1020 <             pref = pre22 * mu_i * mu_j
1021 <              
953 >          if (summationMethod .eq. REACTION_FIELD) then
954               vterm = pref*( ri3*(ct_ij - 3.0d0 * ct_i * ct_j) - &
955                    preRF2*ct_ij )
956               vpair = vpair + vterm
# Line 1049 | Line 981 | contains
981            else
982               if (i_is_SplitDipole) then
983                  if (j_is_SplitDipole) then
984 <                   BigR = sqrt(r2 + 0.25_dp * d_i * d_i + 0.25_dp * d_j * d_j)
984 >                   BigR = sqrt(r2 + 0.25d0 * d_i * d_i + 0.25d0 * d_j * d_j)
985                  else
986 <                   BigR = sqrt(r2 + 0.25_dp * d_i * d_i)
986 >                   BigR = sqrt(r2 + 0.25d0 * d_i * d_i)
987                  endif
988 <                ri = 1.0_dp / BigR
988 >                ri = 1.0d0 / BigR
989                  scale = rij * ri                
990               else
991                  if (j_is_SplitDipole) then
992 <                   BigR = sqrt(r2 + 0.25_dp * d_j * d_j)
993 <                   ri = 1.0_dp / BigR
992 >                   BigR = sqrt(r2 + 0.25d0 * d_j * d_j)
993 >                   ri = 1.0d0 / BigR
994                     scale = rij * ri                            
995                  else                
996                     ri = riji
997 <                   scale = 1.0_dp
997 >                   scale = 1.0d0
998                  endif
999               endif
1000              
1069             ct_ij = uz_i(1)*uz_j(1) + uz_i(2)*uz_j(2) + uz_i(3)*uz_j(3)
1070            
1071             ri2 = ri * ri
1072             ri3 = ri2 * ri
1073             ri4 = ri2 * ri2
1001               sc2 = scale * scale
1002 <            
1003 <             pref = pre22 * mu_i * mu_j
1004 <             vterm = pref * ri3 * (ct_ij - 3.0d0 * ct_i * ct_j * sc2)
1002 >
1003 >             pot_term = (ct_ij - 3.0d0 * ct_i * ct_j * sc2)
1004 >             vterm = pref * ( ri3*pot_term*f1 + (ct_i * ct_j)*f2 )
1005               vpair = vpair + vterm
1006               epot = epot + sw*vterm
1007              
1008 <             a1 = 5.0d0 * ct_i * ct_j * sc2 - ct_ij
1008 >             f13 = f1+f3
1009 >             f134 = f13 + f4
1010              
1011 <             dudx = dudx + sw*pref*3.0d0*ri4*scale &
1012 <                             *(a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1))
1013 <             dudy = dudy + sw*pref*3.0d0*ri4*scale &
1014 <                             *(a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2))
1015 <             dudz = dudz + sw*pref*3.0d0*ri4*scale &
1016 <                             *(a1*zhat-ct_i*uz_j(3)-ct_j*uz_i(3))
1017 <            
1018 <             duduz_i(1) = duduz_i(1) + sw*pref*ri3 &
1019 <                                         *(uz_j(1) - 3.0d0*ct_j*xhat*sc2)
1020 <             duduz_i(2) = duduz_i(2) + sw*pref*ri3 &
1021 <                                         *(uz_j(2) - 3.0d0*ct_j*yhat*sc2)
1022 <             duduz_i(3) = duduz_i(3) + sw*pref*ri3 &
1023 <                                         *(uz_j(3) - 3.0d0*ct_j*zhat*sc2)
1011 > !!$             dudx = dudx + sw*pref * ( ri4*scale*( &
1012 > !!$                  3.0d0*(a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1))*f1 &
1013 > !!$                  - pot_term*f3) &
1014 > !!$                  + 2.0d0*ct_i*ct_j*xhat*(ct_i*uz_j(1)+ct_j*uz_i(1))*f3 &
1015 > !!$                  + (ct_i * ct_j)*f4 )
1016 > !!$             dudy = dudy + sw*pref * ( ri4*scale*( &
1017 > !!$                  3.0d0*(a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2))*f1 &
1018 > !!$                  - pot_term*f3) &
1019 > !!$                  + 2.0d0*ct_i*ct_j*yhat*(ct_i*uz_j(2)+ct_j*uz_i(2))*f3 &
1020 > !!$                  + (ct_i * ct_j)*f4 )
1021 > !!$             dudz = dudz + sw*pref * ( ri4*scale*( &
1022 > !!$                  3.0d0*(a1*zhat-ct_i*uz_j(3)-ct_j*uz_i(3))*f1 &
1023 > !!$                  - pot_term*f3) &
1024 > !!$                  + 2.0d0*ct_i*ct_j*zhat*(ct_i*uz_j(3)+ct_j*uz_i(3))*f3 &
1025 > !!$                  + (ct_i * ct_j)*f4 )
1026 >
1027 >             dudx = dudx + sw*pref * ( ri4*scale*( &
1028 >                  15.0d0*(ct_i * ct_j * sc2)*xhat*f134 - &
1029 >                  3.0d0*(ct_i*uz_j(1) + ct_j*uz_i(1) + ct_ij*xhat)*f134) )
1030 >             dudy = dudy + sw*pref * ( ri4*scale*( &
1031 >                  15.0d0*(ct_i * ct_j * sc2)*yhat*f134 - &
1032 >                  3.0d0*(ct_i*uz_j(2) + ct_j*uz_i(2) + ct_ij*yhat)*f134) )
1033 >             dudz = dudz + sw*pref * ( ri4*scale*( &
1034 >                  15.0d0*(ct_i * ct_j * sc2)*zhat*f134 - &
1035 >                  3.0d0*(ct_i*uz_j(3) + ct_j*uz_i(3) + ct_ij*zhat)*f134) )
1036              
1037 <             duduz_j(1) = duduz_j(1) + sw*pref*ri3 &
1038 <                                         *(uz_i(1) - 3.0d0*ct_i*xhat*sc2)
1039 <             duduz_j(2) = duduz_j(2) + sw*pref*ri3 &
1040 <                                         *(uz_i(2) - 3.0d0*ct_i*yhat*sc2)
1041 <             duduz_j(3) = duduz_j(3) + sw*pref*ri3 &
1042 <                                         *(uz_i(3) - 3.0d0*ct_i*zhat*sc2)
1037 >             duduz_i(1) = duduz_i(1) + sw*pref * &
1038 >                  ( ri3*(uz_j(1) - 3.0d0*ct_j*xhat*sc2)*f1 + (ct_j*xhat)*f2 )
1039 >             duduz_i(2) = duduz_i(2) + sw*pref * &
1040 >                  ( ri3*(uz_j(2) - 3.0d0*ct_j*yhat*sc2)*f1 + (ct_j*yhat)*f2 )
1041 >             duduz_i(3) = duduz_i(3) + sw*pref * &
1042 >                  ( ri3*(uz_j(3) - 3.0d0*ct_j*zhat*sc2)*f1 + (ct_j*zhat)*f2 )
1043 >            
1044 >             duduz_j(1) = duduz_j(1) + sw*pref * &
1045 >                  ( ri3*(uz_i(1) - 3.0d0*ct_i*xhat*sc2)*f1 + (ct_i*xhat)*f2 )
1046 >             duduz_j(2) = duduz_j(2) + sw*pref * &
1047 >                  ( ri3*(uz_i(2) - 3.0d0*ct_i*yhat*sc2)*f1 + (ct_i*yhat)*f2 )
1048 >             duduz_j(3) = duduz_j(3) + sw*pref * &
1049 >                  ( ri3*(uz_i(3) - 3.0d0*ct_i*zhat*sc2)*f1 + (ct_i*zhat)*f2 )
1050            endif
1051         endif
1052      endif
1053  
1054      if (i_is_Quadrupole) then
1055         if (j_is_Charge) then
1056 +          if (screeningMethod .eq. DAMPED) then
1057 +             f0 = derfc(dampingAlpha*rij)
1058 +             varEXP = exp(-alpha2*rij*rij)
1059 +             f1 = alphaPi*rij*varEXP + f0
1060 +             f2 = alphaPi*2.0d0*alpha2*varEXP
1061 +             f3 = f2*rij*rij*rij
1062 +             f4 = 2.0d0*alpha2*f2*rij
1063 +          endif
1064  
1065            ri2 = riji * riji
1066            ri3 = ri2 * riji
# Line 1114 | Line 1069 | contains
1069            cy2 = cy_i * cy_i
1070            cz2 = cz_i * cz_i
1071  
1072 <          if (summationMethod .eq. UNDAMPED_WOLF) then
1073 <             pref = pre14 * q_j / 3.0_dp
1074 <             vterm1 = pref * ri3*( qxx_i * (3.0_dp*cx2 - 1.0_dp) + &
1075 <                  qyy_i * (3.0_dp*cy2 - 1.0_dp) + &
1076 <                  qzz_i * (3.0_dp*cz2 - 1.0_dp) )
1077 <             vterm2 = pref * rcuti3*( 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 + ( vterm1 - vterm2 )
1081 <             epot = epot + sw*( vterm1 - vterm2 )
1082 <            
1083 <             dudx = dudx - sw*(5.0_dp*(vterm1*riji*xhat-vterm2*rcuti2*d(1))) +&
1084 <                  sw*pref * ( (ri4 - rcuti4)*(qxx_i*(6.0_dp*cx_i*ux_i(1)) - &
1085 <                  qxx_i*2.0_dp*(xhat - rcuti*d(1))) + &
1086 <                  (ri4 - rcuti4)*(qyy_i*(6.0_dp*cy_i*uy_i(1)) - &
1087 <                  qyy_i*2.0_dp*(xhat - rcuti*d(1))) + &
1088 <                  (ri4 - rcuti4)*(qzz_i*(6.0_dp*cz_i*uz_i(1)) - &
1089 <                  qzz_i*2.0_dp*(xhat - rcuti*d(1))) )
1090 <             dudy = dudy - sw*(5.0_dp*(vterm1*riji*yhat-vterm2*rcuti2*d(2))) +&
1091 <                  sw*pref * ( (ri4 - rcuti4)*(qxx_i*(6.0_dp*cx_i*ux_i(2)) - &
1092 <                  qxx_i*2.0_dp*(yhat - rcuti*d(2))) + &
1093 <                  (ri4 - rcuti4)*(qyy_i*(6.0_dp*cy_i*uy_i(2)) - &
1094 <                  qyy_i*2.0_dp*(yhat - rcuti*d(2))) + &
1095 <                  (ri4 - rcuti4)*(qzz_i*(6.0_dp*cz_i*uz_i(2)) - &
1096 <                  qzz_i*2.0_dp*(yhat - rcuti*d(2))) )
1097 <             dudz = dudz - sw*(5.0_dp*(vterm1*riji*zhat-vterm2*rcuti2*d(3))) +&
1098 <                  sw*pref * ( (ri4 - rcuti4)*(qxx_i*(6.0_dp*cx_i*ux_i(3)) - &
1099 <                  qxx_i*2.0_dp*(zhat - rcuti*d(3))) + &
1100 <                  (ri4 - rcuti4)*(qyy_i*(6.0_dp*cy_i*uy_i(3)) - &
1101 <                  qyy_i*2.0_dp*(zhat - rcuti*d(3))) + &
1102 <                  (ri4 - rcuti4)*(qzz_i*(6.0_dp*cz_i*uz_i(3)) - &
1103 <                  qzz_i*2.0_dp*(zhat - rcuti*d(3))) )
1104 <            
1105 <             dudux_i(1) = dudux_i(1) + sw*pref*(ri3*(qxx_i*6.0_dp*cx_i*xhat) -&
1106 <                  rcuti4*(qxx_i*6.0_dp*cx_i*d(1)))
1107 <             dudux_i(2) = dudux_i(2) + sw*pref*(ri3*(qxx_i*6.0_dp*cx_i*yhat) -&
1108 <                  rcuti4*(qxx_i*6.0_dp*cx_i*d(2)))
1109 <             dudux_i(3) = dudux_i(3) + sw*pref*(ri3*(qxx_i*6.0_dp*cx_i*zhat) -&
1110 <                  rcuti4*(qxx_i*6.0_dp*cx_i*d(3)))
1111 <            
1112 <             duduy_i(1) = duduy_i(1) + sw*pref*(ri3*(qyy_i*6.0_dp*cy_i*xhat) -&
1113 <                  rcuti4*(qyy_i*6.0_dp*cx_i*d(1)))
1114 <             duduy_i(2) = duduy_i(2) + sw*pref*(ri3*(qyy_i*6.0_dp*cy_i*yhat) -&
1115 <                  rcuti4*(qyy_i*6.0_dp*cx_i*d(2)))
1116 <             duduy_i(3) = duduy_i(3) + sw*pref*(ri3*(qyy_i*6.0_dp*cy_i*zhat) -&
1117 <                  rcuti4*(qyy_i*6.0_dp*cx_i*d(3)))
1118 <            
1164 <             duduz_i(1) = duduz_i(1) + sw*pref*(ri3*(qzz_i*6.0_dp*cz_i*xhat) -&
1165 <                  rcuti4*(qzz_i*6.0_dp*cx_i*d(1)))
1166 <             duduz_i(2) = duduz_i(2) + sw*pref*(ri3*(qzz_i*6.0_dp*cz_i*yhat) -&
1167 <                  rcuti4*(qzz_i*6.0_dp*cx_i*d(2)))
1168 <             duduz_i(3) = duduz_i(3) + sw*pref*(ri3*(qzz_i*6.0_dp*cz_i*zhat) -&
1169 <                  rcuti4*(qzz_i*6.0_dp*cx_i*d(3)))
1072 >          pref = pre14 * q_j / 3.0d0
1073 >          pot_term = ri3 * (qxx_i * (3.0d0*cx2 - 1.0d0) + &
1074 >                            qyy_i * (3.0d0*cy2 - 1.0d0) + &
1075 >                            qzz_i * (3.0d0*cz2 - 1.0d0))
1076 >          vterm = pref * (pot_term*f1 + (qxx_i*cx2 + qyy_i*cy2 + qzz_i*cz2)*f2)
1077 >          vpair = vpair + vterm
1078 >          epot = epot + sw*vterm
1079 >          
1080 >          dudx = dudx - sw*pref*pot_term*riji*xhat*(5.0d0*f1 + f3) + &
1081 >               sw*pref*ri4 * ( &
1082 >               qxx_i*(2.0d0*cx_i*ux_i(1)*(3.0d0*f1 + f3) - 2.0d0*xhat*f1) + &
1083 >               qyy_i*(2.0d0*cy_i*uy_i(1)*(3.0d0*f1 + f3) - 2.0d0*xhat*f1) + &
1084 >               qzz_i*(2.0d0*cz_i*uz_i(1)*(3.0d0*f1 + f3) - 2.0d0*xhat*f1) ) &
1085 >               + (qxx_i*cx2 + qyy_i*cy2 + qzz_i*cz2)*f4
1086 >          dudy = dudy - sw*pref*pot_term*riji*yhat*(5.0d0*f1 + f3) + &
1087 >               sw*pref*ri4 * ( &
1088 >               qxx_i*(2.0d0*cx_i*ux_i(2)*(3.0d0*f1 + f3) - 2.0d0*yhat*f1) + &
1089 >               qyy_i*(2.0d0*cy_i*uy_i(2)*(3.0d0*f1 + f3) - 2.0d0*yhat*f1) + &
1090 >               qzz_i*(2.0d0*cz_i*uz_i(2)*(3.0d0*f1 + f3) - 2.0d0*yhat*f1) ) &
1091 >               + (qxx_i*cx2 + qyy_i*cy2 + qzz_i*cz2)*f4
1092 >          dudz = dudz - sw*pref*pot_term*riji*zhat*(5.0d0*f1 + f3) + &
1093 >               sw*pref*ri4 * ( &
1094 >               qxx_i*(2.0d0*cx_i*ux_i(3)*(3.0d0*f1 + f3) - 2.0d0*zhat*f1) + &
1095 >               qyy_i*(2.0d0*cy_i*uy_i(3)*(3.0d0*f1 + f3) - 2.0d0*zhat*f1) + &
1096 >               qzz_i*(2.0d0*cz_i*uz_i(3)*(3.0d0*f1 + f3) - 2.0d0*zhat*f1) ) &
1097 >               + (qxx_i*cx2 + qyy_i*cy2 + qzz_i*cz2)*f4
1098 >          
1099 >          dudux_i(1) = dudux_i(1) + sw*pref*( ri3*(qxx_i*2.0d0*cx_i*xhat) &
1100 >               * (3.0d0*f1 + f3) )
1101 >          dudux_i(2) = dudux_i(2) + sw*pref*( ri3*(qxx_i*2.0d0*cx_i*yhat) &
1102 >               * (3.0d0*f1 + f3) )
1103 >          dudux_i(3) = dudux_i(3) + sw*pref*( ri3*(qxx_i*2.0d0*cx_i*zhat) &
1104 >               * (3.0d0*f1 + f3) )
1105 >          
1106 >          duduy_i(1) = duduy_i(1) + sw*pref*( ri3*(qyy_i*2.0d0*cy_i*xhat) &
1107 >               * (3.0d0*f1 + f3) )
1108 >          duduy_i(2) = duduy_i(2) + sw*pref*( ri3*(qyy_i*2.0d0*cy_i*yhat) &
1109 >               * (3.0d0*f1 + f3) )
1110 >          duduy_i(3) = duduy_i(3) + sw*pref*( ri3*(qyy_i*2.0d0*cy_i*zhat) &
1111 >               * (3.0d0*f1 + f3) )
1112 >          
1113 >          duduz_i(1) = duduz_i(1) + sw*pref*( ri3*(qzz_i*2.0d0*cz_i*xhat) &
1114 >               * (3.0d0*f1 + f3) )
1115 >          duduz_i(2) = duduz_i(2) + sw*pref*( ri3*(qzz_i*2.0d0*cz_i*yhat) &
1116 >               * (3.0d0*f1 + f3) )
1117 >          duduz_i(3) = duduz_i(3) + sw*pref*( ri3*(qzz_i*2.0d0*cz_i*zhat) &
1118 >               * (3.0d0*f1 + f3) )
1119  
1171          else
1172             pref = pre14 * q_j / 3.0_dp
1173             vterm = pref * ri3 * (qxx_i * (3.0_dp*cx2 - 1.0_dp) + &
1174                  qyy_i * (3.0_dp*cy2 - 1.0_dp) + &
1175                  qzz_i * (3.0_dp*cz2 - 1.0_dp))
1176             vpair = vpair + vterm
1177             epot = epot + sw*vterm
1178            
1179             dudx = dudx - 5.0_dp*sw*vterm*riji*xhat + sw*pref*ri4 * ( &
1180                  qxx_i*(6.0_dp*cx_i*ux_i(1) - 2.0_dp*xhat) + &
1181                  qyy_i*(6.0_dp*cy_i*uy_i(1) - 2.0_dp*xhat) + &
1182                  qzz_i*(6.0_dp*cz_i*uz_i(1) - 2.0_dp*xhat) )
1183             dudy = dudy - 5.0_dp*sw*vterm*riji*yhat + sw*pref*ri4 * ( &
1184                  qxx_i*(6.0_dp*cx_i*ux_i(2) - 2.0_dp*yhat) + &
1185                  qyy_i*(6.0_dp*cy_i*uy_i(2) - 2.0_dp*yhat) + &
1186                  qzz_i*(6.0_dp*cz_i*uz_i(2) - 2.0_dp*yhat) )
1187             dudz = dudz - 5.0_dp*sw*vterm*riji*zhat + sw*pref*ri4 * ( &
1188                  qxx_i*(6.0_dp*cx_i*ux_i(3) - 2.0_dp*zhat) + &
1189                  qyy_i*(6.0_dp*cy_i*uy_i(3) - 2.0_dp*zhat) + &
1190                  qzz_i*(6.0_dp*cz_i*uz_i(3) - 2.0_dp*zhat) )
1191            
1192             dudux_i(1) = dudux_i(1) + sw*pref*ri3*(qxx_i*6.0_dp*cx_i*xhat)
1193             dudux_i(2) = dudux_i(2) + sw*pref*ri3*(qxx_i*6.0_dp*cx_i*yhat)
1194             dudux_i(3) = dudux_i(3) + sw*pref*ri3*(qxx_i*6.0_dp*cx_i*zhat)
1195            
1196             duduy_i(1) = duduy_i(1) + sw*pref*ri3*(qyy_i*6.0_dp*cy_i*xhat)
1197             duduy_i(2) = duduy_i(2) + sw*pref*ri3*(qyy_i*6.0_dp*cy_i*yhat)
1198             duduy_i(3) = duduy_i(3) + sw*pref*ri3*(qyy_i*6.0_dp*cy_i*zhat)
1199            
1200             duduz_i(1) = duduz_i(1) + sw*pref*ri3*(qzz_i*6.0_dp*cz_i*xhat)
1201             duduz_i(2) = duduz_i(2) + sw*pref*ri3*(qzz_i*6.0_dp*cz_i*yhat)
1202             duduz_i(3) = duduz_i(3) + sw*pref*ri3*(qzz_i*6.0_dp*cz_i*zhat)
1203          endif
1120         endif
1121      endif
1122  
# Line 1361 | Line 1277 | contains
1277            
1278         endif
1279  
1280 <    elseif (summationMethod .eq. UNDAMPED_WOLF) then
1281 <       if (ElectrostaticMap(atid1)%is_Charge) then
1366 <          c1 = getCharge(atid1)
1367 <          
1368 <          mypot = mypot - (rcuti * 0.5_dp * c1 * c1)
1369 <       endif
1370 <      
1371 <    elseif (summationMethod .eq. DAMPED_WOLF) then
1280 >    elseif ( (summationMethod .eq. SHIFTED_FORCE) .or. &
1281 >         (summationMethod .eq. SHIFTED_POTENTIAL) ) then
1282         if (ElectrostaticMap(atid1)%is_Charge) then
1283            c1 = getCharge(atid1)
1284            
1285 <          mypot = mypot - (constERFC * rcuti * 0.5_dp + &
1286 <               dampingAlpha*invRootPi) * c1 * c1      
1285 >          if (screeningMethod .eq. DAMPED) then
1286 >             mypot = mypot - (f0c * rcuti * 0.5d0 + &
1287 >                  dampingAlpha*invRootPi) * c1 * c1    
1288 >            
1289 >          else            
1290 >             mypot = mypot - (rcuti * 0.5d0 * c1 * c1)
1291 >            
1292 >          endif
1293         endif
1294      endif
1295      
# Line 1411 | Line 1327 | contains
1327         call checkSummationMethod()
1328      endif
1329  
1330 <    dudx = 0.0d0
1331 <    dudy = 0.0d0
1332 <    dudz = 0.0d0
1330 >    dudx = zero
1331 >    dudy = zero
1332 >    dudz = zero
1333  
1334      riji = 1.0d0/rij
1335  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines