The Elk Code
zpotclmt.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: zpotclmt
8 ! !INTERFACE:
9 pure subroutine zpotclmt(nr,nri,ld,rl,wpr,zrhomt,zvclmt)
10 ! !USES:
11 use modmain
12 ! !INPUT/OUTPUT PARAMETERS:
13 ! nr : number of radial mesh points (in,integer)
14 ! nri : number of points on inner part of muffin-tin (in,integer)
15 ! ld : leading dimension (in,integer)
16 ! rl : r^l on the radial mesh (in,real(ld,-lmaxo-1:lmaxo+2))
17 ! wpr : weights for partial integration on radial mesh (in,real(4,nr))
18 ! zrhomt : muffin-tin charge density (in,complex(*))
19 ! zvclmt : muffin-tin Coulomb potential (out,complex(*))
20 ! !DESCRIPTION:
21 ! Solves the Poisson equation for the charge density contained in an isolated
22 ! muffin-tin using the Green's function approach. In other words, the
23 ! spherical harmonic expansion of the Coulomb potential, $V_{lm}$, is obtained
24 ! from the density expansion, $\rho_{lm}$, by
25 ! $$ V_{lm}(r)=\frac{4\pi}{2l+1}\left(\frac{1}{r^{l+1}}\int_0^r\rho_{lm}(r')
26 ! {r'}^{l+2}dr'+r^l\int_r^R\frac{\rho_{lm}(r')}{{r'}^{l-1}}dr'\right), $$
27 ! where $R$ is the muffin-tin radius.
28 !
29 ! !REVISION HISTORY:
30 ! Created April 2003 (JKD)
31 !EOP
32 !BOC
33 implicit none
34 ! arguments
35 integer, intent(in) :: nr,nri,ld
36 real(8), intent(in) :: rl(ld,-lmaxo-1:lmaxo+2),wpr(4,nr)
37 complex(8), intent(in) :: zrhomt(*)
38 complex(8), intent(out) :: zvclmt(*)
39 ! local variables
40 integer nro,iro,ir
41 integer l,l1,l2,l3
42 integer lm,npi,i0,i
43 real(8) t0
44 complex(8) z1
45 ! automatic arrays
46 complex(8) f1(nr),f2(nr),f3(nr)
47 nro=nr-nri
48 iro=nri+1
49 npi=lmmaxi*nri
50 do l=0,lmaxi
51  l1=l+2
52  l2=-l+1
53  l3=-l-1
54  t0=fourpi/dble(2*l+1)
55  do lm=l**2+1,(l+1)**2
56  do ir=1,nri
57  i=lm+lmmaxi*(ir-1)
58  f1(ir)=rl(ir,l1)*zrhomt(i)
59  f2(ir)=rl(ir,l2)*zrhomt(i)
60  end do
61  i0=lm+npi
62  do ir=iro,nr
63  i=i0+lmmaxo*(ir-iro)
64  f1(ir)=rl(ir,l1)*zrhomt(i)
65  f2(ir)=rl(ir,l2)*zrhomt(i)
66  end do
67  call splintwp(nr,wpr,f1,f3)
68  call splintwp(nr,wpr,f2,f1)
69  z1=f1(nr)
70  do ir=1,nri
71  i=lm+lmmaxi*(ir-1)
72  zvclmt(i)=t0*(rl(ir,l3)*f3(ir)+rl(ir,l)*(z1-f1(ir)))
73  end do
74  do ir=iro,nr
75  i=i0+lmmaxo*(ir-iro)
76  zvclmt(i)=t0*(rl(ir,l3)*f3(ir)+rl(ir,l)*(z1-f1(ir)))
77  end do
78  end do
79 end do
80 do l=lmaxi+1,lmaxo
81  l1=l+2
82  l2=-l+1
83  l3=-l-1
84  t0=fourpi/dble(2*l+1)
85  do lm=l**2+1,(l+1)**2
86  i0=lm+npi
87  do ir=iro,nr
88  i=i0+lmmaxo*(ir-iro)
89  f1(ir)=rl(ir,l1)*zrhomt(i)
90  f2(ir)=rl(ir,l2)*zrhomt(i)
91  end do
92  call splintwp(nro,wpr(1,iro),f1(iro),f3(iro))
93  call splintwp(nro,wpr(1,iro),f2(iro),f1(iro))
94  z1=f1(nr)
95  do ir=iro,nr
96  i=i0+lmmaxo*(ir-iro)
97  zvclmt(i)=t0*(rl(ir,l3)*f3(ir)+rl(ir,l)*(z1-f1(ir)))
98  end do
99  end do
100 end do
101 
102 contains
103 
104 pure subroutine splintwp(n,wp,f,g)
105 implicit none
106 ! arguments
107 integer, intent(in) :: n
108 real(8), intent(in) :: wp(*)
109 complex(8), intent(in) :: f(n)
110 complex(8), intent(out) :: g(n)
111 ! local variables
112 integer i,j
113 complex(8) zsm
114 g(1)=0.d0
115 zsm=wp(5)*f(1)+wp(6)*f(2)+wp(7)*f(3)+wp(8)*f(4)
116 g(2)=zsm
117 do i=2,n-2
118  j=i*4+1
119  zsm=zsm+wp(j)*f(i-1)+wp(j+1)*f(i)+wp(j+2)*f(i+1)+wp(j+3)*f(i+2)
120  g(i+1)=zsm
121 end do
122 j=(n-1)*4+1
123 g(n)=zsm+wp(j)*f(n-3)+wp(j+1)*f(n-2)+wp(j+2)*f(n-1)+wp(j+3)*f(n)
124 end subroutine
125 
126 end subroutine
127 !EOC
128 
integer lmmaxo
Definition: modmain.f90:203
integer lmaxo
Definition: modmain.f90:201
pure subroutine splintwp(n, wp, f, g)
Definition: atom.f90:183
integer lmmaxi
Definition: modmain.f90:207
real(8), parameter fourpi
Definition: modmain.f90:1234
pure subroutine zpotclmt(nr, nri, ld, rl, wpr, zrhomt, zvclmt)
Definition: zpotclmt.f90:10
integer lmaxi
Definition: modmain.f90:205