The Elk Code
rdiracint.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2002-2015 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.
5 
6 !BOP
7 ! !ROUTINE: rdiracint
8 ! !INTERFACE:
9 pure subroutine rdiracint(sol,kpa,e,nr,r,vr,nn,g0,g1,f0,f1)
10 ! !INPUT/OUTPUT PARAMETERS:
11 ! sol : speed of light in atomic units (in,real)
12 ! kpa : quantum number kappa (in,integer)
13 ! e : energy (in,real)
14 ! nr : number of radial mesh points (in,integer)
15 ! r : radial mesh (in,real(nr))
16 ! vr : potential on radial mesh (in,real(nr))
17 ! nn : number of nodes (out,integer)
18 ! g0 : major component multiplied by r (out,real(nr))
19 ! g1 : radial derivative of g0 (out,real(nr))
20 ! f0 : minor component multiplied by r (out,real(nr))
21 ! f1 : radial derivative of f0 (out,real(nr))
22 ! !DESCRIPTION:
23 ! Integrates the radial Dirac equation from $r=0$ outwards. This involves
24 ! using the predictor-corrector method to solve the coupled first-order
25 ! equations (in atomic units)
26 ! \begin{align*}
27 ! \left(\frac{d}{dr}+\frac{\kappa}{r}\right)G_{\kappa}&=\frac{1}{c}
28 ! \{2E_0+E-V\}F_{\kappa}\\
29 ! \left(\frac{d}{dr}-\frac{\kappa}{r}\right)F_{\kappa}&=
30 ! -\frac{1}{c}\{E-V\}G_{\kappa},
31 ! \end{align*}
32 ! where $G_{\kappa}=rg_{\kappa}$ and $F_{\kappa}=rf_{\kappa}$ are the major
33 ! and minor components multiplied by $r$, respectively; $V$ is the external
34 ! potential; $E_0$ is the electron rest energy; $E$ is the eigen energy
35 ! (excluding $E_0$); and $\kappa=l$ for $j=l-\frac{1}{2}$ or $\kappa=-(l+1)$
36 ! for $j=l+\frac{1}{2}$.
37 !
38 ! !REVISION HISTORY:
39 ! Created September 2002 (JKD)
40 ! Polynomial order fixed to 3, September 2013 (JKD)
41 !EOP
42 !BOC
43 implicit none
44 ! arguments
45 real(8), intent(in) :: sol
46 integer, intent(in) :: kpa
47 real(8), intent(in) :: e
48 integer, intent(in) :: nr
49 real(8), intent(in) :: r(nr),vr(nr)
50 integer, intent(out) :: nn
51 real(8), intent(out) :: g0(nr),g1(nr),f0(nr),f1(nr)
52 ! local variables
53 integer ir,ir0,i
54 real(8) ci,e0,t1,t2,t3,t4
55 ! inverse speed of light
56 ci=1.d0/sol
57 ! electron rest energy
58 e0=sol**2
59 t1=2.d0*e0+e
60 ! determine the r -> 0 boundary values of F and G
61 t2=dble(kpa)/r(1)
62 t3=ci*(t1-vr(1))
63 t4=ci*(vr(1)-e)
64 f0(1)=1.d0
65 g0(1)=-t2/t4
66 g1(1)=t3-t2*g0(1)
67 ! extrapolate to the first four points
68 g1(2:4)=g1(1)
69 f1(1:4)=0.d0
70 nn=0
71 do ir=2,nr
72  t2=dble(kpa)/r(ir)
73  t3=ci*(t1-vr(ir))
74  t4=ci*(vr(ir)-e)
75  ir0=max(ir-3,1)
76 ! estimate the derivatives
77  g1(ir)=poly3(r(ir0),g1(ir0),r(ir))
78  f1(ir)=poly3(r(ir0),f1(ir0),r(ir))
79  do i=1,8
80 ! integrate to find wavefunction
81  g0(ir)=poly4i(r(ir0),g1(ir0),r(ir))+g0(ir0)
82  f0(ir)=poly4i(r(ir0),f1(ir0),r(ir))+f0(ir0)
83 ! compute the derivatives
84  g1(ir)=t3*f0(ir)-t2*g0(ir)
85  f1(ir)=t4*g0(ir)+t2*f0(ir)
86  end do
87 ! check for overflow
88  if (abs(g0(ir)) > 1.d100) then
89 ! set the remaining points and return
90  g0(ir+1:nr)=g0(ir); g1(ir+1:nr)=g1(ir)
91  f0(ir+1:nr)=f0(ir); f1(ir+1:nr)=f1(ir)
92  return
93  end if
94 ! check for node
95  if (g0(ir-1)*g0(ir) < 0.d0) nn=nn+1
96 end do
97 
98 contains
99 
100 pure real(8) function poly3(xa,ya,x)
101 implicit none
102 ! arguments
103 real(8), intent(in) :: xa(3),ya(3),x
104 ! local variables
105 real(8) x0,x1,x2,y0,y1,y2
106 real(8) c1,c2,t0,t1,t2
107 ! evaluate the polynomial coefficients
108 x0=xa(1)
109 x1=xa(2)-x0; x2=xa(3)-x0
110 y0=ya(1)
111 y1=ya(2)-y0; y2=ya(3)-y0
112 t0=1.d0/(x1*x2*(x2-x1))
113 t1=x1*y2; t2=x2*y1
114 c1=x2*t2-x1*t1
115 c2=t1-t2
116 t1=x-x0
117 ! evaluate the polynomial
118 poly3=y0+t0*t1*(c1+c2*t1)
119 end function
120 
121 pure real(8) function poly4i(xa,ya,x)
122 implicit none
123 ! arguments
124 real(8), intent(in) :: xa(4),ya(4),x
125 ! local variables
126 real(8) x0,x1,x2,x3,y0,y1,y2,y3
127 real(8) c1,c2,c3,t0,t1,t2,t3,t4,t5,t6
128 ! evaluate the polynomial coefficients
129 x0=xa(1)
130 x1=xa(2)-x0; x2=xa(3)-x0; x3=xa(4)-x0
131 y0=ya(1)
132 y1=ya(2)-y0; y2=ya(3)-y0; y3=ya(4)-y0
133 t4=x1-x2; t5=x1-x3; t6=x2-x3
134 t1=x1*x2*y3; t2=x2*x3*y1; t3=x1*x3
135 t0=1.d0/(x2*t3*t4*t5*t6)
136 t3=t3*y2
137 c3=t1*t4+t2*t6-t3*t5
138 t4=x1**2; t5=x2**2; t6=x3**2
139 c2=t1*(t5-t4)+t2*(t6-t5)+t3*(t4-t6)
140 c1=t1*(x2*t4-x1*t5)+t2*(x3*t5-x2*t6)+t3*(x1*t6-x3*t4)
141 t1=x-x0
142 ! integrate the polynomial
143 poly4i=t1*(y0+t0*t1*(0.5d0*c1+t1*(0.3333333333333333333d0*c2+0.25d0*c3*t1)))
144 end function
145 
146 end subroutine
147 !EOC
148 
pure real(8) function poly3(xa, ya, x)
Definition: rdiracint.f90:101
pure subroutine rdiracint(sol, kpa, e, nr, r, vr, nn, g0, g1, f0, f1)
Definition: rdiracint.f90:10
real(8), parameter sol
Definition: modmain.f90:1251
pure real(8) function poly4i(xa, ya, x)
Definition: rdiracint.f90:122