profiles.density.CoredPowerLawDensityProfile.compute_escape_velocity#
- CoredPowerLawDensityProfile.compute_escape_velocity(r: unyt_array | unyt_quantity, units: str | Unit | None = None, G: unyt_quantity | None = None, **kwargs) unyt_array | unyt_quantity #
Compute the escape velocity at radius \(r\).
The escape velocity is the minimum speed required for a test particle to escape to infinity from radius \(r\) in a spherically symmetric gravitational potential:
\[v_{\mathrm{esc}}(r) = \sqrt{ \frac{2 G M(r)}{r} },\]where \(M(r)\) is the enclosed mass at radius \(r\).
- Parameters:
r (
unyt_quantity
orunyt_array
) – Radius or array of radii at which to compute the escape velocity (must carry length units).units (
str
orUnit
, optional) – Desired output units for the escape velocity. By default, uses the internal units determined by G and the profile parameters.G (
unyt_quantity
, optional) – Gravitational constant to use. Defaults togravitational_constant
.kwargs (
dict
) – Additional keyword arguments passed tocompute_enclosed_mass()
.
- Returns:
v_esc – Escape velocity at each input radius, with appropriate units.
- Return type:
Example
import numpy as np from pisces.profiles.density import ( HernquistDensityProfile, ) profile = HernquistDensityProfile( rho_0=1.0, r_s=5.0 ) r = np.logspace(-1, 2, 50) # kpc v_esc = profile.compute_escape_velocity( r, units="km/s" ) print(v_esc)