NFWPotential¶
-
class
gala.potential.potential.
NFWPotential
(m, r_s, a=1, b=1, c=1, units=None, origin=None, R=None)¶ Bases:
gala.potential.potential.CPotentialBase
General Navarro-Frenk-White potential. Supports spherical, flattened, and triaxiality but the flattening is introduced into the potential, not the density, and can therefore lead to unphysical mass distributions. For a triaxial NFW potential that supports flattening in the density, see
gala.potential.LeeSutoTriaxialNFWPotential
.See also the alternate initializers:
NFWPotential.from_circular_velocity
andNFWPotential.from_M200_c
- Parameters
- m
Quantity
, numeric [mass] Scale mass.
- r_s
Quantity
, numeric [length] Scale radius.
- anumeric
Major axis scale.
- bnumeric
Intermediate axis scale.
- cnumeric
Minor axis scale.
- units
UnitSystem
(optional) Set of non-reducable units that specify (at minimum) the length, mass, time, and angle units.
- origin
Quantity
(optional) The origin of the potential, the default being 0.
- R
Rotation
, array_like (optional) A Scipy
Rotation
object or an array representing a rotation matrix that specifies a rotation of the potential. This is applied after the origin shift. Default is the identity matrix.
- m
Attributes Summary
Methods Summary
__call__
(q)Call self as a function.
acceleration
(q[, t])Compute the acceleration due to the potential at the given position(s).
circular_velocity
(q[, t])Estimate the circular velocity at the given position assuming the potential is spherical.
density
(q[, t])Compute the density value at the given position(s).
energy
(q[, t])Compute the potential energy at the given position(s).
from_M200_c
(M200, c[, rho_c, units, origin, R])Initialize an NFW potential from a virial mass,
M200
, and a concentration,c
.from_circular_velocity
(v_c, r_s[, a, b, c, …])Initialize an NFW potential from a circular velocity, scale radius, and reference radius for the circular velocity.
gradient
(q[, t])Compute the gradient of the potential at the given position(s).
hessian
(q[, t])Compute the Hessian of the potential at the given position(s).
integrate_orbit
(*args, **kwargs)Warning
This is now deprecated. Convenient orbit integration should
mass_enclosed
(q, t)Estimate the mass enclosed within the given position by assuming the potential is spherical.
plot_contours
(grid[, filled, ax, labels, …])Plot equipotentials contours.
plot_density_contours
(grid[, filled, ax, …])Plot density contours.
replace_units
(units)Change the unit system of this potential.
save
(f)Save the potential to a text file.
to_latex
()Return a string LaTeX representation of this potential
to_sympy
(v, p)Return a representation of this potential class as a sympy expression
total_energy
(x, v)Compute the total energy (per unit mass) of a point in phase-space in this potential.
value
(*args, **kwargs)Attributes Documentation
-
Wrapper
= None¶
-
a
= <gala.potential.common.PotentialParameter object>¶
-
b
= <gala.potential.common.PotentialParameter object>¶
-
c
= <gala.potential.common.PotentialParameter object>¶
-
m
= <gala.potential.common.PotentialParameter object>¶
-
ndim
= 3¶
-
r_s
= <gala.potential.common.PotentialParameter object>¶
-
units
¶
Methods Documentation
-
__call__
(q)¶ Call self as a function.
-
acceleration
(q, t=0.0)¶ Compute the acceleration due to the potential at the given position(s).
-
circular_velocity
(q, t=0.0)¶ Estimate the circular velocity at the given position assuming the potential is spherical.
- Parameters
- qarray_like, numeric
Position(s) to estimate the circular velocity.
- Returns
- vcirc
Quantity
Circular velocity at the given position(s). If the input position has shape
q.shape
, the output energy will have shapeq.shape[1:]
.
- vcirc
-
density
(q, t=0.0)¶ Compute the density value at the given position(s).
- Parameters
- Returns
- dens
Quantity
The potential energy or value of the potential. If the input position has shape
q.shape
, the output energy will have shapeq.shape[1:]
.
- dens
-
energy
(q, t=0.0)¶ Compute the potential energy at the given position(s).
- Parameters
- Returns
- E
Quantity
The potential energy per unit mass or value of the potential.
- E
-
static
from_M200_c
(M200, c, rho_c=None, units=None, origin=None, R=None)¶ Initialize an NFW potential from a virial mass,
M200
, and a concentration,c
.- Parameters
- M200
Quantity
, numeric [mass] Virial mass, or mass at 200 times the critical density,
rho_c
.- cnumeric
NFW halo concentration.
- rho_c
Quantity
, numeric [density] Critical density at z=0. If not specified, uses the default astropy cosmology to obtain this,
default_cosmology
.
- M200
-
static
from_circular_velocity
(v_c, r_s, a=1.0, b=1.0, c=1.0, r_ref=None, units=None, origin=None, R=None)¶ Initialize an NFW potential from a circular velocity, scale radius, and reference radius for the circular velocity.
For scale mass \(m_s\), scale radius \(r_s\), scaled reference radius \(u_{\rm ref} = r_{\rm ref}/r_s\):
\[\frac{G\,m_s}{r_s} = \frac{v_c^2}{u_{\rm ref}} \, \left[\frac{u_{\rm ref}}{1+u_{\rm ref}} - \frac{\ln(1+u_{\rm ref})}{u_{\rm ref}^2} \right]^{-1}\]- Parameters
- v_c
Quantity
, numeric [velocity] Circular velocity at the reference radius
r_ref
(see below).- r_s
Quantity
, numeric [length] Scale radius.
- anumeric
Major axis scale.
- bnumeric
Intermediate axis scale.
- cnumeric
Minor axis scale.
- r_ref
Quantity
, numeric [length] (optional) Reference radius at which the circular velocity is given. By default, this is assumed to be the scale radius,
r_s
.
- v_c
-
gradient
(q, t=0.0)¶ Compute the gradient of the potential at the given position(s).
- Parameters
- Returns
- grad
Quantity
The gradient of the potential. Will have the same shape as the input position.
- grad
-
hessian
(q, t=0.0)¶ Compute the Hessian of the potential at the given position(s).
- Parameters
- Returns
- hess
Quantity
The Hessian matrix of second derivatives of the potential. If the input position has shape
q.shape
, the output energy will have shape(q.shape[0],q.shape[0]) + q.shape[1:]
. That is, ann_dim
byn_dim
array (matrix) for each position.
- hess
-
integrate_orbit
(*args, **kwargs)¶ Warning
This is now deprecated. Convenient orbit integration should happen using the
gala.potential.Hamiltonian
class. With a static reference frame, you just need to pass your potential in to theHamiltonian
constructor.Integrate an orbit in the current potential using the integrator class provided. Uses same time specification as
Integrator.run()
– see the documentation forgala.integrate
for more information.- Parameters
- w0
PhaseSpacePosition
, array_like Initial conditions.
- Integrator
Integrator
(optional) Integrator class to use.
- Integrator_kwargsdict (optional)
Any extra keyword argumets to pass to the integrator class when initializing. Only works in non-Cython mode.
- cython_if_possiblebool (optional)
If there is a Cython version of the integrator implemented, and the potential object has a C instance, using Cython will be much faster.
- **time_spec
Specification of how long to integrate. See documentation for
parse_time_specification
.
- w0
- Returns
- orbit
Orbit
- orbit
-
mass_enclosed
(q, t)¶ Estimate the mass enclosed within the given position by assuming the potential is spherical. This is not so good!
- Parameters
- qarray_like, numeric
Position to compute the mass enclosed.
-
plot_contours
(grid, filled=True, ax=None, labels=None, subplots_kw={}, **kwargs)¶ Plot equipotentials contours. Computes the potential energy on a grid (specified by the array
grid
).Warning
Right now the grid input must be arrays and must already be in the unit system of the potential. Quantity support is coming…
- Parameters
- gridtuple
Coordinate grids or slice value for each dimension. Should be a tuple of 1D arrays or numbers.
- filledbool (optional)
Use
contourf()
instead ofcontour()
. Default isTrue
.- axmatplotlib.Axes (optional)
- labelsiterable (optional)
List of axis labels.
- subplots_kwdict
kwargs passed to matplotlib’s subplots() function if an axes object is not specified.
- kwargsdict
kwargs passed to either contourf() or plot().
- Returns
- fig
Figure
- fig
-
plot_density_contours
(grid, filled=True, ax=None, labels=None, subplots_kw={}, **kwargs)¶ Plot density contours. Computes the density on a grid (specified by the array
grid
).Warning
Right now the grid input must be arrays and must already be in the unit system of the potential. Quantity support is coming…
- Parameters
- gridtuple
Coordinate grids or slice value for each dimension. Should be a tuple of 1D arrays or numbers.
- filledbool (optional)
Use
contourf()
instead ofcontour()
. Default isTrue
.- axmatplotlib.Axes (optional)
- labelsiterable (optional)
List of axis labels.
- subplots_kwdict
kwargs passed to matplotlib’s subplots() function if an axes object is not specified.
- kwargsdict
kwargs passed to either contourf() or plot().
- Returns
- fig
Figure
- fig
-
replace_units
(units)¶ Change the unit system of this potential.
- Parameters
- units
UnitSystem
Set of non-reducable units that specify (at minimum) the
- length, mass, time, and angle units.
- units
-
save
(f)¶ Save the potential to a text file. See
save()
for more information.- Parameters
- fstr, file_like
A filename or file-like object to write the input potential object to.
-
classmethod
to_latex
()¶ Return a string LaTeX representation of this potential
- Returns
- latex_strstr
The latex expression as a Python string.
-
classmethod
to_sympy
(v, p)¶ Return a representation of this potential class as a sympy expression
- Returns
- exprsympy expression
- varsdict
A dictionary of sympy symbols used in the expression.
-
total_energy
(x, v)¶ Compute the total energy (per unit mass) of a point in phase-space in this potential. Assumes the last axis of the input position / velocity is the dimension axis, e.g., for 100 points in 3-space, the arrays should have shape (100,3).
- Parameters
- xarray_like, numeric
Position.
- varray_like, numeric
Velocity.
-
value
(*args, **kwargs)¶