Skip to content

Feature/psuedo isothermal test#246

Merged
Jammy2211 merged 13 commits intoPyAutoLabs:mainfrom
Chocologism:feature/psuedo_isothermal_test
Oct 15, 2025
Merged

Feature/psuedo isothermal test#246
Jammy2211 merged 13 commits intoPyAutoLabs:mainfrom
Chocologism:feature/psuedo_isothermal_test

Conversation

@Chocologism
Copy link
Copy Markdown
Contributor

This PR is based on the C-language source code of Lenstool (lenstool/src/e_grad.c, lenstool/src/e_grad2.c, lenstool/src/e_gcpx.c, lenstool/src/e_g2cpx.c). The PIEMD (case (8)) and dPIEMD (case (81)) profiles have been faithfully translated into Python and integrated into PyAutoGalaxy, with details as follows:

  1. PIEMD and dPIEMD adopt the full elliptical expressions as in Lenstool, following Kassiola & Kovner (1993), and make use of the complex variable $I^*$ defined in their Equation 2.3.8. Under this formulation, ellipticity is introduced in the mass distribution rather than the potential. While the latter is mathematically convenient, it can result in unphysical "peanut-shaped" two-dimensional mass distributions at high ellipticity. The profiles implemented in this submission avoid such issues.

  2. All computations are fully analytic, without reliance on special functions or numerical integration, ensuring computational efficiency.

  3. Each step of the derivation has been worked out in detail on paper, and key results and computational steps are annotated in the corresponding sections of the code to ensure readability. The original complex arithmetic has been appropriately simplified using NumPy.

  4. Most of the variable names and function names from Lenstool have been retained for easy cross-reference and comparison.

  5. To distinguish from the existing dPIE in PyAutoLens, in new version it's renamed as dPIEP, indicating its use of pseudo-ellipticity in the potential rather than in the mass density. For consistency, the original lens strength parameter kappa_scale has been replaced by b0 (see in-code comments for justification). Under this reparameterization, a long-standing numerical issue in the original profile for vanishing core radii (ra = 0) has also been resolved.


I have thoroughly tested these profiles, and the following validations have been completed:

  1. When the ellipticity is set to zero, dPIEMD yields identical deflection angles, kappa maps, and lensed images as dPIEP. As ellipticity increases, the differences become more apparent: dPIEP shows a peanut-shaped kappa map, while dPIEMD retains an elliptical shape (convergence_2d_via_jacobian_from()).

  2. In the limiting case of $r_a = 0, r_s = 10^8$, dPIEMD degenerates to SIE, and shows nearly identical behavior to al.mp.Isothermal in terms of deflection angles, kappa maps, lensed images, and magnification maps.

  3. In the limiting case of $r_s = 10^8$, dPIEMD degenerates to PIEMD, with consistent results across all diagnostics.

  4. dPIEMDSph adopts a simplified and more efficient computational form (see code comments), and matches the behavior of SIS in comparative tests.


Remaining Issue:

The Hessians of PIEMD, dPIEMD, and dPIEMDSph are also analytically computed in Lenstool. In this update, I implemented these calculations via a function called analytical_hessian_2d_from(). However, this function has not replaced the default hessian_from method, as I am currently uncertain which implementation is preferable — there are some subtle differences between them.


@Jammy2211 Jammy2211 merged commit 9366083 into PyAutoLabs:main Oct 15, 2025
0 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants