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=(-4.605170185988091, 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)

Class that interpolates a given potential on a grid for fast orbit integration

__init__(RZPot=None, rgrid=(-4.605170185988091, 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)

NAME:

__init__

PURPOSE:

Initialize an interpRZPotential instance

INPUT:

RZPot - RZPotential to be interpolated

rgrid - R grid to be given to linspace as in rs= linspace(*rgrid)

zgrid - z grid to be given to linspace as in zs= linspace(*zgrid)

logR - if True, rgrid is in the log of R so logrs= linspace(*rgrid)

interpPot, interpRforce, interpzforce, interpDens,interpvcirc, interpepifreq, interpverticalfreq, interpdvcircdr= if True, interpolate these functions

use_c= use C to speed up the calculation of the grid

enable_c= enable use of C for interpolations

zsym= if True (default), the potential is assumed to be symmetric around z=0 (so you can use, e.g., zgrid=(0.,1.,101)).

numcores= if set to an integer, use this many cores (only used for vcirc, dvcircdR, epifreq, and verticalfreq; NOT NECESSARILY FASTER, TIME TO MAKE SURE)

ro=, vo= distance and velocity scales for translation into internal units (default from configuration file)

OUTPUT:

instance

HISTORY:

2010-07-21 - Written - Bovy (NYU)

2013-01-24 - Started with new implementation - Bovy (IAS)