mkgxyz3.f 6.47 KB
Newer Older
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 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
      MODULE m_mkgxyz3
c.....------------------------------------------------------------------
c     by use of cartesian x,y,z components of charge density gradients,
c     make the quantities
cc      agrt,agru,agrd,g2rt,g2ru,g2rd,gggrt,gggru,gggrd,gzgr
cc    used to calculate gradient contribution to xc potential and
cc    energy.
c.....------------------------------------------------------------------
      CONTAINS
      SUBROUTINE mkgxyz3(
     >                   igrd,ndm,jsdm,ng3,jspins,vl,
     >                   dvx,dvy,dvz,dvxx,dvyy,dvzz,dvyz,dvzx,dvxy,
     <                   agrt,agru,agrd, g2rt,g2ru,g2rd, 
     <                   gggrt,gggru,gggrd,gzgr)

      IMPLICIT NONE
      INTEGER, INTENT (IN) :: ndm,ng3,igrd,jsdm,jspins
      REAL,    INTENT (IN) :: vl(ndm,jsdm)
      REAL,    INTENT (IN) :: dvx(ndm,jsdm),dvy(ndm,jsdm),dvz(ndm,jsdm)
      REAL, INTENT (IN) :: dvxx(ndm,jsdm),dvyy(ndm,jsdm),dvzz(ndm,jsdm)
      REAL, INTENT (IN) :: dvyz(ndm,jsdm),dvzx(ndm,jsdm),dvxy(ndm,jsdm)

      REAL, INTENT (OUT) :: agrt(ndm),agru(ndm),agrd(ndm)
      REAL, INTENT (OUT) :: g2rt(ndm),g2ru(ndm),g2rd(ndm)
      REAL, INTENT (OUT) :: gggrt(ndm),gggru(ndm),gggrd(ndm),gzgr(ndm)

      REAL vlt,dvxt,dvyt,dvzt,dvxxt,dvyyt,dvzzt,dvyzt,dvzxt,dvxyt,
     &     vlu,dvxu,dvyu,dvzu,dvxxu,dvyyu,dvzzu,dvyzu,dvzxu,dvxyu,
     &     vld,dvxd,dvyd,dvzd,dvxxd,dvyyd,dvzzd,dvyzd,dvzxd,dvxyd,
     &     dagrxt,dagrxd,dagrxu,dagryt,dagryd,dagryu,dagrzt,dagrzd,
     +     dagrzu,dzdx,dzdy,dzdz,
     +     sml
      INTEGER i

      sml = 1.e-14

      DO i = 1,ndm
          agrt(i) = 0.0
          agru(i) = 0.0
          agrd(i) = 0.0
          gggrt(i) = 0.0
          gggru(i) = 0.0
          gggrd(i) = 0.0
          gzgr(i) = 0.0
          g2rt(i) = 0.0
          g2ru(i) = 0.0
          g2rd(i) = 0.0
      ENDDO

      IF (igrd.GT.0) THEN
      IF (jspins.eq.1) THEN

        DO 10 i = 1,ng3

          vlu=max(vl(i,1)/2,sml)
          dvxu=dvx(i,1)/2
          dvyu=dvy(i,1)/2
          dvzu=dvz(i,1)/2
          dvxxu=dvxx(i,1)/2
          dvyyu=dvyy(i,1)/2
          dvzzu=dvzz(i,1)/2
          dvyzu=dvyz(i,1)/2
          dvzxu=dvzx(i,1)/2
          dvxyu=dvxy(i,1)/2

          vld=vlu
          dvxd=dvxu
          dvyd=dvyu
          dvzd=dvzu
          dvxxd=dvxxu
          dvyyd=dvyyu
          dvzzd=dvzzu
          dvyzd=dvyzu
          dvzxd=dvzxu
          dvxyd=dvxyu


          vlt = vlu + vld

          dvxt = dvxu + dvxd
          dvyt = dvyu + dvyd
          dvzt = dvzu + dvzd
          dvxxt = dvxxu + dvxxd
          dvyyt = dvyyu + dvyyd
          dvzzt = dvzzu + dvzzd
          dvyzt = dvyzu + dvyzd
          dvzxt = dvzxu + dvzxd
          dvxyt = dvxyu + dvxyd

c         agr: abs(grad(ro)), t,u,d for total, up and down.

          agrt(i) = max(sqrt(dvxt**2+dvyt**2+dvzt**2),sml)
          agru(i) = max(sqrt(dvxu**2+dvyu**2+dvzu**2),sml)
          agrd(i) = max(sqrt(dvxd**2+dvyd**2+dvzd**2),sml)

          dagrxt = (dvxt*dvxxt+dvyt*dvxyt+dvzt*dvzxt)/agrt(i)
          dagrxu = (dvxu*dvxxu+dvyu*dvxyu+dvzu*dvzxu)/agru(i)
          dagrxd = (dvxd*dvxxd+dvyd*dvxyd+dvzd*dvzxd)/agrd(i)

          dagryt = (dvxt*dvxyt+dvyt*dvyyt+dvzt*dvyzt)/agrt(i)
          dagryu = (dvxu*dvxyu+dvyu*dvyyu+dvzu*dvyzu)/agru(i)
          dagryd = (dvxd*dvxyd+dvyd*dvyyd+dvzd*dvyzd)/agrd(i)

          dagrzt = (dvxt*dvzxt+dvyt*dvyzt+dvzt*dvzzt)/agrt(i)
          dagrzu = (dvxu*dvzxu+dvyu*dvyzu+dvzu*dvzzu)/agru(i)
          dagrzd = (dvxd*dvzxd+dvyd*dvyzd+dvzd*dvzzd)/agrd(i)

          gggrt(i) = dvxt*dagrxt + dvyt*dagryt + dvzt*dagrzt
          gggru(i) = dvxu*dagrxu + dvyu*dagryu + dvzu*dagrzu
          gggrd(i) = dvxd*dagrxd + dvyd*dagryd + dvzd*dagrzd

