New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calculation of SCF expansion based on an N-body representation of the density #444
Conversation
Can you put the tests just in |
I've deleted test_SCFPotential.py and added the test to test_scf.py |
Codecov Report
@@ Coverage Diff @@
## master #444 +/- ##
=======================================
Coverage 99.78% 99.78%
=======================================
Files 183 183
Lines 25635 25711 +76
=======================================
+ Hits 25580 25656 +76
Misses 55 55
Continue to review full report at Codecov.
|
galpy/potential/SCFPotential.py
Outdated
|
||
r = numpy.sqrt(pos[0]**2+pos[1]**2+pos[2]**2) | ||
phi = numpy.arctan2(pos[1],pos[0]) | ||
costheta = pos[2]/r |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Astropy does not (yet) support the ufunc lpmv
, so dimensionless quantities need to be recast.
The following works on both normal and astropy Quantity arrays.
costheta = u.Quantity(pos[2]/r, copy=False).to_value(u.one)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To deal with positions given with units, we'll just have to apply the relevant decorator. I think probably the one used for the 2D potential functions should work?
galpy/potential/SCFPotential.py
Outdated
Cn= numpy.zeros((1,len(r),N,L,1)) | ||
for i in range(N): | ||
for j in range(L): | ||
Cn[0,:,i,j,0]= C[i][j]((r/a-1)/(r/a+1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise, eval_ gegenbauer
is not an astropy-supported ufunc.
galpy/potential/SCFPotential.py
Outdated
Ylm= numpy.nan_to_num(Ylm) | ||
|
||
C= gegenbauer(nn,2.*ll+1.5) | ||
Cn= C((r/a-1)/(r/a+1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise, eval_ gegenbauer
is not an astropy-supported ufunc.
galpy/potential/SCFPotential.py
Outdated
for j,ll in enumerate(l): | ||
for k,mm in enumerate(m[:j+1]): | ||
|
||
Plm= lpmv(mm,ll,costheta) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Astropy does not (yet) support the ufunc lpmv
, so dimensionless quantities need to be recast.
… use to speed up spherical_nbody calculation of coefficients
…mputing the associated Legendre polynomials (and other speed-ups)
Introduce SCF expansion for n-body simulations. Added two new functions in SCFPotential.py for calculating SCF coefficients from an n-body simulation:
-scf_compute_coeffs_spherical_nbody
-scf_compute_coeffs_nbody
Also include a test for the spherical case. Non-spherical test to be added soon.