iexciting-0.9.224
[exciting.git] / src / zfmtinp.f90
blob11c61004074a63139957e9ce6f7554f01ed50dee
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 Lesser General Public
4 ! License. See the file COPYING for license details.
6 !BOP
7 ! !ROUTINE: zfmtinp
8 ! !INTERFACE:
9 complex(8) function zfmtinp(tsh,lmax,nr,r,ld,zfmt1,zfmt2)
10 ! !INPUT/OUTPUT PARAMETERS:
11 ! tsh : .true. if the functions are in spherical harmonics (in,logical)
12 ! lmax : maximum angular momentum
13 ! nr : number of radial mesh points (in,integer)
14 ! r : radial mesh (in,real(nr))
15 ! ld : leading dimension (in,integer)
16 ! zfmt1 : first complex muffin-tin function in spherical harmonics/
17 ! coordinates (in,complex(ld,nr))
18 ! zfmt2 : second complex muffin-tin function in spherical harmonics/
19 ! coordinates (in,complex(ld,nr))
20 ! !DESCRIPTION:
21 ! Calculates the inner product of two complex fuctions in the muffin-tin. In
22 ! other words, given two complex functions of the form
23 ! $$ f({\bf r})=\sum_{l=0}^{l_{\rm max}}\sum_{m=-l}^{l}f_{lm}(r)Y_{lm}
24 ! (\hat{\bf r}), $$
25 ! the function returns
26 ! $$ I=\sum_{l=0}^{l_{\rm max}}\sum_{m=-l}^{l}\int f_{lm}^{1*}(r)
27 ! f_{lm}^2(r)r^2\,dr\;. $$
28 ! Note that if {\tt tsh} is {\tt .false.} the functions are in spherical
29 ! coordinates rather than spherical harmonics. In this case $I$ is multiplied
30 ! by $4\pi/(l_{\rm max}+1)^2$.
32 ! !REVISION HISTORY:
33 ! Created November 2003 (Sharma)
34 !EOP
35 !BOC
36 implicit none
37 ! arguments
38 logical, intent(in) :: tsh
39 integer, intent(in) :: lmax
40 integer, intent(in) :: nr
41 real(8), intent(in) :: r(nr)
42 integer, intent(in) :: ld
43 complex(8), intent(in) :: zfmt1(ld,nr)
44 complex(8), intent(in) :: zfmt2(ld,nr)
45 ! local variables
46 integer lmmax,ir
47 real(8), parameter :: fourpi=12.566370614359172954d0
48 real(8) t1,t2
49 complex(8) zt1
50 ! automatic arrays
51 real(8) fr1(nr),fr2(nr),gr(nr),cf(3,nr)
52 ! external functions
53 complex(8) zdotc
54 external zdotc
55 lmmax=(lmax+1)**2
56 do ir=1,nr
57 t1=r(ir)**2
58 zt1=zdotc(lmmax,zfmt1(:,ir),1,zfmt2(:,ir),1)
59 fr1(ir)=t1*dble(zt1)
60 fr2(ir)=t1*aimag(zt1)
61 end do
62 call fderiv(-1,nr,r,fr1,gr,cf)
63 t1=gr(nr)
64 call fderiv(-1,nr,r,fr2,gr,cf)
65 t2=gr(nr)
66 zfmtinp=cmplx(t1,t2,8)
67 if (.not.tsh) zfmtinp=zfmtinp*fourpi/dble(lmmax)
68 return
69 end function
70 !EOC