# Source code for galpy.potential.DehnenSmoothWrapperPotential

###############################################################################
#   DehnenSmoothWrapperPotential.py: Wrapper to smoothly grow a potential
###############################################################################
from .WrapperPotential import parentWrapperPotential
from ..util import conversion
[docs]class DehnenSmoothWrapperPotential(parentWrapperPotential):
"""Potential wrapper class that implements the growth of a gravitational potential following Dehnen (2000) <http://adsabs.harvard.edu/abs/2000AJ....119..800D>__. The amplitude A applied to a potential wrapped by an instance of this class is changed as

.. math::

A(t) = amp\\,\\left(\\frac{3}{16}\\xi^5-\\frac{5}{8}\\xi^3+\\frac{15}{16}\\xi+\\frac{1}{2}\\right)

where

.. math::

\\xi = \\begin{cases}
-1 & t < t_\\mathrm{form}\\\\
\\end{cases}

if decay=True, the amplitude decays rather than grows as decay = 1 - grow.
"""
ro=None,vo=None):
"""
NAME:

__init__

PURPOSE:

initialize a DehnenSmoothWrapper Potential

INPUT:

amp - amplitude to be applied to the potential (default: 1.)

pot - Potential instance or list thereof; the amplitude of this will be grown by this wrapper

tform - start of growth (can be a Quantity)

tsteady - time from tform at which the potential is fully grown (default: -tform/2, st the perturbation is fully grown at tform/2; can be a Quantity)

decay= (False) if True, decay the amplitude instead of growing it (as 1-grow)

OUTPUT:

(none)

HISTORY:

2017-06-26 - Started - Bovy (UofT)

2018-10-07 - Added 'decay' option - Bovy (UofT)

"""
tform= conversion.parse_time(tform,ro=self._ro,vo=self._vo)
self._tform= tform
else:
self._grow= not decay
self.hasC= True
self.hasC_dxdv= True

def _smooth(self,t):
#Calculate relevant time
if t < self._tform:
smooth= 0.