profiles.density.MooreDensityProfile.compute_fractional_mass_radius#

MooreDensityProfile.compute_fractional_mass_radius(rmin: float | unyt_quantity, rmax: float | unyt_quantity, fraction: float = 0.5, units: str | Unit | None = 'kpc', **kwargs)#

Find the radius enclosing a given fraction of the total mass.

Solves numerically for radius \(r_f\) such that:

\[M(r_f) = f \times M_{\mathrm{tot}}\]

where \(f\) is the desired mass fraction.

Parameters:
Returns:

radius – Radius enclosing the specified mass fraction.

Return type:

unyt_quantity

Raises:

ValueError – If the mass fraction is outside (0, 1) or search bounds are invalid.

Examples

import unyt
from pisces.profiles.density import (
    HernquistDensityProfile,
)

profile = HernquistDensityProfile(
    rho_0=0.05 * unyt.Msun / unyt.kpc**3,
    r_s=10 * unyt.kpc,
)

half_mass_radius = (
    profile.compute_fractional_mass_radius(
        0.1, 100, fraction=0.5, units="kpc"
    )
)
print(f"Half-mass radius: {half_mass_radius:.2f}")