Skip to content

Commit aa79709

Browse files
committed
Preliminary Battaglia pressure profile code, in python.
1 parent dd29a79 commit aa79709

18 files changed

+223
-120
lines changed

cluster_toolkit/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ def _dcast(x):
3434
if isinstance(x, list): x = np.asarray(x, dtype=np.float64, order='C')
3535
return _ffi.cast('double*', x.ctypes.data)
3636

37-
from . import averaging, bias, boostfactors, concentration, deltasigma, density, exclusion, massfunction, miscentering, peak_height, profile_derivatives, sigma_reconstruction, xi
37+
from . import (averaging, bias, boostfactors, concentration, deltasigma,
38+
density, exclusion, massfunction, miscentering, peak_height,
39+
pressure_profile, profile_derivatives, sigma_reconstruction, xi)
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# Author: Jackson O'Donnell
4+
# jacksonhodonnell@gmail.com
5+
'''
6+
Galaxy cluster pressure profiles.
7+
8+
This module implements pressure profiles presented by Battaglia et al. 2012
9+
(https://ui.adsabs.harvard.edu/abs/2012ApJ...758...75B/abstract), referred to
10+
as BBPS.
11+
12+
Their best-fit pressure profile is implemented in the function
13+
`P_BBPS`, and projected profiles are implemented in `projected_P_BBPS` and
14+
`projected_P_BBPS_real`. The difference in the latter is that `projected_P_BBPS`
15+
makes an approximation that reduces cosmology dependence, and
16+
`projected_P_BBPS_real` interpolates over a table of comoving distances to
17+
obtain a more precise answer.
18+
'''
19+
import astropy.constants as c
20+
import astropy.units as u
21+
import numpy as np
22+
from scipy.integrate import quad
23+
24+
25+
def _rho_crit(z, omega_m, omega_lambda):
26+
'''
27+
The critical density of the universe, in units of $Msun*Mpc^{-3}*h^{-2}$.
28+
'''
29+
# The constant is 3 * (100 km / s / Mpc)**2 / (8 * pi * G)
30+
# in units of Msun h^2 Mpc^{-3}
31+
return 2.77536627e+11 * (omega_m * (1 + z)**3 + omega_lambda)
32+
33+
34+
def P_delta(M, z, omega_b, omega_m, omega_lambda, delta=200):
35+
'''
36+
The pressure amplitude of a halo:
37+
38+
P_{delta} = G * M_{delta} * delta * rho_crit(z) \
39+
* omega_b / omega_m / (2R_delta)
40+
41+
See BBPS, section 4.1 for details.
42+
Units: Msun s^{-2} Mpc^{-1}
43+
'''
44+
return c.G * M * delta * _rho_crit(z, omega_m, omega_lambda) * \
45+
omega_b / omega_m / 2 / R_delta(M, omega_m, omega_lambda, z, delta)
46+
47+
48+
def R_delta(M, z, omega_m, omega_lambda, delta=200):
49+
'''
50+
The radius of a sphere of mass M (in Msun), which has a density `delta`
51+
times the critical density of the universe.
52+
53+
Units: Mpc h^(-2/3)
54+
'''
55+
volume = M / (delta * _rho_crit(z, omega_m, omega_lambda))
56+
return (3 * volume / (4 * np.pi))**(1./3)
57+
58+
59+
def P_simple_BBPS_generalized(x, M, z, P_0, x_c, beta,
60+
alpha=1, gamma=-0.3, delta=200):
61+
'''
62+
The generalized dimensionless BBPS pressure profile. Input x should be
63+
`r / R_{delta}`.
64+
'''
65+
return P_0 * (x / x_c)**gamma * (1 + (x / x_c)**alpha)**(-beta)
66+
67+
68+
def P_BBPS_generalized(r, M, z, omega_b, omega_m, omega_lambda,
69+
P_0, x_c, beta, alpha=1, gamma=-0.3, delta=200):
70+
r'''
71+
The generalized NFW form of the Battaglia profile, presented in BBPS2
72+
equation 10 as:
73+
74+
P = P_{delta} P_0 (x / x_c)^\gamma [1 + (x / x_c)^\alpha]^{-\beta}
75+
'''
76+
x = r / R_delta(M, z, omega_m, omega_lambda, delta=delta)
77+
Pd = P_delta(M, z, omega_b, omega_m, omega_lambda, delta=delta)
78+
return Pd * P_simple_BBPS_generalized(x, M, z, P_0, x_c, beta,
79+
alpha=alpha, gamma=gamma, delta=delta)
80+
81+
82+
def _A_BBPS(M, z, A_0, alpha_m, alpha_z):
83+
'''
84+
Mass-Redshift dependency model for the generalized BBPS profile parameters,
85+
fit to simulated halos in that data. The best-fit parameters are presented
86+
in Table 1. of BBPS2
87+
'''
88+
return A_0 * (M / 10**14)**alpha_m * (1 + z)**alpha_z
89+
90+
91+
def P_simple_BBPS(x, M, z):
92+
'''
93+
The best-fit pressure profile presented in BBPS2.
94+
'''
95+
params_P = (18.1, 0.154, -0.758)
96+
params_x_c = (0.497, -0.00865, 0.731)
97+
params_beta = (4.35, 0.0393, 0.415)
98+
P_0 = _A_BBPS(M, z, *params_P)
99+
x_c = _A_BBPS(M, z, *params_x_c)
100+
beta = _A_BBPS(M, z, *params_beta)
101+
return P_simple_BBPS_generalized(x, M, z, P_0, x_c, beta)
102+
103+
104+
def P_BBPS(r, M, z, omega_b, omega_m, omega_lambda):
105+
'''
106+
The best-fit pressure profile presented in BBPS2.
107+
108+
Args:
109+
r (float): Radius from the cluster center, in Mpc.
110+
M (float): Cluster M_{200}, in Msun.
111+
z (float): Cluster redshift.
112+
omega_b (float): Baryon fraction.
113+
omega_m (float): Matter fraction.
114+
omega_lambda (float): Dark energy fraction.
115+
116+
Returns:
117+
float: Pressure at distance `r` from the cluster, in units of \
118+
Msun s^{-2} Mpc^{-1}.
119+
'''
120+
# These are the best-fit parameters from BBPS2 Table 1, under AGN Feedback
121+
# \Delta = 200
122+
params_P = (18.1, 0.154, -0.758)
123+
params_x_c = (0.497, -0.00865, 0.731)
124+
params_beta = (4.35, 0.0393, 0.415)
125+
126+
P_0 = _A_BBPS(M, z, *params_P)
127+
x_c = _A_BBPS(M, z, *params_x_c)
128+
beta = _A_BBPS(M, z, *params_beta)
129+
return P_BBPS_generalized(r, M, z, omega_b, omega_m, omega_lambda,
130+
P_0, x_c, beta)
131+
132+
133+
def projected_P_BBPS(r, M, z, omega_b, omega_m, omega_lambda,
134+
dist=8):
135+
'''
136+
Computes the projected line-of-sight density of a cluster at a radius r
137+
from the cluster center.
138+
139+
Args:
140+
r (float): Radius from the cluster center, in Mpc.
141+
M (float): Cluster M_{200}, in Msun.
142+
z (float): Cluster redshift.
143+
omega_b (float): Baryon fraction.
144+
omega_m (float): Matter fraction.
145+
omega_lambda (float): Dark energy fraction.
146+
147+
Returns:
148+
float: Integrated line-of-sight pressure at distance `r` from the \
149+
cluster, in units of Msun s^{-2}.
150+
'''
151+
R_del = R_delta(M, z, omega_m, omega_lambda)
152+
return quad(lambda x: P_BBPS(np.sqrt(x*x + r*r), M, z,
153+
omega_b, omega_m,
154+
omega_lambda).value,
155+
-dist * R_del, dist * R_del,
156+
epsrel=1e-3)[0] / (1 + z)
157+
158+
159+
def projected_P_BBPS_real(r, M, z, omega_b, omega_m, omega_lambda, chis, zs,
160+
dist=8):
161+
'''
162+
Computes the projected line-of-sight density of a cluster at a radius r
163+
from the cluster center.
164+
165+
Args:
166+
r (float): Radius from the cluster center, in Mpc.
167+
M (float): Cluster M_{200}, in Msun.
168+
z (float): Cluster redshift.
169+
omega_b (float): Baryon fraction.
170+
omega_m (float): Matter fraction.
171+
omega_lambda (float): Dark energy fraction.
172+
chis (1d array of floats): The comoving line-of-sight distance, in Mpc.
173+
zs (1d array of floats): The redshifts corresponding to `chis`.
174+
175+
Returns:
176+
float: Integrated line-of-sight pressure at distance `r` from the \
177+
cluster, in units of Msun s^{-2}.
178+
'''
179+
R_del = R_delta(M, z, omega_m, omega_lambda)
180+
chi_cluster = np.interp(z, zs, chis)
181+
return quad(lambda x: P_BBPS(np.sqrt((x - chi_cluster)**2 + r*r),
182+
M, z,
183+
omega_b, omega_m,
184+
omega_lambda).value
185+
/ (1 + np.interp(x, chis, zs)),
186+
chi_cluster - dist * R_del,
187+
chi_cluster + dist * R_del,
188+
epsrel=1e-3)[0]

docs/api/cluster_toolkit.averaging.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/api/cluster_toolkit.bias.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/api/cluster_toolkit.boostfactors.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/api/cluster_toolkit.concentration.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/api/cluster_toolkit.deltasigma.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/api/cluster_toolkit.density.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/api/cluster_toolkit.exclusion.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/api/cluster_toolkit.massfunction.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)