Mixin to compute forces and second potential derivatives numerically¶

class
galpy.potential.
NumericalPotentialDerivativesMixin
(kwargs)[source]¶ Mixin to add numerical derivatives to a Potential class, use as, e.g.,
class PotWithNumericalDerivs(Potential,NumericalPotentialDerivativesMixin): def __init__(self,*args,**kwargs): NumericalPotentialDerivativesMixin.__init__(self,kwargs) # *not* **kwargs! # Remainder of initialization ... def _evaluate(self,R,z,phi=0.,t=0.): # Evaluate the potential # All forces and second derivatives then computed by NumericalPotentialDerivativesMixin
to add numerical derivatives to a new potential class
PotWithNumericalDerivs
that only implements the potential itself, but not the forces. The class may implement any of the forces or second derivatives, all nonimplemented forces/secondderivatives will be computed numerically by adding this MixinThe step used to compute the first (force) and second derivatives can be controlled at object instantiation by the keyword arguments
dR
,dz
,dphi
(for the forces; 1e8 default) anddR2
,dz2
, anddphi2
(for the second derivaives; 1e4 default)