@@ -287,46 +287,28 @@ def test__convergence_2d_from__nfw_ell():
287287 assert convergence == pytest .approx (1.388511 , 1e-3 )
288288
289289
290- # def test__potential_2d_from():
291- # nfw = ag.mp.NFWSph(centre=(0.3, 0.2), kappa_s=2.5, scale_radius=4.0)
292- #
293- # potential = nfw.potential_2d_from(grid=ag.Grid2DIrregular([[0.1875, 0.1625]]))
294- #
295- # assert potential == pytest.approx(0.03702, 1e-3)
296- #
297- # nfw = ag.mp.NFWSph(centre=(0.3, 0.2), kappa_s=2.5, scale_radius=4.0)
298- #
299- # potential = nfw.potential_2d_from(grid=ag.Grid2DIrregular([[0.1875, 0.1625]]))
300- #
301- # assert potential == pytest.approx(0.03702, 1e-3)
302- #
303- # nfw = ag.mp.NFW(
304- # centre=(0.3, 0.2),
305- # ell_comps=(0.03669, 0.172614),
306- # kappa_s=2.5,
307- # scale_radius=4.0,
308- # )
309- #
310- # potential = nfw.potential_2d_from(grid=ag.Grid2DIrregular([[0.1625, 0.1625]]))
311- #
312- # assert potential == pytest.approx(0.05380, 1e-3)
313- #
314- # nfw_spherical = ag.mp.NFWSph(centre=(0.3, 0.2), kappa_s=2.5, scale_radius=4.0)
315- # nfw_elliptical = ag.mp.NFW(
316- # centre=(0.3, 0.2),
317- # ell_comps=(0.0, 0.0),
318- # kappa_s=2.5,
319- # scale_radius=4.0,
320- # )
321- #
322- # potential_spherical = nfw_spherical.potential_2d_from(
323- # grid=ag.Grid2DIrregular([[0.1875, 0.1625]])
324- # )
325- # potential_elliptical = nfw_elliptical.potential_2d_from(
326- # grid=ag.Grid2DIrregular([[0.1875, 0.1625]])
327- # )
328- #
329- # assert potential_spherical == pytest.approx(potential_elliptical, 1e-3)
290+ def test__potential_2d_from__nfw_sph ():
291+ nfw = ag .mp .NFWSph (centre = (0.3 , 0.2 ), kappa_s = 2.5 , scale_radius = 4.0 )
292+
293+ potential = nfw .potential_2d_from (grid = ag .Grid2DIrregular ([[0.1875 , 0.1625 ]]))
294+
295+ assert potential == pytest .approx (0.148108 , 1e-3 )
296+
297+
298+ def test__potential_2d_from__elliptical_reduces_to_spherical ():
299+ # At zero ellipticity the elliptical NFW (MGE potential) must match the
300+ # spherical NFW (analytic potential) — a cross-check of two independent
301+ # implementations.
302+ spherical = ag .mp .NFWSph (centre = (0.3 , 0.2 ), kappa_s = 2.5 , scale_radius = 4.0 )
303+ elliptical = ag .mp .NFW (
304+ centre = (0.3 , 0.2 ), ell_comps = (0.0 , 0.0 ), kappa_s = 2.5 , scale_radius = 4.0
305+ )
306+
307+ grid = ag .Grid2DIrregular ([[0.1875 , 0.1625 ]])
308+
309+ assert elliptical .potential_2d_from (grid = grid ) == pytest .approx (
310+ spherical .potential_2d_from (grid = grid ).array , 1e-3
311+ )
330312
331313
332314def test__shear_yx_2d_from__nfw_sph_config_1 ():
0 commit comments