MilkyWayPotential¶
-
class
gala.potential.potential.
MilkyWayPotential
(units=<UnitSystem (kpc, Myr, solMass, rad)>, disk=None, halo=None, bulge=None, nucleus=None)[source]¶ Bases:
gala.potential.potential.CCompositePotential
A simple mass-model for the Milky Way consisting of a spherical nucleus and bulge, a Miyamoto-Nagai disk, and a spherical NFW dark matter halo.
The disk model is taken from Bovy (2015) - if you use this potential, please also cite that work.
Default parameters are fixed by fitting to a compilation of recent mass measurements of the Milky Way, from 10 pc to ~150 pc.
Parameters: - units :
UnitSystem
(optional) Set of non-reducable units that specify (at minimum) the length, mass, time, and angle units.
- disk : dict (optional)
Parameters to be passed to the
MiyamotoNagaiPotential
.- bulge : dict (optional)
Parameters to be passed to the
HernquistPotential
.- halo : dict (optional)
Parameters to be passed to the
NFWPotential
.- nucleus : dict (optional)
Parameters to be passed to the
HernquistPotential
.- Note: in subclassing, order of arguments must match order of potential
- components added at bottom of init.
Attributes Summary
mass_enclosed
(q, t)Estimate the mass enclosed within the given position by assuming the potential is spherical. parameters
units
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. clear
()copy
()density
(q[, t])Compute the density value at the given position(s). energy
(q[, t])Compute the potential energy at the given position(s). fromkeys
(S[, v])If not specified, the value defaults to None. get
(k[,d])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
items
()keys
()move_to_end
Move an existing element to the end (or beginning if last==False). plot_contours
(grid[, filled, ax, labels, …])Plot equipotentials contours. plot_density_contours
(grid[, filled, ax, …])Plot density contours. pop
(k[,d])value. popitem
()Pairs are returned in LIFO order if last is true or FIFO order if false. save
(f)Save the potential to a text file. setdefault
(k[,d])to_latex
()total_energy
(x, v)Compute the total energy (per unit mass) of a point in phase-space in this potential. update
([E, ]**F)If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k] value
(*args, **kwargs)values
()Attributes Documentation
-
mass_enclosed
(q, t)¶ Estimate the mass enclosed within the given position by assuming the potential is spherical. This is not so good!
Parameters: - q : array_like, numeric
Position to compute the mass enclosed.
-
parameters
¶
-
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).
Parameters: - q :
PhaseSpacePosition
,Quantity
, array_like Position to compute the acceleration at.
Returns: - acc :
Quantity
The acceleration. Will have the same shape as the input position array,
q
.
- q :
-
circular_velocity
(q, t=0.0)¶ Estimate the circular velocity at the given position assuming the potential is spherical.
Parameters: - q : array_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:]
.
-
clear
() → None. Remove all items from od.¶
-
copy
() → a shallow copy of od¶
-
density
(q, t=0.0)¶ Compute the density value at the given position(s).
Parameters: - q :
PhaseSpacePosition
,Quantity
, array_like The position to compute the value of the potential. If the input position object has no units (i.e. is an
ndarray
), it is assumed to be in the same unit system as the potential.
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:]
.
- q :
-
energy
(q, t=0.0)¶ Compute the potential energy at the given position(s).
Parameters: - q :
PhaseSpacePosition
,Quantity
, array_like The position to compute the value of the potential. If the input position object has no units (i.e. is an
ndarray
), it is assumed to be in the same unit system as the potential.
Returns: - E :
Quantity
The potential energy per unit mass or value of the potential.
- q :
-
fromkeys
(S[, v]) → New ordered dictionary with keys from S.¶ If not specified, the value defaults to None.
-
get
(k[, d]) → D[k] if k in D, else d. d defaults to None.¶
-
gradient
(q, t=0.0)¶ Compute the gradient of the potential at the given position(s).
Parameters: - q :
PhaseSpacePosition
,Quantity
, array_like The position to compute the value of the potential. If the input position object has no units (i.e. is an
ndarray
), it is assumed to be in the same unit system as the potential.
Returns: - grad :
Quantity
The gradient of the potential. Will have the same shape as the input position.
- q :
-
hessian
(q, t=0.0)¶ Compute the Hessian of the potential at the given position(s).
Parameters: - q :
PhaseSpacePosition
,Quantity
, array_like The position to compute the value of the potential. If the input position object has no units (i.e. is an
ndarray
), it is assumed to be in the same unit system as the potential.
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.
- q :
-
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_kwargs : dict (optional)
Any extra keyword argumets to pass to the integrator class when initializing. Only works in non-Cython mode.
- cython_if_possible : bool (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
.
Returns: - orbit :
Orbit
- w0 :
-
items
() → a set-like object providing a view on D's items¶
-
keys
() → a set-like object providing a view on D's keys¶
-
move_to_end
()¶ Move an existing element to the end (or beginning if last==False).
Raises KeyError if the element does not exist. When last=True, acts like a fast version of self[key]=self.pop(key).
-
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: - grid : tuple
Coordinate grids or slice value for each dimension. Should be a tuple of 1D arrays or numbers.
- filled : bool (optional)
Use
contourf()
instead ofcontour()
. Default isTrue
.- ax : matplotlib.Axes (optional)
- labels : iterable (optional)
List of axis labels.
- subplots_kw : dict
kwargs passed to matplotlib’s subplots() function if an axes object is not specified.
- kwargs : dict
kwargs passed to either contourf() or plot().
Returns: - fig :
Figure
-
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: - grid : tuple
Coordinate grids or slice value for each dimension. Should be a tuple of 1D arrays or numbers.
- filled : bool (optional)
Use
contourf()
instead ofcontour()
. Default isTrue
.- ax : matplotlib.Axes (optional)
- labels : iterable (optional)
List of axis labels.
- subplots_kw : dict
kwargs passed to matplotlib’s subplots() function if an axes object is not specified.
- kwargs : dict
kwargs passed to either contourf() or plot().
Returns: - fig :
Figure
-
pop
(k[, d]) → v, remove specified key and return the corresponding¶ value. If key is not found, d is returned if given, otherwise KeyError is raised.
-
popitem
() → (k, v), return and remove a (key, value) pair.¶ Pairs are returned in LIFO order if last is true or FIFO order if false.
-
save
(f)¶ Save the potential to a text file. See
save()
for more information.Parameters: - f : str, file_like
A filename or file-like object to write the input potential object to.
-
setdefault
(k[, d]) → od.get(k,d), also set od[k]=d if k not in od¶
-
to_latex
()¶
-
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: - x : array_like, numeric
Position.
- v : array_like, numeric
Velocity.
-
update
([E, ]**F) → None. Update D from dict/iterable E and F.¶ If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
-
value
(*args, **kwargs)¶
-
values
() → an object providing a view on D's values¶
- units :