The Elk Code
 
Loading...
Searching...
No Matches
cpotcoul.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
6subroutine cpotcoul(nrmt_,nrmti_,npmt_,ld1,rl,ngridg_,igfft_,ngp,gpc,gclgp,ld2,&
7 jlgprmt,ylmgp,sfacgp,crhoir,ld3,cvclmt,cvclir)
8use modmain
9use modphonon
10implicit none
11! arguments
12integer, intent(in) :: nrmt_(nspecies),nrmti_(nspecies),npmt_(nspecies)
13integer, intent(in) :: ld1
14real(8), intent(in) :: rl(ld1,-lmaxo-1:lmaxo+2,nspecies)
15integer, intent(in) :: ngridg_(3),igfft_(*),ngp
16real(8), intent(in) :: gpc(ngp),gclgp(ngp)
17integer, intent(in) :: ld2
18real(8), intent(in) :: jlgprmt(0:lnpsd,ld2,nspecies)
19complex(8), intent(in) :: ylmgp(lmmaxo,ngp),sfacgp(ld2,natmtot)
20complex(4), intent(in) :: crhoir(*)
21integer, intent(in) :: ld3
22complex(4), intent(inout) :: cvclmt(ld3,natmtot)
23complex(4), intent(out) :: cvclir(*)
24! local variables
25integer is,ia,ias
26integer nr,nri,iro
27integer l,lm,lma,lmb
28integer ig,jg,i,i0,i1
29real(8) t1,t2,t3
30complex(8) z1,z2
31! automatic arrays
32real(8) rl2(0:lmaxo)
33complex(8) qlm(lmmaxo,natmtot),zlm(lmmaxo)
34! external functions
35real(8), external :: factn2
36! compute the multipole moments from the muffin-tin potentials
37t1=1.d0/fourpi
38do ias=1,natmtot
39 is=idxis(ias)
40 i=npmt_(is)-lmmaxo
41 do l=0,lmaxo
42 t2=t1*dble(2*l+1)*rmtl(l+1,is)
43 lma=l**2+1; lmb=lma+2*l
44 qlm(lma:lmb,ias)=t2*cvclmt(i+lma:i+lmb,ias)
45 end do
46end do
47! Fourier transform density to G-space and store in zvclir
48call ccopy(ngridg_(1)*ngridg_(2)*ngridg_(3),crhoir,1,cvclir,1)
49call cfftifc(3,ngridg_,-1,cvclir)
50! subtract the multipole moments of the interstitial charge density
51do is=1,nspecies
52 rl2(0:lmaxo)=rmtl(2:lmaxo+2,is)
53 t1=rl2(0)*fourpi*y00
54 do ia=1,natoms(is)
55 ias=idxas(ia,is)
56 zlm(1:lmmaxo)=0.d0
57 do ig=1,ngp
58 jg=igfft_(ig)
59 if (gpc(ig) > epslat) then
60 z1=cvclir(jg)*sfacgp(ig,ias)/gpc(ig)
61 zlm(1)=zlm(1)+jlgprmt(1,ig,is)*t1*z1
62 do l=1,lmaxo
63 lma=l**2+1; lmb=lma+2*l
64 z2=jlgprmt(l+1,ig,is)*rl2(l)*z1
65 zlm(lma:lmb)=zlm(lma:lmb)+z2*conjg(ylmgp(lma:lmb,ig))
66 end do
67 else
68 t2=(fourpi/3.d0)*rmtl(3,is)*y00
69 zlm(1)=zlm(1)+t2*cvclir(jg)
70 end if
71 end do
72 qlm(1:lmmaxo,ias)=qlm(1:lmmaxo,ias)-zlm(1:lmmaxo)
73 end do
74end do
75! find the smooth pseudocharge within the muffin-tin whose multipoles are the
76! difference between the real muffin-tin and interstitial multipoles
77t1=factn2(2*lnpsd+1)/omega
78do ias=1,natmtot
79 is=idxis(ias)
80 do l=0,lmaxo
81 t2=t1/(factn2(2*l+1)*rmtl(l,is))
82 lma=l**2+1; lmb=lma+2*l
83 zlm(lma:lmb)=t2*qlm(lma:lmb,ias)
84 end do
85! add the pseudocharge and real interstitial densities in G-space
86 do ig=1,ngp
87 jg=igfft_(ig)
88 if (gpc(ig) > epslat) then
89 t2=gpc(ig)*rmt(is)
90 t3=1.d0/t2**lnpsd
91 z1=t3*fourpi*y00*zlm(1)
92 do l=1,lmaxo
93 lma=l**2+1; lmb=lma+2*l
94 t3=t3*t2
95 z1=z1+t3*sum(zlm(lma:lmb)*ylmgp(lma:lmb,ig))
96 end do
97 z2=jlgprmt(lnpsd,ig,is)*conjg(sfacgp(ig,ias))
98 cvclir(jg)=cvclir(jg)+z1*z2
99 else
100 t2=fourpi*y00/factn2(2*lnpsd+1)
101 cvclir(jg)=cvclir(jg)+t2*zlm(1)
102 end if
103 end do
104end do
105! solve Poisson's equation in G+p-space for the pseudocharge
106do ig=1,ngp
107 jg=igfft_(ig)
108 cvclir(jg)=gclgp(ig)*cvclir(jg)
109end do
110! match potentials at muffin-tin boundary by adding homogeneous solution
111do ias=1,natmtot
112 is=idxis(ias)
113 nr=nrmt_(is)
114 nri=nrmti_(is)
115 iro=nri+1
116! find the spherical harmonic expansion of the interstitial potential at the
117! muffin-tin radius
118 zlm(1:lmmaxo)=0.d0
119 do ig=1,ngp
120 z1=cvclir(igfft_(ig))*sfacgp(ig,ias)
121 zlm(1)=zlm(1)+jlgprmt(0,ig,is)*fourpi*y00*z1
122 do l=1,lmaxo
123 lma=l**2+1; lmb=lma+2*l
124 z2=jlgprmt(l,ig,is)*z1
125 zlm(lma:lmb)=zlm(lma:lmb)+z2*conjg(ylmgp(lma:lmb,ig))
126 end do
127 end do
128! add the homogenous solution
129 i=npmt_(is)-lmmaxo
130 do l=0,lmaxi
131 t1=1.d0/rmtl(l,is)
132 do lm=l**2+1,(l+1)**2
133 z1=t1*(zlm(lm)-cvclmt(i+lm,ias))
134 i1=lmmaxi*(nri-1)+lm
135 cvclmt(lm:i1:lmmaxi,ias)=cvclmt(lm:i1:lmmaxi,ias)+z1*rl(1:nri,l,is)
136 i0=i1+lmmaxi
137 i1=lmmaxo*(nr-iro)+i0
138 cvclmt(i0:i1:lmmaxo,ias)=cvclmt(i0:i1:lmmaxo,ias)+z1*rl(iro:nr,l,is)
139 end do
140 end do
141 do l=lmaxi+1,lmaxo
142 t1=1.d0/rmtl(l,is)
143 do lm=l**2+1,(l+1)**2
144 z1=t1*(zlm(lm)-cvclmt(i+lm,ias))
145 i0=lmmaxi*nri+lm
146 i1=lmmaxo*(nr-iro)+i0
147 cvclmt(i0:i1:lmmaxo,ias)=cvclmt(i0:i1:lmmaxo,ias)+z1*rl(iro:nr,l,is)
148 end do
149 end do
150end do
151! Fourier transform interstitial potential to real-space
152call cfftifc(3,ngridg_,1,cvclir)
153end subroutine
154
subroutine cfftifc(nd, n, sgn, c)
subroutine cpotcoul(nrmt_, nrmti_, npmt_, ld1, rl, ngridg_, igfft_, ngp, gpc, gclgp, ld2, jlgprmt, ylmgp, sfacgp, crhoir, ld3, cvclmt, cvclir)
Definition cpotcoul.f90:8
elemental real(8) function factn2(n)
Definition factn2.f90:7
real(8), parameter y00
Definition modmain.f90:1233
real(8), dimension(:,:), allocatable rmtl
Definition modmain.f90:167
integer, dimension(maxspecies) natoms
Definition modmain.f90:36
real(8), dimension(maxspecies) rmt
Definition modmain.f90:162
integer, dimension(maxatoms, maxspecies) idxas
Definition modmain.f90:42
integer lmmaxi
Definition modmain.f90:207
real(8) omega
Definition modmain.f90:20
integer, dimension(maxatoms *maxspecies) idxis
Definition modmain.f90:44
real(8), parameter fourpi
Definition modmain.f90:1231
real(8) epslat
Definition modmain.f90:24
integer lmaxi
Definition modmain.f90:205