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 2508 by gezelter, Mon Dec 12 19:32:50 2005 UTC vs.
Revision 2715 by chrisfen, Sun Apr 16 02:51:16 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 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   #if defined(__IFC) || defined(__PGI)
116   ! error function for ifc version > 7.
117    double precision, external :: derfc
118   #endif
119    
120 <  public :: setElectrostaticSumMethod
120 >  public :: setElectrostaticSummationMethod
121    public :: setScreeningMethod
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 146 | Line 153 | contains
153  
154   contains
155  
156 <  subroutine setElectrostaticSumMethod(the_ESM)
156 >  subroutine setElectrostaticSummationMethod(the_ESM)
157      integer, intent(in) :: the_ESM    
158  
159      if ((the_ESM .le. 0) .or. (the_ESM .gt. REACTION_FIELD)) then
160 <       call handleError("setElectrostaticSumMethod", "Unsupported Summation Method")
160 >       call handleError("setElectrostaticSummationMethod", "Unsupported Summation Method")
161      endif
162  
163      summationMethod = the_ESM
164  
165 <  end subroutine setElectrostaticSumMethod
165 >  end subroutine setElectrostaticSummationMethod
166  
167    subroutine setScreeningMethod(the_SM)
168      integer, intent(in) :: the_SM    
# Line 166 | Line 173 | contains
173      real(kind=dp), intent(in) :: thisRcut
174      real(kind=dp), intent(in) :: thisRsw
175      defaultCutoff = thisRcut
176 +    defaultCutoff2 = defaultCutoff*defaultCutoff
177      rrf = defaultCutoff
178      rt = thisRsw
179      haveDefaultCutoff = .true.
# Line 184 | Line 192 | contains
192      haveDielectric = .true.
193    end subroutine setReactionFieldDielectric
194  
195 +  subroutine buildElectroSplines()
196 +  end subroutine buildElectroSplines
197 +
198    subroutine newElectrostaticType(c_ident, is_Charge, is_Dipole, &
199         is_SplitDipole, is_Quadrupole, is_Tap, status)
200  
# Line 414 | Line 425 | contains
425            call handleError("checkSummationMethod", "no Default Cutoff set!")
426         endif
427  
428 <       constEXP = exp(-alpha2*defaultCutoff*defaultCutoff)
428 >       constEXP = exp(-alpha2*defaultCutoff2)
429         invRootPi = 0.56418958354775628695d0
430         alphaPi = 2.0d0*dampingAlpha*invRootPi
431         f0c = derfc(dampingAlpha*defaultCutoff)
432         f1c = alphaPi*defaultCutoff*constEXP + f0c
433 <       f2c = alphaPi*2.0d0*alpha2*constEXP*rcuti2
434 <
433 >       f2c = alphaPi*2.0d0*alpha2*constEXP
434 >       f3c = alphaPi*2.0d0*alpha2*constEXP*defaultCutoff2*defaultCutoff
435      endif
436  
437      if (summationMethod .eq. REACTION_FIELD) then
# Line 482 | Line 493 | contains
493      real (kind=dp) :: varEXP
494      real (kind=dp) :: pot_term
495      real (kind=dp) :: preVal, rfVal
496 +    real (kind=dp) :: f13, f134
497  
498      if (.not.allocated(ElectrostaticMap)) then
499         call handleError("electrostatic", "no ElectrostaticMap was present before first call of do_electrostatic_pair!")
# Line 500 | Line 512 | contains
512      me2 = atid(atom2)
513   #endif
514  
503 !!$    if (rij .ge. defaultCutoff) then
504 !!$       write(*,*) 'warning: rij = ', rij, ' rcut = ', defaultCutoff, ' sw = ', sw
505 !!$    endif
506
515      !! some variables we'll need independent of electrostatic type:
516  
517      riji = 1.0d0 / rij
# Line 688 | Line 696 | contains
696         endif
697  
698         if (j_is_Dipole) then
699 +          if (screeningMethod .eq. DAMPED) then
700 +             f0 = derfc(dampingAlpha*rij)
701 +             varEXP = exp(-alpha2*rij*rij)
702 +             f1 = alphaPi*rij*varEXP + f0
703 +             f3 = alphaPi*2.0d0*alpha2*varEXP*rij*rij*rij
704 +          endif
705  
706            pref = pre12 * q_i * mu_j
707  
# Line 727 | Line 741 | contains
741               ri3 = ri2 * ri
742               sc2 = scale * scale
743  
744 <             vterm = - pref * ct_j * ri2 * scale
744 >             pot_term =  ri2 * scale * f1
745 >             vterm = - pref * ct_j * pot_term
746               vpair = vpair + vterm
747               epot = epot + sw*vterm
748              
# Line 735 | Line 750 | contains
750               !! r_j - r_i and the charge-dipole potential takes the origin
751               !! as the point dipole, which is atom j in this case.
752              
753 <             dudx = dudx - sw*pref * ri3 * ( uz_j(1) - 3.0d0*ct_j*xhat*sc2)
754 <             dudy = dudy - sw*pref * ri3 * ( uz_j(2) - 3.0d0*ct_j*yhat*sc2)
755 <             dudz = dudz - sw*pref * ri3 * ( uz_j(3) - 3.0d0*ct_j*zhat*sc2)
756 <            
757 <             duduz_j(1) = duduz_j(1) - sw*pref * ri2 * xhat * scale
758 <             duduz_j(2) = duduz_j(2) - sw*pref * ri2 * yhat * scale
759 <             duduz_j(3) = duduz_j(3) - sw*pref * ri2 * zhat * scale
753 >             dudx = dudx - sw*pref * ri3 * ( uz_j(1)*f1 - &
754 >                  ct_j*xhat*sc2*( 3.0d0*f1 + f3 ) )
755 >             dudy = dudy - sw*pref * ri3 * ( uz_j(2)*f1 - &
756 >                  ct_j*yhat*sc2*( 3.0d0*f1 + f3 ) )
757 >             dudz = dudz - sw*pref * ri3 * ( uz_j(3)*f1 - &
758 >                  ct_j*zhat*sc2*( 3.0d0*f1 + f3 ) )
759 >                          
760 >             duduz_j(1) = duduz_j(1) - sw*pref * pot_term * xhat
761 >             duduz_j(2) = duduz_j(2) - sw*pref * pot_term * yhat
762 >             duduz_j(3) = duduz_j(3) - sw*pref * pot_term * zhat
763  
764            endif
765         endif
766  
767         if (j_is_Quadrupole) then
768 +          if (screeningMethod .eq. DAMPED) then
769 +             f0 = derfc(dampingAlpha*rij)
770 +             varEXP = exp(-alpha2*rij*rij)
771 +             f1 = alphaPi*rij*varEXP + f0
772 +             f2 = alphaPi*2.0d0*alpha2*varEXP
773 +             f3 = f2*rij*rij*rij
774 +             f4 = 2.0d0*alpha2*f2*rij
775 +          endif
776 +
777            ri2 = riji * riji
778            ri3 = ri2 * riji
779            ri4 = ri2 * ri2
# Line 755 | Line 782 | contains
782            cz2 = cz_j * cz_j
783  
784            pref =  pre14 * q_i / 3.0_dp
785 <          vterm = pref * ri3 * (qxx_j * (3.0_dp*cx2 - 1.0_dp) + &
785 >          pot_term = ri3*(qxx_j * (3.0_dp*cx2 - 1.0_dp) + &
786                 qyy_j * (3.0_dp*cy2 - 1.0_dp) + &
787                 qzz_j * (3.0_dp*cz2 - 1.0_dp))
788 +          vterm = pref * (pot_term*f1 + (qxx_j*cx2 + qyy_j*cy2 + qzz_j*cz2)*f2)
789            vpair = vpair + vterm
790            epot = epot + sw*vterm
791            
792 <          dudx = dudx - 5.0_dp*sw*vterm*riji*xhat + sw*pref * ri4 * ( &
793 <               qxx_j*(6.0_dp*cx_j*ux_j(1) - 2.0_dp*xhat) + &
794 <               qyy_j*(6.0_dp*cy_j*uy_j(1) - 2.0_dp*xhat) + &
795 <               qzz_j*(6.0_dp*cz_j*uz_j(1) - 2.0_dp*xhat) )
796 <          dudy = dudy - 5.0_dp*sw*vterm*riji*yhat + sw*pref * ri4 * ( &
797 <               qxx_j*(6.0_dp*cx_j*ux_j(2) - 2.0_dp*yhat) + &
798 <               qyy_j*(6.0_dp*cy_j*uy_j(2) - 2.0_dp*yhat) + &
799 <               qzz_j*(6.0_dp*cz_j*uz_j(2) - 2.0_dp*yhat) )
800 <          dudz = dudz - 5.0_dp*sw*vterm*riji*zhat + sw*pref * ri4 * ( &
801 <               qxx_j*(6.0_dp*cx_j*ux_j(3) - 2.0_dp*zhat) + &
802 <               qyy_j*(6.0_dp*cy_j*uy_j(3) - 2.0_dp*zhat) + &
803 <               qzz_j*(6.0_dp*cz_j*uz_j(3) - 2.0_dp*zhat) )
804 <          
805 <          dudux_j(1) = dudux_j(1) + sw*pref * ri3*(qxx_j*6.0_dp*cx_j*xhat)
806 <          dudux_j(2) = dudux_j(2) + sw*pref * ri3*(qxx_j*6.0_dp*cx_j*yhat)
807 <          dudux_j(3) = dudux_j(3) + sw*pref * ri3*(qxx_j*6.0_dp*cx_j*zhat)
792 >          dudx = dudx - sw*pref*pot_term*riji*xhat*(5.0d0*f1 + f3) + &
793 >               sw*pref*ri4 * ( &
794 >               qxx_j*(2.0_dp*cx_j*ux_j(1)*(3.0d0*f1 + f3) - 2.0_dp*xhat*f1) + &
795 >               qyy_j*(2.0_dp*cy_j*uy_j(1)*(3.0d0*f1 + f3) - 2.0_dp*xhat*f1) + &
796 >               qzz_j*(2.0_dp*cz_j*uz_j(1)*(3.0d0*f1 + f3) - 2.0_dp*xhat*f1) ) &
797 >               + (qxx_j*cx2 + qyy_j*cy2 + qzz_j*cz2)*f4
798 >          dudy = dudy - sw*pref*pot_term*riji*yhat*(5.0d0*f1 + f3) + &
799 >               sw*pref*ri4 * ( &
800 >               qxx_j*(2.0_dp*cx_j*ux_j(2)*(3.0d0*f1 + f3) - 2.0_dp*yhat*f1) + &
801 >               qyy_j*(2.0_dp*cy_j*uy_j(2)*(3.0d0*f1 + f3) - 2.0_dp*yhat*f1) + &
802 >               qzz_j*(2.0_dp*cz_j*uz_j(2)*(3.0d0*f1 + f3) - 2.0_dp*yhat*f1) ) &
803 >               + (qxx_j*cx2 + qyy_j*cy2 + qzz_j*cz2)*f4
804 >          dudz = dudz - sw*pref*pot_term*riji*zhat*(5.0d0*f1 + f3) + &
805 >               sw*pref*ri4 * ( &
806 >               qxx_j*(2.0_dp*cx_j*ux_j(3)*(3.0d0*f1 + f3) - 2.0_dp*zhat*f1) + &
807 >               qyy_j*(2.0_dp*cy_j*uy_j(3)*(3.0d0*f1 + f3) - 2.0_dp*zhat*f1) + &
808 >               qzz_j*(2.0_dp*cz_j*uz_j(3)*(3.0d0*f1 + f3) - 2.0_dp*zhat*f1) ) &
809 >               + (qxx_j*cx2 + qyy_j*cy2 + qzz_j*cz2)*f4
810            
811 <          duduy_j(1) = duduy_j(1) + sw*pref * ri3*(qyy_j*6.0_dp*cy_j*xhat)
812 <          duduy_j(2) = duduy_j(2) + sw*pref * ri3*(qyy_j*6.0_dp*cy_j*yhat)
813 <          duduy_j(3) = duduy_j(3) + sw*pref * ri3*(qyy_j*6.0_dp*cy_j*zhat)
811 >          dudux_j(1) = dudux_j(1) + sw*pref*ri3*( (qxx_j*2.0_dp*cx_j*xhat) &
812 >               * (3.0d0*f1 + f3) )
813 >          dudux_j(2) = dudux_j(2) + sw*pref*ri3*( (qxx_j*2.0_dp*cx_j*yhat) &
814 >               * (3.0d0*f1 + f3) )
815 >          dudux_j(3) = dudux_j(3) + sw*pref*ri3*( (qxx_j*2.0_dp*cx_j*zhat) &
816 >               * (3.0d0*f1 + f3) )
817            
818 <          duduz_j(1) = duduz_j(1) + sw*pref * ri3*(qzz_j*6.0_dp*cz_j*xhat)
819 <          duduz_j(2) = duduz_j(2) + sw*pref * ri3*(qzz_j*6.0_dp*cz_j*yhat)
820 <          duduz_j(3) = duduz_j(3) + sw*pref * ri3*(qzz_j*6.0_dp*cz_j*zhat)
818 >          duduy_j(1) = duduy_j(1) + sw*pref*ri3*( (qyy_j*2.0_dp*cy_j*xhat) &
819 >               * (3.0d0*f1 + f3) )
820 >          duduy_j(2) = duduy_j(2) + sw*pref*ri3*( (qyy_j*2.0_dp*cy_j*yhat) &
821 >               * (3.0d0*f1 + f3) )
822 >          duduy_j(3) = duduy_j(3) + sw*pref*ri3*( (qyy_j*2.0_dp*cy_j*zhat) &
823 >               * (3.0d0*f1 + f3) )
824            
825 +          duduz_j(1) = duduz_j(1) + sw*pref*ri3*( (qzz_j*2.0_dp*cz_j*xhat) &
826 +               * (3.0d0*f1 + f3) )
827 +          duduz_j(2) = duduz_j(2) + sw*pref*ri3*( (qzz_j*2.0_dp*cz_j*yhat) &
828 +               * (3.0d0*f1 + f3) )
829 +          duduz_j(3) = duduz_j(3) + sw*pref*ri3*( (qzz_j*2.0_dp*cz_j*zhat) &
830 +               * (3.0d0*f1 + f3) )
831 +          
832         endif
833      endif
834      
835      if (i_is_Dipole) then
836  
837         if (j_is_Charge) then
838 +          if (screeningMethod .eq. DAMPED) then
839 +             f0 = derfc(dampingAlpha*rij)
840 +             varEXP = exp(-alpha2*rij*rij)
841 +             f1 = alphaPi*rij*varEXP + f0
842 +             f3 = alphaPi*2.0d0*alpha2*varEXP*rij*rij*rij
843 +          endif
844            
845            pref = pre12 * q_j * mu_i
846            
# Line 799 | Line 848 | contains
848               ri2 = riji * riji
849               ri3 = ri2 * riji
850              
851 <             pot_term = ri2 - rcuti2
851 >             pot_term = ri2*f1 - rcuti2*f1c
852               vterm = pref * ct_i * pot_term
853               vpair = vpair + vterm
854               epot = epot + sw*vterm
855              
856 <             dudx = dudx + sw*pref * ( ri3*(uz_i(1)-3.0d0*ct_i*xhat) )
857 <             dudy = dudy + sw*pref * ( ri3*(uz_i(2)-3.0d0*ct_i*yhat) )
858 <             dudz = dudz + sw*pref * ( ri3*(uz_i(3)-3.0d0*ct_i*zhat) )
856 >             dudx = dudx + sw*pref*( ri3*(uz_i(1)*f1-ct_i*xhat*(3.0d0*f1+f3)) )
857 >             dudy = dudy + sw*pref*( ri3*(uz_i(2)*f1-ct_i*yhat*(3.0d0*f1+f3)) )
858 >             dudz = dudz + sw*pref*( ri3*(uz_i(3)*f1-ct_i*zhat*(3.0d0*f1+f3)) )
859              
860               duduz_i(1) = duduz_i(1) + sw*pref * xhat * pot_term
861               duduz_i(2) = duduz_i(2) + sw*pref * yhat * pot_term
# Line 816 | Line 865 | contains
865               ri2 = riji * riji
866               ri3 = ri2 * riji
867  
868 <             pot_term = ri2 - rcuti2 + 2.0d0*rcuti3*( rij - defaultCutoff )
868 >             !! might need a -(f1c-f0c) or dct_i/dr in the derivative term...
869 >             pot_term = ri2*f1 - rcuti2*f1c + &
870 >                  (2.0d0*rcuti3*f1c + f2c)*( rij - defaultCutoff )
871               vterm = pref * ct_i * pot_term
872               vpair = vpair + vterm
873               epot = epot + sw*vterm
874              
875 <             dudx = dudx + sw*pref * ( (ri3-rcuti3)*(uz_i(1)-3.0d0*ct_i*xhat) )
876 <             dudy = dudy + sw*pref * ( (ri3-rcuti3)*(uz_i(2)-3.0d0*ct_i*yhat) )
877 <             dudz = dudz + sw*pref * ( (ri3-rcuti3)*(uz_i(3)-3.0d0*ct_i*zhat) )
875 >             dudx = dudx + sw*pref*( ri3*(uz_i(1)*f1-ct_i*xhat*(3.0d0*f1+f3)) &
876 >                  - rcuti3*(uz_i(1)*f1c-ct_i*xhat*(3.0d0*f1c+f3c)) )
877 >             dudy = dudy + sw*pref*( ri3*(uz_i(2)*f1-ct_i*yhat*(3.0d0*f1+f3)) &
878 >                  - rcuti3*(uz_i(1)*f1c-ct_i*xhat*(3.0d0*f1c+f3c)) )
879 >             dudz = dudz + sw*pref*( ri3*(uz_i(3)*f1-ct_i*zhat*(3.0d0*f1+f3)) &
880 >                  - rcuti3*(uz_i(1)*f1c-ct_i*xhat*(3.0d0*f1c+f3c)) )
881              
882               duduz_i(1) = duduz_i(1) + sw*pref * xhat * pot_term
883               duduz_i(2) = duduz_i(2) + sw*pref * yhat * pot_term
884               duduz_i(3) = duduz_i(3) + sw*pref * zhat * pot_term
885 <
885 >
886            elseif (summationMethod .eq. REACTION_FIELD) then
887               ri2 = riji * riji
888               ri3 = ri2 * riji
# Line 862 | Line 916 | contains
916               ri3 = ri2 * ri
917               sc2 = scale * scale
918  
919 <             vterm = pref * ct_i * ri2 * scale
919 >             pot_term = ri2 * f1 * scale
920 >             vterm = pref * ct_i * pot_term
921               vpair = vpair + vterm
922               epot = epot + sw*vterm
923              
924 <             dudx = dudx + sw*pref * ri3 * ( uz_i(1) - 3.0d0 * ct_i * xhat*sc2)
925 <             dudy = dudy + sw*pref * ri3 * ( uz_i(2) - 3.0d0 * ct_i * yhat*sc2)
926 <             dudz = dudz + sw*pref * ri3 * ( uz_i(3) - 3.0d0 * ct_i * zhat*sc2)
924 >             dudx = dudx + sw*pref * ri3 * ( uz_i(1)*f1 - &
925 >                  ct_i*xhat*sc2*( 3.0d0*f1 + f3 ) )
926 >             dudy = dudy + sw*pref * ri3 * ( uz_i(2)*f1 - &
927 >                  ct_i*yhat*sc2*( 3.0d0*f1 + f3 ) )
928 >             dudz = dudz + sw*pref * ri3 * ( uz_i(3)*f1 - &
929 >                  ct_i*zhat*sc2*( 3.0d0*f1 + f3 ) )
930              
931 <             duduz_i(1) = duduz_i(1) + sw*pref * ri2 * xhat * scale
932 <             duduz_i(2) = duduz_i(2) + sw*pref * ri2 * yhat * scale
933 <             duduz_i(3) = duduz_i(3) + sw*pref * ri2 * zhat * scale
931 >             duduz_i(1) = duduz_i(1) + sw*pref * pot_term * xhat
932 >             duduz_i(2) = duduz_i(2) + sw*pref * pot_term * yhat
933 >             duduz_i(3) = duduz_i(3) + sw*pref * pot_term * zhat
934            endif
935         endif
936        
937         if (j_is_Dipole) then
938 +          if (screeningMethod .eq. DAMPED) then
939 +             f0 = derfc(dampingAlpha*rij)
940 +             varEXP = exp(-alpha2*rij*rij)
941 +             f1 = alphaPi*rij*varEXP + f0
942 +             f2 = alphaPi*2.0d0*alpha2*varEXP
943 +             f3 = f2*rij*rij*rij
944 +             f4 = 2.0d0*alpha2*f3*rij*rij
945 +          endif
946 +
947            ct_ij = uz_i(1)*uz_j(1) + uz_i(2)*uz_j(2) + uz_i(3)*uz_j(3)
948            
949            ri2 = riji * riji
# Line 935 | Line 1002 | contains
1002              
1003               sc2 = scale * scale
1004  
1005 <             vterm = pref * ri3 * (ct_ij - 3.0d0 * ct_i * ct_j * sc2)
1005 >             pot_term = (ct_ij - 3.0d0 * ct_i * ct_j * sc2)
1006 >             vterm = pref * ( ri3*pot_term*f1 + (ct_i * ct_j)*f2 )
1007               vpair = vpair + vterm
1008               epot = epot + sw*vterm
1009              
1010 <             a1 = 5.0d0 * ct_i * ct_j * sc2 - ct_ij
1010 >             f13 = f1+f3
1011 >             f134 = f13 + f4
1012              
1013 <             dudx = dudx + sw*pref*3.0d0*ri4*scale &
1014 <                             *(a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1))
1015 <             dudy = dudy + sw*pref*3.0d0*ri4*scale &
1016 <                             *(a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2))
1017 <             dudz = dudz + sw*pref*3.0d0*ri4*scale &
1018 <                             *(a1*zhat-ct_i*uz_j(3)-ct_j*uz_i(3))
1013 > !!$             dudx = dudx + sw*pref * ( ri4*scale*( &
1014 > !!$                  3.0d0*(a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1))*f1 &
1015 > !!$                  - pot_term*f3) &
1016 > !!$                  + 2.0d0*ct_i*ct_j*xhat*(ct_i*uz_j(1)+ct_j*uz_i(1))*f3 &
1017 > !!$                  + (ct_i * ct_j)*f4 )
1018 > !!$             dudy = dudy + sw*pref * ( ri4*scale*( &
1019 > !!$                  3.0d0*(a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2))*f1 &
1020 > !!$                  - pot_term*f3) &
1021 > !!$                  + 2.0d0*ct_i*ct_j*yhat*(ct_i*uz_j(2)+ct_j*uz_i(2))*f3 &
1022 > !!$                  + (ct_i * ct_j)*f4 )
1023 > !!$             dudz = dudz + sw*pref * ( ri4*scale*( &
1024 > !!$                  3.0d0*(a1*zhat-ct_i*uz_j(3)-ct_j*uz_i(3))*f1 &
1025 > !!$                  - pot_term*f3) &
1026 > !!$                  + 2.0d0*ct_i*ct_j*zhat*(ct_i*uz_j(3)+ct_j*uz_i(3))*f3 &
1027 > !!$                  + (ct_i * ct_j)*f4 )
1028 >
1029 >             dudx = dudx + sw*pref * ( ri4*scale*( &
1030 >                  15.0d0*(ct_i * ct_j * sc2)*xhat*f134 - &
1031 >                  3.0d0*(ct_i*uz_j(1) + ct_j*uz_i(1) + ct_ij*xhat)*f134) )
1032 >             dudy = dudy + sw*pref * ( ri4*scale*( &
1033 >                  15.0d0*(ct_i * ct_j * sc2)*yhat*f134 - &
1034 >                  3.0d0*(ct_i*uz_j(2) + ct_j*uz_i(2) + ct_ij*yhat)*f134) )
1035 >             dudz = dudz + sw*pref * ( ri4*scale*( &
1036 >                  15.0d0*(ct_i * ct_j * sc2)*zhat*f134 - &
1037 >                  3.0d0*(ct_i*uz_j(3) + ct_j*uz_i(3) + ct_ij*zhat)*f134) )
1038              
1039 <             duduz_i(1) = duduz_i(1) + sw*pref*ri3 &
1040 <                                         *(uz_j(1) - 3.0d0*ct_j*xhat*sc2)
1041 <             duduz_i(2) = duduz_i(2) + sw*pref*ri3 &
1042 <                                         *(uz_j(2) - 3.0d0*ct_j*yhat*sc2)
1043 <             duduz_i(3) = duduz_i(3) + sw*pref*ri3 &
1044 <                                         *(uz_j(3) - 3.0d0*ct_j*zhat*sc2)
1039 >             duduz_i(1) = duduz_i(1) + sw*pref * &
1040 >                  ( ri3*(uz_j(1) - 3.0d0*ct_j*xhat*sc2)*f1 + (ct_j*xhat)*f2 )
1041 >             duduz_i(2) = duduz_i(2) + sw*pref * &
1042 >                  ( ri3*(uz_j(2) - 3.0d0*ct_j*yhat*sc2)*f1 + (ct_j*yhat)*f2 )
1043 >             duduz_i(3) = duduz_i(3) + sw*pref * &
1044 >                  ( ri3*(uz_j(3) - 3.0d0*ct_j*zhat*sc2)*f1 + (ct_j*zhat)*f2 )
1045              
1046 <             duduz_j(1) = duduz_j(1) + sw*pref*ri3 &
1047 <                                         *(uz_i(1) - 3.0d0*ct_i*xhat*sc2)
1048 <             duduz_j(2) = duduz_j(2) + sw*pref*ri3 &
1049 <                                         *(uz_i(2) - 3.0d0*ct_i*yhat*sc2)
1050 <             duduz_j(3) = duduz_j(3) + sw*pref*ri3 &
1051 <                                         *(uz_i(3) - 3.0d0*ct_i*zhat*sc2)
1046 >             duduz_j(1) = duduz_j(1) + sw*pref * &
1047 >                  ( ri3*(uz_i(1) - 3.0d0*ct_i*xhat*sc2)*f1 + (ct_i*xhat)*f2 )
1048 >             duduz_j(2) = duduz_j(2) + sw*pref * &
1049 >                  ( ri3*(uz_i(2) - 3.0d0*ct_i*yhat*sc2)*f1 + (ct_i*yhat)*f2 )
1050 >             duduz_j(3) = duduz_j(3) + sw*pref * &
1051 >                  ( ri3*(uz_i(3) - 3.0d0*ct_i*zhat*sc2)*f1 + (ct_i*zhat)*f2 )
1052            endif
1053         endif
1054      endif
1055  
1056      if (i_is_Quadrupole) then
1057         if (j_is_Charge) then
1058 +          if (screeningMethod .eq. DAMPED) then
1059 +             f0 = derfc(dampingAlpha*rij)
1060 +             varEXP = exp(-alpha2*rij*rij)
1061 +             f1 = alphaPi*rij*varEXP + f0
1062 +             f2 = alphaPi*2.0d0*alpha2*varEXP
1063 +             f3 = f2*rij*rij*rij
1064 +             f4 = 2.0d0*alpha2*f2*rij
1065 +          endif
1066 +
1067            ri2 = riji * riji
1068            ri3 = ri2 * riji
1069            ri4 = ri2 * ri2
# Line 975 | Line 1072 | contains
1072            cz2 = cz_i * cz_i
1073  
1074            pref = pre14 * q_j / 3.0_dp
1075 <          vterm = pref * ri3 * (qxx_i * (3.0_dp*cx2 - 1.0_dp) + &
1076 <               qyy_i * (3.0_dp*cy2 - 1.0_dp) + &
1077 <               qzz_i * (3.0_dp*cz2 - 1.0_dp))
1075 >          pot_term = ri3 * (qxx_i * (3.0_dp*cx2 - 1.0_dp) + &
1076 >                            qyy_i * (3.0_dp*cy2 - 1.0_dp) + &
1077 >                            qzz_i * (3.0_dp*cz2 - 1.0_dp))
1078 >          vterm = pref * (pot_term*f1 + (qxx_i*cx2 + qyy_i*cy2 + qzz_i*cz2)*f2)
1079            vpair = vpair + vterm
1080            epot = epot + sw*vterm
1081            
1082 <          dudx = dudx - 5.0_dp*sw*vterm*riji*xhat + sw*pref*ri4 * ( &
1083 <               qxx_i*(6.0_dp*cx_i*ux_i(1) - 2.0_dp*xhat) + &
1084 <               qyy_i*(6.0_dp*cy_i*uy_i(1) - 2.0_dp*xhat) + &
1085 <               qzz_i*(6.0_dp*cz_i*uz_i(1) - 2.0_dp*xhat) )
1086 <          dudy = dudy - 5.0_dp*sw*vterm*riji*yhat + sw*pref*ri4 * ( &
1087 <               qxx_i*(6.0_dp*cx_i*ux_i(2) - 2.0_dp*yhat) + &
1088 <               qyy_i*(6.0_dp*cy_i*uy_i(2) - 2.0_dp*yhat) + &
1089 <               qzz_i*(6.0_dp*cz_i*uz_i(2) - 2.0_dp*yhat) )
1090 <          dudz = dudz - 5.0_dp*sw*vterm*riji*zhat + sw*pref*ri4 * ( &
1091 <               qxx_i*(6.0_dp*cx_i*ux_i(3) - 2.0_dp*zhat) + &
1092 <               qyy_i*(6.0_dp*cy_i*uy_i(3) - 2.0_dp*zhat) + &
1093 <               qzz_i*(6.0_dp*cz_i*uz_i(3) - 2.0_dp*zhat) )
1094 <          
1095 <          dudux_i(1) = dudux_i(1) + sw*pref*ri3*(qxx_i*6.0_dp*cx_i*xhat)
1096 <          dudux_i(2) = dudux_i(2) + sw*pref*ri3*(qxx_i*6.0_dp*cx_i*yhat)
1097 <          dudux_i(3) = dudux_i(3) + sw*pref*ri3*(qxx_i*6.0_dp*cx_i*zhat)
1098 <          
1099 <          duduy_i(1) = duduy_i(1) + sw*pref*ri3*(qyy_i*6.0_dp*cy_i*xhat)
1002 <          duduy_i(2) = duduy_i(2) + sw*pref*ri3*(qyy_i*6.0_dp*cy_i*yhat)
1003 <          duduy_i(3) = duduy_i(3) + sw*pref*ri3*(qyy_i*6.0_dp*cy_i*zhat)
1082 >          dudx = dudx - sw*pref*pot_term*riji*xhat*(5.0d0*f1 + f3) + &
1083 >               sw*pref*ri4 * ( &
1084 >               qxx_i*(2.0_dp*cx_i*ux_i(1)*(3.0d0*f1 + f3) - 2.0_dp*xhat*f1) + &
1085 >               qyy_i*(2.0_dp*cy_i*uy_i(1)*(3.0d0*f1 + f3) - 2.0_dp*xhat*f1) + &
1086 >               qzz_i*(2.0_dp*cz_i*uz_i(1)*(3.0d0*f1 + f3) - 2.0_dp*xhat*f1) ) &
1087 >               + (qxx_i*cx2 + qyy_i*cy2 + qzz_i*cz2)*f4
1088 >          dudy = dudy - sw*pref*pot_term*riji*yhat*(5.0d0*f1 + f3) + &
1089 >               sw*pref*ri4 * ( &
1090 >               qxx_i*(2.0_dp*cx_i*ux_i(2)*(3.0d0*f1 + f3) - 2.0_dp*yhat*f1) + &
1091 >               qyy_i*(2.0_dp*cy_i*uy_i(2)*(3.0d0*f1 + f3) - 2.0_dp*yhat*f1) + &
1092 >               qzz_i*(2.0_dp*cz_i*uz_i(2)*(3.0d0*f1 + f3) - 2.0_dp*yhat*f1) ) &
1093 >               + (qxx_i*cx2 + qyy_i*cy2 + qzz_i*cz2)*f4
1094 >          dudz = dudz - sw*pref*pot_term*riji*zhat*(5.0d0*f1 + f3) + &
1095 >               sw*pref*ri4 * ( &
1096 >               qxx_i*(2.0_dp*cx_i*ux_i(3)*(3.0d0*f1 + f3) - 2.0_dp*zhat*f1) + &
1097 >               qyy_i*(2.0_dp*cy_i*uy_i(3)*(3.0d0*f1 + f3) - 2.0_dp*zhat*f1) + &
1098 >               qzz_i*(2.0_dp*cz_i*uz_i(3)*(3.0d0*f1 + f3) - 2.0_dp*zhat*f1) ) &
1099 >               + (qxx_i*cx2 + qyy_i*cy2 + qzz_i*cz2)*f4
1100            
1101 <          duduz_i(1) = duduz_i(1) + sw*pref*ri3*(qzz_i*6.0_dp*cz_i*xhat)
1102 <          duduz_i(2) = duduz_i(2) + sw*pref*ri3*(qzz_i*6.0_dp*cz_i*yhat)
1103 <          duduz_i(3) = duduz_i(3) + sw*pref*ri3*(qzz_i*6.0_dp*cz_i*zhat)
1101 >          dudux_i(1) = dudux_i(1) + sw*pref*( ri3*(qxx_i*2.0_dp*cx_i*xhat) &
1102 >               * (3.0d0*f1 + f3) )
1103 >          dudux_i(2) = dudux_i(2) + sw*pref*( ri3*(qxx_i*2.0_dp*cx_i*yhat) &
1104 >               * (3.0d0*f1 + f3) )
1105 >          dudux_i(3) = dudux_i(3) + sw*pref*( ri3*(qxx_i*2.0_dp*cx_i*zhat) &
1106 >               * (3.0d0*f1 + f3) )
1107 >          
1108 >          duduy_i(1) = duduy_i(1) + sw*pref*( ri3*(qyy_i*2.0_dp*cy_i*xhat) &
1109 >               * (3.0d0*f1 + f3) )
1110 >          duduy_i(2) = duduy_i(2) + sw*pref*( ri3*(qyy_i*2.0_dp*cy_i*yhat) &
1111 >               * (3.0d0*f1 + f3) )
1112 >          duduy_i(3) = duduy_i(3) + sw*pref*( ri3*(qyy_i*2.0_dp*cy_i*zhat) &
1113 >               * (3.0d0*f1 + f3) )
1114 >          
1115 >          duduz_i(1) = duduz_i(1) + sw*pref*( ri3*(qzz_i*2.0_dp*cz_i*xhat) &
1116 >               * (3.0d0*f1 + f3) )
1117 >          duduz_i(2) = duduz_i(2) + sw*pref*( ri3*(qzz_i*2.0_dp*cz_i*yhat) &
1118 >               * (3.0d0*f1 + f3) )
1119 >          duduz_i(3) = duduz_i(3) + sw*pref*( ri3*(qzz_i*2.0_dp*cz_i*zhat) &
1120 >               * (3.0d0*f1 + f3) )
1121  
1122         endif
1123      endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines