Skip to content

Commit ec3f05c

Browse files
author
Niek Wielders
committed
xp=np in kappa_s_scale_radius_and_core_radius_for_duffy
1 parent e719e44 commit ec3f05c

3 files changed

Lines changed: 58 additions & 6 deletions

File tree

autogalaxy/profiles/mass/dark/cnfw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(
1212
centre: Tuple[float, float] = (0.0, 0.0),
1313
kappa_s: float = 0.05,
1414
scale_radius: float = 1.0,
15-
core_radius: float = 0.5,
15+
core_radius: float = 0.01,
1616
):
1717
"""
1818
Represents a spherical cored NFW density distribution

autogalaxy/profiles/mass/dark/mcr_util.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def kappa_s_and_scale_radius_for_duffy(mass_at_200, redshift_object, redshift_so
5858

5959
return kappa_s, scale_radius, radius_at_200
6060

61-
def kappa_s_scale_radius_and_core_radius_for_duffy(mass_at_200, f_c, redshift_object, redshift_source):
61+
def kappa_s_scale_radius_and_core_radius_for_duffy(mass_at_200, f_c, redshift_object, redshift_source, xp=np):
6262
"""
6363
Computes the AutoGalaxy cNFW parameters (kappa_s, scale_radius, core_radius) for an NFW halo of the given
6464
mass, enforcing the Penarrubia '12 mass-concentration relation.
@@ -87,7 +87,7 @@ def kappa_s_scale_radius_and_core_radius_for_duffy(mass_at_200, f_c, redshift_ob
8787
kpc_per_arcsec = cosmology.kpc_per_arcsec_from(redshift=redshift_object)
8888

8989
radius_at_200 = (
90-
mass_at_200 / (200.0 * cosmic_average_density * (4.0 * np.pi / 3.0))
90+
mass_at_200 / (200.0 * cosmic_average_density * (4.0 * xp.pi / 3.0))
9191
) ** (
9292
1.0 / 3.0
9393
) # r200
@@ -97,11 +97,11 @@ def kappa_s_scale_radius_and_core_radius_for_duffy(mass_at_200, f_c, redshift_ob
9797
concentration = coefficient * (mass_at_200 / 2.952465309e12) ** (
9898
-0.084
9999
) # mass-concentration relation. (Duffy+2008)
100-
mass_concentration_relation = ((f_c**2 * np.log(1 + concentration / f_c) + (1 - 2 * f_c) * np.log(1 + concentration)) / (1 + f_c)**2
100+
mass_concentration_relation = ((f_c**2 * xp.log(1 + concentration / f_c) + (1 - 2 * f_c) * xp.log(1 + concentration)) / (1 + f_c)**2
101101
- concentration / ((1+concentration) * (1-f_c))) #mass concentration relation (Penarrubia+2012)
102102

103103
scale_radius_kpc = radius_at_200 / concentration # scale radius in kpc
104-
rho_0 = mass_at_200 / (4 * np.pi * scale_radius_kpc**3 * mass_concentration_relation)
104+
rho_0 = mass_at_200 / (4 * xp.pi * scale_radius_kpc**3 * mass_concentration_relation)
105105
kappa_s = rho_0 * scale_radius_kpc / critical_surface_density # kappa_s
106106
scale_radius = scale_radius_kpc / kpc_per_arcsec # scale radius in arcsec
107107
core_radius = f_c * scale_radius # core radius in arcsec

test_autogalaxy/profiles/mass/dark/test_nfw_mcr.py

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test__mass_and_concentration_consistent_with_normal_nfw():
3838
redshift_profile=0.6, redshift_source=2.5, cosmology=cosmology
3939
)
4040

41-
# We uare using the NFWTruncatedSph to check the mass gives a conosistnt kappa_s, given certain radii.
41+
# We are using the NFWTruncatedSph to check the mass gives a consistnt kappa_s, given certain radii.
4242

4343
assert mass_at_200_via_kappa_s == mass_at_200_via_mass
4444
assert concentration_via_kappa_s == concentration_via_mass
@@ -53,6 +53,58 @@ def test__mass_and_concentration_consistent_with_normal_nfw():
5353

5454
assert mp.scale_radius == pytest.approx(0.273382, 1.0e-4)
5555

56+
# def test__mass_and_concentration_consistent_with_cored_nfw():
57+
#
58+
# from autogalaxy.cosmology.model import FlatLambdaCDMWrap
59+
#
60+
# cosmology = FlatLambdaCDMWrap(H0=70.0, Om0=0.3)
61+
#
62+
# mp = ag.mp.cNFWMCRDuffySph(
63+
# centre=(1.0, 2.0),
64+
# mass_at_200=1.0e9,
65+
# f_c=0.01,
66+
# redshift_object=0.6,
67+
# redshift_source=2.5,
68+
# )
69+
#
70+
# mass_at_200_via_mass = mp.mass_at_200_solar_masses(
71+
# redshift_object=0.6, redshift_source=2.5, cosmology=cosmology
72+
# )
73+
# concentration_via_mass = mp.concentration(
74+
# redshift_profile=0.6, redshift_source=2.5, cosmology=cosmology
75+
# )
76+
#
77+
# cnfw_kappa_s = ag.mp.cNFWSph(
78+
# centre=(1.0, 2.0),
79+
# kappa_s=mp.kappa_s,
80+
# scale_radius=mp.scale_radius,
81+
# core_radius=mp.core_radius,
82+
# )
83+
#
84+
# mass_at_200_via_kappa_s = cnfw_kappa_s.mass_at_200_solar_masses(
85+
# redshift_object=0.6, redshift_source=2.5, cosmology=cosmology
86+
# )
87+
# concentration_via_kappa_s = cnfw_kappa_s.concentration(
88+
# redshift_profile=0.6, redshift_source=2.5, cosmology=cosmology
89+
# )
90+
#
91+
# # We are using the NFWTruncatedSph to check the mass gives a consistnt kappa_s, given certain radii.
92+
#
93+
# assert mass_at_200_via_kappa_s == mass_at_200_via_mass
94+
# assert concentration_via_kappa_s == concentration_via_mass
95+
#
96+
# assert mp.centre == (1.0, 2.0)
97+
#
98+
# assert mp.axis_ratio() == 1.0
99+
#
100+
# assert mp.angle() == 0.0
101+
#
102+
# assert mp.inner_slope == 1.0
103+
#
104+
# assert mp.scale_radius == pytest.approx(0.273382, 1.0e-4)
105+
#
106+
# assert mp.core_radius == pytest.approx(0.00273382, 1.0e-6)
107+
56108

57109
def test__mass_and_concentration_consistent_with_normal_nfw__scatter_0():
58110

0 commit comments

Comments
 (0)