excwb91.f90 5.7 KB
Newer Older
Matthias Redies's avatar
Matthias Redies committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
MODULE m_excwb91
!.....-----------------------------------------------------------------
!.....pw91 exchange-correlation energy density in hartree.
!.....------------------------------------------------------------------
CONTAINS
   SUBROUTINE excwb91( &
      mirm,irmx,rh1,rh2,agr,agru,agrd, &
      g2r,g2ru,g2rd,gggr,gggru,gggrd,gzgr, &
      exc, &
      idsprs,isprsv,sprsv)

      USE m_corl91
      USE m_corg91
      USE m_xch91
      USE m_constants

      IMPLICIT NONE

! .. Arguments ..
      INTEGER, INTENT (IN) :: irmx,mirm,idsprs,isprsv
      REAL,    INTENT (IN) :: sprsv

      REAL,    INTENT (IN) :: rh1(mirm),rh2(mirm)
      REAL,    INTENT (IN) :: agr(mirm),agru(mirm),agrd(mirm)
      REAL,    INTENT (IN) :: g2r(mirm),g2ru(mirm),g2rd(mirm)
      REAL,    INTENT (IN) :: gggr(mirm),gggru(mirm)
      REAL,    INTENT (IN) :: gggrd(mirm),gzgr(mirm)
      REAL,    INTENT (OUT) :: exc(mirm)

! .. local variables
      REAL :: ro,zta,alf,alfc,c13,c23,c43,c53, &
              cedg,cedl,dbrod,dbrou,dsprs,ec,ecrs,eczta,fk,gz, &
              ro13,ro2,rod,rod3,rod43,rod53,rou,rou3,rou43,rou53, &
              rs,sd,sk,su,tc,td,tksg,tu,uc,ud,uu,vc, &
              vcgd,vcgu,vcld,vclu,vxgd,vxgu,vxld, &
              vxlu,wc,xced,xedg,xedgd,xedgu,xedl,xedld,xedlu

      INTEGER :: i
      REAL, PARAMETER :: sml = 1.e-14
      REAL, PARAMETER :: huges = 1.e+6
!.....------------------------------------------------------------------
!.....huges: if su(sdw).gt.huges, grad.expansion calc.non-excuted.
!.....-----------------------------------------------------------------

      do 300 i = 1,irmx

         ro=rh1(i)+rh2(i)
         zta=(rh1(i)-rh2(i))/ro
         if(zta > 1.0-sml) zta = 1.0 - sml
         if(zta < -1.0-sml) zta = -1.0 + sml

         !.....
         !       xedl,xedg: exchange energy density (local,grad.exp.) in ry.
         !       cedl,cedg: exchange energy density (local,grad.expnd.) in ry.
         !       all later in hartree.
         !.....
         xedl = 0.0e0
         cedl = 0.0e0
         xedg = 0.0e0
         cedg = 0.0e0

         !.....
         if(ro < sml) then
            ro = sml
            zta = 0.0
            go to 200
         endif
         !.....
         c13 = 1.e0/3.e0
         c23 = 2.e0/3.e0
         c43 = 4.e0/3.e0
         c53 = 5.e0/3.e0
         !.....  alf=-3*(3/4*pai)**(1/3).
         alf = -1.861051473e0
         !.....
         ro2 = ro*ro
         ro13 = ro**c13
         !.....
         rou = rh1(i)
         rou3 = rou**3
         rou43 = rou**c43
         !.....
         rod = rh2(i)
         rod3 = rod**3
         rod43 = rod**c43
         !.....
         !       gr2=drr*drr
         !       gr2u=drru**2
         !       drrd=drr-drru
         !       gr2d=drrd**2
         !       ddrrd=ddrr-ddrru
         !.....
         !.....  gz,gz2,gz3: for wang-perdew ssf.
         gz = ((1.0+zta)**c23+ (1.0-zta)**c23)/2.e0
         !.....
         rs = 0.620350491/ro13
         !.....
         !.....  xedl: exchange-energy-density in ry.
         xedl = alf* (rou43+rod43)
         !.....
         !....  .gradient correction.
         !.....
         if(abs(agr(i)) < sml) go to 200
         !.....

         !.....
         dsprs = 1.0
         if(idsprs == 1) dsprs = 1.e-19
         if(isprsv == 1) dsprs = dsprs*sprsv

         !.....
         !      agr,agru,agrd: abs(grad(rho)), for all, up, and down.
         !c     gr2,gr2u,gr2d: grad(rho_all)**2, grad(rho_up)**2, grad(rho_d)**2.
         !      g2r,g2ru,g2rd: laplacian rho_all, _up and _down.
         !      gggru,-d: grad(rho)*grad(abs(grad(rho))) for all,up and down.
         !      grgru,-d: grad(rho_all)*grad(rhor_up) and for down.

         !         g2r=ddrr+2*drr/rv
         !.....
         rou53 = rou**c53
         !.....
         !.....  edrru: d(abs(d(rou)/dr))/dr, edrrd for down.
         !         edrru=ddrru
         !         if(drru.lt.0.) edrru=-ddrru
         !.....
         !         agr,agbru,-d: abs(grad(rho)),for rou, rod.
         !         gggru,-d: grad(rho)*grad(abs(grad(rho))) for up and down.
         !.....  su:at ro=2*rou. 1/(2(3*pai**2)**(1/3))*|grad(rou)|/rou**(4/3).
         su = 0.128278244*agru(i)/rou43
         if(su > huges) go to 200
         !         g2ru=ddrru+2*drru/rv
         tu = .016455307e0*g2ru(i)/rou53
         uu = 0.002110857e0*gggru(i)/rou3

         dbrou = rou*2

         call xch91(dbrou,su,uu,tu,xedlu,xedgu,vxlu,vxgu)

         xedl = xedlu/2
         xedgu = dsprs*xedgu

         !.....
         rod53 = rod**c53
         !         edrrd=ddrrd
         !         if(drrd.lt.0.) edrrd=-ddrrd

         sd = 0.128278244*agrd(i)/rod43
         if(sd > huges) go to 200

         !         g2rd=ddrrd+2*drrd/rv

         td = .016455307e0*g2rd(i)/rod53
         ud = 0.002110857e0*gggrd(i)/rod3

         dbrod = rod*2

         call xch91(dbrod,sd,ud,td,xedld,xedgd,vxld,vxgd)

         xedl = xedl + xedld/2
         xedgd = dsprs*xedgd

         xedg = (xedgu+xedgd)/2

         !....   cro: c(n) of (6),phys.rev..b33,8822('86). in ry.
         !....   dcdr: d(cro)/d(ro).
         !.....  0.001625816=1.745*f(=0.11)*cro(rs=0).

         call corl91(rs,zta,ec,vclu,vcld,ecrs,eczta,alfc)

         cedl = ec*2.e0*ro

         fk = 1.91915829/rs
         sk = sqrt(4.e0*fk/pi_const)
         tksg = 2.e0*sk*gz
         tc = agr(i)/ (ro*tksg)
         uc = gggr(i)/ (ro2*tksg**3)
         vc = g2r(i)/ (ro*tksg**2)
         wc = gzgr(i)/ (ro*tksg**2)

         call corg91(fk,sk,gz,ec,ecrs,eczta,rs,zta,tc,uc,vc,wc,cedg, &
                     vcgu,vcgd)

         cedg = dsprs*cedg*ro*2.e0

200      continue

         xced = (xedl+cedl+xedg+cedg)
         if(ro >= sml) xced = xced/ro

         !     change to hartree.
         exc(i) = xced/2.e0

300   END DO

   END SUBROUTINE excwb91
END MODULE m_excwb91