profiles.density.HernquistDensityProfile.compute_cosmological_overdensity_radius#
- HernquistDensityProfile.compute_cosmological_overdensity_radius(z: float, delta_target: float, rmin: float | unyt_quantity, rmax: float | unyt_quantity, units: str | Unit | None = 'kpc', cosmology: Cosmology | None = None, **kwargs)#
Find the radius enclosing a target overdensity relative to the critical density at redshift \(z\).
Numerically solves for radius \(r_{\Delta}\) satisfying:
\[\Delta(r_{\Delta}) = \Delta_{\mathrm{target}}\]- Parameters:
z (
float
) – Redshift at which to compute overdensity.delta_target (
float
) – Desired overdensity value (must be positive).rmin (
float
) – Lower bound for root-finding search interval, in units specified byunits
.rmax (
float
) – Upper bound for root-finding search interval.units (
str
orUnit
, optional) – Units forrmin
andrmax
. Default iskpc
.cosmology (
Cosmology
, optional) – Cosmology used to compute \(\rho_{\mathrm{crit}}(z)\). Defaults topisces_config
.**kwargs – Additional arguments passed to
compute_enclosed_mass()
.
- Returns:
r_delta – Radius enclosing the target overdensity.
- Return type:
- Raises:
ValueError – If inputs are invalid or critical density calculation fails.
Examples
from astropy.cosmology import Planck18 from pisces.profiles.density import ( HernquistDensityProfile, ) profile = HernquistDensityProfile( rho_0=0.05, r_s=10 ) r_delta = profile.compute_cosmological_overdensity_radius( z=0.3, delta_target=200, rmin=1, rmax=500, units="kpc", cosmology=Planck18, ) print(f"r_200 = {r_delta:.2f}")