fix: use analytic potential for truncated NFW - #564
Merged
Conversation
Jammy2211
marked this pull request as ready for review
August 9, 2026 18:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the MGE approximation in
NFWTruncatedSph.potential_2d_fromwith the exact analytic potential for the Baltz, Marshall & Oguri (2009) n=1 truncated NFW profile.Use a sixth-order small-radius series to avoid catastrophic cancellation in NumPy/JAX float32, retain a finite zero-centred potential convention, and correct the paper's arXiv identifier.
Fixes #563.
API Changes
NFWTruncatedSph.potential_2d_fromnow returns the analytic BMO potential instead of the previous MGE approximation.A reusable dimensionless analytic helper,
potential_func_sph_from, is added.See full details below.
Test Plan
pytest test_autogalaxy/profiles/mass/dark/test_nfw_truncated.py -q— 48 passedpytest test_autogalaxy/ -q— 1054 passedGate Record
PR creation was explicitly authorized despite unrelated PyAutoHeart RED reasons from another task's shared checkout:
PyAutoFit: 2 commit(s) behind originPyAutoGalaxy: on branch feature/point-source-light (not main)PyAutoGalaxy: 1 commit(s) behind originAfter CI passed, the human explicitly authorized merge. A fresh isolated-main Heart run removed all three RED reasons and reported
STALEonly because release-validation/install sidecars are unavailable in this web runtime.Full API Changes (for automation & release notes)
Added
autogalaxy.profiles.mass.dark.nfw_truncated.potential_func_sph_from(grid_radius, tau, xp=np)— evaluates the dimensionless analytic n=1 truncated-NFW lensing potential with stable small-radius handling.Changed Behaviour
autogalaxy.profiles.mass.dark.nfw_truncated.NFWTruncatedSph.potential_2d_from(grid, xp=np, **kwargs)— now uses the analytic BMO equation (18) potential rather than an MGE approximation; the paper convention sets the central additive constant to zero.Migration
Generated by the PyAutoLabs agent workflow.