The Elk Code
zpotcoul.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2002-2005 J. K. Dewhurst, S. Sharma and C. Ambrosch-Draxl.
3 ! This file is distributed under the terms of the GNU General Public License.
4 ! See the file COPYING for license details.
5 
6 !BOP
7 ! !ROUTINE: zpotcoul
8 ! !INTERFACE:
9 subroutine zpotcoul(iash,nrmt_,nrmti_,npmt_,ld1,rl,ngridg_,igfft_,ngp,gpc, &
10  gclgp,ld2,jlgprmt,ylmgp,sfacgp,ld3,zvclmt,zvclir)
11 ! !USES:
12 use modmain
13 ! !INPUT/OUTPUT PARAMETERS:
14 ! iash : if iash > 0 then the homogeous solution is stored for this
15 ! muffin-tin in the array zvclmt(:,natmtot+1) (in,integer)
16 ! nrmt_ : number of radial points for each species (in,integer(nspecies))
17 ! nrmti_ : number of radial points on inner part (in,integer(nspecies))
18 ! npmt_ : total number of points in muffin-tins (in,integer(nspecies))
19 ! ld1 : leading dimension (in,integer)
20 ! rl : r^l on radial mesh for each species
21 ! (in,real(ld1,-lmaxo-1:lmaxo+2,nspecies))
22 ! ngridg_ : G-vector grid sizes (in,integer(3))
23 ! igfft_ : map from G-vector index to FFT array (in,integer(*))
24 ! ngp : number of G+p-vectors (in,integer)
25 ! gpc : G+p-vector lengths (in,real(ngp))
26 ! gclgp : Coulomb Green's function in G+p-space (in,real(ngp))
27 ! ld2 : leading dimension (in,integer)
28 ! jlgprmt : spherical Bessel functions for evergy G+p-vector and muffin-tin
29 ! radius (in,real(0:lnpsd,ld2,nspecies))
30 ! ylmgp : spherical harmonics of the G+p-vectors (in,complex(lmmaxo,ngp))
31 ! sfacgp : structure factors of the G+p-vectors (in,complex(ld2,natmtot))
32 ! ld3 : leading dimension (in,integer)
33 ! zvclmt : muffin-tin Coulomb potential, with the contribution from the
34 ! isolated muffin-tin density precalculated and passed in
35 ! (inout,complex(ld3,*))
36 ! zvclir : interstitial charge density on input and Coulomb potential on
37 ! output (inout,complex(*))
38 ! !DESCRIPTION:
39 ! Calculates the Coulomb potential of a complex charge density by solving
40 ! Poisson's equation using the method of M. Weinert, {\it J. Math. Phys.}
41 ! {\bf 22}, 2433 (1981). First, the multipole moments of the muffin-tin charge
42 ! are determined for the $j$th atom of the $i$th species by
43 ! $$ q_{ij;lm}^{\rm MT}=\int_0^{R_i}r^{l+2}\rho_{ij;lm}(r)dr+z_{ij}Y_{00}
44 ! \,\delta_{l,0}\;, $$
45 ! where $R_i$ is the muffin-tin radius and $z_{ij}$ is a point charge located
46 ! at the atom center (usually the nuclear charge, which should be taken as
47 ! {\bf negative}). Next, the multipole moments of the continuation of the
48 ! interstitial density, $\rho^{\rm I}$, into the muffin-tin are found with
49 ! $$ q_{ij;lm}^{\rm I}=4\pi i^l R_i^{l+3}\sum_{\bf G}\frac{j_{l+1}(GR_i)}
50 ! {GR_i}\rho^{\rm I}({\bf G})\exp(i{\bf G}\cdot{\bf r}_{ij})Y_{lm}^*
51 ! (\hat{\bf G}), $$
52 ! remembering that
53 ! $$ \lim_{x\rightarrow 0}\frac{j_{l+n}(x)}{x^n}=\frac{1}{(2n+1)!!}
54 ! \delta_{l,0} $$
55 ! should be used for the case ${\bf G}=0$. A pseudocharge is now constructed
56 ! which is equal to the real density in the interstitial region and whose
57 ! multipoles are the difference between the real and interstitial muffin-tin
58 ! multipoles. This pseudocharge density is smooth in the sense that it can be
59 ! expanded in terms of the finite set of ${\bf G}$-vectors. In each muffin-tin
60 ! the pseudocharge has the form
61 ! $$ \rho_{ij}^{\rm P}({\bf r})=\rho^{\rm I}({\bf r}-{\bf r}_{ij})+\sum_{lm}
62 ! \rho_{ij;lm}^{\rm P}\frac{1}{R_i^{l+3}}\left(\frac{r}{R_i}\right)^l\left(1-
63 ! \frac{r^2}{R_i^2}\right)^{N_i}Y_{lm}(\hat{\bf r}) $$
64 ! where
65 ! $$ \rho_{ij;lm}^{\rm P}=\frac{(2l+2N_i+3)!!}{2^N_iN_i!(2l+1)!!}\left(
66 ! q_{ij;lm}^{\rm MT}-q_{ij;lm}^{\rm I}\right) $$
67 ! and $N_i\approx\frac{1}{4}R_iG_{\rm max}$ is generally a good choice.
68 ! The pseudocharge in reciprocal space is given by
69 ! $$ \rho^{\rm P}({\bf G})=\rho^{\rm I}({\bf G})+\sum_{ij;lm}2^{N_i}N_i!
70 ! \frac{4\pi(-i)^l}{\Omega R_i^l}\frac{j_{l+N_i+1}(GR_i)}{(GR_i)^{N_i+1}}
71 ! \rho_{ij;lm}^{\rm P}\exp(-i{\bf G}\cdot{\bf r}_{ij})Y_{lm}(\hat{\bf G}) $$
72 ! which may be used for solving Poisson's equation directly
73 ! $$ V^{\rm P}({\bf G})=\begin{cases}
74 ! 4\pi\frac{\rho^{\rm P}({\bf G})}{G^2} & G>0 \\
75 ! 0 & G=0 \end{cases} $$
76 ! The usual Green's function approach is then employed to determine the
77 ! potential in the muffin-tin sphere due to charge in the sphere. In other
78 ! words
79 ! $$ V_{ij;lm}^{\rm MT}(r)=\frac{4\pi}{2l+1}\left(\frac{1}{r^{l+1}}\int_0^r
80 ! \rho_{ij;lm}^{\rm MT}(r'){r'}^{l+2}dr'+r^l\int_r^{R_i}\frac{
81 ! \rho_{ij;lm}^{\rm MT}(r')}{{r'}^{l-1}}dr'\right)+\frac{1}{Y_{00}}
82 ! \frac{z_{ij}}{r}\delta_{l,0} $$
83 ! where the last term is the monopole arising from the point charge. All that
84 ! remains is to add the homogenous solution of Poisson's equation,
85 ! $$ V_{ij}^{\rm H}({\bf r})=\sum_{lm}V_{ij;lm}^{\rm H}\left(\frac{r}
86 ! {R_i}\right)^lY_{lm}(\hat{\bf r}), $$
87 ! to the muffin-tin potential so that it is continuous at the muffin-tin
88 ! boundary. Therefore the coefficients, $\rho_{ij;lm}^{\rm H}$, are given by
89 ! $$ V_{ij;lm}^{\rm H}=4\pi i^l\sum_{\bf G}j_{l}(Gr)V^{\rm P}({\bf G})
90 ! \exp(i{\bf G}\cdot{\bf r}_{ij})Y_{lm}^*(\hat{\bf G})-V_{ij;lm}^{\rm MT}
91 ! (R_i). $$
92 ! Finally note that the ${\bf G}$-vectors passed to the routine can represent
93 ! vectors with a non-zero offset, ${\bf G}+{\bf p}$ say, which is required for
94 ! calculating Coulomb matrix elements.
95 !
96 ! !REVISION HISTORY:
97 ! Created April 2003 (JKD)
98 !EOP
99 !BOC
100 implicit none
101 ! arguments
102 integer, intent(in) :: iash,nrmt_(nspecies),nrmti_(nspecies),npmt_(nspecies)
103 integer, intent(in) :: ld1
104 real(8), intent(in) :: rl(ld1,-lmaxo-1:lmaxo+2,nspecies)
105 integer, intent(in) :: ngridg_(3),igfft_(*),ngp
106 real(8), intent(in) :: gpc(ngp),gclgp(ngp)
107 integer, intent(in) :: ld2
108 real(8), intent(in) :: jlgprmt(0:lnpsd,ld2,nspecies)
109 complex(8), intent(in) :: ylmgp(lmmaxo,ngp),sfacgp(ld2,natmtot)
110 integer, intent(in) :: ld3
111 complex(8), intent(inout) :: zvclmt(ld3,*),zvclir(*)
112 ! local variables
113 integer is,ia,ias
114 integer nr,nri,iro,np
115 integer l,lm,lma,lmb
116 integer ig,jg,i,i0,i1
117 real(8) t1,t2,t3
118 complex(8) z1,z2
119 ! automatic arrays
120 real(8) rl2(0:lmaxo)
121 complex(8) qlm(lmmaxo,natmtot),zlm(lmmaxo),zhmt(ld3)
122 ! external functions
123 real(8), external :: factn2
124 ! compute the multipole moments from the muffin-tin potentials
125 t1=1.d0/fourpi
126 do ias=1,natmtot
127  is=idxis(ias)
128  i=npmt_(is)-lmmaxo
129  do l=0,lmaxo
130  t2=t1*dble(2*l+1)*rmtl(l+1,is)
131  lma=l**2+1; lmb=lma+2*l
132  qlm(lma:lmb,ias)=t2*zvclmt(i+lma:i+lmb,ias)
133  end do
134 end do
135 ! Fourier transform density to G-space
136 call zfftifc(3,ngridg_,-1,zvclir)
137 ! subtract the multipole moments of the interstitial charge density
138 do is=1,nspecies
139  rl2(0:lmaxo)=rmtl(2:lmaxo+2,is)
140  t1=rl2(0)*fourpi*y00
141  do ia=1,natoms(is)
142  ias=idxas(ia,is)
143  zlm(1:lmmaxo)=0.d0
144  do ig=1,ngp
145  jg=igfft_(ig)
146  if (gpc(ig) > epslat) then
147  z1=zvclir(jg)*sfacgp(ig,ias)/gpc(ig)
148  zlm(1)=zlm(1)+jlgprmt(1,ig,is)*t1*z1
149  do l=1,lmaxo
150  lma=l**2+1; lmb=lma+2*l
151  z2=jlgprmt(l+1,ig,is)*rl2(l)*z1
152  zlm(lma:lmb)=zlm(lma:lmb)+z2*conjg(ylmgp(lma:lmb,ig))
153  end do
154  else
155  t2=(fourpi/3.d0)*rmtl(3,is)*y00
156  zlm(1)=zlm(1)+t2*zvclir(jg)
157  end if
158  end do
159  qlm(1:lmmaxo,ias)=qlm(1:lmmaxo,ias)-zlm(1:lmmaxo)
160  end do
161 end do
162 ! find the smooth pseudocharge within the muffin-tin whose multipoles are the
163 ! difference between the real muffin-tin and interstitial multipoles
164 t1=factn2(2*lnpsd+1)/omega
165 do ias=1,natmtot
166  is=idxis(ias)
167  do l=0,lmaxo
168  t2=t1/(factn2(2*l+1)*rmtl(l,is))
169  lma=l**2+1; lmb=lma+2*l
170  zlm(lma:lmb)=t2*qlm(lma:lmb,ias)
171  end do
172 ! add the pseudocharge and real interstitial densities in G-space
173  do ig=1,ngp
174  jg=igfft_(ig)
175  if (gpc(ig) > epslat) then
176  t2=gpc(ig)*rmt(is)
177  t3=1.d0/t2**lnpsd
178  z1=t3*fourpi*y00*zlm(1)
179  do l=1,lmaxo
180  lma=l**2+1; lmb=lma+2*l
181  t3=t3*t2
182  z1=z1+t3*sum(zlm(lma:lmb)*ylmgp(lma:lmb,ig))
183  end do
184  z2=jlgprmt(lnpsd,ig,is)*conjg(sfacgp(ig,ias))
185  zvclir(jg)=zvclir(jg)+z1*z2
186  else
187  t2=fourpi*y00/factn2(2*lnpsd+1)
188  zvclir(jg)=zvclir(jg)+t2*zlm(1)
189  end if
190  end do
191 end do
192 ! solve Poisson's equation in G+p-space for the pseudocharge
193 do ig=1,ngp
194  jg=igfft_(ig)
195  zvclir(jg)=gclgp(ig)*zvclir(jg)
196 end do
197 ! match potentials at muffin-tin boundary by adding homogeneous solution
198 do ias=1,natmtot
199  is=idxis(ias)
200  nr=nrmt_(is)
201  nri=nrmti_(is)
202  iro=nri+1
203  np=npmt_(is)
204 ! find the spherical harmonic expansion of the interstitial potential at the
205 ! muffin-tin radius
206  zlm(1:lmmaxo)=0.d0
207  do ig=1,ngp
208  z1=zvclir(igfft_(ig))*sfacgp(ig,ias)
209  zlm(1)=zlm(1)+(jlgprmt(0,ig,is)*fourpi*y00)*z1
210  do l=1,lmaxo
211  lma=l**2+1; lmb=lma+2*l
212  z2=jlgprmt(l,ig,is)*z1
213  zlm(lma:lmb)=zlm(lma:lmb)+z2*conjg(ylmgp(lma:lmb,ig))
214  end do
215  end do
216 ! calculate the homogenous solution
217  i=np-lmmaxo
218  do l=0,lmaxi
219  t1=1.d0/rmtl(l,is)
220  do lm=l**2+1,(l+1)**2
221  z1=t1*(zlm(lm)-zvclmt(i+lm,ias))
222  i1=lmmaxi*(nri-1)+lm
223  zhmt(lm:i1:lmmaxi)=z1*rl(1:nri,l,is)
224  i0=i1+lmmaxi
225  i1=lmmaxo*(nr-iro)+i0
226  zhmt(i0:i1:lmmaxo)=z1*rl(iro:nr,l,is)
227  end do
228  end do
229  do l=lmaxi+1,lmaxo
230  t1=1.d0/rmtl(l,is)
231  do lm=l**2+1,(l+1)**2
232  z1=t1*(zlm(lm)-zvclmt(i+lm,ias))
233  i0=lmmaxi*nri+lm
234  i1=lmmaxo*(nr-iro)+i0
235  zhmt(i0:i1:lmmaxo)=z1*rl(iro:nr,l,is)
236  end do
237  end do
238  zvclmt(1:np,ias)=zvclmt(1:np,ias)+zhmt(1:np)
239 ! store the homogenous solution if required
240  if (iash > 0) then
241  if (ias == iash) zvclmt(1:np,natmtot+1)=zhmt(1:np)
242  end if
243 end do
244 ! Fourier transform interstitial potential to real-space
245 call zfftifc(3,ngridg_,1,zvclir)
246 end subroutine
247 !EOC
248 
integer, dimension(maxatoms, maxspecies) idxas
Definition: modmain.f90:42
real(8) omega
Definition: modmain.f90:20
real(8), dimension(:,:), allocatable rmtl
Definition: modmain.f90:167
subroutine zfftifc(nd, n, sgn, z)
Definition: zfftifc_fftw.f90:7
subroutine zpotcoul(iash, nrmt_, nrmti_, npmt_, ld1, rl, ngridg_, igfft_, ngp, gpc, gclgp, ld2, jlgprmt, ylmgp, sfacgp, ld3, zvclmt, zvclir)
Definition: zpotcoul.f90:11
real(8), dimension(maxspecies) rmt
Definition: modmain.f90:162
integer, dimension(maxspecies) natoms
Definition: modmain.f90:36
integer, dimension(maxatoms *maxspecies) idxis
Definition: modmain.f90:44
integer lmmaxi
Definition: modmain.f90:207
real(8) epslat
Definition: modmain.f90:24
real(8), parameter fourpi
Definition: modmain.f90:1228
real(8), parameter y00
Definition: modmain.f90:1230
integer lmaxi
Definition: modmain.f90:205