c         dzdx=d(zeta)/dx,..

          dzdx = (dvxu-dvxd)/vlt - (vlu-vld)*dvxt/vlt**2
          dzdy = (dvyu-dvyd)/vlt - (vlu-vld)*dvyt/vlt**2
          dzdz = (dvzu-dvzd)/vlt - (vlu-vld)*dvzt/vlt**2

c         gzgr=grad(zeta)*grad(ro).

          gzgr(i) = dzdx*dvxt + dzdy*dvyt + dzdz*dvzt

c         g2r: grad(grad(ro))

          g2rt(i) = dvxxt + dvyyt + dvzzt
          g2ru(i) = dvxxu + dvyyu + dvzzu
          g2rd(i) = dvxxd + dvyyd + dvzzd


  10    ENDDO

      ELSE

        DO 20 i = 1,ng3

          vlu = max(vl(i,1),sml)
          dvxu=dvx(i,1)
          dvyu=dvy(i,1)
          dvzu=dvz(i,1)
          dvxxu=dvxx(i,1)
          dvyyu=dvyy(i,1)
          dvzzu=dvzz(i,1)
          dvyzu=dvyz(i,1)
          dvzxu=dvzx(i,1)
          dvxyu=dvxy(i,1)

          vld = max(vl(i,jspins),sml)
          dvxd=dvx(i,jspins)
          dvyd=dvy(i,jspins)
          dvzd=dvz(i,jspins)
          dvxxd=dvxx(i,jspins)
          dvyyd=dvyy(i,jspins)
          dvzzd=dvzz(i,jspins)
          dvyzd=dvyz(i,jspins)
          dvzxd=dvzx(i,jspins)
          dvxyd=dvxy(i,jspins)

          vlt = vlu + vld

          dvxt = dvxu + dvxd
          dvyt = dvyu + dvyd
          dvzt = dvzu + dvzd
          dvxxt = dvxxu + dvxxd
          dvyyt = dvyyu + dvyyd
          dvzzt = dvzzu + dvzzd
          dvyzt = dvyzu + dvyzd
          dvzxt = dvzxu + dvzxd
          dvxyt = dvxyu + dvxyd

c         agr: abs(grad(ro)), t,u,d for total, up and down.

          agrt(i) = max(sqrt(dvxt**2+dvyt**2+dvzt**2),sml)
          agru(i) = max(sqrt(dvxu**2+dvyu**2+dvzu**2),sml)
          agrd(i) = max(sqrt(dvxd**2+dvyd**2+dvzd**2),sml)

          dagrxt = (dvxt*dvxxt+dvyt*dvxyt+dvzt*dvzxt)/agrt(i)
          dagrxu = (dvxu*dvxxu+dvyu*dvxyu+dvzu*dvzxu)/agru(i)
          dagrxd = (dvxd*dvxxd+dvyd*dvxyd+dvzd*dvzxd)/agrd(i)

          dagryt = (dvxt*dvxyt+dvyt*dvyyt+dvzt*dvyzt)/agrt(i)
          dagryu = (dvxu*dvxyu+dvyu*dvyyu+dvzu*dvyzu)/agru(i)
          dagryd = (dvxd*dvxyd+dvyd*dvyyd+dvzd*dvyzd)/agrd(i)

          dagrzt = (dvxt*dvzxt+dvyt*dvyzt+dvzt*dvzzt)/agrt(i)
          dagrzu = (dvxu*dvzxu+dvyu*dvyzu+dvzu*dvzzu)/agru(i)
          dagrzd = (dvxd*dvzxd+dvyd*dvyzd+dvzd*dvzzd)/agrd(i)

          gggrt(i) = dvxt*dagrxt + dvyt*dagryt + dvzt*dagrzt
          gggru(i) = dvxu*dagrxu + dvyu*dagryu + dvzu*dagrzu
          gggrd(i) = dvxd*dagrxd + dvyd*dagryd + dvzd*dagrzd

c         dzdx=d(zeta)/dx,..

          dzdx = (dvxu-dvxd)/vlt -  (vlu-vld)*dvxt/vlt**2
          dzdy = (dvyu-dvyd)/vlt -  (vlu-vld)*dvyt/vlt**2
          dzdz = (dvzu-dvzd)/vlt -  (vlu-vld)*dvzt/vlt**2

c         gzgr=grad(zeta)*grad(ro).

          gzgr(i) = dzdx*dvxt + dzdy*dvyt + dzdz*dvzt

c         g2r: grad(grad(ro))

          g2rt(i) = dvxxt + dvyyt + dvzzt
          g2ru(i) = dvxxu + dvyyu + dvzzu
          g2rd(i) = dvxxd + dvyyd + dvzzd

  20    ENDDO

      ENDIF
      ENDIF ! igrd.GT.0

      END SUBROUTINE mkgxyz3
      END MODULE m_mkgxyz3