exciting-0.9.150
[exciting.git] / src / zfmtinp.f90
blob1d0c9831f536c51dab272e20c0da201c422f536e
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 if (lmax.lt.0) then
56 write(*,*)
57 write(*,'("Error(zfmtinp): lmax < 0 : ",I8)') lmax
58 write(*,*)
59 stop
60 end if
61 lmmax=(lmax+1)**2
62 do ir=1,nr
63 t1=r(ir)**2
64 zt1=zdotc(lmmax,zfmt1(1,ir),1,zfmt2(1,ir),1)
65 fr1(ir)=t1*dble(zt1)
66 fr2(ir)=t1*aimag(zt1)
67 end do
68 call fderiv(-1,nr,r,fr1,gr,cf)
69 t1=gr(nr)
70 call fderiv(-1,nr,r,fr2,gr,cf)
71 t2=gr(nr)
72 zfmtinp=cmplx(t1,t2,8)
73 if (.not.tsh) zfmtinp=zfmtinp*fourpi/dble(lmmax)
74 return
75 end function
76 !EOC