Conversation
…ius_and_core_radius_for_duffy
…file to AbstractgNFW in cnfw.py
There was a problem hiding this comment.
Pull request overview
This PR adds support for a spherical cored NFW (cNFW) mass profile and a corresponding Ludlow-based mass–concentration–radius mapping, together with tests and prior configuration. The new profile is wired into the existing dark-matter mass profile API and cosmology utilities.
Changes:
- Introduces a
cNFWSphmass profile with analytic deflection formula and placeholder convergence/potential methods. - Adds
cNFWMCRLudlowSphpluskappa_s_scale_radius_and_core_radius_for_ludlowto derive cNFW parameters fromM200using a Penarrubia-based mass–concentration relation. - Wires the new classes into
autogalaxy.profiles.mass.darkandautogalaxy.profiles.mass, adds YAML priors, and creates tests validating deflections and consistency with existing NFW MCR machinery.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
test_autogalaxy/profiles/mass/dark/test_nfw_mcr.py |
Adds a cored-NFW MCR test mirroring existing NFW MCR tests, and tweaks a comment around the consistency check. |
test_autogalaxy/profiles/mass/dark/test_cnfw.py |
Adds unit tests for cNFWSph deflections, convergence, and potential at a specific radius. |
autogalaxy/profiles/mass/dark/mcr_util.py |
Introduces kappa_s_scale_radius_and_core_radius_for_ludlow to compute (kappa_s, scale_radius, core_radius) from M200 using Ludlow cosmology plus a Penarrubia-style mass–concentration relation. |
autogalaxy/profiles/mass/dark/cnfw_mcr.py |
Implements cNFWMCRLudlowSph that wraps the MCR utility and instantiates a cNFWSph with derived parameters. |
autogalaxy/profiles/mass/dark/cnfw.py |
Adds the cNFWSph cored NFW spherical profile with its analytic radial deflection, helper functions F_func / dev_F_func, and stubbed convergence/potential methods. |
autogalaxy/profiles/mass/dark/__init__.py |
Exposes cNFWSph and cNFWMCRLudlowSph in the dark-profile public API. |
autogalaxy/profiles/mass/__init__.py |
Re-exports cNFWSph and cNFWMCRLudlowSph at the higher-level mass API namespace. |
autogalaxy/config/priors/mass/dark/cnfw_mcr.yaml |
Defines sampling priors for cNFWMCRLudlowSph, including mass_at_200, f_c, and redshifts. |
autogalaxy/config/priors/mass/dark/cnfw.yaml |
Adds priors for the direct cNFWSph parameters kappa_s, scale_radius, and core_radius. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| mcr_penarrubia = ((f_c**2 * xp.log(1 + concentration / f_c) + (1 - 2 * f_c) * xp.log(1 + concentration)) / (1 + f_c)**2 | ||
| - concentration / ((1+concentration) * (1-f_c))) #mass concentration relation (Penarrubia+2012) | ||
|
|
||
| scale_radius_kpc = radius_at_200 / concentration # scale radius in kpc | ||
| rho_0 = mass_at_200 / (4 * xp.pi * scale_radius_kpc**3 * mcr_penarrubia) | ||
| kappa_s = rho_0 * scale_radius_kpc / critical_surface_density # kappa_s | ||
| scale_radius = scale_radius_kpc / kpc_per_arcsec # scale radius in arcsec | ||
| core_radius = f_c * scale_radius # core radius in arcsec |
There was a problem hiding this comment.
mcr_penarrubia and rho_0 use f_c in log(1 + concentration / f_c) and in a (1 - f_c) denominator, so f_c=0 (allowed by callers and priors) will produce divisions by zero / log(0) and NaNs; this function should guard against f_c<=0 (and f_c>=1 for the (1-f_c) term) or enforce a strictly positive, bounded prior for f_c.
| deflection_r = ( | ||
| factor | ||
| * (self.F_func(theta, self.scale_radius, xp=xp) - self.F_func(theta, self.core_radius, xp=xp) | ||
| - (self.scale_radius - self.core_radius) * self.dev_F_func(theta, self.scale_radius, xp=xp) | ||
| ) | ||
| / (theta * (self.scale_radius - self.core_radius)**2) | ||
| ) |
There was a problem hiding this comment.
The deflection formula divides by (self.scale_radius - self.core_radius)**2, so if scale_radius equals core_radius this will raise a division-by-zero error; consider either constraining these parameters so they cannot coincide (e.g. via priors / validation) or handling the degenerate scale_radius == core_radius limit explicitly.
|
Other than deleting all the commented out code flagged by copilot above, I'm happy for you to go ahead and merge this. Its worth reading through copilots suggestions, but I dont think any need doing in order to make this mergeable. |
Inclusing of the cored NFW in profiles/mass/dark/ together with a cored NFW msr calculation (including a new function in msr_util).