Interpolated spherical potential¶
The interpSphericalPotential
class provides a general interface to
generate interpolated instances of spherical potentials or lists of
such potentials. This interpolated potential can be used in any
function where other threedimensional galpy potentials can be
used. This includes functions that use C
to speed up
calculations.
The interpSphericalPotential
interpolates the radial force of a
spherical potential and determines the potential and its second
derivative from the base radialforce interpolation object. To set up
an interpSphericalPotential
instance, either provide it with a
function that returns the radial force or with a galpy
potential or list of
potentials, and also provide the radial interpolation grid in each case.
For example, to use a function that gives the radial force, do
>>> from galpy import potential
>>> ip= potential.interpSphericalPotential(rforce=lambda r: 1./r,
rgrid=numpy.geomspace(0.01,20,101),Phi0=0.)
which sets up an interpSphericalPotential
instance that has the
same radial force as the spherical LogarithmicHaloPotential
. If
you have a function that gives the enclosed mass within a given
radius, simply pass it divided by \(r^2\) to set up a
interpSphericalPotential
instance for this enclosedmass profile.
Note that the force function has to return the force in galpy
’s
internal units and it has to take the radius in internal units. For example,
if you have the enclosed mass in solar masses, divide it by the
following mass_conversion
factor
>>> from galpy.util import conversion
>>> mass_conversion= conversion.mass_in_msol(vo,ro)
where vo
and ro
are the usual unitconversion parameters (they cannot
be Quantities in this case, they need to be floats in km/s and kpc). To convert
the radius in kpc to/from internal units, simply divide/multiply by ro
. The radial
interpolation grid also specifies radii in internal units.
Alternatively, you can specify a galpy
potential or list of
potentials and (again) the radial interpolation grid, as for example,
>>> lp= LogarithmicHaloPotential(normalize=1.)
>>> ip= potential.interpSphericalPotential(rforce=lp,
rgrid=numpy.geomspace(0.01,20,101))
Note that, because the potential is defined through integration of the
(negative) radial force, we need to specify the potential at the
smallest grid point, which is done through the Phi0=
keyword in
the first example. When using a galpy
potential (or list), this
value is automatically determined.
Also note that the density of the potential is assumed to be zero outside of the final radial grid point. That is, the potential outside of the final grid point is \(GM/r\) where \(M\) is the mass within the final grid point. If during an orbit integration, the orbit strays outside of the interpolation grid, a warning is issued.
Warning
The density of a interpSphericalPotential
instance is assumed to be zero outside of the largest radial grid point.

class
galpy.potential.
interpSphericalPotential
(self, rforce=None, rgrid=numpy.geomspace(0.01, 20, 101), Phi0=None, ro=None, vo=None)[source]¶ Class that interpolates a spherical potential on a grid

__init__
(self, rforce=None, rgrid=numpy.geomspace(0.01, 20, 101), Phi0=None, ro=None, vo=None)[source]¶ NAME:
__init__PURPOSE:
initialize an interpolated, spherical potentialINPUT:
rforce= (None) Either a) function that gives the radial force (in internal units) as a function of r (in internal units) or b) a galpy Potential instance or list thereof
rgrid= (numpy.geomspace(0.01,20,101)) radial grid in internal units on which to evaluate the potential for interpolation (note that beyond rgrid[1], the potential is extrapolated as GM(<rgrid[1])/r)
Phi0= (0.) value of the potential at rgrid[0] in internal units (only necessary when rforce is a function, for galpy potentials automatically determined)
ro=, vo= distance and velocity scales for translation into internal units (default from configuration file)
OUTPUT:
(none)HISTORY:
20200713  Written  Bovy (UofT)
