The Elk Code
shankeli.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2008 F. Bultmark, F. Cricchio, L. Nordstrom and J. K. Dewhurst.
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: shankeli
8 ! !INTERFACE:
9 subroutine shankeli(lmax,x,hl)
10 ! !INPUT/OUTPUT PARAMETERS:
11 ! lmax : maximum order of Hankel function (in,integer)
12 ! x : real argument (in,real)
13 ! hl : array of returned values (out,real(0:lmax))
14 ! !DESCRIPTION:
15 ! Computes the spherical Hankel function of the first kind with imaginary
16 ! argument, $\tilde{h}_l(x)=i^lh_l(ix)$, for real $x$ and
17 ! $l=0\ldots l_{\rm max}$. The recurrence relation
18 ! $$ \tilde{h}_{l+1}(x)=\frac{2l+1}{x}\tilde{h}_l(x)+\tilde{h}_{l-1}(x) $$
19 ! is used upwards. The starting values there are
20 ! $\tilde{h}_0(x)=-e^{-x}/x$ and $\tilde{h}_1(x)=\tilde{h}_0(x)(1+1/x)$.
21 ! For $x\ll 1$ we use the asymptotic form
22 ! $$ \tilde{h}_l(x)\approx\frac{-(2l-1)!!}{(-x)^{l+1}}. $$
23 !
24 ! !REVISION HISTORY:
25 ! Created April 2008 from sbessel routine (Lars Nordstrom)
26 ! Changed name, September 2021 (JKD)
27 !EOP
28 !BOC
29 implicit none
30 ! arguments
31 integer, intent(in) :: lmax
32 real(8), intent(in) :: x
33 real(8), intent(out) :: hl(0:lmax)
34 ! local variables
35 integer l
36 real(8) xi,h0,h1,t1
37 if ((lmax < 0).or.(lmax > 50)) then
38  write(*,*)
39  write(*,'("Error(shankeli): lmax out of range : ",I8)') lmax
40  write(*,*)
41  stop
42 end if
43 if ((x <= 0.d0).or.(x > 1.d8)) then
44  write(*,*)
45  write(*,'("Error(shankeli): x out of range : ",G18.10)') x
46  write(*,*)
47  stop
48 end if
49 xi=1.d0/x
50 hl(0)=-xi*exp(-x)
51 if (lmax == 0) return
52 ! treat x << 1
53 if (x < 1.d-8) then
54  t1=-xi
55  do l=1,lmax
56  t1=t1*xi*dble(2*l-1)
57  hl(l)=t1
58  end do
59  return
60 end if
61 ! recurse up
62 hl(1)=hl(0)*(1.d0+xi)
63 if (lmax == 1) return
64 h0=hl(0)
65 h1=hl(1)
66 do l=2,lmax
67  t1=(2*l-1)*h1*xi+h0
68  h0=h1
69  h1=t1
70  hl(l)=h1
71 end do
72 end subroutine
73 !EOC
74 
subroutine shankeli(lmax, x, hl)
Definition: shankeli.f90:10