Skip to content

Commit

Permalink
WantCls=False; tidy; new feedback benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-mead committed Apr 23, 2023
1 parent f586e1a commit efe173c
Show file tree
Hide file tree
Showing 30 changed files with 307 additions and 180 deletions.
7 changes: 4 additions & 3 deletions hmcode/camb_stuff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
import camb

def run(zs, Omega_c, Omega_b, Omega_k, h, ns, sigma_8,
m_nu=0., w=-1., wa=0., As=2e-9, norm_sigma8=True, kmax_CAMB=200.,
log10_T_AGN=None, verbose=False):
m_nu=0., w=-1., wa=0., log10_T_AGN=None,
As=2e-9, norm_sigma8=True, kmax_CAMB=200., verbose=False):

# Sets cosmological parameters in camb to calculate the linear power spectrum
# TODO: Setting 'WantCls=False' in CAMBparams spoils the agreement... why?
if log10_T_AGN:
non_linear_model = camb.nonlinear.Halofit(halofit_version="mead2020_feedback",
HMCode_logT_AGN=log10_T_AGN)
else:
non_linear_model = camb.nonlinear.Halofit(halofit_version="mead2020")
pars = camb.CAMBparams(WantCls=False, NonLinearModel=non_linear_model)
pars = camb.CAMBparams(NonLinearModel=non_linear_model)
wb, wc = Omega_b*h**2, Omega_c*h**2

# This function sets standard and helium set using BBN consistency
Expand Down
14 changes: 7 additions & 7 deletions hmcode/linear_growth.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# Third-party imports
import numpy as np
import camb
from camb import CAMBdata

# Parameters
a_init = 1e-4 # Initial scale-factor for growth ODE integration

def _w(a:float, CAMB_results:camb.CAMBdata, LCDM=False) -> float:
def _w(a:float, CAMB_results:CAMBdata, LCDM=False) -> float:
'''
Dark energy equation of state for w0, wa models
'''
w0, wa = (-1., 0.) if LCDM else (CAMB_results.Params.DarkEnergy.w, CAMB_results.Params.DarkEnergy.wa)
return w0+(1.-a)*wa


def _X_w(a:float, CAMB_results:camb.CAMBdata, LCDM=False) -> float:
def _X_w(a:float, CAMB_results:CAMBdata, LCDM=False) -> float:
'''
Cosmological dark energy density for w0, wa models
'''
w0, wa = (-1., 0.) if LCDM else (CAMB_results.Params.DarkEnergy.w, CAMB_results.Params.DarkEnergy.wa)
return a**(-3.*(1.+w0+wa))*np.exp(-3.*wa*(1.-a))


def _Omega_m(a:float, CAMB_results:camb.CAMBdata, LCDM=False) -> float:
def _Omega_m(a:float, CAMB_results:CAMBdata, LCDM=False) -> float:
'''
Evolution of Omgea_m with scale-factor ignoring radiation
'''
Expand All @@ -32,7 +32,7 @@ def _Omega_m(a:float, CAMB_results:camb.CAMBdata, LCDM=False) -> float:
return Om_m*a**-3/_Hubble2(a, CAMB_results, LCDM)


def _Hubble2(a:float, CAMB_results:camb.CAMBdata, LCDM=False) -> float:
def _Hubble2(a:float, CAMB_results:CAMBdata, LCDM=False) -> float:
'''
Squared Hubble parameter ignoring radiation
Massive neutrinos are counted as 'matter'
Expand All @@ -47,7 +47,7 @@ def _Hubble2(a:float, CAMB_results:camb.CAMBdata, LCDM=False) -> float:
return H2


def _AH(a:float, CAMB_results:camb.CAMBdata, LCDM=False) -> float:
def _AH(a:float, CAMB_results:CAMBdata, LCDM=False) -> float:
'''
Acceleration parameter ignoring radiation
Massive neutrinos are counted as 'matter'
Expand All @@ -61,7 +61,7 @@ def _AH(a:float, CAMB_results:camb.CAMBdata, LCDM=False) -> float:
return AH


def get_growth_interpolator(CAMB_results:camb.CAMBdata, LCDM=False) -> callable:
def get_growth_interpolator(CAMB_results:CAMBdata, LCDM=False) -> callable:
'''
Solve the linear growth ODE and returns an interpolating function for the solution
LCDM = True forces w = -1 and imposes flatness by modifying the dark-energy density
Expand Down
177 changes: 164 additions & 13 deletions notebooks/demo.ipynb

Large diffs are not rendered by default.

38 changes: 7 additions & 31 deletions notebooks/feedback.ipynb

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_0.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_1.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_10.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_11.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_12.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_13.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_14.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_15.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_16.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_17.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_18.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_19.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_2.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_20.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_21.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_22.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_23.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_24.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_3.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_4.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_5.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_6.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_7.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_8.dat

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/benchmarks_feedback/cosmology_9.dat

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion tests/test_feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
_, results, _, _, _ = camb_stuff.run(zs, Omega_c, Omega_b, Omega_k, h, ns, sigma_8, m_nu, w0, wa)

# Get the pyHMcode spectrum
#Supp_HMcode = hmcode.get_feedback_suppression(k, zs, results, T_AGN)
Pk_feedback = hmcode.power(k, zs, results, T_AGN=T_AGN, verbose=False)
Pk_gravity = hmcode.power(k, zs, results, T_AGN=None)
Supp_HMcode = Pk_feedback/Pk_gravity
Expand Down

0 comments on commit efe173c

Please sign in to comment.