The Elk Code
zftcf.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2023 J. K. Dewhurst and S. Sharma.
3 ! This file is distributed under the terms of the GNU General Public License.
4 ! See the file COPYING for license details.
5 
6 subroutine zftcf(ngp,jlgpr,ylmgp,ld,sfacgp,cfmt,cfir,zfgp)
7 use modmain
8 implicit none
9 ! arguments
10 integer, intent(in) :: ngp
11 real(8), intent(in) :: jlgpr(njcmax,nspecies,ngp)
12 ! note the Yₗₘ include a prefactor of 4π (-i)ˡ
13 complex(8), intent(in) :: ylmgp(lmmaxo,ngp)
14 integer, intent(in) :: ld
15 complex(8), intent(in) :: sfacgp(ld,natmtot)
16 complex(4), intent(in) :: cfmt(npcmtmax,natmtot),cfir(ngtc)
17 complex(8), intent(out) :: zfgp(ngp)
18 ! local variables
19 integer is,ia,ias,ig
20 integer nrc,nrci,irco,irc
21 integer l,lm,n,i,j
22 real(8) t0,y0
23 complex(8) zsm,z1
24 ! automatic arrays
25 complex(4) ylm(2:lmmaxo),cfft(ngtc)
26 !-----------------------------------!
27 ! interstitial contribution !
28 !-----------------------------------!
29 ! multiply by coarse characteristic function
30 cfft(1:ngtc)=cfir(1:ngtc)*cfrc(1:ngtc)
31 ! Fourier transform to coarse G-grid
32 call cfftifc(3,ngdgc,-1,cfft)
33 zfgp(1:ngp)=cfft(igfc(1:ngp))
34 !---------------------------------!
35 ! muffin-tin contribution !
36 !---------------------------------!
37 t0=1.d0/omega
38 y0=t0*fourpi*y00
39 do ig=1,ngp
40  ylm(2:lmmaxo)=t0*ylmgp(2:lmmaxo,ig)
41  do is=1,nspecies
42  nrc=nrcmt(is)
43  nrci=nrcmti(is)
44  irco=nrci+1
45  do ia=1,natoms(is)
46  ias=idxas(ia,is)
47  zsm=0.d0
48  i=1
49  j=1
50 ! inner part of muffin-tin, note that lmaxi >= 1
51  if (lmaxi == 1) then
52  do irc=1,nrci
53  zsm=zsm+wr2cmt(irc,is)*(jlgpr(j,is,ig)*y0*cfmt(i,ias) &
54  +jlgpr(j+1,is,ig)*(cfmt(i+1,ias)*ylm(2)+cfmt(i+2,ias)*ylm(3) &
55  +cfmt(i+3,ias)*ylm(4)))
56  i=i+4
57  j=j+2
58  end do
59  else
60  do irc=1,nrci
61  z1=jlgpr(j,is,ig)*y0*cfmt(i,ias)+jlgpr(j+1,is,ig) &
62  *(cfmt(i+1,ias)*ylm(2)+cfmt(i+2,ias)*ylm(3)+cfmt(i+3,ias)*ylm(4))
63  i=i+4
64  j=j+2
65  do l=2,lmaxi
66  n=2*l
67  lm=l**2+1
68  z1=z1+jlgpr(j,is,ig)*sum(cfmt(i:i+n,ias)*ylm(lm:lm+n))
69  i=i+n+1
70  j=j+1
71  end do
72  zsm=zsm+wr2cmt(irc,is)*z1
73  end do
74  end if
75 ! outer part of muffin-tin, note that lmaxo >= 3
76  do irc=irco,nrc
77  z1=jlgpr(j,is,ig)*y0*cfmt(i,ias)+jlgpr(j+1,is,ig) &
78  *(cfmt(i+1,ias)*ylm(2)+cfmt(i+2,ias)*ylm(3)+cfmt(i+3,ias)*ylm(4)) &
79  +jlgpr(j+2,is,ig) &
80  *(cfmt(i+4,ias)*ylm(5)+cfmt(i+5,ias)*ylm(6)+cfmt(i+6,ias)*ylm(7) &
81  +cfmt(i+7,ias)*ylm(8)+cfmt(i+8,ias)*ylm(9)) &
82  +jlgpr(j+3,is,ig) &
83  *(cfmt(i+9,ias)*ylm(10)+cfmt(i+10,ias)*ylm(11)+cfmt(i+11,ias)*ylm(12) &
84  +cfmt(i+12,ias)*ylm(13)+cfmt(i+13,ias)*ylm(14)+cfmt(i+14,ias)*ylm(15)&
85  +cfmt(i+15,ias)*ylm(16))
86  i=i+16
87  j=j+4
88  do l=4,lmaxo
89  n=2*l
90  lm=l**2+1
91  z1=z1+jlgpr(j,is,ig)*sum(cfmt(i:i+n,ias)*ylm(lm:lm+n))
92  i=i+n+1
93  j=j+1
94  end do
95  zsm=zsm+wr2cmt(irc,is)*z1
96  end do
97  zfgp(ig)=zfgp(ig)+conjg(sfacgp(ig,ias))*zsm
98  end do
99  end do
100 end do
101 end subroutine
102 
integer, dimension(maxatoms, maxspecies) idxas
Definition: modmain.f90:42
real(8) omega
Definition: modmain.f90:20
integer lmaxo
Definition: modmain.f90:201
subroutine cfftifc(nd, n, sgn, c)
Definition: cfftifc_fftw.f90:7
subroutine zftcf(ngp, jlgpr, ylmgp, ld, sfacgp, cfmt, cfir, zfgp)
Definition: zftcf.f90:7
integer, dimension(:), allocatable igfc
Definition: modmain.f90:410
integer, dimension(maxspecies) natoms
Definition: modmain.f90:36
real(8), dimension(:,:), allocatable wr2cmt
Definition: modmain.f90:189
integer, dimension(3) ngdgc
Definition: modmain.f90:388
real(8), parameter fourpi
Definition: modmain.f90:1234
real(8), dimension(:), allocatable cfrc
Definition: modmain.f90:438
integer, dimension(maxspecies) nrcmt
Definition: modmain.f90:173
integer, dimension(maxspecies) nrcmti
Definition: modmain.f90:211
real(8), parameter y00
Definition: modmain.f90:1236
integer lmaxi
Definition: modmain.f90:205