mkgl0.f90 2.29 KB
Newer Older
Matthias Redies's avatar
Matthias Redies committed
1
MODULE m_mkgl0
Matthias Redies's avatar
Matthias Redies committed
2 3 4 5 6 7 8 9 10
!      ------------------------------------------------------------------
!      make quantities for vxcallg. for paramag. case
!        dens,drr,ddrr are charge density and its gradient for nonmag.
!        one spin.

!      agr: abs(grad(ro)), g2r: laplacian(ro),
!      gggr: grad(ro)*grad(agr),
!      grgru,d: grad(ro)*grad(rou),for rod., gzgr: grad(zeta)*grad(ro).
!      ------------------------------------------------------------------
Matthias Redies's avatar
Matthias Redies committed
11
CONTAINS
Matthias Redies's avatar
Matthias Redies committed
12
   SUBROUTINE mkgl0(jspins,rad, densi,drri,ddrri, grad)
Matthias Redies's avatar
Matthias Redies committed
13 14 15 16

      USE m_types
      IMPLICIT NONE

Matthias Redies's avatar
Matthias Redies committed
17 18 19
      INTEGER, INTENT (IN) :: jspins
      REAL,    INTENT (IN) :: rad(:),densi(:,:)
      REAL,    INTENT (IN) :: drri(:,:),ddrri(:,:)
Matthias Redies's avatar
Matthias Redies committed
20
      TYPE(t_gradients)::grad
Matthias Redies's avatar
Matthias Redies committed
21

Matthias Redies's avatar
Matthias Redies committed
22
      REAL dagrr,dagrru,ddrr,ddrrd,ddrru,drr,drrd,drru,dzdr,ro,rod,rou,rv,spnf
Matthias Redies's avatar
Matthias Redies committed
23 24
      INTEGER i
!     ------------------------------------------------------------------
Matthias Redies's avatar
Matthias Redies committed
25

Matthias Redies's avatar
Matthias Redies committed
26 27
      spnf = 1./(3-jspins)
      IF (allocated(grad%sigma)) THEN
Matthias Redies's avatar
Matthias Redies committed
28
         DO i=1,size(rad)
Matthias Redies's avatar
Matthias Redies committed
29 30 31 32 33 34 35 36
            grad%sigma(1,i)=spnf * drri(i,1)*spnf * drri(i,1)
            IF (jspins>1) THEN
               grad%sigma(2,i)=spnf * drri(i,1)*spnf * drri(i,2)
               grad%sigma(3,i)=spnf * drri(i,2)*spnf * drri(i,2)
            ENDIF
         ENDDO
         RETURN
      ENDIF
Matthias Redies's avatar
Matthias Redies committed
37
      DO i = 1,size(rad)
Matthias Redies's avatar
Matthias Redies committed
38

Matthias Redies's avatar
Matthias Redies committed
39 40 41 42 43 44 45 46 47 48 49
         rv = rad(i)
         ro =  spnf * (densi(i,1) + densi(i,jspins))
         rou = spnf * densi(i,1)
         rod = spnf * densi(i,jspins)

         drr =   spnf * (drri(i,1) + drri(i,jspins))
         drru =  spnf * drri(i,1)
         drrd =  spnf * drri(i,jspins)
         ddrr =  spnf * (ddrri(i,1) + ddrri(i,jspins))
         ddrru = spnf * ddrri(i,1)
         ddrrd = spnf * ddrri(i,jspins)
Matthias Redies's avatar
Matthias Redies committed
50

Matthias Redies's avatar
Matthias Redies committed
51 52 53
         grad%agrt(i) = abs(drr)
         grad%agru(i) = abs(drru)
         grad%agrd(i) = grad%agru(i)
Matthias Redies's avatar
Matthias Redies committed
54

Matthias Redies's avatar
Matthias Redies committed
55 56
         dagrr = drr*ddrr/grad%agrt(i)
         dagrru = drru*ddrru/grad%agru(i)
Matthias Redies's avatar
Matthias Redies committed
57

Matthias Redies's avatar
Matthias Redies committed
58 59 60
         grad%gggrt(i) = drr*dagrr
         grad%gggru(i) = drru*dagrru
         grad%gggrd(i) = grad%gggru(i)
Matthias Redies's avatar
Matthias Redies committed
61

Matthias Redies's avatar
Matthias Redies committed
62
         dzdr = ((drru-drrd)*ro- (rou-rod)*drr)/ro**2
Matthias Redies's avatar
Matthias Redies committed
63

Matthias Redies's avatar
Matthias Redies committed
64
         grad%gzgr(i) = dzdr*drr
Matthias Redies's avatar
Matthias Redies committed
65

Matthias Redies's avatar
Matthias Redies committed
66 67 68
         grad%g2rt(i) = ddrr + 2*drr/rv
         grad%g2ru(i) = ddrru + 2*drru/rv
         grad%g2rd(i) = ddrrd + 2*drrd/rv
Matthias Redies's avatar
Matthias Redies committed
69

Matthias Redies's avatar
Matthias Redies committed
70 71
         grad%grgru(i) = drr*drru
         grad%grgrd(i) = drr*drrd
Matthias Redies's avatar
Matthias Redies committed
72 73 74

      ENDDO

Matthias Redies's avatar
Matthias Redies committed
75 76
   END SUBROUTINE mkgl0
END MODULE m_mkgl0