get_integrator#

gala.integrate.get_integrator(name)[source]#

Get an integrator class from a string name.

This function allows you to specify an integrator by its string name instead of directly importing the class.

Parameters:
namestr or Integrator class

The name of the integrator (case-insensitive) or an integrator class. If an integrator class is passed in, it is returned unchanged. Valid integrator names are: ‘leapfrog’, ‘dopri853’, ‘dop853’, ‘rk5’, ‘ruth4’.

Returns:
integrator_clsIntegrator class

The integrator class corresponding to the input name.

Examples

Get an integrator class by name:

>>> from gala.integrate import get_integrator
>>> LeapfrogIntegrator = get_integrator('leapfrog')
>>> LeapfrogIntegrator
<class 'gala.integrate.pyintegrators.leapfrog.LeapfrogIntegrator'>

Use with potential integration:

>>> import gala.potential as gp
>>> pot = gp.HernquistPotential(m=1e11, c=10, units='galactic')
>>> w0 = gd.PhaseSpacePosition(pos=[10,0,0], vel=[0,175,0])
>>> orbit = gp.Hamiltonian(pot).integrate_orbit(
...     w0, dt=1., n_steps=1000, Integrator='leapfrog'
... )

If you pass in an integrator class, it is returned unchanged:

>>> from gala.integrate import LeapfrogIntegrator
>>> get_integrator(LeapfrogIntegrator) is LeapfrogIntegrator
True