2 from numpy.testing
import assert_allclose, run_module_suite
4 from os.path
import dirname, join
6 GROWTH_TOLERANCE = 1e-4
19 Omega_v_vals = np.array([0.7, 0.7, 0.7, 0.65, 0.75])
20 w0_vals = np.array([-1.0, -0.9, -0.9, -0.9, -0.9])
21 wa_vals = np.array([0.0, 0.0, 0.1, 0.1, 0.1])
25 Read the file containing growth factor benchmarks for the low redshifts. 28 dat = np.genfromtxt(join(dirname(__file__),
"benchmark/growth_model1-5.txt")).T
29 assert(dat.shape == (6,6))
38 Read the file containing growth factor benchmarks for the whole redshift range. 41 dat = np.genfromtxt(join(dirname(__file__),
"benchmark/growth_cosmomad_allz.txt")).T
42 assert(dat.shape == (6,10))
55 Compare growth factor calculated by pyccl with the values in the benchmark 56 file. This test only works if radiation is explicitly set to 0. 60 Omega_k = 1.0 - Omega_c - Omega_b - Omega_v
62 cosmo = ccl.Cosmology(Omega_c=Omega_c, Omega_b=Omega_b, Neff=Neff, m_nu=m_nu,
63 h=h, A_s=A_s, n_s=n_s, Omega_k=Omega_k,
64 w0=w0, wa=wa, Omega_g=0)
68 gfac = ccl.growth_factor_unnorm(cosmo, a)
71 assert_allclose(gfac, gfac_bench, atol=1e-12, rtol=GROWTH_TOLERANCE)
76 compare_growth(z_lowz, gfac_lowz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i])
80 compare_growth(z_lowz, gfac_lowz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i])
84 compare_growth(z_lowz, gfac_lowz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i])
88 compare_growth(z_lowz, gfac_lowz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i])
92 compare_growth(z_lowz, gfac_lowz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i])
97 compare_growth(z_allz, gfac_allz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i])
101 compare_growth(z_allz, gfac_allz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i])
105 compare_growth(z_allz, gfac_allz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i])
109 compare_growth(z_allz, gfac_allz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i])
113 compare_growth(z_allz, gfac_allz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i])
117 Compare the modified growth function computed by CCL against the exact 118 result for a particular modification of the growth rate. 122 z_mg = np.zeros(nz_mg)
123 df_mg = np.zeros(nz_mg)
124 for i
in range(0, nz_mg):
125 z_mg[i] = 4. * (i + 0.0) / (nz_mg - 1.)
126 df_mg[i] = 0.1 / (1. + z_mg[i])
129 cosmo1 = ccl.Cosmology(Omega_c=0.25, Omega_b=0.05, Omega_k=0., Neff=0., m_nu=0.,
130 w0=-1., wa=0., h=0.7, A_s=2.1e-9, n_s=0.96)
131 cosmo2 = ccl.Cosmology(Omega_c=0.25, Omega_b=0.05, Omega_k=0., Neff=0., m_nu=0.,
132 w0=-1., wa=0., h=0.7, A_s=2.1e-9, n_s=0.96,
133 z_mg=z_mg, df_mg=df_mg)
141 d1 = ccl.growth_factor(cosmo1, a)
142 d2 = ccl.growth_factor(cosmo2, a)
143 f1 = ccl.growth_rate(cosmo1, a)
144 f2 = ccl.growth_rate(cosmo2, a)
147 d2r = d1 * np.exp(0.1*(a-1.))
150 assert_allclose(d2r, d2, rtol=GROWTH_TOLERANCE)
151 assert_allclose(f2r, f2, rtol=GROWTH_TOLERANCE)
154 if __name__ ==
"__main__":
def test_growth_allz_model_2()
def read_growth_lowz_benchmark_file()
def test_growth_lowz_model_4()
def test_growth_lowz_model_2()
def test_growth_allz_model_4()
def read_growth_allz_benchmark_file()
def test_growth_lowz_model_3()
def compare_growth(z, gfac_bench, Omega_v, w0, wa)
auto range(T const &first, T const &last) -> Generator< T >
def test_growth_lowz_model_1()
def test_growth_allz_model_1()
def test_growth_allz_model_0()
def test_growth_allz_model_3()
def test_growth_lowz_model_0()