Skip to content

Commit

Permalink
Move _call_internal to general isotropicsphericaldf, add some notes a…
Browse files Browse the repository at this point in the history
…bout sphericaldfs
  • Loading branch information
jobovy committed Sep 11, 2020
1 parent 8f7d069 commit d24cedc
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 25 deletions.
25 changes: 0 additions & 25 deletions galpy/df/isotropicHernquistdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,6 @@ def __init__(self,pot=None,ro=None,vo=None):
self._GMa = self._psi0*self._pot.a**2.
self._fEnorm= 1./numpy.sqrt(2.)/(2*numpy.pi)**3/self._GMa**1.5

def _call_internal(self,*args):
"""
NAME:
_call_internal
PURPOSE
Calculate the distribution function for an isotropic Hernquist
INPUT:
E,L,Lz - The energy, angular momemtum magnitude, and its z component (only E is used)
OUTPUT:
f(x,v) = f(E[x,v])
HISTORY:
2020-07 - Written - Lane (UofT)
"""
return self.fE(args[0])

def fE(self,E):
"""
NAME:
Expand Down
43 changes: 43 additions & 0 deletions galpy/df/sphericaldf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@
# - sphericaldf: superclass of all spherical DFs
# - isotropicsphericaldf: superclass of all isotropic spherical DFs
# - anisotropicsphericaldf: superclass of all anisotropic spherical DFs
#
# To implement a new DF do something like:
# - Inherit from isotropicsphericaldf for an isotropic DF and implement
# fE(self,E) which returns the DF as a function of E (see kingdf), then
# you should be set! You may also have to implement _vmax_at_r(self,pot,r)
# when the maximum velocity at a given position is less than the escape
# velocity
# - Inherit from anisotropicsphericaldf for an anisotropic DF, then you need
# to implement a bunch of functions:
# * _call_internal(self,*args,**kwargs): which returns the DF as a
# function of (E,L,Lz)
# * _sample_eta(self,n=1): to sample the velocity angle
# * _p_v_at_r(self,v,r): whcih returns p(v|r)
# constantbetadf is an example of this
#
# Note that we may have to re-think the implementation of anisotropic DFs to
# allow more general forms such as Osipkov-Merritt...
#
import numpy
import scipy.interpolate
from scipy import integrate, special
Expand Down Expand Up @@ -440,6 +458,31 @@ def __init__(self,pot=None,scale=None,ro=None,vo=None):
"""
sphericaldf.__init__(self,pot=pot,scale=scale,ro=ro,vo=vo)

def _call_internal(self,*args):
"""
NAME:
_call_internal
PURPOSE
Calculate the distribution function for an isotropic DF
INPUT:
E,L,Lz - The energy, angular momemtum magnitude, and its z component (only E is used)
OUTPUT:
f(x,v) = f(E[x,v])
HISTORY:
2020-07 - Written - Lane (UofT)
"""
return self.fE(args[0])

def _vmomentdensity(self,r,n,m):
if m%2 == 1 or n%2 == 1:
return 0.
Expand Down

0 comments on commit d24cedc

Please sign in to comment.