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 2399 by chrisfen, Wed Oct 26 23:31:40 2005 UTC vs.
Revision 2402 by chrisfen, Tue Nov 1 19:09:30 2005 UTC

# Line 86 | Line 86 | module electrostatic_module
86    logical, save :: haveDielectric = .false.
87    real(kind=DP), save :: constERFC = 0.0_DP
88    real(kind=DP), save :: constEXP = 0.0_DP
89  logical, save :: haveDWAconstants = .false.
89    real(kind=dp), save :: rcuti = 0.0_DP
90    real(kind=dp), save :: rcuti2 = 0.0_DP
91    real(kind=dp), save :: rcuti3 = 0.0_DP
# Line 98 | Line 97 | module electrostatic_module
97    real(kind=dp), save :: rrfsq = 1.0_DP
98    real(kind=dp), save :: preRF = 0.0_DP
99    real(kind=dp), save :: preRF2 = 0.0_DP
101  logical, save :: preRFCalculated = .false.
100  
101   #ifdef __IFC
102   ! error function for ifc version > 7.
# Line 109 | Line 107 | module electrostatic_module
107    public :: setElectrostaticCutoffRadius
108    public :: setDampedWolfAlpha
109    public :: setReactionFieldDielectric
112  public :: setReactionFieldPrefactor
110    public :: newElectrostaticType
111    public :: setCharge
112    public :: setDipoleMoment
# Line 119 | Line 116 | module electrostatic_module
116    public :: getCharge
117    public :: getDipoleMoment
118    public :: destroyElectrostaticTypes
119 <  public :: rf_self_self
119 >  public :: self_self
120    public :: rf_self_excludes
121  
122    type :: Electrostatic
# Line 170 | Line 167 | contains
167      dielectric = thisDielectric
168      haveDielectric = .true.
169    end subroutine setReactionFieldDielectric
173
174  subroutine setReactionFieldPrefactor
175    if (haveDefaultCutoff .and. haveDielectric) then
176       defaultCutoff2 = defaultCutoff*defaultCutoff
177       preRF = (dielectric-1.0d0) / &
178            ((2.0d0*dielectric+1.0d0)*defaultCutoff2*defaultCutoff)
179       preRF2 = 2.0d0*preRF
180       preRFCalculated = .true.
181    else if (.not.haveDefaultCutoff) then
182       call handleError("setReactionFieldPrefactor", "Default cutoff not set")
183    else
184       call handleError("setReactionFieldPrefactor", "Dielectric not set")
185    endif
186  end subroutine setReactionFieldPrefactor
170  
171    subroutine newElectrostaticType(c_ident, is_Charge, is_Dipole, &
172         is_SplitDipole, is_Quadrupole, is_Tap, status)
# Line 407 | Line 390 | contains
390      rcuti4 = rcuti2*rcuti2
391  
392      if (summationMethod .eq. DAMPED_WOLF) then
393 <       if (.not.haveDWAconstants) then
394 <          
412 <          if (.not.haveDampingAlpha) then
413 <             call handleError("checkSummationMethod", "no Damping Alpha set!")
414 <          endif
415 <          
416 <          if (.not.haveDefaultCutoff) then
417 <             call handleError("checkSummationMethod", "no Default Cutoff set!")
418 <          endif
419 <
420 <          constEXP = exp(-dampingAlpha*dampingAlpha*defaultCutoff*defaultCutoff)
421 <          constERFC = derfc(dampingAlpha*defaultCutoff)
422 <          invRootPi = 0.56418958354775628695d0
423 <          alphaPi = 2*dampingAlpha*invRootPi
424 <  
425 <          haveDWAconstants = .true.
393 >       if (.not.haveDampingAlpha) then
394 >          call handleError("checkSummationMethod", "no Damping Alpha set!")
395         endif
396 +      
397 +       if (.not.haveDefaultCutoff) then
398 +          call handleError("checkSummationMethod", "no Default Cutoff set!")
399 +       endif
400 +
401 +       constEXP = exp(-dampingAlpha*dampingAlpha*defaultCutoff*defaultCutoff)
402 +       constERFC = derfc(dampingAlpha*defaultCutoff)
403 +       invRootPi = 0.56418958354775628695d0
404 +       alphaPi = 2*dampingAlpha*invRootPi
405 +      
406      endif
407  
408      if (summationMethod .eq. REACTION_FIELD) then
409 <       if (.not.haveDielectric) then
410 <          call handleError("checkSummationMethod", "no reaction field Dielectric set!")
409 >       if (haveDielectric) then
410 >          defaultCutoff2 = defaultCutoff*defaultCutoff
411 >          preRF = (dielectric-1.0d0) / &
412 >               ((2.0d0*dielectric+1.0d0)*defaultCutoff2*defaultCutoff)
413 >          preRF2 = 2.0d0*preRF
414 >       else
415 >          call handleError("checkSummationMethod", "Dielectric not set")
416         endif
417 +      
418      endif
419  
420      summationMethodChecked = .true.
421    end subroutine checkSummationMethod
422  
423 <
424 <
423 > !!$
424 > !!$  subroutine doElectrostaticPair(atom1, atom2, d, rij, r2, sw, &
425 > !!$       vpair, fpair, pot, eFrame, f, t, do_pot)
426    subroutine doElectrostaticPair(atom1, atom2, d, rij, r2, sw, &
427 <       vpair, fpair, pot, eFrame, f, t, do_pot, indirect_only)
427 >       vpair, fpair, pot, eFrame, f, t, do_pot, felec)
428  
429 <    logical, intent(in) :: do_pot, indirect_only
429 >    logical, intent(in) :: do_pot
430  
431      integer, intent(in) :: atom1, atom2
432      integer :: localError
# Line 448 | Line 434 | contains
434      real(kind=dp), intent(in) :: rij, r2, sw
435      real(kind=dp), intent(in), dimension(3) :: d
436      real(kind=dp), intent(inout) :: vpair
437 <    real(kind=dp), intent(inout), dimension(3) :: fpair
437 >    real(kind=dp), intent(inout), dimension(3) :: fpair    
438 >    real(kind=dp), intent(inout), dimension(3) :: felec
439  
440      real( kind = dp ) :: pot
441      real( kind = dp ), dimension(9,nLocal) :: eFrame
# Line 489 | Line 476 | contains
476         call checkSummationMethod()
477      endif
478  
492    if (.not.preRFCalculated) then
493       call setReactionFieldPrefactor()
494    endif
495
479   #ifdef IS_MPI
480      me1 = atid_Row(atom1)
481      me2 = atid_Col(atom2)
# Line 649 | Line 632 | contains
632               vpair = vpair + vterm
633               epot = epot + sw*vterm
634              
635 <             dudr  = -sw*pre11*q_i*q_j * (riji*riji-rcuti2)*riji
635 >             dudr  = -sw*pre11*q_i*q_j * (riji*riji-rcuti2)
636              
637 <             dudx = dudx + dudr * d(1)
638 <             dudy = dudy + dudr * d(2)
639 <             dudz = dudz + dudr * d(3)
637 >             dudx = dudx + dudr * xhat
638 >             dudy = dudy + dudr * yhat
639 >             dudz = dudz + dudr * zhat
640  
641            elseif (summationMethod .eq. DAMPED_WOLF) then
642               varERFC = derfc(dampingAlpha*rij)
# Line 662 | Line 645 | contains
645               vpair = vpair + vterm
646               epot = epot + sw*vterm
647              
648 <             dudr  = -sw*pre11*q_i*q_j * ( riji*((varERFC*riji*riji &
649 <                                                  + alphaPi*varEXP) &
650 <                                                 - (constERFC*rcuti2 &
668 <                                                    + alphaPi*constEXP)) )
648 >             dudr  = -sw*pre11*q_i*q_j * (((varERFC*riji*riji &
649 >                  + alphaPi*varEXP*riji) - (constERFC*rcuti2 &
650 >                  + alphaPi*constEXP*rcuti)) )
651              
652 <             dudx = dudx + dudr * d(1)
653 <             dudy = dudy + dudr * d(2)
654 <             dudz = dudz + dudr * d(3)
652 >             dudx = dudx + dudr * xhat
653 >             dudy = dudy + dudr * yhat
654 >             dudz = dudz + dudr * zhat
655  
656            elseif (summationMethod .eq. REACTION_FIELD) then
657               preVal = pre11 * q_i * q_j
# Line 965 | Line 947 | contains
947         if (j_is_Dipole) then
948  
949            if (summationMethod .eq. UNDAMPED_WOLF) then
950 + !!$             ct_ij = uz_i(1)*uz_j(1) + uz_i(2)*uz_j(2) + uz_i(3)*uz_j(3)
951 + !!$
952 + !!$             ri2 = riji * riji
953 + !!$             ri3 = ri2 * riji
954 + !!$             ri4 = ri2 * ri2
955 + !!$
956 + !!$             pref = pre22 * mu_i * mu_j
957 + !!$             vterm = pref * (ri3 - rcuti3) * (ct_ij - 3.0d0 * ct_i * ct_j)
958 + !!$             vpair = vpair + vterm
959 + !!$             epot = epot + sw*vterm
960 + !!$            
961 + !!$             a1 = 5.0d0 * ct_i * ct_j - ct_ij
962 + !!$            
963 + !!$             dudx = dudx + sw*pref*3.0d0*( &
964 + !!$                  ri4*(a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1)) &
965 + !!$                  - rcuti4*(a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1)) )
966 + !!$             dudy = dudy + sw*pref*3.0d0*( &
967 + !!$                  ri4*(a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2)) &
968 + !!$                  - rcuti4*(a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2)) )
969 + !!$             dudz = dudz + sw*pref*3.0d0*( &
970 + !!$                  ri4*(a1*zhat-ct_i*uz_j(3)-ct_j*uz_i(3)) &
971 + !!$                  - rcuti4*(a1*zhat-ct_i*uz_j(3)-ct_j*uz_i(3)) )
972 + !!$            
973 + !!$             duduz_i(1) = duduz_i(1) + sw*pref*(ri3*(uz_j(1)-3.0d0*ct_j*xhat) &
974 + !!$                  - rcuti3*(uz_j(1) - 3.0d0*ct_j*xhat))
975 + !!$             duduz_i(2) = duduz_i(2) + sw*pref*(ri3*(uz_j(2)-3.0d0*ct_j*yhat) &
976 + !!$                  - rcuti3*(uz_j(2) - 3.0d0*ct_j*yhat))
977 + !!$             duduz_i(3) = duduz_i(3) + sw*pref*(ri3*(uz_j(3)-3.0d0*ct_j*zhat) &
978 + !!$                  - rcuti3*(uz_j(3) - 3.0d0*ct_j*zhat))
979 + !!$             duduz_j(1) = duduz_j(1) + sw*pref*(ri3*(uz_i(1)-3.0d0*ct_i*xhat) &
980 + !!$                  - rcuti3*(uz_i(1) - 3.0d0*ct_i*xhat))
981 + !!$             duduz_j(2) = duduz_j(2) + sw*pref*(ri3*(uz_i(2)-3.0d0*ct_i*yhat) &
982 + !!$                  - rcuti3*(uz_i(2) - 3.0d0*ct_i*yhat))
983 + !!$             duduz_j(3) = duduz_j(3) + sw*pref*(ri3*(uz_i(3)-3.0d0*ct_i*zhat) &
984 + !!$                  - rcuti3*(uz_i(3) - 3.0d0*ct_i*zhat))
985 +          
986 +          elseif (summationMethod .eq. DAMPED_WOLF) then
987 +             ct_ij = uz_i(1)*uz_j(1) + uz_i(2)*uz_j(2) + uz_i(3)*uz_j(3)
988 +            
989               ri2 = riji * riji
990               ri3 = ri2 * riji
991               ri4 = ri2 * ri2
992 <
992 >             sc2 = scale * scale
993 >            
994               pref = pre22 * mu_i * mu_j
995 <             vterm = pref * (ri3 - rcuti3) * (ct_ij - 3.0d0 * ct_i * ct_j)
995 >             vterm = pref * ri3 * (ct_ij - 3.0d0 * ct_i * ct_j)
996               vpair = vpair + vterm
997               epot = epot + sw*vterm
998              
999 <             a1 = 5.0d0 * ct_i * ct_j - ct_ij
999 >             a1 = 5.0d0 * ct_i * ct_j * sc2 - ct_ij
1000              
1001 <             dudx = dudx + sw*pref*3.0d0*ri4 &
1002 <                             * (a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1)) &
1003 <                         - sw*pref*3.0d0*rcuti4 &
982 <                             * (a1*rcuti*d(1)-ct_i*uz_j(1)-ct_j*uz_i(1))
983 <             dudy = dudy + sw*pref*3.0d0*ri4 &
984 <                             * (a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2)) &
985 <                         - sw*pref*3.0d0*rcuti4 &
986 <                             * (a1*rcuti*d(2)-ct_i*uz_j(2)-ct_j*uz_i(2))
987 <             dudz = dudz + sw*pref*3.0d0*ri4 &
988 <                             * (a1*zhat-ct_i*uz_j(3)-ct_j*uz_i(3)) &
989 <                         - sw*pref*3.0d0*rcuti4 &
990 <                             * (a1*rcuti*d(3)-ct_i*uz_j(3)-ct_j*uz_i(3))
1001 >             dudx = dudx + sw*pref*3.0d0*ri4*(a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1))
1002 >             dudy = dudy + sw*pref*3.0d0*ri4*(a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2))
1003 >             dudz = dudz + sw*pref*3.0d0*ri4*(a1*zhat-ct_i*uz_j(3)-ct_j*uz_i(3))
1004              
1005 <             duduz_i(1) = duduz_i(1) + sw*pref*(ri3*(uz_j(1)-3.0d0*ct_j*xhat) &
1006 <                  - rcuti3*(uz_j(1) - 3.0d0*ct_j*d(1)*rcuti))
1007 <             duduz_i(2) = duduz_i(2) + sw*pref*(ri3*(uz_j(2)-3.0d0*ct_j*yhat) &
1008 <                  - rcuti3*(uz_j(2) - 3.0d0*ct_j*d(2)*rcuti))
1009 <             duduz_i(3) = duduz_i(3) + sw*pref*(ri3*(uz_j(3)-3.0d0*ct_j*zhat) &
1010 <                  - rcuti3*(uz_j(3) - 3.0d0*ct_j*d(3)*rcuti))
1011 <             duduz_j(1) = duduz_j(1) + sw*pref*(ri3*(uz_i(1)-3.0d0*ct_i*xhat) &
1012 <                  - rcuti3*(uz_i(1) - 3.0d0*ct_i*d(1)*rcuti))
1013 <             duduz_j(2) = duduz_j(2) + sw*pref*(ri3*(uz_i(2)-3.0d0*ct_i*yhat) &
1001 <                  - rcuti3*(uz_i(2) - 3.0d0*ct_i*d(2)*rcuti))
1002 <             duduz_j(3) = duduz_j(3) + sw*pref*(ri3*(uz_i(3)-3.0d0*ct_i*zhat) &
1003 <                  - rcuti3*(uz_i(3) - 3.0d0*ct_i*d(3)*rcuti))
1004 <
1005 <         elseif (summationMethod .eq. REACTION_FIELD) then
1005 >             duduz_i(1) = duduz_i(1) + sw*pref*ri3 *(uz_j(1) - 3.0d0*ct_j*xhat)
1006 >             duduz_i(2) = duduz_i(2) + sw*pref*ri3 *(uz_j(2) - 3.0d0*ct_j*yhat)
1007 >             duduz_i(3) = duduz_i(3) + sw*pref*ri3 *(uz_j(3) - 3.0d0*ct_j*zhat)
1008 >            
1009 >             duduz_j(1) = duduz_j(1) + sw*pref*ri3 *(uz_i(1) - 3.0d0*ct_i*xhat)
1010 >             duduz_j(2) = duduz_j(2) + sw*pref*ri3 *(uz_i(2) - 3.0d0*ct_i*yhat)
1011 >             duduz_j(3) = duduz_j(3) + sw*pref*ri3 *(uz_i(3) - 3.0d0*ct_i*zhat)
1012 >            
1013 >          elseif (summationMethod .eq. REACTION_FIELD) then
1014               ct_ij = uz_i(1)*uz_j(1) + uz_i(2)*uz_j(2) + uz_i(3)*uz_j(3)
1015  
1016               ri2 = riji * riji
# Line 1311 | Line 1319 | contains
1319  
1320    end subroutine destroyElectrostaticTypes
1321  
1322 <  subroutine rf_self_self(atom1, eFrame, rfpot, t, do_pot)
1322 >  subroutine self_self(atom1, eFrame, mypot, t, do_pot)
1323      logical, intent(in) :: do_pot
1324      integer, intent(in) :: atom1
1325      integer :: atid1
1326      real(kind=dp), dimension(9,nLocal) :: eFrame
1327      real(kind=dp), dimension(3,nLocal) :: t
1328 <    real(kind=dp) :: mu1
1329 <    real(kind=dp) :: preVal, epot, rfpot
1328 >    real(kind=dp) :: mu1, c1
1329 >    real(kind=dp) :: preVal, epot, mypot
1330      real(kind=dp) :: eix, eiy, eiz
1323
1324    if (.not.preRFCalculated) then
1325       call setReactionFieldPrefactor()
1326    endif
1331  
1332      ! this is a local only array, so we use the local atom type id's:
1333      atid1 = atid(atom1)
1334 +
1335 +    if (.not.summationMethodChecked) then
1336 +       call checkSummationMethod()
1337 +    endif
1338      
1339 <    if (ElectrostaticMap(atid1)%is_Dipole) then
1340 <       mu1 = getDipoleMoment(atid1)
1341 <      
1342 <       preVal = pre22 * preRF2 * mu1*mu1
1343 <       rfpot = rfpot - 0.5d0*preVal
1344 <      
1345 <       ! The self-correction term adds into the reaction field vector
1346 <      
1347 <       eix = preVal * eFrame(3,atom1)
1348 <       eiy = preVal * eFrame(6,atom1)
1349 <       eiz = preVal * eFrame(9,atom1)
1350 <      
1351 <       ! once again, this is self-self, so only the local arrays are needed
1352 <       ! even for MPI jobs:
1353 <      
1354 <       t(1,atom1)=t(1,atom1) - eFrame(6,atom1)*eiz + &
1355 <            eFrame(9,atom1)*eiy
1356 <       t(2,atom1)=t(2,atom1) - eFrame(9,atom1)*eix + &
1357 <            eFrame(3,atom1)*eiz
1358 <       t(3,atom1)=t(3,atom1) - eFrame(3,atom1)*eiy + &
1359 <            eFrame(6,atom1)*eix
1339 >    if (summationMethod .eq. REACTION_FIELD) then
1340 >       if (ElectrostaticMap(atid1)%is_Dipole) then
1341 >          mu1 = getDipoleMoment(atid1)
1342 >          
1343 >          preVal = pre22 * preRF2 * mu1*mu1
1344 >          mypot = mypot - 0.5d0*preVal
1345 >          
1346 >          ! The self-correction term adds into the reaction field vector
1347 >          
1348 >          eix = preVal * eFrame(3,atom1)
1349 >          eiy = preVal * eFrame(6,atom1)
1350 >          eiz = preVal * eFrame(9,atom1)
1351 >          
1352 >          ! once again, this is self-self, so only the local arrays are needed
1353 >          ! even for MPI jobs:
1354 >          
1355 >          t(1,atom1)=t(1,atom1) - eFrame(6,atom1)*eiz + &
1356 >               eFrame(9,atom1)*eiy
1357 >          t(2,atom1)=t(2,atom1) - eFrame(9,atom1)*eix + &
1358 >               eFrame(3,atom1)*eiz
1359 >          t(3,atom1)=t(3,atom1) - eFrame(3,atom1)*eiy + &
1360 >               eFrame(6,atom1)*eix
1361 >          
1362 >       endif
1363 >
1364 >    elseif (summationMethod .eq. UNDAMPED_WOLF) then
1365 >       if (ElectrostaticMap(atid1)%is_Charge) then
1366 >          c1 = getCharge(atid1)
1367 >          
1368 >          mypot = mypot - (rcuti * 0.5_dp * c1 * c1)
1369 >       endif
1370        
1371 +    elseif (summationMethod .eq. DAMPED_WOLF) then
1372 +       if (ElectrostaticMap(atid1)%is_Charge) then
1373 +          c1 = getCharge(atid1)
1374 +          
1375 +          mypot = mypot - (constERFC * rcuti * 0.5_dp + &
1376 +               dampingAlpha*invRootPi) * c1 * c1      
1377 +       endif
1378      endif
1379      
1380      return
1381 <  end subroutine rf_self_self
1381 >  end subroutine self_self
1382  
1383 <  subroutine rf_self_excludes(atom1, atom2, sw, eFrame, d, rij, vpair, rfpot, &
1383 >  subroutine rf_self_excludes(atom1, atom2, sw, eFrame, d, rij, vpair, myPot, &
1384         f, t, do_pot)
1385      logical, intent(in) :: do_pot
1386      integer, intent(in) :: atom1
# Line 1379 | Line 1404 | contains
1404      real(kind=dp) :: xhat, yhat, zhat
1405      real(kind=dp) :: ct_i, ct_j
1406      real(kind=dp) :: ri2, ri3, riji, vterm
1407 <    real(kind=dp) :: pref, preVal, rfVal, rfpot
1407 >    real(kind=dp) :: pref, preVal, rfVal, myPot
1408      real(kind=dp) :: dudx, dudy, dudz, dudr
1409  
1410 <    if (.not.preRFCalculated) then
1411 <       call setReactionFieldPrefactor()
1410 >    if (.not.summationMethodChecked) then
1411 >       call checkSummationMethod()
1412      endif
1413  
1414      dudx = 0.0d0
# Line 1411 | Line 1436 | contains
1436         preVal = pre11 * q_i * q_j
1437         rfVal = preRF*rij*rij
1438         vterm = preVal * rfVal
1414
1415       rfpot = rfpot + sw*vterm
1439        
1440 +       myPot = myPot + sw*vterm
1441 +      
1442         dudr  = sw*preVal * 2.0d0*rfVal*riji
1443 <              
1443 >      
1444         dudx = dudx + dudr * xhat
1445         dudy = dudy + dudr * yhat
1446         dudz = dudz + dudr * zhat
1447 <
1447 >      
1448      elseif (i_is_Charge.and.j_is_Dipole) then
1449         q_i = ElectrostaticMap(atid1)%charge
1450         mu_j = ElectrostaticMap(atid2)%dipole_moment
# Line 1427 | Line 1452 | contains
1452         uz_j(2) = eFrame(6,atom2)
1453         uz_j(3) = eFrame(9,atom2)
1454         ct_j = uz_j(1)*xhat + uz_j(2)*yhat + uz_j(3)*zhat
1455 <
1455 >      
1456         ri2 = riji * riji
1457         ri3 = ri2 * riji
1458        
1459         pref = pre12 * q_i * mu_j
1460         vterm = - pref * ct_j * ( ri2 - preRF2*rij )
1461 <       rfpot = rfpot + sw*vterm
1462 <
1463 <       dudx = dudx - sw*pref*( ri3*(uz_j(1)-3.0d0*ct_j*xhat) - preRF2*uz_j(1) )
1464 <       dudy = dudy - sw*pref*( ri3*(uz_j(2)-3.0d0*ct_j*yhat) - preRF2*uz_j(2) )
1465 <       dudz = dudz - sw*pref*( ri3*(uz_j(3)-3.0d0*ct_j*zhat) - preRF2*uz_j(3) )
1466 <
1461 >       myPot = myPot + sw*vterm
1462 >      
1463 >       dudx = dudx - sw*pref*( ri3*(uz_j(1)-3.0d0*ct_j*xhat) &
1464 >            - preRF2*uz_j(1) )
1465 >       dudy = dudy - sw*pref*( ri3*(uz_j(2)-3.0d0*ct_j*yhat) &
1466 >            - preRF2*uz_j(2) )
1467 >       dudz = dudz - sw*pref*( ri3*(uz_j(3)-3.0d0*ct_j*zhat) &
1468 >            - preRF2*uz_j(3) )
1469 >      
1470         duduz_j(1) = duduz_j(1) - sw * pref * xhat * ( ri2 - preRF2*rij )
1471         duduz_j(2) = duduz_j(2) - sw * pref * yhat * ( ri2 - preRF2*rij )
1472         duduz_j(3) = duduz_j(3) - sw * pref * zhat * ( ri2 - preRF2*rij )
1473 <              
1473 >      
1474      elseif (i_is_Dipole.and.j_is_Charge) then
1475         mu_i = ElectrostaticMap(atid1)%dipole_moment
1476         q_j = ElectrostaticMap(atid2)%charge
# Line 1450 | Line 1478 | contains
1478         uz_i(2) = eFrame(6,atom1)
1479         uz_i(3) = eFrame(9,atom1)
1480         ct_i = uz_i(1)*xhat + uz_i(2)*yhat + uz_i(3)*zhat
1481 <
1481 >      
1482         ri2 = riji * riji
1483         ri3 = ri2 * riji
1484        
1485         pref = pre12 * q_j * mu_i
1486         vterm = pref * ct_i * ( ri2 - preRF2*rij )
1487 <       rfpot = rfpot + sw*vterm
1487 >       myPot = myPot + sw*vterm
1488        
1489 <       dudx = dudx + sw*pref*( ri3*(uz_i(1)-3.0d0*ct_i*xhat) - preRF2*uz_i(1) )
1490 <       dudy = dudy + sw*pref*( ri3*(uz_i(2)-3.0d0*ct_i*yhat) - preRF2*uz_i(2) )
1491 <       dudz = dudz + sw*pref*( ri3*(uz_i(3)-3.0d0*ct_i*zhat) - preRF2*uz_i(3) )
1489 >       dudx = dudx + sw*pref*( ri3*(uz_i(1)-3.0d0*ct_i*xhat) &
1490 >            - preRF2*uz_i(1) )
1491 >       dudy = dudy + sw*pref*( ri3*(uz_i(2)-3.0d0*ct_i*yhat) &
1492 >            - preRF2*uz_i(2) )
1493 >       dudz = dudz + sw*pref*( ri3*(uz_i(3)-3.0d0*ct_i*zhat) &
1494 >            - preRF2*uz_i(3) )
1495        
1496         duduz_i(1) = duduz_i(1) + sw * pref * xhat * ( ri2 - preRF2*rij )
1497         duduz_i(2) = duduz_i(2) + sw * pref * yhat * ( ri2 - preRF2*rij )
1498         duduz_i(3) = duduz_i(3) + sw * pref * zhat * ( ri2 - preRF2*rij )
1499        
1500      endif
1501 <    
1502 <    ! accumulate the forces and torques resulting from the RF self term
1501 >      
1502 >
1503 >    ! accumulate the forces and torques resulting from the self term
1504      f(1,atom1) = f(1,atom1) + dudx
1505      f(2,atom1) = f(2,atom1) + dudy
1506      f(3,atom1) = f(3,atom1) + dudz

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines