xcbh.f 9.65 KB
Newer Older
1 2 3 4 5 6
!--------------------------------------------------------------------------------
! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
! This file is part of FLEUR and available as free software under the conditions
! of the MIT license as expressed in the LICENSE file in more detail.
!--------------------------------------------------------------------------------

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
      MODULE m_xcbh 
      use m_juDFT
!-----------------------------------------------------------------------
!     Called in case of icorr=2,3 : spin-polarized exchange-correlation 
!       potential of U. von Barth and L. Hedin, J.Phys.C5,1629 (1972)
!       icorr = 2: parametrization of Moruzzi,Janak,Williams
!       icorr = 3: parametrization of von Barth and Hedin
!
!     krla=1: Relativistic correction of exchange energy and potential 
!             related to Dirac kinetic energy, according to:
!             A.H. MacDonald and S.H. Vosko, J. Phys. C12, 2977 (1979)
!
!     be careful: calculation in rydberg!
!
!     vxcbh calculates the XC-potential and
!     excbh calculates the XC-energy
!
!     based on a subroutine by S. Bluegel;   r.pentcheva 22.01.96
!-----------------------------------------------------------------------

      USE m_constants, ONLY : pi_const
      USE m_relcor
      IMPLICIT NONE

      REAL, PARAMETER, PRIVATE :: ff  = 3.847322101863  ! 1 / ( 2^(1/3) - 1 )
      REAL, PARAMETER, PRIVATE :: cvx = 1.221774115422  ! 2 * ( 3/(2*pi) )^(2/3)
      REAL, PARAMETER, PRIVATE :: cpmjw = 0.045  , cfmjw = 0.0225
      REAL, PARAMETER, PRIVATE :: cpvbh = 0.0504 , cfvbh = 0.0254
      REAL, PARAMETER, PRIVATE :: rpmjw = 21.0 , rfmjw = 52.916684096
      REAL, PARAMETER, PRIVATE :: rpvbh = 30.0 , rfvbh = 75.0
      REAL, PARAMETER, PRIVATE :: d_15 = 1.e-15
      REAL, PARAMETER, PRIVATE :: one = 1.0 , three = 3.0 , four = 4.0
      REAL, PARAMETER, PRIVATE :: half = 0.5 , thrd = one/three
      REAL, PARAMETER, PRIVATE :: hfthrd = 0.79370052705 ! 2^(-1/3)
      REAL, PARAMETER, PRIVATE :: thrhalf = three * half
      REAL, PARAMETER, PRIVATE :: fothrd = four * thrd , two = 2.0


      CONTAINS
!************************************************************************
      SUBROUTINE vxcbh
48
     >                (iofile,xcpot,jspins,
49 50 51
     >                 mgrid,ngrid,rh,
     <                 vx,vxc)
!************************************************************************
52
      USE m_types_xcpot_data
53
!     
54 55
!     .. Scalar Arguments ..
      INTEGER, INTENT (IN) :: jspins
56
      TYPE(t_xcpot_data), INTENT (IN) :: xcpot  !  run mode parameters
57 58 59 60 61 62 63 64 65 66
      INTEGER, INTENT (IN) :: iofile      !  file number for read and write
      INTEGER, INTENT (IN) :: mgrid,ngrid !  mesh points
!
!     .. Array Arguments ..
      REAL, INTENT (IN)  :: rh(mgrid,jspins)      ! charge density
      REAL, INTENT (OUT) :: vxc(mgrid,jspins)     ! xc potential
      REAL, INTENT (OUT) :: vx (mgrid,jspins)     ! x  potential
!
!     .. Local Scalars ..
      REAL txthrd,tythrd,muxp,mucp,mucf,ecfmp,tauc,mucnm
67 68 69
      REAL :: rho, rh1, rh2 ! total, spin up & spin down charge density
      REAL :: x, y, cp, cf, rp, rf, rs, ecprs, ecfrs
      INTEGER :: ir
70 71 72 73 74 75 76 77 78 79 80 81
!
!     .. Local Arrays ..
      REAL, ALLOCATABLE :: psi(:)       ! relativistic exchange potential corr.
!
!---- Intrinsic Functions
      INTRINSIC alog,max

!
!-----> evaluate relativistic corrections for exchange
! 
      ALLOCATE ( psi(ngrid) )
      CALL relcor(
82
     >            mgrid,ngrid,jspins,xcpot%krla,.true.,rh,
83 84 85 86
     <            psi)
!
!-----> select exchange correlation potential
!
87
      IF (xcpot%is_mjw) THEN
88 89
         cp = cpmjw ; cf = cfmjw
         rp = rpmjw ; rf = rfmjw
90
      ELSEIF (xcpot%is_bh) THEN
91 92 93 94
         cp = cpvbh ; cf = cfvbh
         rp = rpvbh ; rf = rfvbh
      ELSE
         WRITE (iofile,FMT=2000)
95
          CALL juDFT_error("BUG:vxcbh",calledby="xcbh")
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
      END IF
 2000 FORMAT (13x,'set key for exchange-correlation potential')
!
!-----> calculate exchange correlation potential
!
      IF ( jspins .EQ. 2) THEN               ! spinpolarized calculation

        DO ir = 1,ngrid                        ! loop over realspace gridpoints
          rh1 = max(d_15,rh(ir,1))
          rh2 = max(d_15,rh(ir,jspins))
          rho = rh1 + rh2
          x = rh1/rho
          y = rh2/rho
          txthrd = (2*x)**thrd
          tythrd = (2*y)**thrd
          rs= (four*pi_const*rho/three)**thrd
          rs = 1/rs

          ecprs = -cp*fc(rs/rp)            ! calculate correlation energy
          ecfrs = -cf*fc(rs/rf)            ! p : paramagnetic, f : ferromagnetic
                                           ! x : exchange,     c : correlation
          muxp = -psi(ir)* (cvx/rs)        ! paramagnetic exchange potential 
                                           !       (psi contains rel. corr.)
          mucp = -cp*alog(one+rp/rs)       ! calculate correlation potential
          mucf = -cf*alog(one+rf/rs)
          ecfmp = fothrd * (ecfrs-ecprs)
          tauc = mucf - mucp - ecfmp
          mucnm = mucp + tauc*fex(x) - ff*ecfmp

          vxc(ir,1)      = mucnm + (muxp+ff*ecfmp)*txthrd  ! collect correlation 
          vxc(ir,jspins) = mucnm + (muxp+ff*ecfmp)*tythrd  ! and exchange parts
        
          vx (ir,1)      = muxp*txthrd
          vx (ir,jspins) = muxp*tythrd
        ENDDO

      ELSEIF ( jspins .EQ. 1 ) THEN        ! non - spinpolarized calculation

        DO ir = 1, ngrid                   ! loop over realspace gridpoints
          rh1 = max(d_15,rh(ir,1))
          rs = (four*pi_const*rh1/three)**thrd
          rs = 1/rs 
          muxp = -psi(ir) * (cvx/rs)       ! paramagnetic exchange potential 
                                           !       (psi contains rel. corr.)
          mucp = -cp* alog(one+rp/rs)      ! calculate correlation potential
          vxc(ir,1)     = mucp + muxp      ! collect correlation & exchange part
        
          vx (ir,1)     = muxp
        ENDDO

      ELSE
         WRITE (iofile,'('' error in jspins, jspins ='',i2)') jspins
          CALL juDFT_error("vxcbh",calledby="xcbh")
      ENDIF

      DEALLOCATE (psi)
      RETURN   

      END SUBROUTINE vxcbh
C***********************************************************************
      SUBROUTINE excbh
157
     >                (iofile,xcpot,jspins,
158 159 160
     >                 mgrid,ngrid,rh,
     <                 exc)
C***********************************************************************
161
      USE m_types_xcpot_data
162
!     
163 164
!     .. Scalar Arguments ..
      INTEGER, INTENT (IN) :: jspins
165
      TYPE(t_xcpot_data), INTENT (IN) :: xcpot !  run mode parameters
166 167 168 169 170 171 172 173 174
      INTEGER, INTENT (IN) :: iofile      !  file number for read and write
      INTEGER, INTENT (IN) :: mgrid,ngrid !  mesh points
!
!     .. Array Arguments ..
      REAL, INTENT (IN)  :: rh(mgrid,jspins)      ! charge density
      REAL, INTENT (OUT) :: exc(mgrid)            ! xc energy
!
!     .. Local Scalars ..
      REAL thfpi,thrquart,exprs,exfrs,excprs,excfrs
175 176 177
      REAL :: rho, rh1, rh2 ! total, spin up & spin down charge density
      REAL :: x, y, cp, cf, rp, rf, rs, ecprs, ecfrs
      INTEGER :: ir
178 179 180 181 182 183 184 185 186 187 188 189
!
!     .. Local Arrays ..
      REAL, ALLOCATABLE :: phi(:)       ! relativistic exchange energy correct.
!
!-----> Intrinsic Functions
      INTRINSIC alog,max
!
      thrquart = 0.75
      thfpi = thrquart/pi_const

      ALLOCATE ( phi(ngrid) )
      CALL relcor(
190
     >            mgrid,ngrid,jspins,xcpot%krla,.false.,rh,
191 192 193 194
     <            phi)
!
!-----> select exchange correlation potential
!
195
      IF (xcpot%is_mjw) THEN
196 197
         cp = cpmjw ; cf = cfmjw
         rp = rpmjw ; rf = rfmjw
198
      ELSEIF (xcpot%is_bh) THEN
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
         cp = cpvbh ; cf = cfvbh
         rp = rpvbh ; rf = rfvbh
      ELSE
         WRITE (iofile,FMT=2000)
          CALL juDFT_error("excbh",calledby="xcbh")
      END IF
 2000 FORMAT (13x,'set key for exchange-correlation potential')

      IF ( jspins .EQ. 2) THEN       ! spinpolarized calculation

        DO  ir = 1,ngrid                  ! loop over realspace gridpoints
          rh1 = max(d_15,rh(ir,1))
          rh2 = max(d_15,rh(ir,jspins))
          rho = rh1 + rh2
          x = rh1/rho
          rs= (thfpi/rho)**thrd

          exprs = -phi(ir)*thrquart*cvx/rs    ! first exchange energy 
          exfrs = (2.0**thrd)*exprs           ! phi contains rel. corr.

          ecprs = -cp*fc(rs/rp)               ! calculate correlation energy
          ecfrs = -cf*fc(rs/rf)               ! p: paramagnetic, f: ferromagn.

          excprs = exprs + ecprs              ! now add correlation energy
          excfrs = exfrs + ecfrs

          exc(ir) = excprs + (excfrs-excprs)*fex(x) ! collect all terms
        ENDDO 

      ELSEIF ( jspins .EQ. 1 ) THEN  ! non - spinpolarized calculation

        DO ir = 1,ngrid                    ! loop over realspace gridpoints
          rh1 = max(d_15,rh(ir,1)) 
          rs = (thfpi/rh1)**thrd
          exprs = -phi(ir)*thrquart*cvx/rs ! exchange energy ; phi contains 
                                           ! relativistic correctionS
          ecprs = -cp*fc(rs/rp)            ! calculate correlation energy
          exc(ir) = exprs + ecprs          ! add correlation energy
        ENDDO

       ELSE
         WRITE (iofile,'('' error in jspins, jspins ='',i2)') jspins
          CALL juDFT_error("excbh",calledby="xcbh")
       ENDIF

      DEALLOCATE (phi)
      RETURN

      END SUBROUTINE excbh
!--------------------------------------------------------------------
      REAL FUNCTION fc(x)
        REAL x
        fc = (one+(x)*(x)*(x))*alog(one+one/(x))
     +        + half*(x) - (x)*(x) - thrd
      END  FUNCTION fc
      REAL FUNCTION fex(x)
        REAL x
        fex = ff/hfthrd*((x)**fothrd +(1-(x))**fothrd - hfthrd)
      END FUNCTION fex
!--------------------------------------------------------------------

      END MODULE m_xcbh