Skip to content

Commit 3aaa8c9

Browse files
working now
1 parent 6294e49 commit 3aaa8c9

33 files changed

+62
-38
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import hmcode
3333
# Ranges
3434
k = np.logspace(-3, 1, 100) # Wavenumbers [h/Mpc]
3535
zs = [3., 2., 1., 0.5, 0.] # Redshifts
36+
T_AGN = 10**7.8 # Feedback temperature [K]
3637
3738
# Run CAMB
3839
parameters = camb.CAMBparams(WantCls=False)
@@ -41,7 +42,7 @@ parameters.set_matter_power(redshifts=zs, kmax=100.) # kmax should be much large
4142
results = camb.get_results(parameters)
4243
4344
# HMcode
44-
Pk = hmcode.power(k, zs, results)
45+
Pk = hmcode.power(k, zs, results, T_AGN)
4546
```
4647

4748
## Note
@@ -80,7 +81,7 @@ I think any residual differences between codes must therefore stem from:
8081
But I didn't have time to investigate these differences more thoroughly. Note that there are accuracy parameters in `CAMB-HMcode` fixed at the $10^{-4}$ level, so you would never expect better than 0.01% agreement. Given that `HMcode` is only accurate at the ~2.5% level compared to simulated power spectra, the level of agreement between the codes seems okay to me, with the caveats above regarding very massive neutrinos.
8182

8283
While writing this code I had a few ideas for future improvements:
83-
- Add the `HMcode-2020` baryon-feedback model; this would not be too hard for the enthusiastic student/postdoc.
84+
- ~~Add the `HMcode-2020` baryon-feedback model; this would not be too hard for the enthusiastic student/postdoc.~~ (Thanks Laila Linke!)
8485
- The predictions are a bit sensitive to the smoothing $\sigma$ used for the dewiggling. This should probably be a fitted parameter.
8586
- It's annoying having to calculate linear growth functions (all, LCDM), especially since the linear growth doesn't really exist. One should probably use the $P(k)$ amplitude evolution over time at some cleverly chosen scale instead, or instead the evolution of $\sigma(R)$ over time at some pertinent $R$ value. Note that the growth factors are *only* used to calculate the [Dolag et al. (2004)](https://arxiv.org/abs/astro-ph/0309771) correction and [Mead (2017)](https://arxiv.org/abs/1606.05345) $\delta_\mathrm{c}$, $\Delta_\mathrm{v}$.
8687
- I never liked the halo bloating parameter, it's hard to understand the effect of modifying halo profiles in Fourier space. Someone should get rid of this (maybe modify the halo mass function instead?).

hmcode/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
from .hmcode import power
2-
from .hmcode import _get_feedback_suppression as get_feedback_suppression
1+
from .hmcode import power

hmcode/hmcode.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def power(k:np.array, zs:np.array, CAMB_results:camb.CAMBdata, T_AGN=None,
157157
else: # Use vanilla-ish halo model if no HMcode tweaks used
158158
B, eta = 4., 0.
159159

160-
if T_AGN:
160+
if T_AGN and not tweaks:
161161
B = feedback_params['B0']*np.power(10, z*feedback_params['Bz'])
162162
Mb = feedback_params['Mb0']*np.power(10, z*feedback_params['Mbz'])
163163
fstar = feedback_params['f0']*np.power(10, z*feedback_params['fz'])
@@ -171,7 +171,7 @@ def power(k:np.array, zs:np.array, CAMB_results:camb.CAMBdata, T_AGN=None,
171171
print('Halo bloating; eta: {:.4}'.format(eta))
172172
print('Minimum halo concentration; B: {:.4}'.format(B))#, B/4.)
173173
print('Transition smoothing; alpha: {:.4}'.format(alpha))
174-
if T_AGN:
174+
if T_AGN and not tweaks:
175175
print('Gas-loss halo-mass parameter Mb: {:1e}'.format(Mb))
176176
print('Effective halo stellar-mass fraction f*: {:.4f}'.format(f))
177177
print()
@@ -186,11 +186,11 @@ def power(k:np.array, zs:np.array, CAMB_results:camb.CAMBdata, T_AGN=None,
186186
rv = hmod.virial_radius(M)
187187
Uk = np.ones((len(k), len(M)))
188188
for iM, (_rv, _c, _nu) in enumerate(zip(rv, c, nu)): # TODO: Remove loop for speed?
189-
if T_AGN:
189+
if T_AGN and not tweaks:
190190
Uk[:, iM] = _win_NFW_baryons(k*(_nu**eta), _rv, _c, M[iM], Mb, fstar, Om_m, Om_c, Om_b)[:, 0]
191191
else:
192192
Uk[:, iM] = _win_NFW(k*(_nu**eta), _rv, _c)[:, 0]
193-
if T_AGN: # NOTE: No Factor of 1-f_nu for baryonic, because this effect is already included!
193+
if T_AGN and not tweaks: # NOTE: No Factor of 1-f_nu for baryonic, because this effect is already included!
194194
profile = halo.profile.Fourier(k, M, Uk, amplitude=M/hmod.rhom, mass_tracer=True)
195195
else: # NOTE: Factor of 1-f_nu in profile amplitude
196196
profile = halo.profile.Fourier(k, M, Uk, amplitude=M*(1.-f_nu)/hmod.rhom, mass_tracer=True)
@@ -209,7 +209,7 @@ def power(k:np.array, zs:np.array, CAMB_results:camb.CAMBdata, T_AGN=None,
209209
Pk_hm = Pk_lin+_Pk_1h['m-m']
210210
Pk_HMcode[iz, :] = Pk_hm
211211

212-
if tweaks and T_AGN:
212+
if T_AGN and tweaks:
213213
suppression = _get_feedback_suppression(k, zs, CAMB_results, T_AGN, Mmin=Mmin, Mmax=Mmax, nM=nM, verbose=False)
214214
Pk_HMcode *= suppression
215215

notebooks/feedback.ipynb

Lines changed: 33 additions & 13 deletions
Large diffs are not rendered by default.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)