From 69505ff89aedbb36f564977af3924aea7195e521 Mon Sep 17 00:00:00 2001 From: Jo Bovy Date: Fri, 2 Oct 2020 21:36:35 -0400 Subject: [PATCH] Implement TwoPowerSphericalPotential masses so they work for r=numpy.inf --- galpy/potential/TwoPowerSphericalPotential.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/galpy/potential/TwoPowerSphericalPotential.py b/galpy/potential/TwoPowerSphericalPotential.py index 1349e4a93..c903717a3 100644 --- a/galpy/potential/TwoPowerSphericalPotential.py +++ b/galpy/potential/TwoPowerSphericalPotential.py @@ -459,7 +459,7 @@ def _mass(self,R,z=0.,t=0.): 2019-11-20 - Written - Starkman (UofT) """ r= R if z is None else numpy.sqrt(R**2.+z**2.) - return (r/(r+self.a))**(3.-self.alpha)/(3.-self.alpha) + return 1./(1.+self.a/r)**(3.-self.alpha)/(3.-self.alpha) # written so it works for r=numpy.inf class DehnenCoreSphericalPotential(DehnenSphericalPotential): """Class that implements the Dehnen Spherical Potential from `Dehnen (1993) `_ with alpha=0 (corresponding to an inner core) @@ -657,7 +657,7 @@ def _mass(self,R,z=0.,t=0.): 2019-11-20 - Written - Starkman (UofT) """ r= R if z is None else numpy.sqrt(R**2.+z**2.) - return (r/(r+self.a))**3./3. + return 1./(1.+self.a/r)**3./3. # written so it works for r=numpy.inf class HernquistPotential(DehnenSphericalPotential): """Class that implements the Hernquist potential @@ -848,7 +848,7 @@ def _mass(self,R,z=0.,t=0.): 2014-01-29 - Written - Bovy (IAS) """ r= R if z is None else numpy.sqrt(R**2.+z**2.) - return (r/self.a)**2./2./(1.+r/self.a)**2. + return 1./(1.+self.a/r)**2./2. # written so it works for r=numpy.inf @kms_to_kpcGyrDecorator def _nemo_accpars(self,vo,ro): @@ -1074,7 +1074,7 @@ def _mass(self,R,z=0.,t=0.): 2014-01-29 - Written - Bovy (IAS) """ r= R if z is None else numpy.sqrt(R**2.+z**2.) - return r/self.a/(1.+r/self.a) + return 1./(1.+self.a/r) # written so it works for r=numpy.inf class NFWPotential(TwoPowerSphericalPotential): """Class that implements the NFW potential