The Elk Code
 
Loading...
Searching...
No Matches
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:
9subroutine 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
29implicit none
30! arguments
31integer, intent(in) :: lmax
32real(8), intent(in) :: x
33real(8), intent(out) :: hl(0:lmax)
34! local variables
35integer l
36real(8) xi,h0,h1,t1
37if ((lmax < 0).or.(lmax > 50)) then
38 write(*,*)
39 write(*,'("Error(shankeli): lmax out of range : ",I8)') lmax
40 write(*,*)
41 stop
42end if
43if ((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
48end if
49xi=1.d0/x
50hl(0)=-xi*exp(-x)
51if (lmax == 0) return
52! treat x << 1
53if (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
60end if
61! recurse up
62hl(1)=hl(0)*(1.d0+xi)
63if (lmax == 1) return
64h0=hl(0)
65h1=hl(1)
66do l=2,lmax
67 t1=(2*l-1)*h1*xi+h0
68 h0=h1
69 h1=t1
70 hl(l)=h1
71end do
72end subroutine
73!EOC
74
subroutine shankeli(lmax, x, hl)
Definition shankeli.f90:10