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 2717 by gezelter, Mon Apr 17 21:49:12 2006 UTC vs.
Revision 2756 by gezelter, Wed May 17 15:37:15 2006 UTC

# Line 65 | Line 65 | module electrostatic_module
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.0637778d0
68 >  real(kind=dp), parameter :: pre11 = 332.0637778_dp
69    !! Charge-Dipole, assuming charges are measured in electrons, and
70    !! dipoles are measured in debyes
71 <  real(kind=dp), parameter :: pre12 = 69.13373d0
71 >  real(kind=dp), parameter :: pre12 = 69.13373_dp
72    !! Dipole-Dipole, assuming dipoles are measured in debyes
73 <  real(kind=dp), parameter :: pre22 = 14.39325d0
73 >  real(kind=dp), parameter :: pre22 = 14.39325_dp
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.13373d0
77 >  real(kind=dp), parameter :: pre14 = 69.13373_dp
78  
79 +  real(kind=dp), parameter :: zero = 0.0_dp
80 +  
81 +  !! number of points for electrostatic splines
82 +  integer, parameter :: np = 100
83 +
84    !! variables to handle different summation methods for long-range
85    !! electrostatics:
86    integer, save :: summationMethod = NONE
# Line 111 | Line 116 | module electrostatic_module
116    real(kind=dp), save :: f2c = 0.0_DP
117    real(kind=dp), save :: f3c = 0.0_DP
118    real(kind=dp), save :: f4c = 0.0_DP
119 +  real(kind=dp), save :: df0 = 0.0_DP
120 +  type(cubicSpline), save :: f0spline
121 +  logical, save :: haveElectroSpline = .false.
122 +  real(kind=dp), save :: one_third = 1.0_DP / 3.0_DP
123  
124   #if defined(__IFC) || defined(__PGI)
125   ! error function for ifc version > 7.
126 <  double precision, external :: derfc
126 >  real(kind=dp), external :: erfc
127   #endif
128    
129    public :: setElectrostaticSummationMethod
# Line 122 | Line 131 | module electrostatic_module
131    public :: setElectrostaticCutoffRadius
132    public :: setDampingAlpha
133    public :: setReactionFieldDielectric
134 <  public :: buildElectroSplines
134 >  public :: buildElectroSpline
135    public :: newElectrostaticType
136    public :: setCharge
137    public :: setDipoleMoment
# Line 194 | Line 203 | contains
203      haveDielectric = .true.
204    end subroutine setReactionFieldDielectric
205  
206 <  subroutine buildElectroSplines()
207 <  end subroutine buildElectroSplines
206 >  subroutine buildElectroSpline()
207 >    real( kind = dp ), dimension(np) :: xvals, yvals
208 >    real( kind = dp ) :: dx, rmin, rval
209 >    integer :: i
210  
211 +    rmin = 0.0_dp
212 +
213 +    dx = (defaultCutoff-rmin) / dble(np-1)
214 +    
215 +    do i = 1, np
216 +       rval = rmin + dble(i-1)*dx
217 +       xvals(i) = rval
218 +       yvals(i) = erfc(dampingAlpha*rval)
219 +    enddo
220 +
221 +    call newSpline(f0spline, xvals, yvals, .true.)
222 +
223 +    haveElectroSpline = .true.
224 +  end subroutine buildElectroSpline
225 +
226    subroutine newElectrostaticType(c_ident, is_Charge, is_Dipole, &
227         is_SplitDipole, is_Quadrupole, is_Tap, status)
228  
# Line 413 | Line 439 | contains
439         call handleError("checkSummationMethod", "no Default Cutoff set!")
440      endif
441  
442 <    rcuti = 1.0d0 / defaultCutoff
442 >    rcuti = 1.0_dp / defaultCutoff
443      rcuti2 = rcuti*rcuti
444      rcuti3 = rcuti2*rcuti
445      rcuti4 = rcuti2*rcuti2
# Line 428 | Line 454 | contains
454         endif
455  
456         constEXP = exp(-alpha2*defaultCutoff2)
457 <       invRootPi = 0.56418958354775628695d0
458 <       alphaPi = 2.0d0*dampingAlpha*invRootPi
459 <       f0c = derfc(dampingAlpha*defaultCutoff)
457 >       invRootPi = 0.56418958354775628695_dp
458 >       alphaPi = 2.0_dp*dampingAlpha*invRootPi
459 >       f0c = erfc(dampingAlpha*defaultCutoff)
460         f1c = alphaPi*defaultCutoff*constEXP + f0c
461 <       f2c = alphaPi*2.0d0*alpha2*constEXP
462 <       f3c = alphaPi*2.0d0*alpha2*constEXP*defaultCutoff2*defaultCutoff
461 >       f2c = alphaPi*2.0_dp*alpha2*constEXP
462 >       f3c = alphaPi*2.0_dp*alpha2*constEXP*defaultCutoff2*defaultCutoff
463      endif
464  
465      if (summationMethod .eq. REACTION_FIELD) then
466         if (haveDielectric) then
467            defaultCutoff2 = defaultCutoff*defaultCutoff
468 <          preRF = (dielectric-1.0d0) / &
469 <               ((2.0d0*dielectric+1.0d0)*defaultCutoff2*defaultCutoff)
470 <          preRF2 = 2.0d0*preRF
468 >          preRF = (dielectric-1.0_dp) / &
469 >               ((2.0_dp*dielectric+1.0_dp)*defaultCutoff2*defaultCutoff)
470 >          preRF2 = 2.0_dp*preRF
471         else
472            call handleError("checkSummationMethod", "Dielectric not set")
473         endif
474        
475      endif
476  
477 +    if (.not.haveElectroSpline) then
478 +       call buildElectroSpline()
479 +    end if
480 +
481      summationMethodChecked = .true.
482    end subroutine checkSummationMethod
483  
# Line 495 | Line 525 | contains
525      real (kind=dp) :: varEXP
526      real (kind=dp) :: pot_term
527      real (kind=dp) :: preVal, rfVal
528 <    real (kind=dp) :: f13, f134
528 >    real (kind=dp) :: cti3, ctj3, ctidotj
529 >    real (kind=dp) :: ri7damp, ri5damp, prei3, prei4
530 >    real (kind=dp) :: xhatdot2, yhatdot2, zhatdot2
531 >    real (kind=dp) :: xhatdot5, yhatdot5, zhatdot5
532  
533      if (.not.summationMethodChecked) then
534         call checkSummationMethod()
# Line 511 | Line 544 | contains
544  
545      !! some variables we'll need independent of electrostatic type:
546  
547 <    riji = 1.0d0 / rij
547 >    riji = 1.0_dp / rij
548    
549      xhat = d(1) * riji
550      yhat = d(2) * riji
# Line 550 | Line 583 | contains
583         if (i_is_SplitDipole) then
584            d_i = ElectrostaticMap(me1)%split_dipole_distance
585         endif
586 <
586 >       duduz_i = zero
587      endif
588  
589      if (i_is_Quadrupole) then
# Line 581 | Line 614 | contains
614         cx_i = ux_i(1)*xhat + ux_i(2)*yhat + ux_i(3)*zhat
615         cy_i = uy_i(1)*xhat + uy_i(2)*yhat + uy_i(3)*zhat
616         cz_i = uz_i(1)*xhat + uz_i(2)*yhat + uz_i(3)*zhat
617 +       dudux_i = zero
618 +       duduy_i = zero
619 +       duduz_i = zero
620      endif
621  
622      if (j_is_Charge) then
# Line 603 | Line 639 | contains
639         if (j_is_SplitDipole) then
640            d_j = ElectrostaticMap(me2)%split_dipole_distance
641         endif
642 +       duduz_j = zero
643      endif
644  
645      if (j_is_Quadrupole) then
# Line 633 | Line 670 | contains
670         cx_j = ux_j(1)*xhat + ux_j(2)*yhat + ux_j(3)*zhat
671         cy_j = uy_j(1)*xhat + uy_j(2)*yhat + uy_j(3)*zhat
672         cz_j = uz_j(1)*xhat + uz_j(2)*yhat + uz_j(3)*zhat
673 +       dudux_j = zero
674 +       duduy_j = zero
675 +       duduz_j = zero
676      endif
677    
678 <    epot = 0.0d0
679 <    dudx = 0.0d0
680 <    dudy = 0.0d0
681 <    dudz = 0.0d0
678 >    epot = zero
679 >    dudx = zero
680 >    dudy = zero
681 >    dudz = zero  
682  
643    dudux_i = 0.0d0
644    duduy_i = 0.0d0
645    duduz_i = 0.0d0
646
647    dudux_j = 0.0d0
648    duduy_j = 0.0d0
649    duduz_j = 0.0d0
650
683      if (i_is_Charge) then
684  
685         if (j_is_Charge) then
686            if (screeningMethod .eq. DAMPED) then
687 <             f0 = derfc(dampingAlpha*rij)
688 <             varEXP = exp(-alpha2*rij*rij)
689 <             f1 = alphaPi*rij*varEXP + f0
687 >             ! assemble the damping variables
688 >             call lookupUniformSpline1d(f0spline, rij, f0, df0)
689 >             f1 = -rij * df0 + f0
690            endif
691  
692            preVal = pre11 * q_i * q_j
# Line 674 | Line 706 | contains
706               rfVal = preRF*rij*rij
707               vterm = preVal * ( riji + rfVal )
708              
709 <             dudr  = sw * preVal * ( 2.0d0*rfVal - riji )*riji
709 >             dudr  = sw * preVal * ( 2.0_dp*rfVal - riji )*riji
710    
711            else
712               vterm = preVal * riji*f0
# Line 694 | Line 726 | contains
726  
727         if (j_is_Dipole) then
728            if (screeningMethod .eq. DAMPED) then
729 <             f0 = derfc(dampingAlpha*rij)
730 <             varEXP = exp(-alpha2*rij*rij)
731 <             f1 = alphaPi*rij*varEXP + f0
732 <             f3 = alphaPi*2.0d0*alpha2*varEXP*rij*rij*rij
729 >             ! assemble the damping variables
730 >             call lookupUniformSpline1d(f0spline, rij, f0, df0)
731 >             f1 = -rij * df0 + f0
732 >             f3 = -2.0_dp*alpha2*df0*rij*rij*rij
733            endif
734  
735            pref = pre12 * q_i * mu_j
# Line 710 | Line 742 | contains
742               vpair = vpair + vterm
743               epot = epot + sw*vterm
744              
745 <             !! this has a + sign in the () because the rij vector is
714 <             !! r_j - r_i and the charge-dipole potential takes the origin
715 <             !! as the point dipole, which is atom j in this case.
716 <            
717 <             dudx = dudx - sw*pref*( ri3*(uz_j(1) - 3.0d0*ct_j*xhat) - &
745 >             dudx = dudx - sw*pref*( ri3*(uz_j(1) - 3.0_dp*ct_j*xhat) - &
746                                       preRF2*uz_j(1) )
747 <             dudy = dudy - sw*pref*( ri3*(uz_j(2) - 3.0d0*ct_j*yhat) - &
747 >             dudy = dudy - sw*pref*( ri3*(uz_j(2) - 3.0_dp*ct_j*yhat) - &
748                                       preRF2*uz_j(2) )
749 <             dudz = dudz - sw*pref*( ri3*(uz_j(3) - 3.0d0*ct_j*zhat) - &
749 >             dudz = dudz - sw*pref*( ri3*(uz_j(3) - 3.0_dp*ct_j*zhat) - &
750                                       preRF2*uz_j(3) )        
751               duduz_j(1) = duduz_j(1) - sw*pref * xhat * ( ri2 - preRF2*rij )
752               duduz_j(2) = duduz_j(2) - sw*pref * yhat * ( ri2 - preRF2*rij )
# Line 726 | Line 754 | contains
754  
755            else
756               if (j_is_SplitDipole) then
757 <                BigR = sqrt(r2 + 0.25d0 * d_j * d_j)
758 <                ri = 1.0d0 / BigR
757 >                BigR = sqrt(r2 + 0.25_dp * d_j * d_j)
758 >                ri = 1.0_dp / BigR
759                  scale = rij * ri
760               else
761                  ri = riji
762 <                scale = 1.0d0
762 >                scale = 1.0_dp
763               endif
764              
765               ri2 = ri * ri
# Line 739 | Line 767 | contains
767               sc2 = scale * scale
768  
769               pot_term =  ri2 * scale * f1
770 <             vterm = - pref * ct_j * pot_term
770 >             vterm = -pref * ct_j * pot_term
771               vpair = vpair + vterm
772               epot = epot + sw*vterm
773              
774 <             !! this has a + sign in the () because the rij vector is
775 <             !! r_j - r_i and the charge-dipole potential takes the origin
748 <             !! as the point dipole, which is atom j in this case.
774 >             prei3 = sw*pref*ri3
775 >             ri5damp = 3.0_dp*f1 + f3
776              
777 <             dudx = dudx - sw*pref * ri3 * ( uz_j(1)*f1 - &
778 <                  ct_j*xhat*sc2*( 3.0d0*f1 + f3 ) )
779 <             dudy = dudy - sw*pref * ri3 * ( uz_j(2)*f1 - &
753 <                  ct_j*yhat*sc2*( 3.0d0*f1 + f3 ) )
754 <             dudz = dudz - sw*pref * ri3 * ( uz_j(3)*f1 - &
755 <                  ct_j*zhat*sc2*( 3.0d0*f1 + f3 ) )
777 >             dudx = dudx - prei3 * ( uz_j(1)*f1 - ct_j*xhat*sc2*ri5damp )
778 >             dudy = dudy - prei3 * ( uz_j(2)*f1 - ct_j*yhat*sc2*ri5damp )
779 >             dudz = dudz - prei3 * ( uz_j(3)*f1 - ct_j*zhat*sc2*ri5damp )
780                            
781               duduz_j(1) = duduz_j(1) - sw*pref * pot_term * xhat
782               duduz_j(2) = duduz_j(2) - sw*pref * pot_term * yhat
# Line 763 | Line 787 | contains
787  
788         if (j_is_Quadrupole) then
789            if (screeningMethod .eq. DAMPED) then
790 <             f0 = derfc(dampingAlpha*rij)
791 <             varEXP = exp(-alpha2*rij*rij)
792 <             f1 = alphaPi*rij*varEXP + f0
793 <             f2 = alphaPi*2.0d0*alpha2*varEXP
794 <             f3 = f2*rij*rij*rij
795 <             f4 = 2.0d0*alpha2*f2*rij
790 >             ! assemble the damping variables
791 >             call lookupUniformSpline1d(f0spline, rij, f0, df0)
792 >             f1 = -rij * df0 + f0
793 >             f2 = -2.0_dp*alpha2*df0
794 >             f3 = f2*r2*rij
795 >             f4 = 0.4_dp*alpha2*f3*r2
796            endif
797 +          ri5damp = f1 + f3*one_third
798 +          ri7damp = ri5damp + f4
799  
800            ri2 = riji * riji
801            ri3 = ri2 * riji
776          ri4 = ri2 * ri2
802            cx2 = cx_j * cx_j
803            cy2 = cy_j * cy_j
804            cz2 = cz_j * cz_j
805  
806 <          pref =  pre14 * q_i / 3.0d0
807 <          pot_term = ri3*(qxx_j * (3.0d0*cx2 - 1.0d0) + &
808 <               qyy_j * (3.0d0*cy2 - 1.0d0) + &
809 <               qzz_j * (3.0d0*cz2 - 1.0d0))
810 <          vterm = pref * (pot_term*f1 + (qxx_j*cx2 + qyy_j*cy2 + qzz_j*cz2)*f2)
806 >          pref =  pre14 * q_i * one_third
807 >
808 >          pot_term = ri3*( qxx_j*(3.0_dp*cx2*ri5damp - f1) + &
809 >               qyy_j*(3.0_dp*cy2*ri5damp - f1) + &
810 >               qzz_j*(3.0_dp*cz2*ri5damp - f1) )
811 >          vterm = pref * pot_term
812            vpair = vpair + vterm
813            epot = epot + sw*vterm
814 +
815 +          ! precompute variables for convenience (and obfuscation unfortunatly)
816 +          prei3 = 3.0_dp*sw*pref*ri3
817 +          prei4 = prei3*riji
818 +          xhatdot2 = xhat*2.0_dp * ri5damp
819 +          yhatdot2 = yhat*2.0_dp * ri5damp
820 +          zhatdot2 = zhat*2.0_dp * ri5damp
821 +          xhatdot5 = xhat*5.0_dp * ri7damp
822 +          yhatdot5 = yhat*5.0_dp * ri7damp
823 +          zhatdot5 = zhat*5.0_dp * ri7damp
824 +
825 +          dudx = dudx - prei4 * ( &
826 +               qxx_j*(cx2*xhatdot5 - (2.0_dp*cx_j*ux_j(1) + xhat)*ri5damp) + &
827 +               qyy_j*(cy2*xhatdot5 - (2.0_dp*cy_j*uy_j(1) + xhat)*ri5damp) + &
828 +               qzz_j*(cz2*xhatdot5 - (2.0_dp*cz_j*uz_j(1) + xhat)*ri5damp) )
829 +          dudy = dudy - prei4 * ( &
830 +               qxx_j*(cx2*yhatdot5 - (2.0_dp*cx_j*ux_j(2) + yhat)*ri5damp) + &
831 +               qyy_j*(cy2*yhatdot5 - (2.0_dp*cy_j*uy_j(2) + yhat)*ri5damp) + &
832 +               qzz_j*(cz2*yhatdot5 - (2.0_dp*cz_j*uz_j(2) + yhat)*ri5damp) )
833 +          dudz = dudz - prei4 * ( &
834 +               qxx_j*(cx2*zhatdot5 - (2.0_dp*cx_j*ux_j(3) + zhat)*ri5damp) + &
835 +               qyy_j*(cy2*zhatdot5 - (2.0_dp*cy_j*uy_j(3) + zhat)*ri5damp) + &
836 +               qzz_j*(cz2*zhatdot5 - (2.0_dp*cz_j*uz_j(3) + zhat)*ri5damp) )
837            
838 <          dudx = dudx - sw*pref*pot_term*riji*xhat*(5.0d0*f1 + f3) + &
839 <               sw*pref*ri4 * ( &
840 <               qxx_j*(2.0d0*cx_j*ux_j(1)*(3.0d0*f1 + f3) - 2.0d0*xhat*f1) + &
792 <               qyy_j*(2.0d0*cy_j*uy_j(1)*(3.0d0*f1 + f3) - 2.0d0*xhat*f1) + &
793 <               qzz_j*(2.0d0*cz_j*uz_j(1)*(3.0d0*f1 + f3) - 2.0d0*xhat*f1) ) &
794 <               + (qxx_j*cx2 + qyy_j*cy2 + qzz_j*cz2)*f4
795 <          dudy = dudy - sw*pref*pot_term*riji*yhat*(5.0d0*f1 + f3) + &
796 <               sw*pref*ri4 * ( &
797 <               qxx_j*(2.0d0*cx_j*ux_j(2)*(3.0d0*f1 + f3) - 2.0d0*yhat*f1) + &
798 <               qyy_j*(2.0d0*cy_j*uy_j(2)*(3.0d0*f1 + f3) - 2.0d0*yhat*f1) + &
799 <               qzz_j*(2.0d0*cz_j*uz_j(2)*(3.0d0*f1 + f3) - 2.0d0*yhat*f1) ) &
800 <               + (qxx_j*cx2 + qyy_j*cy2 + qzz_j*cz2)*f4
801 <          dudz = dudz - sw*pref*pot_term*riji*zhat*(5.0d0*f1 + f3) + &
802 <               sw*pref*ri4 * ( &
803 <               qxx_j*(2.0d0*cx_j*ux_j(3)*(3.0d0*f1 + f3) - 2.0d0*zhat*f1) + &
804 <               qyy_j*(2.0d0*cy_j*uy_j(3)*(3.0d0*f1 + f3) - 2.0d0*zhat*f1) + &
805 <               qzz_j*(2.0d0*cz_j*uz_j(3)*(3.0d0*f1 + f3) - 2.0d0*zhat*f1) ) &
806 <               + (qxx_j*cx2 + qyy_j*cy2 + qzz_j*cz2)*f4
838 >          dudux_j(1) = dudux_j(1) + prei3*(qxx_j*cx_j*xhatdot2)
839 >          dudux_j(2) = dudux_j(2) + prei3*(qxx_j*cx_j*yhatdot2)
840 >          dudux_j(3) = dudux_j(3) + prei3*(qxx_j*cx_j*zhatdot2)
841            
842 <          dudux_j(1) = dudux_j(1) + sw*pref*ri3*( (qxx_j*2.0d0*cx_j*xhat) &
843 <               * (3.0d0*f1 + f3) )
844 <          dudux_j(2) = dudux_j(2) + sw*pref*ri3*( (qxx_j*2.0d0*cx_j*yhat) &
811 <               * (3.0d0*f1 + f3) )
812 <          dudux_j(3) = dudux_j(3) + sw*pref*ri3*( (qxx_j*2.0d0*cx_j*zhat) &
813 <               * (3.0d0*f1 + f3) )
842 >          duduy_j(1) = duduy_j(1) + prei3*(qyy_j*cy_j*xhatdot2)
843 >          duduy_j(2) = duduy_j(2) + prei3*(qyy_j*cy_j*yhatdot2)
844 >          duduy_j(3) = duduy_j(3) + prei3*(qyy_j*cy_j*zhatdot2)
845            
846 <          duduy_j(1) = duduy_j(1) + sw*pref*ri3*( (qyy_j*2.0d0*cy_j*xhat) &
847 <               * (3.0d0*f1 + f3) )
848 <          duduy_j(2) = duduy_j(2) + sw*pref*ri3*( (qyy_j*2.0d0*cy_j*yhat) &
849 <               * (3.0d0*f1 + f3) )
819 <          duduy_j(3) = duduy_j(3) + sw*pref*ri3*( (qyy_j*2.0d0*cy_j*zhat) &
820 <               * (3.0d0*f1 + f3) )
821 <          
822 <          duduz_j(1) = duduz_j(1) + sw*pref*ri3*( (qzz_j*2.0d0*cz_j*xhat) &
823 <               * (3.0d0*f1 + f3) )
824 <          duduz_j(2) = duduz_j(2) + sw*pref*ri3*( (qzz_j*2.0d0*cz_j*yhat) &
825 <               * (3.0d0*f1 + f3) )
826 <          duduz_j(3) = duduz_j(3) + sw*pref*ri3*( (qzz_j*2.0d0*cz_j*zhat) &
827 <               * (3.0d0*f1 + f3) )
846 >          duduz_j(1) = duduz_j(1) + prei3*(qzz_j*cz_j*xhatdot2)
847 >          duduz_j(2) = duduz_j(2) + prei3*(qzz_j*cz_j*yhatdot2)
848 >          duduz_j(3) = duduz_j(3) + prei3*(qzz_j*cz_j*zhatdot2)
849 >
850            
851         endif
852      endif
# Line 833 | Line 855 | contains
855  
856         if (j_is_Charge) then
857            if (screeningMethod .eq. DAMPED) then
858 <             f0 = derfc(dampingAlpha*rij)
859 <             varEXP = exp(-alpha2*rij*rij)
860 <             f1 = alphaPi*rij*varEXP + f0
861 <             f3 = alphaPi*2.0d0*alpha2*varEXP*rij*rij*rij
858 >             ! assemble the damping variables
859 >             call lookupUniformSpline1d(f0spline, rij, f0, df0)
860 >             f1 = -rij * df0 + f0
861 >             f3 = -2.0_dp*alpha2*df0*r2*rij
862            endif
863            
864            pref = pre12 * q_j * mu_i
865            
866 <          if (summationMethod .eq. SHIFTED_POTENTIAL) then
845 <             ri2 = riji * riji
846 <             ri3 = ri2 * riji
847 <            
848 <             pot_term = ri2*f1 - rcuti2*f1c
849 <             vterm = pref * ct_i * pot_term
850 <             vpair = vpair + vterm
851 <             epot = epot + sw*vterm
852 <            
853 <             dudx = dudx + sw*pref*( ri3*(uz_i(1)*f1-ct_i*xhat*(3.0d0*f1+f3)) )
854 <             dudy = dudy + sw*pref*( ri3*(uz_i(2)*f1-ct_i*yhat*(3.0d0*f1+f3)) )
855 <             dudz = dudz + sw*pref*( ri3*(uz_i(3)*f1-ct_i*zhat*(3.0d0*f1+f3)) )
856 <            
857 <             duduz_i(1) = duduz_i(1) + sw*pref * xhat * pot_term
858 <             duduz_i(2) = duduz_i(2) + sw*pref * yhat * pot_term
859 <             duduz_i(3) = duduz_i(3) + sw*pref * zhat * pot_term
866 >          if (summationMethod .eq. REACTION_FIELD) then
867  
861          elseif (summationMethod .eq. SHIFTED_FORCE) then
868               ri2 = riji * riji
869               ri3 = ri2 * riji
870  
865             !! might need a -(f1c-f0c) or dct_i/dr in the derivative term...
866             pot_term = ri2*f1 - rcuti2*f1c + &
867                  (2.0d0*rcuti3*f1c + f2c)*( rij - defaultCutoff )
868             vterm = pref * ct_i * pot_term
869             vpair = vpair + vterm
870             epot = epot + sw*vterm
871            
872             dudx = dudx + sw*pref*( ri3*(uz_i(1)*f1-ct_i*xhat*(3.0d0*f1+f3)) &
873                  - rcuti3*(uz_i(1)*f1c-ct_i*xhat*(3.0d0*f1c+f3c)) )
874             dudy = dudy + sw*pref*( ri3*(uz_i(2)*f1-ct_i*yhat*(3.0d0*f1+f3)) &
875                  - rcuti3*(uz_i(1)*f1c-ct_i*xhat*(3.0d0*f1c+f3c)) )
876             dudz = dudz + sw*pref*( ri3*(uz_i(3)*f1-ct_i*zhat*(3.0d0*f1+f3)) &
877                  - rcuti3*(uz_i(1)*f1c-ct_i*xhat*(3.0d0*f1c+f3c)) )
878            
879             duduz_i(1) = duduz_i(1) + sw*pref * xhat * pot_term
880             duduz_i(2) = duduz_i(2) + sw*pref * yhat * pot_term
881             duduz_i(3) = duduz_i(3) + sw*pref * zhat * pot_term
882
883          elseif (summationMethod .eq. REACTION_FIELD) then
884             ri2 = riji * riji
885             ri3 = ri2 * riji
886
871               vterm = pref * ct_i * ( ri2 - preRF2*rij )
872               vpair = vpair + vterm
873               epot = epot + sw*vterm
874              
875 <             dudx = dudx + sw*pref * ( ri3*(uz_i(1) - 3.0d0*ct_i*xhat) - &
875 >             dudx = dudx + sw*pref * ( ri3*(uz_i(1) - 3.0_dp*ct_i*xhat) - &
876                    preRF2*uz_i(1) )
877 <             dudy = dudy + sw*pref * ( ri3*(uz_i(2) - 3.0d0*ct_i*yhat) - &
877 >             dudy = dudy + sw*pref * ( ri3*(uz_i(2) - 3.0_dp*ct_i*yhat) - &
878                    preRF2*uz_i(2) )
879 <             dudz = dudz + sw*pref * ( ri3*(uz_i(3) - 3.0d0*ct_i*zhat) - &
879 >             dudz = dudz + sw*pref * ( ri3*(uz_i(3) - 3.0_dp*ct_i*zhat) - &
880                    preRF2*uz_i(3) )
881              
882               duduz_i(1) = duduz_i(1) + sw*pref * xhat * ( ri2 - preRF2*rij )
# Line 901 | Line 885 | contains
885  
886            else
887               if (i_is_SplitDipole) then
888 <                BigR = sqrt(r2 + 0.25d0 * d_i * d_i)
889 <                ri = 1.0d0 / BigR
888 >                BigR = sqrt(r2 + 0.25_dp * d_i * d_i)
889 >                ri = 1.0_dp / BigR
890                  scale = rij * ri
891               else
892                  ri = riji
893 <                scale = 1.0d0
893 >                scale = 1.0_dp
894               endif
895              
896               ri2 = ri * ri
# Line 918 | Line 902 | contains
902               vpair = vpair + vterm
903               epot = epot + sw*vterm
904              
905 <             dudx = dudx + sw*pref * ri3 * ( uz_i(1)*f1 - &
906 <                  ct_i*xhat*sc2*( 3.0d0*f1 + f3 ) )
923 <             dudy = dudy + sw*pref * ri3 * ( uz_i(2)*f1 - &
924 <                  ct_i*yhat*sc2*( 3.0d0*f1 + f3 ) )
925 <             dudz = dudz + sw*pref * ri3 * ( uz_i(3)*f1 - &
926 <                  ct_i*zhat*sc2*( 3.0d0*f1 + f3 ) )
905 >             prei3 = sw*pref*ri3
906 >             ri5damp = 3.0_dp*f1 + f3
907              
908 +             dudx = dudx + prei3 * ( uz_i(1)*f1 - ct_i*xhat*sc2*ri5damp )
909 +             dudy = dudy + prei3 * ( uz_i(2)*f1 - ct_i*yhat*sc2*ri5damp )
910 +             dudz = dudz + prei3 * ( uz_i(3)*f1 - ct_i*zhat*sc2*ri5damp )
911 +
912               duduz_i(1) = duduz_i(1) + sw*pref * pot_term * xhat
913               duduz_i(2) = duduz_i(2) + sw*pref * pot_term * yhat
914               duduz_i(3) = duduz_i(3) + sw*pref * pot_term * zhat
915 +            
916            endif
917         endif
918        
919         if (j_is_Dipole) then
920 <          if (screeningMethod .eq. DAMPED) then
921 <             f0 = derfc(dampingAlpha*rij)
922 <             varEXP = exp(-alpha2*rij*rij)
923 <             f1 = alphaPi*rij*varEXP + f0
924 <             f2 = alphaPi*2.0d0*alpha2*varEXP
925 <             f3 = f2*rij*rij*rij
926 <             f4 = 2.0d0*alpha2*f3*rij*rij
927 <          endif
920 > !!$          if (screeningMethod .eq. DAMPED) then
921 > !!$             ! assemble the damping variables
922 > !!$             call lookupUniformSpline1d(f0spline, rij, f0, df0)
923 > !!$             f1 = -rij * df0 + f0
924 > !!$             f2 = -2.0_dp*alpha2*df0
925 > !!$             f3 = f2*r2*rij
926 > !!$             f4 = 0.4_dp*alpha2*f3*r2
927 > !!$          endif
928  
929            ct_ij = uz_i(1)*uz_j(1) + uz_i(2)*uz_j(2) + uz_i(3)*uz_j(3)
930            
# Line 950 | Line 935 | contains
935            pref = pre22 * mu_i * mu_j
936  
937            if (summationMethod .eq. REACTION_FIELD) then
938 <             vterm = pref*( ri3*(ct_ij - 3.0d0 * ct_i * ct_j) - &
938 >             vterm = pref*( ri3*(ct_ij - 3.0_dp * ct_i * ct_j) - &
939                    preRF2*ct_ij )
940               vpair = vpair + vterm
941               epot = epot + sw*vterm
942              
943 <             a1 = 5.0d0 * ct_i * ct_j - ct_ij
943 >             a1 = 5.0_dp * ct_i * ct_j - ct_ij
944              
945 <             dudx = dudx + sw*pref*3.0d0*ri4 &
945 >             dudx = dudx + sw*pref*3.0_dp*ri4 &
946                               * (a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1))
947 <             dudy = dudy + sw*pref*3.0d0*ri4 &
947 >             dudy = dudy + sw*pref*3.0_dp*ri4 &
948                               * (a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2))
949 <             dudz = dudz + sw*pref*3.0d0*ri4 &
949 >             dudz = dudz + sw*pref*3.0_dp*ri4 &
950                               * (a1*zhat-ct_i*uz_j(3)-ct_j*uz_i(3))
951              
952 <             duduz_i(1) = duduz_i(1) + sw*pref*(ri3*(uz_j(1)-3.0d0*ct_j*xhat) &
952 >             duduz_i(1) = duduz_i(1) + sw*pref*(ri3*(uz_j(1)-3.0_dp*ct_j*xhat) &
953                    - preRF2*uz_j(1))
954 <             duduz_i(2) = duduz_i(2) + sw*pref*(ri3*(uz_j(2)-3.0d0*ct_j*yhat) &
954 >             duduz_i(2) = duduz_i(2) + sw*pref*(ri3*(uz_j(2)-3.0_dp*ct_j*yhat) &
955                    - preRF2*uz_j(2))
956 <             duduz_i(3) = duduz_i(3) + sw*pref*(ri3*(uz_j(3)-3.0d0*ct_j*zhat) &
956 >             duduz_i(3) = duduz_i(3) + sw*pref*(ri3*(uz_j(3)-3.0_dp*ct_j*zhat) &
957                    - preRF2*uz_j(3))
958 <             duduz_j(1) = duduz_j(1) + sw*pref*(ri3*(uz_i(1)-3.0d0*ct_i*xhat) &
958 >             duduz_j(1) = duduz_j(1) + sw*pref*(ri3*(uz_i(1)-3.0_dp*ct_i*xhat) &
959                    - preRF2*uz_i(1))
960 <             duduz_j(2) = duduz_j(2) + sw*pref*(ri3*(uz_i(2)-3.0d0*ct_i*yhat) &
960 >             duduz_j(2) = duduz_j(2) + sw*pref*(ri3*(uz_i(2)-3.0_dp*ct_i*yhat) &
961                    - preRF2*uz_i(2))
962 <             duduz_j(3) = duduz_j(3) + sw*pref*(ri3*(uz_i(3)-3.0d0*ct_i*zhat) &
962 >             duduz_j(3) = duduz_j(3) + sw*pref*(ri3*(uz_i(3)-3.0_dp*ct_i*zhat) &
963                    - preRF2*uz_i(3))
964  
965            else
966               if (i_is_SplitDipole) then
967                  if (j_is_SplitDipole) then
968 <                   BigR = sqrt(r2 + 0.25d0 * d_i * d_i + 0.25d0 * d_j * d_j)
968 >                   BigR = sqrt(r2 + 0.25_dp * d_i * d_i + 0.25_dp * d_j * d_j)
969                  else
970 <                   BigR = sqrt(r2 + 0.25d0 * d_i * d_i)
970 >                   BigR = sqrt(r2 + 0.25_dp * d_i * d_i)
971                  endif
972 <                ri = 1.0d0 / BigR
972 >                ri = 1.0_dp / BigR
973                  scale = rij * ri                
974               else
975                  if (j_is_SplitDipole) then
976 <                   BigR = sqrt(r2 + 0.25d0 * d_j * d_j)
977 <                   ri = 1.0d0 / BigR
976 >                   BigR = sqrt(r2 + 0.25_dp * d_j * d_j)
977 >                   ri = 1.0_dp / BigR
978                     scale = rij * ri                            
979                  else                
980                     ri = riji
981 <                   scale = 1.0d0
981 >                   scale = 1.0_dp
982                  endif
983               endif
984              
985               sc2 = scale * scale
986  
987 <             pot_term = (ct_ij - 3.0d0 * ct_i * ct_j * sc2)
988 <             vterm = pref * ( ri3*pot_term*f1 + (ct_i * ct_j)*f2 )
987 >             pot_term = (ct_ij - 3.0_dp * ct_i * ct_j * sc2)
988 > !!$             vterm = pref * ( ri3*pot_term*f1 + (ct_i * ct_j * sc2)*f2 )
989 >             vterm = pref * ri3 * pot_term
990               vpair = vpair + vterm
991               epot = epot + sw*vterm
992              
993 <             f13 = f1+f3
994 <             f134 = f13 + f4
995 <            
996 < !!$             dudx = dudx + sw*pref * ( ri4*scale*( &
997 < !!$                  3.0d0*(a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1))*f1 &
998 < !!$                  - pot_term*f3) &
999 < !!$                  + 2.0d0*ct_i*ct_j*xhat*(ct_i*uz_j(1)+ct_j*uz_i(1))*f3 &
1000 < !!$                  + (ct_i * ct_j)*f4 )
1001 < !!$             dudy = dudy + sw*pref * ( ri4*scale*( &
1002 < !!$                  3.0d0*(a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2))*f1 &
1003 < !!$                  - pot_term*f3) &
1018 < !!$                  + 2.0d0*ct_i*ct_j*yhat*(ct_i*uz_j(2)+ct_j*uz_i(2))*f3 &
1019 < !!$                  + (ct_i * ct_j)*f4 )
1020 < !!$             dudz = dudz + sw*pref * ( ri4*scale*( &
1021 < !!$                  3.0d0*(a1*zhat-ct_i*uz_j(3)-ct_j*uz_i(3))*f1 &
1022 < !!$                  - pot_term*f3) &
1023 < !!$                  + 2.0d0*ct_i*ct_j*zhat*(ct_i*uz_j(3)+ct_j*uz_i(3))*f3 &
1024 < !!$                  + (ct_i * ct_j)*f4 )
993 >             ! precompute variables for convenience (and obfuscation
994 >             ! unfortunatly)
995 > !!$             ri5damp = f1 + f3*one_third
996 > !!$             ri7damp = 5.0_dp*(ri5damp + f4)
997 >             prei3 = sw*pref*ri3
998 >             prei4 = 3.0_dp*sw*pref*ri4*scale
999 > !!$             cti3 = 3.0_dp*ct_i*sc2*ri5damp
1000 > !!$             ctj3 = 3.0_dp*ct_j*sc2*ri5damp
1001 >             cti3 = 3.0_dp*ct_i*sc2
1002 >             ctj3 = 3.0_dp*ct_j*sc2
1003 >             ctidotj = ct_i * ct_j * sc2
1004  
1005 <             dudx = dudx + sw*pref * ( ri4*scale*( &
1006 <                  15.0d0*(ct_i * ct_j * sc2)*xhat*f134 - &
1007 <                  3.0d0*(ct_i*uz_j(1) + ct_j*uz_i(1) + ct_ij*xhat)*f134) )
1008 <             dudy = dudy + sw*pref * ( ri4*scale*( &
1009 <                  15.0d0*(ct_i * ct_j * sc2)*yhat*f134 - &
1010 <                  3.0d0*(ct_i*uz_j(2) + ct_j*uz_i(2) + ct_ij*yhat)*f134) )
1011 <             dudz = dudz + sw*pref * ( ri4*scale*( &
1012 <                  15.0d0*(ct_i * ct_j * sc2)*zhat*f134 - &
1013 <                  3.0d0*(ct_i*uz_j(3) + ct_j*uz_i(3) + ct_ij*zhat)*f134) )
1005 >             dudx = dudx + prei4 * ( 5.0_dp*ctidotj*xhat - &
1006 >                  (ct_i*uz_j(1) + ct_j*uz_i(1) + ct_ij*xhat) )
1007 >             dudy = dudy + prei4 * ( 5.0_dp*ctidotj*yhat - &
1008 >                  (ct_i*uz_j(2) + ct_j*uz_i(2) + ct_ij*yhat) )
1009 >             dudz = dudz + prei4 * ( 5.0_dp*ctidotj*zhat - &
1010 >                  (ct_i*uz_j(3) + ct_j*uz_i(3) + ct_ij*zhat) )
1011 >
1012 >             duduz_i(1) = duduz_i(1) + prei3 * ( uz_j(1) - ctj3*xhat )
1013 >             duduz_i(2) = duduz_i(2) + prei3 * ( uz_j(2) - ctj3*yhat )
1014 >             duduz_i(3) = duduz_i(3) + prei3 * ( uz_j(3) - ctj3*zhat )
1015              
1016 <             duduz_i(1) = duduz_i(1) + sw*pref * &
1017 <                  ( ri3*(uz_j(1) - 3.0d0*ct_j*xhat*sc2)*f1 + (ct_j*xhat)*f2 )
1018 <             duduz_i(2) = duduz_i(2) + sw*pref * &
1019 <                  ( ri3*(uz_j(2) - 3.0d0*ct_j*yhat*sc2)*f1 + (ct_j*yhat)*f2 )
1020 <             duduz_i(3) = duduz_i(3) + sw*pref * &
1021 <                  ( ri3*(uz_j(3) - 3.0d0*ct_j*zhat*sc2)*f1 + (ct_j*zhat)*f2 )
1022 <            
1023 <             duduz_j(1) = duduz_j(1) + sw*pref * &
1024 <                  ( ri3*(uz_i(1) - 3.0d0*ct_i*xhat*sc2)*f1 + (ct_i*xhat)*f2 )
1025 <             duduz_j(2) = duduz_j(2) + sw*pref * &
1026 <                  ( ri3*(uz_i(2) - 3.0d0*ct_i*yhat*sc2)*f1 + (ct_i*yhat)*f2 )
1027 <             duduz_j(3) = duduz_j(3) + sw*pref * &
1028 <                  ( ri3*(uz_i(3) - 3.0d0*ct_i*zhat*sc2)*f1 + (ct_i*zhat)*f2 )
1016 >             duduz_j(1) = duduz_j(1) + prei3 * ( uz_i(1) - cti3*xhat )
1017 >             duduz_j(2) = duduz_j(2) + prei3 * ( uz_i(2) - cti3*yhat )
1018 >             duduz_j(3) = duduz_j(3) + prei3 * ( uz_i(3) - cti3*zhat )
1019 >
1020 > !!$             dudx = dudx + prei4 * ( ctidotj*xhat*ri7damp - &
1021 > !!$                  (ct_i*uz_j(1) + ct_j*uz_i(1) + ct_ij*xhat)*ri5damp )
1022 > !!$             dudy = dudy + prei4 * ( ctidotj*yhat*ri7damp - &
1023 > !!$                  (ct_i*uz_j(2) + ct_j*uz_i(2) + ct_ij*yhat)*ri5damp )
1024 > !!$             dudz = dudz + prei4 * ( ctidotj*zhat*ri7damp - &
1025 > !!$                  (ct_i*uz_j(3) + ct_j*uz_i(3) + ct_ij*zhat)*ri5damp )
1026 > !!$
1027 > !!$             duduz_i(1) = duduz_i(1) + prei3 * ( uz_j(1)*f1 - ctj3*xhat )
1028 > !!$             duduz_i(2) = duduz_i(2) + prei3 * ( uz_j(2)*f1 - ctj3*yhat )
1029 > !!$             duduz_i(3) = duduz_i(3) + prei3 * ( uz_j(3)*f1 - ctj3*zhat )
1030 > !!$            
1031 > !!$             duduz_j(1) = duduz_j(1) + prei3 * ( uz_i(1)*f1 - cti3*xhat )
1032 > !!$             duduz_j(2) = duduz_j(2) + prei3 * ( uz_i(2)*f1 - cti3*yhat )
1033 > !!$             duduz_j(3) = duduz_j(3) + prei3 * ( uz_i(3)*f1 - cti3*zhat )
1034 >
1035            endif
1036         endif
1037      endif
# Line 1053 | Line 1039 | contains
1039      if (i_is_Quadrupole) then
1040         if (j_is_Charge) then
1041            if (screeningMethod .eq. DAMPED) then
1042 <             f0 = derfc(dampingAlpha*rij)
1043 <             varEXP = exp(-alpha2*rij*rij)
1044 <             f1 = alphaPi*rij*varEXP + f0
1045 <             f2 = alphaPi*2.0d0*alpha2*varEXP
1046 <             f3 = f2*rij*rij*rij
1047 <             f4 = 2.0d0*alpha2*f2*rij
1042 >             ! assemble the damping variables
1043 >             call lookupUniformSpline1d(f0spline, rij, f0, df0)
1044 >             f1 = -rij * df0 + f0
1045 >             f2 = -2.0_dp*alpha2*df0
1046 >             f3 = f2*r2*rij
1047 >             f4 = 0.4_dp*alpha2*f3*r2
1048            endif
1049 +          ri5damp = f1 + f3*one_third
1050 +          ri7damp = ri5damp + f4
1051  
1052            ri2 = riji * riji
1053            ri3 = ri2 * riji
# Line 1068 | Line 1056 | contains
1056            cy2 = cy_i * cy_i
1057            cz2 = cz_i * cz_i
1058  
1059 <          pref = pre14 * q_j / 3.0d0
1060 <          pot_term = ri3 * (qxx_i * (3.0d0*cx2 - 1.0d0) + &
1061 <                            qyy_i * (3.0d0*cy2 - 1.0d0) + &
1062 <                            qzz_i * (3.0d0*cz2 - 1.0d0))
1063 <          vterm = pref * (pot_term*f1 + (qxx_i*cx2 + qyy_i*cy2 + qzz_i*cz2)*f2)
1059 >          pref = pre14 * q_j * one_third
1060 >
1061 >          pot_term = ri3 * ( qxx_i * (3.0_dp*cx2*ri5damp - f1) + &
1062 >                             qyy_i * (3.0_dp*cy2*ri5damp - f1) + &
1063 >                             qzz_i * (3.0_dp*cz2*ri5damp - f1) )
1064 >
1065 >          vterm = pref * pot_term
1066            vpair = vpair + vterm
1067            epot = epot + sw*vterm
1068 +
1069 +          ! precompute variables for convenience (and obfuscation unfortunatly)
1070 +          prei3 = 3.0_dp*sw*pref*ri3
1071 +          prei4 = prei3*riji
1072 +          xhatdot2 = xhat*2.0_dp * ri5damp
1073 +          yhatdot2 = yhat*2.0_dp * ri5damp
1074 +          zhatdot2 = zhat*2.0_dp * ri5damp
1075 +          xhatdot5 = xhat*5.0_dp * ri7damp
1076 +          yhatdot5 = yhat*5.0_dp * ri7damp
1077 +          zhatdot5 = zhat*5.0_dp * ri7damp
1078 +
1079 +          dudx = dudx - prei4 * ( &
1080 +               qxx_i*(cx2*xhatdot5 - (2.0_dp*cx_i*ux_i(1) + xhat)*ri5damp) + &
1081 +               qyy_i*(cy2*xhatdot5 - (2.0_dp*cy_i*uy_i(1) + xhat)*ri5damp) + &
1082 +               qzz_i*(cz2*xhatdot5 - (2.0_dp*cz_i*uz_i(1) + xhat)*ri5damp) )
1083 +          dudy = dudy - prei4 * ( &
1084 +               qxx_i*(cx2*yhatdot5 - (2.0_dp*cx_i*ux_i(2) + yhat)*ri5damp) + &
1085 +               qyy_i*(cy2*yhatdot5 - (2.0_dp*cy_i*uy_i(2) + yhat)*ri5damp) + &
1086 +               qzz_i*(cz2*yhatdot5 - (2.0_dp*cz_i*uz_i(2) + yhat)*ri5damp) )
1087 +          dudz = dudz - prei4 * ( &
1088 +               qxx_i*(cx2*zhatdot5 - (2.0_dp*cx_i*ux_i(3) + zhat)*ri5damp) + &
1089 +               qyy_i*(cy2*zhatdot5 - (2.0_dp*cy_i*uy_i(3) + zhat)*ri5damp) + &
1090 +               qzz_i*(cz2*zhatdot5 - (2.0_dp*cz_i*uz_i(3) + zhat)*ri5damp) )
1091            
1092 <          dudx = dudx - sw*pref*pot_term*riji*xhat*(5.0d0*f1 + f3) + &
1093 <               sw*pref*ri4 * ( &
1094 <               qxx_i*(2.0d0*cx_i*ux_i(1)*(3.0d0*f1 + f3) - 2.0d0*xhat*f1) + &
1082 <               qyy_i*(2.0d0*cy_i*uy_i(1)*(3.0d0*f1 + f3) - 2.0d0*xhat*f1) + &
1083 <               qzz_i*(2.0d0*cz_i*uz_i(1)*(3.0d0*f1 + f3) - 2.0d0*xhat*f1) ) &
1084 <               + (qxx_i*cx2 + qyy_i*cy2 + qzz_i*cz2)*f4
1085 <          dudy = dudy - sw*pref*pot_term*riji*yhat*(5.0d0*f1 + f3) + &
1086 <               sw*pref*ri4 * ( &
1087 <               qxx_i*(2.0d0*cx_i*ux_i(2)*(3.0d0*f1 + f3) - 2.0d0*yhat*f1) + &
1088 <               qyy_i*(2.0d0*cy_i*uy_i(2)*(3.0d0*f1 + f3) - 2.0d0*yhat*f1) + &
1089 <               qzz_i*(2.0d0*cz_i*uz_i(2)*(3.0d0*f1 + f3) - 2.0d0*yhat*f1) ) &
1090 <               + (qxx_i*cx2 + qyy_i*cy2 + qzz_i*cz2)*f4
1091 <          dudz = dudz - sw*pref*pot_term*riji*zhat*(5.0d0*f1 + f3) + &
1092 <               sw*pref*ri4 * ( &
1093 <               qxx_i*(2.0d0*cx_i*ux_i(3)*(3.0d0*f1 + f3) - 2.0d0*zhat*f1) + &
1094 <               qyy_i*(2.0d0*cy_i*uy_i(3)*(3.0d0*f1 + f3) - 2.0d0*zhat*f1) + &
1095 <               qzz_i*(2.0d0*cz_i*uz_i(3)*(3.0d0*f1 + f3) - 2.0d0*zhat*f1) ) &
1096 <               + (qxx_i*cx2 + qyy_i*cy2 + qzz_i*cz2)*f4
1092 >          dudux_i(1) = dudux_i(1) + prei3*(qxx_i*cx_i*xhatdot2)
1093 >          dudux_i(2) = dudux_i(2) + prei3*(qxx_i*cx_i*yhatdot2)
1094 >          dudux_i(3) = dudux_i(3) + prei3*(qxx_i*cx_i*zhatdot2)
1095            
1096 <          dudux_i(1) = dudux_i(1) + sw*pref*( ri3*(qxx_i*2.0d0*cx_i*xhat) &
1097 <               * (3.0d0*f1 + f3) )
1098 <          dudux_i(2) = dudux_i(2) + sw*pref*( ri3*(qxx_i*2.0d0*cx_i*yhat) &
1101 <               * (3.0d0*f1 + f3) )
1102 <          dudux_i(3) = dudux_i(3) + sw*pref*( ri3*(qxx_i*2.0d0*cx_i*zhat) &
1103 <               * (3.0d0*f1 + f3) )
1096 >          duduy_i(1) = duduy_i(1) + prei3*(qyy_i*cy_i*xhatdot2)
1097 >          duduy_i(2) = duduy_i(2) + prei3*(qyy_i*cy_i*yhatdot2)
1098 >          duduy_i(3) = duduy_i(3) + prei3*(qyy_i*cy_i*zhatdot2)
1099            
1100 <          duduy_i(1) = duduy_i(1) + sw*pref*( ri3*(qyy_i*2.0d0*cy_i*xhat) &
1101 <               * (3.0d0*f1 + f3) )
1102 <          duduy_i(2) = duduy_i(2) + sw*pref*( ri3*(qyy_i*2.0d0*cy_i*yhat) &
1108 <               * (3.0d0*f1 + f3) )
1109 <          duduy_i(3) = duduy_i(3) + sw*pref*( ri3*(qyy_i*2.0d0*cy_i*zhat) &
1110 <               * (3.0d0*f1 + f3) )
1111 <          
1112 <          duduz_i(1) = duduz_i(1) + sw*pref*( ri3*(qzz_i*2.0d0*cz_i*xhat) &
1113 <               * (3.0d0*f1 + f3) )
1114 <          duduz_i(2) = duduz_i(2) + sw*pref*( ri3*(qzz_i*2.0d0*cz_i*yhat) &
1115 <               * (3.0d0*f1 + f3) )
1116 <          duduz_i(3) = duduz_i(3) + sw*pref*( ri3*(qzz_i*2.0d0*cz_i*zhat) &
1117 <               * (3.0d0*f1 + f3) )
1118 <
1100 >          duduz_i(1) = duduz_i(1) + prei3*(qzz_i*cz_i*xhatdot2)
1101 >          duduz_i(2) = duduz_i(2) + prei3*(qzz_i*cz_i*yhatdot2)
1102 >          duduz_i(3) = duduz_i(3) + prei3*(qzz_i*cz_i*zhatdot2)
1103         endif
1104      endif
1105  
1106  
1107      if (do_pot) then
1108   #ifdef IS_MPI
1109 <       pot_row(ELECTROSTATIC_POT,atom1) = pot_row(ELECTROSTATIC_POT,atom1) + 0.5d0*epot
1110 <       pot_col(ELECTROSTATIC_POT,atom2) = pot_col(ELECTROSTATIC_POT,atom2) + 0.5d0*epot
1109 >       pot_row(ELECTROSTATIC_POT,atom1) = pot_row(ELECTROSTATIC_POT,atom1) + 0.5_dp*epot
1110 >       pot_col(ELECTROSTATIC_POT,atom2) = pot_col(ELECTROSTATIC_POT,atom2) + 0.5_dp*epot
1111   #else
1112         pot = pot + epot
1113   #endif
# Line 1256 | Line 1240 | contains
1240            mu1 = getDipoleMoment(atid1)
1241            
1242            preVal = pre22 * preRF2 * mu1*mu1
1243 <          mypot = mypot - 0.5d0*preVal
1243 >          mypot = mypot - 0.5_dp*preVal
1244            
1245            ! The self-correction term adds into the reaction field vector
1246            
# Line 1282 | Line 1266 | contains
1266            c1 = getCharge(atid1)
1267            
1268            if (screeningMethod .eq. DAMPED) then
1269 <             mypot = mypot - (f0c * rcuti * 0.5d0 + &
1269 >             mypot = mypot - (f0c * rcuti * 0.5_dp + &
1270                    dampingAlpha*invRootPi) * c1 * c1    
1271              
1272            else            
1273 <             mypot = mypot - (rcuti * 0.5d0 * c1 * c1)
1273 >             mypot = mypot - (rcuti * 0.5_dp * c1 * c1)
1274              
1275            endif
1276         endif
# Line 1326 | Line 1310 | contains
1310         call checkSummationMethod()
1311      endif
1312  
1313 <    dudx = 0.0d0
1314 <    dudy = 0.0d0
1315 <    dudz = 0.0d0
1313 >    dudx = zero
1314 >    dudy = zero
1315 >    dudz = zero
1316  
1317 <    riji = 1.0d0/rij
1317 >    riji = 1.0_dp/rij
1318  
1319      xhat = d(1) * riji
1320      yhat = d(2) * riji
# Line 1354 | Line 1338 | contains
1338        
1339         myPot = myPot + sw*vterm
1340        
1341 <       dudr  = sw*preVal * 2.0d0*rfVal*riji
1341 >       dudr  = sw*preVal * 2.0_dp*rfVal*riji
1342        
1343         dudx = dudx + dudr * xhat
1344         dudy = dudy + dudr * yhat
# Line 1375 | Line 1359 | contains
1359         vterm = - pref * ct_j * ( ri2 - preRF2*rij )
1360         myPot = myPot + sw*vterm
1361        
1362 <       dudx = dudx - sw*pref*( ri3*(uz_j(1)-3.0d0*ct_j*xhat) &
1362 >       dudx = dudx - sw*pref*( ri3*(uz_j(1)-3.0_dp*ct_j*xhat) &
1363              - preRF2*uz_j(1) )
1364 <       dudy = dudy - sw*pref*( ri3*(uz_j(2)-3.0d0*ct_j*yhat) &
1364 >       dudy = dudy - sw*pref*( ri3*(uz_j(2)-3.0_dp*ct_j*yhat) &
1365              - preRF2*uz_j(2) )
1366 <       dudz = dudz - sw*pref*( ri3*(uz_j(3)-3.0d0*ct_j*zhat) &
1366 >       dudz = dudz - sw*pref*( ri3*(uz_j(3)-3.0_dp*ct_j*zhat) &
1367              - preRF2*uz_j(3) )
1368        
1369         duduz_j(1) = duduz_j(1) - sw * pref * xhat * ( ri2 - preRF2*rij )
# Line 1401 | Line 1385 | contains
1385         vterm = pref * ct_i * ( ri2 - preRF2*rij )
1386         myPot = myPot + sw*vterm
1387        
1388 <       dudx = dudx + sw*pref*( ri3*(uz_i(1)-3.0d0*ct_i*xhat) &
1388 >       dudx = dudx + sw*pref*( ri3*(uz_i(1)-3.0_dp*ct_i*xhat) &
1389              - preRF2*uz_i(1) )
1390 <       dudy = dudy + sw*pref*( ri3*(uz_i(2)-3.0d0*ct_i*yhat) &
1390 >       dudy = dudy + sw*pref*( ri3*(uz_i(2)-3.0_dp*ct_i*yhat) &
1391              - preRF2*uz_i(2) )
1392 <       dudz = dudz + sw*pref*( ri3*(uz_i(3)-3.0d0*ct_i*zhat) &
1392 >       dudz = dudz + sw*pref*( ri3*(uz_i(3)-3.0_dp*ct_i*zhat) &
1393              - preRF2*uz_i(3) )
1394        
1395         duduz_i(1) = duduz_i(1) + sw * pref * xhat * ( ri2 - preRF2*rij )

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines