src/equilibrium.f90: fix floating point exception

If frhopol is called with a very small ρ_p, less than then step size of
ε_machine^⅓, the two sided finite step differentiation evaluates frhotor
at ρ_p < 0, producing a floating point exception.
In this case we use the single- sided definition.
This commit is contained in:
Michele Guerini Rocco 2024-02-01 01:44:31 +01:00
parent 32f44c5cba
commit 7ed2f9a394
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450

View File

@ -1155,7 +1155,12 @@ contains
f(1) = frhotor(x(1)) - rho_t
else
! return f'(x), computed numerically
if (x(1) - e > 0) then
df(1,1) = (frhotor(x(1) + e) - frhotor(x(1) - e)) / (2*e)
else
! single-sided when close to ρ=0
df(1,1) = (frhotor(x(1) + e) - frhotor(x(1))) / e
end if
end if
end subroutine