Function to invert the tortoise radius as a function of Schwarzschild radius.
Simple Newton root finding algorithm. Have problems converging for negative rstar as it overshoots and rschw-2M can become negative.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | z | The tortoise radius to invert, . |
||
real(kind=wp), | intent(in) | :: | mass | The mass of the black hole, . |
The return value is .
function rschw( z, mass )
!! Function to invert the tortoise radius as a function of Schwarzschild
!! radius.
!!
!! Simple Newton root finding algorithm. Have problems converging for
!! negative rstar as it overshoots and rschw-2M can become negative.
implicit none
real(wp), intent(in) :: z
!! The tortoise radius to invert, \(z\).
real(wp), intent(in) :: mass
!! The mass of the black hole, \(M\).
real(wp) :: rschw
!! The return value is \(r_{\mathrm{schw}}(z)-2M\).
real(wp) :: xcurrent, xnew
integer(ip) :: iter
! real(wp), parameter :: eps = 1.0e-12_wp
iter = 0
xcurrent = 1.0_wp
loop: do
iter = iter+1
xnew = (z - 2.0_wp*mass*log(0.5_wp*xcurrent/mass)) &
/(1+2.0_wp*mass/xcurrent)
if ( abs ( xnew - xcurrent) < eps(1.0_wp) ) exit loop
if (iter>maxiter) stop 'Function rschw failed to converge. Aborting'
xcurrent = xnew
end do loop
rschw = xnew
end function rschw