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 2296 by chrisfen, Thu Sep 15 00:13:56 2005 UTC vs.
Revision 2310 by chrisfen, Mon Sep 19 23:21:46 2005 UTC

# Line 54 | Line 54 | module electrostatic_module
54  
55    PRIVATE
56  
57 + #define __FORTRAN90
58 + #include "UseTheForce/DarkSide/fElectrostaticSummationMethod.h"
59 +
60    !! these prefactors convert the multipole interactions into kcal / mol
61    !! all were computed assuming distances are measured in angstroms
62    !! Charge-Charge, assuming charges are measured in electrons
# Line 68 | Line 71 | module electrostatic_module
71    !! This unit is also known affectionately as an esu centi-barn.
72    real(kind=dp), parameter :: pre14 = 69.13373_dp
73  
74 +  !! variables to handle different summation methods for long-range electrostatics:
75 +  integer, save :: summationMethod = NONE
76 +  logical, save :: summationMethodChecked = .false.
77 +  real(kind=DP), save :: defaultCutoff = 0.0_DP
78 +  logical, save :: haveDefaultCutoff = .false.
79 +  real(kind=DP), save :: dampingAlpha = 0.0_DP
80 +  logical, save :: haveDampingAlpha = .false.
81 +  real(kind=DP), save :: dielectric = 0.0_DP
82 +  logical, save :: haveDielectric = .false.
83 +  real(kind=DP), save :: constERFC = 0.0_DP
84 +  real(kind=DP), save :: constEXP = 0.0_DP
85 +  logical, save :: haveDWAconstants = .false.
86 +  real(kind=dp), save :: rcuti = 0.0_dp
87 +  real(kind=dp), save :: rcuti2 = 0.0_dp
88 +  real(kind=dp), save :: rcuti3 = 0.0_dp
89 +  real(kind=dp), save :: rcuti4 = 0.0_dp
90 +
91 +
92 +  public :: setElectrostaticSummationMethod
93 +  public :: setElectrostaticCutoffRadius
94 +  public :: setDampedWolfAlpha
95 +  public :: setReactionFieldDielectric
96    public :: newElectrostaticType
97    public :: setCharge
98    public :: setDipoleMoment
# Line 96 | Line 121 | contains
121  
122   contains
123  
124 +  subroutine setElectrostaticSummationMethod(the_ESM)
125 +    integer, intent(in) :: the_ESM    
126 +
127 +    if ((the_ESM .le. 0) .or. (the_ESM .gt. REACTION_FIELD)) then
128 +       call handleError("setElectrostaticSummationMethod", "Unsupported Summation Method")
129 +    endif
130 +
131 +    summationMethod = the_ESM
132 +  end subroutine setElectrostaticSummationMethod
133 +
134 +  subroutine setElectrostaticCutoffRadius(thisRcut)
135 +    real(kind=dp), intent(in) :: thisRcut
136 +    defaultCutoff = thisRcut
137 +    haveDefaultCutoff = .true.
138 +  end subroutine setElectrostaticCutoffRadius
139 +
140 +  subroutine setDampedWolfAlpha(thisAlpha)
141 +    real(kind=dp), intent(in) :: thisAlpha
142 +    dampingAlpha = thisAlpha
143 +    haveDampingAlpha = .true.
144 +  end subroutine setDampedWolfAlpha
145 +  
146 +  subroutine setReactionFieldDielectric(thisDielectric)
147 +    real(kind=dp), intent(in) :: thisDielectric
148 +    dielectric = thisDielectric
149 +    haveDielectric = .true.
150 +  end subroutine setReactionFieldDielectric
151 +
152    subroutine newElectrostaticType(c_ident, is_Charge, is_Dipole, &
153         is_SplitDipole, is_Quadrupole, is_Tap, status)
154  
# Line 306 | Line 359 | contains
359      dm = ElectrostaticMap(atid)%dipole_moment
360    end function getDipoleMoment
361  
362 +  subroutine checkSummationMethod()
363 +
364 +    if (.not.haveDefaultCutoff) then
365 +       call handleError("checkSummationMethod", "no Default Cutoff set!")
366 +    endif
367 +
368 +    rcuti = 1.0d0 / defaultCutoff
369 +    rcuti2 = rcuti*rcuti
370 +    rcuti3 = rcuti2*rcuti
371 +    rcuti4 = rcuti2*rcuti2
372 +
373 +    if (summationMethod .eq. DAMPED_WOLF) then
374 +       if (.not.haveDWAconstants) then
375 +          
376 +          if (.not.haveDampingAlpha) then
377 +             call handleError("checkSummationMethod", "no Damping Alpha set!")
378 +          endif
379 +          
380 +          if (.not.haveDefaultCutoff) then
381 +             call handleError("checkSummationMethod", "no Default Cutoff set!")
382 +          endif
383 +
384 +          constEXP = exp(-dampingAlpha*dampingAlpha*defaultCutoff*defaultCutoff)
385 +          constERFC = erfc(dampingAlpha*defaultCutoff)
386 +          
387 +          haveDWAconstants = .true.
388 +       endif
389 +    endif
390 +
391 +    if (summationMethod .eq. REACTION_FIELD) then
392 +       if (.not.haveDielectric) then
393 +          call handleError("checkSummationMethod", "no reaction field Dielectric set!")
394 +       endif
395 +    endif
396 +
397 +    summationMethodChecked = .true.
398 +  end subroutine checkSummationMethod
399 +
400 +
401 +
402    subroutine doElectrostaticPair(atom1, atom2, d, rij, r2, sw, &
403 <       vpair, fpair, pot, eFrame, f, t, do_pot, corrMethod, rcuti)
403 >       vpair, fpair, pot, eFrame, f, t, do_pot)
404  
405      logical, intent(in) :: do_pot
406  
407      integer, intent(in) :: atom1, atom2
408      integer :: localError
316    integer, intent(in) :: corrMethod
409  
410 <    real(kind=dp), intent(in) :: rij, r2, sw, rcuti
410 >    real(kind=dp), intent(in) :: rij, r2, sw
411      real(kind=dp), intent(in), dimension(3) :: d
412      real(kind=dp), intent(inout) :: vpair
413      real(kind=dp), intent(inout), dimension(3) :: fpair
# Line 346 | Line 438 | contains
438      real (kind=dp) :: xhat, yhat, zhat
439      real (kind=dp) :: dudx, dudy, dudz
440      real (kind=dp) :: scale, sc2, bigR, switcher, dswitcher
349    real (kind=dp) :: rcuti2, rcuti3, rcuti4
441  
442      if (.not.allocated(ElectrostaticMap)) then
443         call handleError("electrostatic", "no ElectrostaticMap was present before first call of do_electrostatic_pair!")
444         return
445      end if
446  
447 +    if (.not.summationMethodChecked) then
448 +       call checkSummationMethod()
449 +      
450 +    endif
451 +
452 +
453   #ifdef IS_MPI
454      me1 = atid_Row(atom1)
455      me2 = atid_Col(atom2)
# Line 368 | Line 465 | contains
465      xhat = d(1) * riji
466      yhat = d(2) * riji
467      zhat = d(3) * riji
371
372    rcuti2 = rcuti*rcuti
373    rcuti3 = rcuti2*rcuti
374    rcuti4 = rcuti2*rcuti2
468  
469      swi = 1.0d0 / sw
470  
# Line 518 | Line 611 | contains
611  
612         if (j_is_Charge) then
613  
614 <          if (corrMethod .eq. 1) then
614 >          if (summationMethod .eq. UNDAMPED_WOLF) then
615               vterm = pre11 * q_i * q_j * (riji - rcuti)
616  
617               vpair = vpair + vterm
# Line 550 | Line 643 | contains
643  
644            pref = sw * pre12 * q_i * mu_j
645  
646 <          if (corrMethod .eq. 1) then
646 >          if (summationMethod .eq. UNDAMPED_WOLF) then
647               ri2 = riji * riji
648               ri3 = ri2 * riji
649  
# Line 617 | Line 710 | contains
710  
711            pref =  sw * pre14 * q_i / 3.0_dp
712  
713 <          if (corrMethod .eq. 1) then
713 >          if (summationMethod .eq. UNDAMPED_WOLF) then
714               vterm1 = pref * ri3*( qxx_j * (3.0_dp*cx2 - 1.0_dp) + &
715                    qyy_j * (3.0_dp*cy2 - 1.0_dp) + &
716                    qzz_j * (3.0_dp*cz2 - 1.0_dp) )
# Line 715 | Line 808 | contains
808  
809            pref = sw * pre12 * q_j * mu_i
810  
811 <          if (corrMethod .eq. 1) then
811 >          if (summationMethod .eq. UNDAMPED_WOLF) then
812               ri2 = riji * riji
813               ri3 = ri2 * riji
814  
# Line 770 | Line 863 | contains
863  
864            pref = sw * pre22 * mu_i * mu_j
865  
866 <          if (corrMethod .eq. 1) then
866 >          if (summationMethod .eq. UNDAMPED_WOLF) then
867               ri2 = riji * riji
868               ri3 = ri2 * riji
869               ri4 = ri2 * ri2
# Line 873 | Line 966 | contains
966  
967            pref = sw * pre14 * q_j / 3.0_dp
968  
969 <          if (corrMethod .eq. 1) then
969 >          if (summationMethod .eq. UNDAMPED_WOLF) then
970               vterm1 = pref * ri3*( qxx_i * (3.0_dp*cx2 - 1.0_dp) + &
971                    qyy_i * (3.0_dp*cy2 - 1.0_dp) + &
972                    qzz_i * (3.0_dp*cz2 - 1.0_dp) )

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines