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 2228 by gezelter, Fri Apr 15 22:04:00 2005 UTC vs.
Revision 2229 by chrisfen, Tue May 17 22:35:01 2005 UTC

# Line 85 | Line 85 | module electrostatic_module
85       logical :: is_Dipole = .false.
86       logical :: is_SplitDipole = .false.
87       logical :: is_Quadrupole = .false.
88 +     logical :: is_Tap = .false.
89       real(kind=DP) :: charge = 0.0_DP
90       real(kind=DP) :: dipole_moment = 0.0_DP
91       real(kind=DP) :: split_dipole_distance = 0.0_DP
# Line 96 | Line 97 | contains
97   contains
98  
99    subroutine newElectrostaticType(c_ident, is_Charge, is_Dipole, &
100 <       is_SplitDipole, is_Quadrupole, status)
100 >       is_SplitDipole, is_Quadrupole, is_Tap, status)
101  
102      integer, intent(in) :: c_ident
103      logical, intent(in) :: is_Charge
104      logical, intent(in) :: is_Dipole
105      logical, intent(in) :: is_SplitDipole
106      logical, intent(in) :: is_Quadrupole
107 +    logical, intent(in) :: is_Tap
108      integer, intent(out) :: status
109      integer :: nAtypes, myATID, i, j
110  
# Line 139 | Line 141 | contains
141      ElectrostaticMap(myATID)%is_Dipole = is_Dipole
142      ElectrostaticMap(myATID)%is_SplitDipole = is_SplitDipole
143      ElectrostaticMap(myATID)%is_Quadrupole = is_Quadrupole
144 +    ElectrostaticMap(myATID)%is_Tap = is_Tap
145  
146    end subroutine newElectrostaticType
147  
# Line 328 | Line 331 | contains
331  
332      logical :: i_is_Charge, i_is_Dipole, i_is_SplitDipole, i_is_Quadrupole
333      logical :: j_is_Charge, j_is_Dipole, j_is_SplitDipole, j_is_Quadrupole
334 +    logical :: i_is_Tap, j_is_Tap
335      integer :: me1, me2, id1, id2
336      real (kind=dp) :: q_i, q_j, mu_i, mu_j, d_i, d_j
337      real (kind=dp) :: qxx_i, qyy_i, qzz_i
# Line 340 | Line 344 | contains
344      real (kind=dp) :: pref, vterm, epot, dudr    
345      real (kind=dp) :: xhat, yhat, zhat
346      real (kind=dp) :: dudx, dudy, dudz
347 <    real (kind=dp) :: scale, sc2, bigR
347 >    real (kind=dp) :: scale, sc2, bigR, switcher, dswitcher
348  
349      if (.not.allocated(ElectrostaticMap)) then
350         call handleError("electrostatic", "no ElectrostaticMap was present before first call of do_electrostatic_pair!")
# Line 364 | Line 368 | contains
368      zhat = d(3) * riji
369  
370      !! logicals
367
371      i_is_Charge = ElectrostaticMap(me1)%is_Charge
372      i_is_Dipole = ElectrostaticMap(me1)%is_Dipole
373      i_is_SplitDipole = ElectrostaticMap(me1)%is_SplitDipole
374      i_is_Quadrupole = ElectrostaticMap(me1)%is_Quadrupole
375 +    i_is_Tap = ElectrostaticMap(me1)%is_Tap
376  
377      j_is_Charge = ElectrostaticMap(me2)%is_Charge
378      j_is_Dipole = ElectrostaticMap(me2)%is_Dipole
379      j_is_SplitDipole = ElectrostaticMap(me2)%is_SplitDipole
380      j_is_Quadrupole = ElectrostaticMap(me2)%is_Quadrupole
381 +    j_is_Tap = ElectrostaticMap(me2)%is_Tap
382  
383      if (i_is_Charge) then
384         q_i = ElectrostaticMap(me1)%charge      
# Line 428 | Line 433 | contains
433         cz_i = uz_i(1)*xhat + uz_i(2)*yhat + uz_i(3)*zhat
434      endif
435  
431
436      if (j_is_Charge) then
437         q_j = ElectrostaticMap(me2)%charge      
438      endif
# Line 480 | Line 484 | contains
484         cy_j = uy_j(1)*xhat + uy_j(2)*yhat + uy_j(3)*zhat
485         cz_j = uz_j(1)*xhat + uz_j(2)*yhat + uz_j(3)*zhat
486      endif
487 +    
488 +    switcher = 1.0d0
489 +    dswitcher = 0.0d0
490 + !    if (j_is_Tap .and. i_is_Tap) then
491 + !      call calc_switch(rij, mu_i, switcher, dswitcher)
492 + !    endif
493  
494      epot = 0.0_dp
495      dudx = 0.0_dp
# Line 654 | Line 664 | contains
664  
665            a1 = 5.0d0 * ct_i * ct_j * sc2 - ct_ij
666  
667 <          dudx=dudx+pref*sw*3.0d0*ri4*scale*(a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1))
668 <          dudy=dudy+pref*sw*3.0d0*ri4*scale*(a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2))
669 <          dudz=dudz+pref*sw*3.0d0*ri4*scale*(a1*zhat-ct_i*uz_j(3)-ct_j*uz_i(3))
667 >          dudx = dudx + switcher*pref*sw*3.0d0*ri4*scale &
668 >                         *(a1*xhat-ct_i*uz_j(1)-ct_j*uz_i(1)) + vterm*dswitcher
669 >          dudy = dudy + switcher*pref*sw*3.0d0*ri4*scale &
670 >                         *(a1*yhat-ct_i*uz_j(2)-ct_j*uz_i(2)) + vterm*dswitcher
671 >          dudz = dudz + switcher*pref*sw*3.0d0*ri4*scale &
672 >                         *(a1*zhat-ct_i*uz_j(3)-ct_j*uz_i(3)) + vterm*dswitcher
673  
674 <          duduz_i(1) = duduz_i(1) + pref*sw*ri3*(uz_j(1) - 3.0d0*ct_j*xhat*sc2)
675 <          duduz_i(2) = duduz_i(2) + pref*sw*ri3*(uz_j(2) - 3.0d0*ct_j*yhat*sc2)
676 <          duduz_i(3) = duduz_i(3) + pref*sw*ri3*(uz_j(3) - 3.0d0*ct_j*zhat*sc2)
674 >          duduz_i(1) = duduz_i(1) + switcher*pref*sw*ri3 &
675 >                                     *(uz_j(1) - 3.0d0*ct_j*xhat*sc2)
676 >          duduz_i(2) = duduz_i(2) + switcher*pref*sw*ri3 &
677 >                                     *(uz_j(2) - 3.0d0*ct_j*yhat*sc2)
678 >          duduz_i(3) = duduz_i(3) + switcher*pref*sw*ri3 &
679 >                                     *(uz_j(3) - 3.0d0*ct_j*zhat*sc2)
680  
681 <          duduz_j(1) = duduz_j(1) + pref*sw*ri3*(uz_i(1) - 3.0d0*ct_i*xhat*sc2)
682 <          duduz_j(2) = duduz_j(2) + pref*sw*ri3*(uz_i(2) - 3.0d0*ct_i*yhat*sc2)
683 <          duduz_j(3) = duduz_j(3) + pref*sw*ri3*(uz_i(3) - 3.0d0*ct_i*zhat*sc2)
681 >          duduz_j(1) = duduz_j(1) + switcher*pref*sw*ri3 &
682 >                                     *(uz_i(1) - 3.0d0*ct_i*xhat*sc2)
683 >          duduz_j(2) = duduz_j(2) + switcher*pref*sw*ri3 &
684 >                                     *(uz_i(2) - 3.0d0*ct_i*yhat*sc2)
685 >          duduz_j(3) = duduz_j(3) + switcher*pref*sw*ri3 &
686 >                                     *(uz_i(3) - 3.0d0*ct_i*zhat*sc2)
687         endif
688  
689      endif
# Line 822 | Line 841 | contains
841      return
842    end subroutine doElectrostaticPair
843  
844 +  !! calculates the switching functions and their derivatives for a given
845 +  subroutine calc_switch(r, mu, scale, dscale)
846  
847 +    real (kind=dp), intent(in) :: r, mu
848 +    real (kind=dp), intent(inout) :: scale, dscale
849 +    real (kind=dp) :: rl, ru, mulow, minRatio, temp, scaleVal
850 +
851 +    ! distances must be in angstroms
852 +    rl = 2.75d0
853 +    ru = 2.85d0
854 +    mulow = 3.3856d0 ! 1.84 * 1.84
855 +    minRatio = mulow / (mu*mu)
856 +    scaleVal = 1.0d0 - minRatio
857 +    
858 +    if (r.lt.rl) then
859 +       scale = minRatio
860 +       dscale = 0.0d0
861 +    elseif (r.gt.ru) then
862 +       scale = 1.0d0
863 +       dscale = 0.0d0
864 +    else
865 +       scale = 1.0d0 - scaleVal*((ru + 2.0d0*r - 3.0d0*rl) * (ru-r)**2) &
866 +                        / ((ru - rl)**3)
867 +       dscale = -scaleVal * 6.0d0 * (r-ru)*(r-rl)/((ru - rl)**3)    
868 +    endif
869 +        
870 +    return
871 +  end subroutine calc_switch
872 +
873    subroutine destroyElectrostaticTypes()
874  
875      if(allocated(ElectrostaticMap)) deallocate(ElectrostaticMap)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines