Skip to content

Commit

Permalink
Use Poisson's equation for the density
Browse files Browse the repository at this point in the history
  • Loading branch information
jobovy committed Sep 24, 2013
1 parent b6c77f1 commit 71469a7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions galpy/potential_src/Potential.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def zforce(self,R,z,phi=0.,t=0.):
except AttributeError:
raise PotentialError("'_zforce' function not implemented for this potential")

def dens(self,R,z,phi=0.,t=0.):
def dens(self,R,z,phi=0.,t=0.,_forcepoisson=False):
"""
NAME:
dens
Expand All @@ -128,9 +128,14 @@ def dens(self,R,z,phi=0.,t=0.):
2010-08-08 - Written - Bovy (NYU)
"""
try:
if _forcepoisson: raise AttributeError #Hack!
return self._amp*self._dens(R,z,phi=phi,t=t)
except AttributeError:
raise PotentialError("'_dens' function not implemented for this potential")
#Use the Poisson equation to get the density
return (-self.Rforce(R,z,phi=phi,t=t)/R
+self.R2deriv(R,z,phi=phi,t=t)
+self.phi2deriv(R,z,phi=phi,t=t)/R**2.
+self.z2deriv(R,z,phi=phi,t=t))/4./nu.pi

def R2deriv(self,R,Z,phi=0.,t=0.):
"""
Expand Down

0 comments on commit 71469a7

Please sign in to comment.