Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions autogalaxy/profiles/mass/dark/nfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,18 @@ def deflections_2d_via_analytic_from(
self.radial_grid_from(grid=grid, xp=xp, **kwargs).array,
)

deflection_grid = xp.multiply(
(4.0 * self.kappa_s * self.scale_radius / eta),
self.deflection_func_sph(grid_radius=eta, xp=xp),
# Guard r=0: the deflection at the centre of a spherical profile is exactly
# zero by symmetry, but the analytic form here divides by eta and calls
# arccosh(1/r) which both blow up at the origin.
eta_safe = xp.where(eta < 1e-6, 1e-6, eta)

deflection_grid = xp.where(
eta < 1e-6,
0.0,
xp.multiply(
(4.0 * self.kappa_s * self.scale_radius / eta_safe),
self.deflection_func_sph(grid_radius=eta_safe, xp=xp),
),
)

return self._cartesian_grid_via_radial_from(
Expand Down
Loading