Interpolated axisymmetric potential¶
The interpRZPotential class provides a general interface to
generate interpolated instances of general three-dimensional,
axisymmetric potentials or lists of such potentials. This interpolated
potential can be used in any function where other three-dimensional
galpy potentials can be used. This includes functions that use C
to speed up calculations, if the interpRZPotential instance was
set up with enable_c=True. Initialize as
>>> from galpy import potential
>>> ip= potential.interpRZPotential(potential.MWPotential,interpPot=True)
which sets up an interpolation of the potential itself only. The
potential and all different forces and functions (dens, vcirc,
epifreq, verticalfreq, dvcircdR) are interpolated
separately and one needs to specify that these need to be interpolated
separately (so, for example, one needs to set interpRforce=True to
interpolate the radial force, or interpvcirc=True to interpolate
the circular velocity).
When points outside the grid are requested within the python code, the
instance will fall back on the original (non-interpolated)
potential. However, when the potential is used purely in C, like
during orbit integration in C or during action–angle evaluations
in C, there is no way for the potential to fall back onto the
original potential and nonsense or NaNs will be returned. Therefore,
when using interpRZPotential in C, one must make sure that the
whole relevant part of the (R,z) plane is covered. One more time:
Warning
When an interpolated potential is used purely in C, like during orbit integration in C or during action–angle evaluations in C, there is no way for the potential to fall back onto the original potential and nonsense or NaNs will be returned. Therefore, when using interpRZPotential in C, one must make sure that the whole relevant part of the (R,z) plane is covered.
- class galpy.potential.interpRZPotential(RZPot=None, rgrid=(np.float64(-4.605170185988091), np.float64(2.995732273553991), 101), zgrid=(0.0, 1.0, 101), logR=True, interpPot=False, interpRforce=False, interpzforce=False, interpDens=False, interpvcirc=False, interpdvcircdr=False, interpepifreq=False, interpverticalfreq=False, ro=None, vo=None, use_c=False, enable_c=False, zsym=True, numcores=None)[source]¶
Class that interpolates a given potential on a grid for fast orbit integration
- __init__(RZPot=None, rgrid=(np.float64(-4.605170185988091), np.float64(2.995732273553991), 101), zgrid=(0.0, 1.0, 101), logR=True, interpPot=False, interpRforce=False, interpzforce=False, interpDens=False, interpvcirc=False, interpdvcircdr=False, interpepifreq=False, interpverticalfreq=False, ro=None, vo=None, use_c=False, enable_c=False, zsym=True, numcores=None)[source]¶
Initialize an interpRZPotential instance.
- Parameters:
RZPot (RZPotential or a combined potential formed using addition (pot1+pot2+…)) – RZPotential to be interpolated.
rgrid (tuple, optional) – R grid to be given to linspace as in rs= linspace(*rgrid).
zgrid (tuple, optional) – z grid to be given to linspace as in zs= linspace(*zgrid).
logR (bool, optional) – If True, rgrid is in the log of R so logrs= linspace(*rgrid).
interpPot (bool, optional) – If True, interpolate the potential.
interpRforce (bool, optional) – If True, interpolate the radial force.
interpzforce (bool, optional) – If True, interpolate the vertical force.
interpDens (bool, optional) – If True, interpolate the density.
interpvcirc (bool, optional) – If True, interpolate the circular velocity.
interpdvcircdr (bool, optional) – If True, interpolate the derivative of the circular velocity with respect to R.
interpepifreq (bool, optional) – If True, interpolate the epicyclic frequency.
interpverticalfreq (bool, optional) – If True, interpolate the vertical frequency.
ro (float, optional) – Distance scale for translation into internal units (default from configuration file).
vo (float, optional) – Velocity scale for translation into internal units (default from configuration file).
use_c (bool, optional) – Use C to speed up the calculation of the grid.
enable_c (bool, optional) – Enable use of C for interpolations.
zsym (bool, optional) – If True (default), the potential is assumed to be symmetric around z=0 (so you can use, e.g., zgrid=(0.,1.,101)).
numcores (int, optional) – If set to an integer, use this many cores (only used for vcirc, dvcircdR, epifreq, and verticalfreq; NOT NECESSARILY FASTER, TIME TO MAKE SURE).
Notes
2010-07-21 - Written - Bovy (NYU)
2013-01-24 - Started with new implementation - Bovy (IAS)