MN3ExponentialDiskPotential#

class gala.potential.potential.MN3ExponentialDiskPotential(m, h_R, h_z, positive_density=True, sech2_z=True, units=None, origin=None, R=None)[source]#

Bases: CPotentialBase

A sum of three Miyamoto-Nagai disk potentials that approximate the potential generated by a double exponential disk.

This model is taken from Smith et al. (2015) - if you use this potential class, please also cite that work.

As described in the above reference, this approximation has two options: (1) with the positive_density=True argument set, this density will be positive everywhere, but is only a good approximation of the exponential density within about 5 disk scale lengths, and (2) with positive_density=False, this density will be negative in some regions, but is a better approximation out to about 7 or 8 disk scale lengths.

Parameters:
mQuantity, numeric [mass]

Mass.

h_RQuantity, numeric [length]

Radial (exponential) scale length.

h_zQuantity, numeric [length]

If sech2_z=True, this is the scale height in a sech^2 vertical profile. If sech2_z=False, this is an exponential scale height.

unitsUnitSystem (optional)

Set of non-reducable units that specify (at minimum) the length, mass, time, and angle units.

originQuantity (optional)

The origin of the potential, the default being 0.

RRotation, 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.

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).

as_interop(package, **kwargs)

Interoperability with other Galactic dynamics packages

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).

get_three_potentials()

Return three MiyamotoNagaiPotential instances that represent the three internal components of this MN3 potential model

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)

Integrate an orbit in the current potential using the integrator class provided.

mass_enclosed(q, t)

Estimate the mass enclosed within the given position by assuming the potential is spherical.

plot_contours(grid[, t, filled, ax, labels, ...])

Plot equipotentials contours.

plot_density_contours(grid[, t, filled, ax, ...])

Plot density contours.

plot_rotation_curve(R_grid[, t, ax, labels])

Plot the rotation curve or circular velocity curve for this potential on the input grid of cylindrical radii.

replace_units(units)

Change the unit system of this potential.

replicate(**kwargs)

Return a copy of the potential instance with some parameter values changed.

save(f)

Save the potential to a text file.

to_galpy_potential([ro, vo])

to_latex()

Return a string LaTeX representation of this potential

to_sympy()

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

h_R = <PotentialParameter: h_R [length]>#
h_z = <PotentialParameter: h_z [length]>#
m = <PotentialParameter: m [mass]>#
ndim = 3#
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:
qPhaseSpacePosition, Quantity, array_like

Position to compute the acceleration at.

Returns:
accQuantity

The acceleration. Will have the same shape as the input position array, q.

as_interop(package, **kwargs)#

Interoperability with other Galactic dynamics packages

Parameters:
packagestr

The package to export the potential to. Currently supported packages are "galpy" and "agama".

kwargs

Any additional keyword arguments are passed to the interop function.

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:
vcircQuantity

Circular velocity at the given position(s). If the input position has shape q.shape, the output energy will have shape q.shape[1:].

density(q, t=0.0)#

Compute the density value at the given position(s).

Parameters:
qPhaseSpacePosition, 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:
densQuantity

The potential energy or value of the potential. If the input position has shape q.shape, the output energy will have shape q.shape[1:].

energy(q, t=0.0)#

Compute the potential energy at the given position(s).

Parameters:
qPhaseSpacePosition, 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:
EQuantity

The potential energy per unit mass or value of the potential.

get_three_potentials()[source]#

Return three MiyamotoNagaiPotential instances that represent the three internal components of this MN3 potential model

gradient(q, t=0.0)#

Compute the gradient of the potential at the given position(s).

Parameters:
qPhaseSpacePosition, 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:
gradQuantity

The gradient of the potential. Will have the same shape as the input position.

hessian(q, t=0.0)#

Compute the Hessian of the potential at the given position(s).

Parameters:
qPhaseSpacePosition, 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:
hessQuantity

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, an n_dim by n_dim array (matrix) for each position.

integrate_orbit(*args, **kwargs)#

Integrate an orbit in the current potential using the integrator class provided. Uses same time specification as Integrator() – see the documentation for gala.integrate for more information.

Parameters:
w0PhaseSpacePosition, array_like

Initial conditions.

IntegratorIntegrator (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.

store_allbool (optional)

Controls whether to store the phase-space position at all intermediate timesteps. Set to False to store only the final values (i.e. the phase-space position(s) at the final timestep). Default is True.

**time_spec

Specification of how long to integrate. See documentation for parse_time_specification.

Returns:
orbitOrbit
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, t=0.0, 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.

tquantity-like (optional)

The time to evaluate at.

filledbool (optional)

Use contourf() instead of contour(). Default is True.

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:
figFigure
plot_density_contours(grid, t=0.0, filled=True, ax=None, labels=None, subplots_kw={}, **kwargs)#

Plot density contours. Computes the density on a grid (specified by the array grid).

Warning

For 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.

tquantity-like (optional)

The time to evaluate at.

filledbool (optional)

Use contourf() instead of contour(). Default is True.

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:
figFigure
plot_rotation_curve(R_grid, t=0.0, ax=None, labels=None, **plot_kwargs)#

Plot the rotation curve or circular velocity curve for this potential on the input grid of cylindrical radii.

Parameters:
R_gridarray_like

A grid of radius values to compute the rotation curve at. This should be a one-dimensional grid.

tquantity-like (optional)

The time to evaluate at.

axmatplotlib.Axes (optional)
labelsiterable (optional)

List of axis labels. Set to False to disable adding labels.

plot_kwargsdict

kwargs passed to plot().

Returns:
figFigure
axAxes
replace_units(units)#

Change the unit system of this potential.

Parameters:
unitsUnitSystem

Set of non-reducable units that specify (at minimum) the

length, mass, time, and angle units.
replicate(**kwargs)#

Return a copy of the potential instance with some parameter values changed. This always produces copies of any parameter arrays.

Parameters:
**kwargs

All other keyword arguments are used to overwrite parameter values when making the copy.

Returns:
replicantPotentialBase subclass instance

The replicated potential.

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.

to_galpy_potential(ro=None, vo=None)#

Deprecated since version v1.8: This has been replaced by a more general interoperability framework.

Convert a Gala potential to a Galpy potential instance

Parameters:
roquantity-like (optional)
voquantity-like (optional)
classmethod to_latex()#

Return a string LaTeX representation of this potential

Returns:
latex_strstr

The latex expression as a Python string.

classmethod to_sympy()#

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)#