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 2439 by chrisfen, Tue Nov 15 19:42:22 2005 UTC vs.
Revision 2717 by gezelter, Mon Apr 17 21:49:12 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 64 | 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.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
80    !! electrostatics:
# Line 103 | Line 104 | module electrostatic_module
104    real(kind=dp), save :: f0 = 1.0_DP
105    real(kind=dp), save :: f1 = 1.0_DP
106    real(kind=dp), save :: f2 = 0.0_DP
107 +  real(kind=dp), save :: f3 = 0.0_DP
108 +  real(kind=dp), save :: f4 = 0.0_DP
109    real(kind=dp), save :: f0c = 1.0_DP
110    real(kind=dp), save :: f1c = 1.0_DP
111    real(kind=dp), save :: f2c = 0.0_DP
112 +  real(kind=dp), save :: f3c = 0.0_DP
113 +  real(kind=dp), save :: f4c = 0.0_DP
114  
115 < #ifdef __IFC
115 > #if defined(__IFC) || defined(__PGI)
116   ! error function for ifc version > 7.
117    double precision, external :: derfc
118   #endif
# Line 117 | Line 122 | module electrostatic_module
122    public :: setElectrostaticCutoffRadius
123    public :: setDampingAlpha
124    public :: setReactionFieldDielectric
125 +  public :: buildElectroSplines
126    public :: newElectrostaticType
127    public :: setCharge
128    public :: setDipoleMoment
# Line 129 | Line 135 | module electrostatic_module
135    public :: self_self
136    public :: rf_self_excludes
137  
138 +
139    type :: Electrostatic
140       integer :: c_ident
141       logical :: is_Charge = .false.
# Line 144 | Line 151 | contains
151  
152    type(Electrostatic), dimension(:), allocatable :: ElectrostaticMap
153  
154 +  logical, save :: hasElectrostaticMap
155 +
156   contains
157  
158    subroutine setElectrostaticSummationMethod(the_ESM)
# Line 166 | Line 175 | contains
175      real(kind=dp), intent(in) :: thisRcut
176      real(kind=dp), intent(in) :: thisRsw
177      defaultCutoff = thisRcut
178 +    defaultCutoff2 = defaultCutoff*defaultCutoff
179      rrf = defaultCutoff
180      rt = thisRsw
181      haveDefaultCutoff = .true.
# Line 184 | Line 194 | contains
194      haveDielectric = .true.
195    end subroutine setReactionFieldDielectric
196  
197 +  subroutine buildElectroSplines()
198 +  end subroutine buildElectroSplines
199 +
200    subroutine newElectrostaticType(c_ident, is_Charge, is_Dipole, &
201         is_SplitDipole, is_Quadrupole, is_Tap, status)
202  
# Line 211 | Line 224 | contains
224            return
225         end if
226  
227 <       if (.not. allocated(ElectrostaticMap)) then
215 <          allocate(ElectrostaticMap(nAtypes))
216 <       endif
227 >       allocate(ElectrostaticMap(nAtypes))
228  
229      end if
230  
# Line 231 | Line 242 | contains
242      ElectrostaticMap(myATID)%is_Quadrupole = is_Quadrupole
243      ElectrostaticMap(myATID)%is_Tap = is_Tap
244  
245 +    hasElectrostaticMap = .true.
246 +
247    end subroutine newElectrostaticType
248  
249    subroutine setCharge(c_ident, charge, status)
# Line 242 | Line 255 | contains
255      status = 0
256      myATID = getFirstMatchingElement(atypes, "c_ident", c_ident)
257  
258 <    if (.not.allocated(ElectrostaticMap)) then
258 >    if (.not.hasElectrostaticMap) then
259         call handleError("electrostatic", "no ElectrostaticMap was present before first call of setCharge!")
260         status = -1
261         return
# Line 272 | Line 285 | contains
285      status = 0
286      myATID = getFirstMatchingElement(atypes, "c_ident", c_ident)
287  
288 <    if (.not.allocated(ElectrostaticMap)) then
288 >    if (.not.hasElectrostaticMap) then
289         call handleError("electrostatic", "no ElectrostaticMap was present before first call of setDipoleMoment!")
290         status = -1
291         return
# Line 302 | Line 315 | contains
315      status = 0
316      myATID = getFirstMatchingElement(atypes, "c_ident", c_ident)
317  
318 <    if (.not.allocated(ElectrostaticMap)) then
318 >    if (.not.hasElectrostaticMap) then
319         call handleError("electrostatic", "no ElectrostaticMap was present before first call of setSplitDipoleDistance!")
320         status = -1
321         return
# Line 332 | Line 345 | contains
345      status = 0
346      myATID = getFirstMatchingElement(atypes, "c_ident", c_ident)
347  
348 <    if (.not.allocated(ElectrostaticMap)) then
348 >    if (.not.hasElectrostaticMap) then
349         call handleError("electrostatic", "no ElectrostaticMap was present before first call of setQuadrupoleMoments!")
350         status = -1
351         return
# Line 363 | Line 376 | contains
376      integer :: localError
377      real(kind=dp) :: c
378  
379 <    if (.not.allocated(ElectrostaticMap)) then
379 >    if (.not.hasElectrostaticMap) then
380         call handleError("electrostatic", "no ElectrostaticMap was present before first call of getCharge!")
381         return
382      end if
# Line 381 | Line 394 | contains
394      integer :: localError
395      real(kind=dp) :: dm
396  
397 <    if (.not.allocated(ElectrostaticMap)) then
397 >    if (.not.hasElectrostaticMap) then
398         call handleError("electrostatic", "no ElectrostaticMap was present before first call of getDipoleMoment!")
399         return
400      end if
# Line 414 | Line 427 | contains
427            call handleError("checkSummationMethod", "no Default Cutoff set!")
428         endif
429  
430 <       constEXP = exp(-alpha2*defaultCutoff*defaultCutoff)
430 >       constEXP = exp(-alpha2*defaultCutoff2)
431         invRootPi = 0.56418958354775628695d0
432         alphaPi = 2.0d0*dampingAlpha*invRootPi
433         f0c = derfc(dampingAlpha*defaultCutoff)
434         f1c = alphaPi*defaultCutoff*constEXP + f0c
435 <       f2c = alphaPi*2.0d0*alpha2*constEXP*rcuti2
436 <
435 >       f2c = alphaPi*2.0d0*alpha2*constEXP
436 >       f3c = alphaPi*2.0d0*alpha2*constEXP*defaultCutoff2*defaultCutoff
437      endif
438  
439      if (summationMethod .eq. REACTION_FIELD) then
# Line 439 | Line 452 | contains
452    end subroutine checkSummationMethod
453  
454  
455 <  subroutine doElectrostaticPair(atom1, atom2, d, rij, r2, sw, &
455 >  subroutine doElectrostaticPair(atom1, atom2, d, rij, r2, rcut, sw, &
456         vpair, fpair, pot, eFrame, f, t, do_pot)
457  
458      logical, intent(in) :: do_pot
# Line 447 | Line 460 | contains
460      integer, intent(in) :: atom1, atom2
461      integer :: localError
462  
463 <    real(kind=dp), intent(in) :: rij, r2, sw
463 >    real(kind=dp), intent(in) :: rij, r2, sw, rcut
464      real(kind=dp), intent(in), dimension(3) :: d
465      real(kind=dp), intent(inout) :: vpair
466      real(kind=dp), intent(inout), dimension(3) :: fpair    
# Line 482 | Line 495 | contains
495      real (kind=dp) :: varEXP
496      real (kind=dp) :: pot_term
497      real (kind=dp) :: preVal, rfVal
498 +    real (kind=dp) :: f13, f134
499  
486    if (.not.allocated(ElectrostaticMap)) then
487       call handleError("electrostatic", "no ElectrostaticMap was present before first call of do_electrostatic_pair!")
488       return
489    end if
490
500      if (.not.summationMethodChecked) then
501         call checkSummationMethod()
502      endif
# Line 500 | Line 509 | contains
509      me2 = atid(atom2)
510   #endif
511  
503 !!$    if (rij .ge. defaultCutoff) then
504 !!$       write(*,*) 'warning: rij = ', rij, ' rcut = ', defaultCutoff, ' sw = ', sw
505 !!$    endif
506
512      !! some variables we'll need independent of electrostatic type:
513  
514      riji = 1.0d0 / rij
# Line 630 | Line 635 | contains
635         cz_j = uz_j(1)*xhat + uz_j(2)*yhat + uz_j(3)*zhat
636      endif
637    
638 <    epot = 0.0_dp
639 <    dudx = 0.0_dp
640 <    dudy = 0.0_dp
641 <    dudz = 0.0_dp
638 >    epot = 0.0d0
639 >    dudx = 0.0d0
640 >    dudy = 0.0d0
641 >    dudz = 0.0d0
642  
643 <    dudux_i = 0.0_dp
644 <    duduy_i = 0.0_dp
645 <    duduz_i = 0.0_dp
643 >    dudux_i = 0.0d0
644 >    duduy_i = 0.0d0
645 >    duduz_i = 0.0d0
646  
647 <    dudux_j = 0.0_dp
648 <    duduy_j = 0.0_dp
649 <    duduz_j = 0.0_dp
647 >    dudux_j = 0.0d0
648 >    duduy_j = 0.0d0
649 >    duduz_j = 0.0d0
650  
651      if (i_is_Charge) then
652  
# Line 688 | Line 693 | contains
693         endif
694  
695         if (j_is_Dipole) then
696 +          if (screeningMethod .eq. DAMPED) then
697 +             f0 = derfc(dampingAlpha*rij)
698 +             varEXP = exp(-alpha2*rij*rij)
699 +             f1 = alphaPi*rij*varEXP + f0
700 +             f3 = alphaPi*2.0d0*alpha2*varEXP*rij*rij*rij
701 +          endif
702  
703            pref = pre12 * q_i * mu_j
704  
# Line 715 | Line 726 | contains
726  
727            else
728               if (j_is_SplitDipole) then
729 <                BigR = sqrt(r2 + 0.25_dp * d_j * d_j)
730 <                ri = 1.0_dp / BigR
729 >                BigR = sqrt(r2 + 0.25d0 * d_j * d_j)
730 >                ri = 1.0d0 / BigR
731                  scale = rij * ri
732               else
733                  ri = riji
734 <                scale = 1.0_dp
734 >                scale = 1.0d0
735               endif
736              
737               ri2 = ri * ri
738               ri3 = ri2 * ri
739               sc2 = scale * scale
740  
741 <             vterm = - pref * ct_j * ri2 * scale
741 >             pot_term =  ri2 * scale * f1
742 >             vterm = - pref * ct_j * pot_term
743               vpair = vpair + vterm
744               epot = epot + sw*vterm
745              
# Line 735 | Line 747 | contains
747               !! r_j - r_i and the charge-dipole potential takes the origin
748               !! as the point dipole, which is atom j in this case.
749              
750 <             dudx = dudx - sw*pref * ri3 * ( uz_j(1) - 3.0d0*ct_j*xhat*sc2)
751 <             dudy = dudy - sw*pref * ri3 * ( uz_j(2) - 3.0d0*ct_j*yhat*sc2)
752 <             dudz = dudz - sw*pref * ri3 * ( uz_j(3) - 3.0d0*ct_j*zhat*sc2)
753 <            
754 <             duduz_j(1) = duduz_j(1) - sw*pref * ri2 * xhat * scale
755 <             duduz_j(2) = duduz_j(2) - sw*pref * ri2 * yhat * scale
756 <             duduz_j(3) = duduz_j(3) - sw*pref * ri2 * zhat * scale
750 >             dudx = dudx - sw*pref * ri3 * ( uz_j(1)*f1 - &
751 >                  ct_j*xhat*sc2*( 3.0d0*f1 + f3 ) )
752 >             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 ) )
756 >                          
757 >             duduz_j(1) = duduz_j(1) - sw*pref * pot_term * xhat
758 >             duduz_j(2) = duduz_j(2) - sw*pref * pot_term * yhat
759 >             duduz_j(3) = duduz_j(3) - sw*pref * pot_term * zhat
760  
761            endif
762         endif
763  
764         if (j_is_Quadrupole) then
765 +          if (screeningMethod .eq. DAMPED) then
766 +             f0 = derfc(dampingAlpha*rij)
767 +             varEXP = exp(-alpha2*rij*rij)
768 +             f1 = alphaPi*rij*varEXP + f0
769 +             f2 = alphaPi*2.0d0*alpha2*varEXP
770 +             f3 = f2*rij*rij*rij
771 +             f4 = 2.0d0*alpha2*f2*rij
772 +          endif
773 +
774            ri2 = riji * riji
775            ri3 = ri2 * riji
776            ri4 = ri2 * ri2
# Line 754 | Line 778 | contains
778            cy2 = cy_j * cy_j
779            cz2 = cz_j * cz_j
780  
781 <          pref =  pre14 * q_i / 3.0_dp
782 <          vterm = pref * ri3 * (qxx_j * (3.0_dp*cx2 - 1.0_dp) + &
783 <               qyy_j * (3.0_dp*cy2 - 1.0_dp) + &
784 <               qzz_j * (3.0_dp*cz2 - 1.0_dp))
781 >          pref =  pre14 * q_i / 3.0d0
782 >          pot_term = ri3*(qxx_j * (3.0d0*cx2 - 1.0d0) + &
783 >               qyy_j * (3.0d0*cy2 - 1.0d0) + &
784 >               qzz_j * (3.0d0*cz2 - 1.0d0))
785 >          vterm = pref * (pot_term*f1 + (qxx_j*cx2 + qyy_j*cy2 + qzz_j*cz2)*f2)
786            vpair = vpair + vterm
787            epot = epot + sw*vterm
788            
789 <          dudx = dudx - 5.0_dp*sw*vterm*riji*xhat + sw*pref * ri4 * ( &
790 <               qxx_j*(6.0_dp*cx_j*ux_j(1) - 2.0_dp*xhat) + &
791 <               qyy_j*(6.0_dp*cy_j*uy_j(1) - 2.0_dp*xhat) + &
792 <               qzz_j*(6.0_dp*cz_j*uz_j(1) - 2.0_dp*xhat) )
793 <          dudy = dudy - 5.0_dp*sw*vterm*riji*yhat + sw*pref * ri4 * ( &
794 <               qxx_j*(6.0_dp*cx_j*ux_j(2) - 2.0_dp*yhat) + &
795 <               qyy_j*(6.0_dp*cy_j*uy_j(2) - 2.0_dp*yhat) + &
796 <               qzz_j*(6.0_dp*cz_j*uz_j(2) - 2.0_dp*yhat) )
797 <          dudz = dudz - 5.0_dp*sw*vterm*riji*zhat + sw*pref * ri4 * ( &
798 <               qxx_j*(6.0_dp*cx_j*ux_j(3) - 2.0_dp*zhat) + &
799 <               qyy_j*(6.0_dp*cy_j*uy_j(3) - 2.0_dp*zhat) + &
800 <               qzz_j*(6.0_dp*cz_j*uz_j(3) - 2.0_dp*zhat) )
789 >          dudx = dudx - sw*pref*pot_term*riji*xhat*(5.0d0*f1 + f3) + &
790 >               sw*pref*ri4 * ( &
791 >               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
807            
808 <          dudux_j(1) = dudux_j(1) + sw*pref * ri3*(qxx_j*6.0_dp*cx_j*xhat)
809 <          dudux_j(2) = dudux_j(2) + sw*pref * ri3*(qxx_j*6.0_dp*cx_j*yhat)
810 <          dudux_j(3) = dudux_j(3) + sw*pref * ri3*(qxx_j*6.0_dp*cx_j*zhat)
808 >          dudux_j(1) = dudux_j(1) + sw*pref*ri3*( (qxx_j*2.0d0*cx_j*xhat) &
809 >               * (3.0d0*f1 + f3) )
810 >          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) )
814            
815 <          duduy_j(1) = duduy_j(1) + sw*pref * ri3*(qyy_j*6.0_dp*cy_j*xhat)
816 <          duduy_j(2) = duduy_j(2) + sw*pref * ri3*(qyy_j*6.0_dp*cy_j*yhat)
817 <          duduy_j(3) = duduy_j(3) + sw*pref * ri3*(qyy_j*6.0_dp*cy_j*zhat)
815 >          duduy_j(1) = duduy_j(1) + sw*pref*ri3*( (qyy_j*2.0d0*cy_j*xhat) &
816 >               * (3.0d0*f1 + f3) )
817 >          duduy_j(2) = duduy_j(2) + sw*pref*ri3*( (qyy_j*2.0d0*cy_j*yhat) &
818 >               * (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*6.0_dp*cz_j*xhat)
823 <          duduz_j(2) = duduz_j(2) + sw*pref * ri3*(qzz_j*6.0_dp*cz_j*yhat)
824 <          duduz_j(3) = duduz_j(3) + sw*pref * ri3*(qzz_j*6.0_dp*cz_j*zhat)
825 <          
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) )
828 >          
829         endif
830      endif
831      
832      if (i_is_Dipole) then
833  
834         if (j_is_Charge) then
835 +          if (screeningMethod .eq. DAMPED) then
836 +             f0 = derfc(dampingAlpha*rij)
837 +             varEXP = exp(-alpha2*rij*rij)
838 +             f1 = alphaPi*rij*varEXP + f0
839 +             f3 = alphaPi*2.0d0*alpha2*varEXP*rij*rij*rij
840 +          endif
841            
842            pref = pre12 * q_j * mu_i
843            
# Line 799 | Line 845 | contains
845               ri2 = riji * riji
846               ri3 = ri2 * riji
847              
848 <             pot_term = ri2 - rcuti2
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)-3.0d0*ct_i*xhat) )
854 <             dudy = dudy + sw*pref * ( ri3*(uz_i(2)-3.0d0*ct_i*yhat) )
855 <             dudz = dudz + sw*pref * ( ri3*(uz_i(3)-3.0d0*ct_i*zhat) )
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
# Line 816 | Line 862 | contains
862               ri2 = riji * riji
863               ri3 = ri2 * riji
864  
865 <             pot_term = ri2 - rcuti2 + 2.0d0*rcuti3*( rij - defaultCutoff )
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-rcuti3)*(uz_i(1)-3.0d0*ct_i*xhat) )
873 <             dudy = dudy + sw*pref * ( (ri3-rcuti3)*(uz_i(2)-3.0d0*ct_i*yhat) )
874 <             dudz = dudz + sw*pref * ( (ri3-rcuti3)*(uz_i(3)-3.0d0*ct_i*zhat) )
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 <
882 >
883            elseif (summationMethod .eq. REACTION_FIELD) then
884               ri2 = riji * riji
885               ri3 = ri2 * riji
# Line 850 | Line 901 | contains
901  
902            else
903               if (i_is_SplitDipole) then
904 <                BigR = sqrt(r2 + 0.25_dp * d_i * d_i)
905 <                ri = 1.0_dp / BigR
904 >                BigR = sqrt(r2 + 0.25d0 * d_i * d_i)
905 >                ri = 1.0d0 / BigR
906                  scale = rij * ri
907               else
908                  ri = riji
909 <                scale = 1.0_dp
909 >                scale = 1.0d0
910               endif
911              
912               ri2 = ri * ri
913               ri3 = ri2 * ri
914               sc2 = scale * scale
915  
916 <             vterm = pref * ct_i * ri2 * scale
916 >             pot_term = ri2 * f1 * scale
917 >             vterm = pref * ct_i * pot_term
918               vpair = vpair + vterm
919               epot = epot + sw*vterm
920              
921 <             dudx = dudx + sw*pref * ri3 * ( uz_i(1) - 3.0d0 * ct_i * xhat*sc2)
922 <             dudy = dudy + sw*pref * ri3 * ( uz_i(2) - 3.0d0 * ct_i * yhat*sc2)
923 <             dudz = dudz + sw*pref * ri3 * ( uz_i(3) - 3.0d0 * ct_i * zhat*sc2)
921 >             dudx = dudx + sw*pref * ri3 * ( uz_i(1)*f1 - &
922 >                  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 ) )
927              
928 <             duduz_i(1) = duduz_i(1) + sw*pref * ri2 * xhat * scale
929 <             duduz_i(2) = duduz_i(2) + sw*pref * ri2 * yhat * scale
930 <             duduz_i(3) = duduz_i(3) + sw*pref * ri2 * zhat * scale
928 >             duduz_i(1) = duduz_i(1) + sw*pref * pot_term * xhat
929 >             duduz_i(2) = duduz_i(2) + sw*pref * pot_term * yhat
930 >             duduz_i(3) = duduz_i(3) + sw*pref * pot_term * zhat
931            endif
932         endif
933        
934         if (j_is_Dipole) then
935 +          if (screeningMethod .eq. DAMPED) then
936 +             f0 = derfc(dampingAlpha*rij)
937 +             varEXP = exp(-alpha2*rij*rij)
938 +             f1 = alphaPi*rij*varEXP + f0
939 +             f2 = alphaPi*2.0d0*alpha2*varEXP
940 +             f3 = f2*rij*rij*rij
941 +             f4 = 2.0d0*alpha2*f3*rij*rij
942 +          endif
943 +
944            ct_ij = uz_i(1)*uz_j(1) + uz_i(2)*uz_j(2) + uz_i(3)*uz_j(3)
945            
946            ri2 = riji * riji
# Line 916 | Line 980 | contains
980            else
981               if (i_is_SplitDipole) then
982                  if (j_is_SplitDipole) then
983 <                   BigR = sqrt(r2 + 0.25_dp * d_i * d_i + 0.25_dp * d_j * d_j)
983 >                   BigR = sqrt(r2 + 0.25d0 * d_i * d_i + 0.25d0 * d_j * d_j)
984                  else
985 <                   BigR = sqrt(r2 + 0.25_dp * d_i * d_i)
985 >                   BigR = sqrt(r2 + 0.25d0 * d_i * d_i)
986                  endif
987 <                ri = 1.0_dp / BigR
987 >                ri = 1.0d0 / BigR
988                  scale = rij * ri                
989               else
990                  if (j_is_SplitDipole) then
991 <                   BigR = sqrt(r2 + 0.25_dp * d_j * d_j)
992 <                   ri = 1.0_dp / BigR
991 >                   BigR = sqrt(r2 + 0.25d0 * d_j * d_j)
992 >                   ri = 1.0d0 / BigR
993                     scale = rij * ri                            
994                  else                
995                     ri = riji
996 <                   scale = 1.0_dp
996 >                   scale = 1.0d0
997                  endif
998               endif
999              
1000               sc2 = scale * scale
1001  
1002 <             vterm = pref * ri3 * (ct_ij - 3.0d0 * ct_i * ct_j * sc2)
1002 >             pot_term = (ct_ij - 3.0d0 * ct_i * ct_j * sc2)
1003 >             vterm = pref * ( ri3*pot_term*f1 + (ct_i * ct_j)*f2 )
1004               vpair = vpair + vterm
1005               epot = epot + sw*vterm
1006              
1007 <             a1 = 5.0d0 * ct_i * ct_j * sc2 - ct_ij
1007 >             f13 = f1+f3
1008 >             f134 = f13 + f4
1009              
1010 <             dudx = dudx + sw*pref*3.0d0*ri4*scale &
1011 <                             *(a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1))
1012 <             dudy = dudy + sw*pref*3.0d0*ri4*scale &
1013 <                             *(a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2))
1014 <             dudz = dudz + sw*pref*3.0d0*ri4*scale &
1015 <                             *(a1*zhat-ct_i*uz_j(3)-ct_j*uz_i(3))
1010 > !!$             dudx = dudx + sw*pref * ( ri4*scale*( &
1011 > !!$                  3.0d0*(a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1))*f1 &
1012 > !!$                  - pot_term*f3) &
1013 > !!$                  + 2.0d0*ct_i*ct_j*xhat*(ct_i*uz_j(1)+ct_j*uz_i(1))*f3 &
1014 > !!$                  + (ct_i * ct_j)*f4 )
1015 > !!$             dudy = dudy + sw*pref * ( ri4*scale*( &
1016 > !!$                  3.0d0*(a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2))*f1 &
1017 > !!$                  - 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 )
1025 >
1026 >             dudx = dudx + sw*pref * ( ri4*scale*( &
1027 >                  15.0d0*(ct_i * ct_j * sc2)*xhat*f134 - &
1028 >                  3.0d0*(ct_i*uz_j(1) + ct_j*uz_i(1) + ct_ij*xhat)*f134) )
1029 >             dudy = dudy + sw*pref * ( ri4*scale*( &
1030 >                  15.0d0*(ct_i * ct_j * sc2)*yhat*f134 - &
1031 >                  3.0d0*(ct_i*uz_j(2) + ct_j*uz_i(2) + ct_ij*yhat)*f134) )
1032 >             dudz = dudz + sw*pref * ( ri4*scale*( &
1033 >                  15.0d0*(ct_i * ct_j * sc2)*zhat*f134 - &
1034 >                  3.0d0*(ct_i*uz_j(3) + ct_j*uz_i(3) + ct_ij*zhat)*f134) )
1035              
1036 <             duduz_i(1) = duduz_i(1) + sw*pref*ri3 &
1037 <                                         *(uz_j(1) - 3.0d0*ct_j*xhat*sc2)
1038 <             duduz_i(2) = duduz_i(2) + sw*pref*ri3 &
1039 <                                         *(uz_j(2) - 3.0d0*ct_j*yhat*sc2)
1040 <             duduz_i(3) = duduz_i(3) + sw*pref*ri3 &
1041 <                                         *(uz_j(3) - 3.0d0*ct_j*zhat*sc2)
1036 >             duduz_i(1) = duduz_i(1) + sw*pref * &
1037 >                  ( ri3*(uz_j(1) - 3.0d0*ct_j*xhat*sc2)*f1 + (ct_j*xhat)*f2 )
1038 >             duduz_i(2) = duduz_i(2) + sw*pref * &
1039 >                  ( ri3*(uz_j(2) - 3.0d0*ct_j*yhat*sc2)*f1 + (ct_j*yhat)*f2 )
1040 >             duduz_i(3) = duduz_i(3) + sw*pref * &
1041 >                  ( ri3*(uz_j(3) - 3.0d0*ct_j*zhat*sc2)*f1 + (ct_j*zhat)*f2 )
1042              
1043 <             duduz_j(1) = duduz_j(1) + sw*pref*ri3 &
1044 <                                         *(uz_i(1) - 3.0d0*ct_i*xhat*sc2)
1045 <             duduz_j(2) = duduz_j(2) + sw*pref*ri3 &
1046 <                                         *(uz_i(2) - 3.0d0*ct_i*yhat*sc2)
1047 <             duduz_j(3) = duduz_j(3) + sw*pref*ri3 &
1048 <                                         *(uz_i(3) - 3.0d0*ct_i*zhat*sc2)
1043 >             duduz_j(1) = duduz_j(1) + sw*pref * &
1044 >                  ( ri3*(uz_i(1) - 3.0d0*ct_i*xhat*sc2)*f1 + (ct_i*xhat)*f2 )
1045 >             duduz_j(2) = duduz_j(2) + sw*pref * &
1046 >                  ( ri3*(uz_i(2) - 3.0d0*ct_i*yhat*sc2)*f1 + (ct_i*yhat)*f2 )
1047 >             duduz_j(3) = duduz_j(3) + sw*pref * &
1048 >                  ( ri3*(uz_i(3) - 3.0d0*ct_i*zhat*sc2)*f1 + (ct_i*zhat)*f2 )
1049            endif
1050         endif
1051      endif
1052  
1053      if (i_is_Quadrupole) then
1054         if (j_is_Charge) then
1055 +          if (screeningMethod .eq. DAMPED) then
1056 +             f0 = derfc(dampingAlpha*rij)
1057 +             varEXP = exp(-alpha2*rij*rij)
1058 +             f1 = alphaPi*rij*varEXP + f0
1059 +             f2 = alphaPi*2.0d0*alpha2*varEXP
1060 +             f3 = f2*rij*rij*rij
1061 +             f4 = 2.0d0*alpha2*f2*rij
1062 +          endif
1063 +
1064            ri2 = riji * riji
1065            ri3 = ri2 * riji
1066            ri4 = ri2 * ri2
# Line 974 | Line 1068 | contains
1068            cy2 = cy_i * cy_i
1069            cz2 = cz_i * cz_i
1070  
1071 <          pref = pre14 * q_j / 3.0_dp
1072 <          vterm = pref * ri3 * (qxx_i * (3.0_dp*cx2 - 1.0_dp) + &
1073 <               qyy_i * (3.0_dp*cy2 - 1.0_dp) + &
1074 <               qzz_i * (3.0_dp*cz2 - 1.0_dp))
1071 >          pref = pre14 * q_j / 3.0d0
1072 >          pot_term = ri3 * (qxx_i * (3.0d0*cx2 - 1.0d0) + &
1073 >                            qyy_i * (3.0d0*cy2 - 1.0d0) + &
1074 >                            qzz_i * (3.0d0*cz2 - 1.0d0))
1075 >          vterm = pref * (pot_term*f1 + (qxx_i*cx2 + qyy_i*cy2 + qzz_i*cz2)*f2)
1076            vpair = vpair + vterm
1077            epot = epot + sw*vterm
1078            
1079 <          dudx = dudx - 5.0_dp*sw*vterm*riji*xhat + sw*pref*ri4 * ( &
1080 <               qxx_i*(6.0_dp*cx_i*ux_i(1) - 2.0_dp*xhat) + &
1081 <               qyy_i*(6.0_dp*cy_i*uy_i(1) - 2.0_dp*xhat) + &
1082 <               qzz_i*(6.0_dp*cz_i*uz_i(1) - 2.0_dp*xhat) )
1083 <          dudy = dudy - 5.0_dp*sw*vterm*riji*yhat + sw*pref*ri4 * ( &
1084 <               qxx_i*(6.0_dp*cx_i*ux_i(2) - 2.0_dp*yhat) + &
1085 <               qyy_i*(6.0_dp*cy_i*uy_i(2) - 2.0_dp*yhat) + &
1086 <               qzz_i*(6.0_dp*cz_i*uz_i(2) - 2.0_dp*yhat) )
1087 <          dudz = dudz - 5.0_dp*sw*vterm*riji*zhat + sw*pref*ri4 * ( &
1088 <               qxx_i*(6.0_dp*cx_i*ux_i(3) - 2.0_dp*zhat) + &
1089 <               qyy_i*(6.0_dp*cy_i*uy_i(3) - 2.0_dp*zhat) + &
1090 <               qzz_i*(6.0_dp*cz_i*uz_i(3) - 2.0_dp*zhat) )
1091 <          
1092 <          dudux_i(1) = dudux_i(1) + sw*pref*ri3*(qxx_i*6.0_dp*cx_i*xhat)
1093 <          dudux_i(2) = dudux_i(2) + sw*pref*ri3*(qxx_i*6.0_dp*cx_i*yhat)
1094 <          dudux_i(3) = dudux_i(3) + sw*pref*ri3*(qxx_i*6.0_dp*cx_i*zhat)
1079 >          dudx = dudx - sw*pref*pot_term*riji*xhat*(5.0d0*f1 + f3) + &
1080 >               sw*pref*ri4 * ( &
1081 >               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
1097            
1098 <          duduy_i(1) = duduy_i(1) + sw*pref*ri3*(qyy_i*6.0_dp*cy_i*xhat)
1099 <          duduy_i(2) = duduy_i(2) + sw*pref*ri3*(qyy_i*6.0_dp*cy_i*yhat)
1100 <          duduy_i(3) = duduy_i(3) + sw*pref*ri3*(qyy_i*6.0_dp*cy_i*zhat)
1098 >          dudux_i(1) = dudux_i(1) + sw*pref*( ri3*(qxx_i*2.0d0*cx_i*xhat) &
1099 >               * (3.0d0*f1 + f3) )
1100 >          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) )
1104 >          
1105 >          duduy_i(1) = duduy_i(1) + sw*pref*( ri3*(qyy_i*2.0d0*cy_i*xhat) &
1106 >               * (3.0d0*f1 + f3) )
1107 >          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*6.0_dp*cz_i*xhat)
1113 <          duduz_i(2) = duduz_i(2) + sw*pref*ri3*(qzz_i*6.0_dp*cz_i*yhat)
1114 <          duduz_i(3) = duduz_i(3) + sw*pref*ri3*(qzz_i*6.0_dp*cz_i*zhat)
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  
1119         endif
1120      endif
# Line 1166 | Line 1276 | contains
1276            
1277         endif
1278  
1279 <    elseif (summationMethod .eq. SHIFTED_FORCE) then
1279 >    elseif ( (summationMethod .eq. SHIFTED_FORCE) .or. &
1280 >         (summationMethod .eq. SHIFTED_POTENTIAL) ) then
1281         if (ElectrostaticMap(atid1)%is_Charge) then
1282            c1 = getCharge(atid1)
1283            
1284            if (screeningMethod .eq. DAMPED) then
1285 <             mypot = mypot - (f0c * rcuti * 0.5_dp + &
1285 >             mypot = mypot - (f0c * rcuti * 0.5d0 + &
1286                    dampingAlpha*invRootPi) * c1 * c1    
1287              
1288            else            
1289 <             mypot = mypot - (rcuti * 0.5_dp * c1 * c1)
1289 >             mypot = mypot - (rcuti * 0.5d0 * c1 * c1)
1290              
1291            endif
1292         endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines