fix(mass): convergence_func on PowerLawBroken, PowerLawMultipole, cNFW family#467
Merged
Conversation
…W family Follow-up to #466 (dPIE convergence_func). Adds the abstract convergence_func hook to the three mass-profile families that define convergence_2d_from but never overrode convergence_func, so radial mass integration (mass_integral -> mass_angular_within_circle_from -> Einstein radius) and MGE three_D=False potential decomposition no longer raise NotImplementedError. PowerLawBroken's MGE potential is incompatible with its piecewise convergence, so potential_2d_from now raises an explanatory NotImplementedError. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Merged
1 task
Collaborator
Author
|
Workspace PR: PyAutoLabs/autolens_workspace_test#136 |
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
Follow-up to #466, which added
convergence_functo the dPIE family. A planning-time audit flagged ~12 more profiles; on inspection most already inherit a workingconvergence_func(DevVaucouleurs, Exponential, GaussianGradient, SersicGradient, the NFW MCR variants). Three families genuinely lacked it and are reachable via radial mass integration (mass_integral→mass_angular_within_circle_from→ Einstein radius) and/or MGEthree_D=Falsepotential decomposition, where the abstractconvergence_funcraisedNotImplementedError:_convergenceradial helper shared byconvergence_2d_fromand a newconvergence_func.convergence_funcreturns the zero monopole (a pure multipole encloses zero net azimuthally-averaged mass).convergence_funcreuses the MGE-of-3D-density decomposition radially; q-independent likeNFW.convergence_func.Separately,
PowerLawBroken.potential_2d_fromnow raises a clearNotImplementedError. Its MGE potential decomposition integrates the convergence along a complex contour, which requires an analytic convergence; the broken power law's convergence is piecewise (kink atbreak_radius) so the result was numerically invalid (~1e7). It already raisedNotImplementedErrorbefore this PR (via the missingconvergence_func); this makes the failure explicit and documented. Convergence, deflections,convergence_func, and the Einstein-radius / enclosed-mass integrals remain correct.API Changes
Added
convergence_funcoverrides onPowerLawBroken,PowerLawBrokenSph(inherited),PowerLawMultipole, and thecNFWfamily (cNFWSph+ MCR variants inherit).PowerLawBroken._convergenceis a new private radial helper.PowerLawBroken.potential_2d_fromnow raisesNotImplementedErrorexplicitly (it was already non-functional). No signatures of existing public methods changed. See full details below.Test Plan
python -m pytest test_autogalaxy/profiles/mass/— 413 passedtest_power_law_broken.py,test_power_law_multipole.py,test_cnfw.py(convergence_func matches radial helper / zero monopole / q-independence; mass integral runs; potential raises)autolens_workspace_test/scripts/mass/{total,dark}.py: convergence_func enclosed-mass cross-check (mass_angular = πR·α) PASS for PowerLawBrokenSph (rel 1.7e-11), cNFWSph (rel 1.5e-4), PowerLawMultipole (0); cNFW/cNFWSph self-consistency all PASSFull API Changes (for automation & release notes)
Added
PowerLawBroken.convergence_func(grid_radius, xp=np)— radial κ(r); inherited byPowerLawBrokenSphPowerLawBroken._convergence(radii, xp=np)— private radial helper shared withconvergence_2d_fromPowerLawMultipole.convergence_func(grid_radius, xp=np)— returns zero (zero monopole of a pure multipole)cNFW.convergence_func(grid_radius, xp=np)— MGE-of-3D-density radial convergence; inherited bycNFWSph,cNFWMCRScatterLudlow(Sph),cNFWMCRLudlow(Sph)Changed Behaviour
PowerLawBroken.potential_2d_from/PowerLawBrokenSphnow raiseNotImplementedErrorwith an explanatory message (the MGE potential is numerically invalid for the profile's piecewise convergence). Convergence, deflections, and Einstein-radius integrals are unaffected.🤖 Generated with Claude Code