Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
ccl_test_growth Namespace Reference

Functions

def read_growth_lowz_benchmark_file ()
 
def read_growth_allz_benchmark_file ()
 
def compare_growth (z, gfac_bench, Omega_v, w0, wa)
 
def test_growth_lowz_model_0 ()
 
def test_growth_lowz_model_1 ()
 
def test_growth_lowz_model_2 ()
 
def test_growth_lowz_model_3 ()
 
def test_growth_lowz_model_4 ()
 
def test_growth_allz_model_0 ()
 
def test_growth_allz_model_1 ()
 
def test_growth_allz_model_2 ()
 
def test_growth_allz_model_3 ()
 
def test_growth_allz_model_4 ()
 
def test_mgrowth ()
 

Variables

int GROWTH_TOLERANCE = 1
 
float Omega_c = 0.25
 
float Omega_b = 0.05
 
int Neff = 0
 
int m_nu = 0
 
float h = 0.7
 
float A_s = 2.1e-9
 
float n_s = 0.96
 
 Omega_v_vals = np.array([0.7, 0.7, 0.7, 0.65, 0.75])
 
 w0_vals = np.array([-1.0, -0.9, -0.9, -0.9, -0.9])
 
 wa_vals = np.array([0.0, 0.0, 0.1, 0.1, 0.1])
 

Function Documentation

def ccl_test_growth.compare_growth (   z,
  gfac_bench,
  Omega_v,
  w0,
  wa 
)
Compare growth factor calculated by pyccl with the values in the benchmark
file. This test only works if radiation is explicitly set to 0.

Definition at line 53 of file ccl_test_growth.py.

Referenced by test_growth_allz_model_0(), test_growth_allz_model_1(), test_growth_allz_model_2(), test_growth_allz_model_3(), test_growth_allz_model_4(), test_growth_lowz_model_0(), test_growth_lowz_model_1(), test_growth_lowz_model_2(), test_growth_lowz_model_3(), and test_growth_lowz_model_4().

53 def compare_growth(z, gfac_bench, Omega_v, w0, wa):
54  """
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.
57  """
58 
59  # Set Omega_K in a consistent way
60  Omega_k = 1.0 - Omega_c - Omega_b - Omega_v
61 
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)
65 
66  # Calculate distance using pyccl
67  a = 1. / (1. + z)
68  gfac = ccl.growth_factor_unnorm(cosmo, a)
69 
70  # Compare to benchmark data
71  assert_allclose(gfac, gfac_bench, atol=1e-12, rtol=GROWTH_TOLERANCE)
72 
73 
def compare_growth(z, gfac_bench, Omega_v, w0, wa)
def ccl_test_growth.read_growth_allz_benchmark_file ( )
Read the file containing growth factor benchmarks for the whole redshift range.

Definition at line 36 of file ccl_test_growth.py.

References read_growth_lowz_benchmark_file().

37  """
38  Read the file containing growth factor benchmarks for the whole redshift range.
39  """
40  # Load data from file
41  dat = np.genfromtxt(join(dirname(__file__),"benchmark/growth_cosmomad_allz.txt")).T
42  assert(dat.shape == (6,10))
43 
44  # Split into redshift column and growth(z) columns
45  z = dat[0]
46  gfac = dat[1:]
47  return z, gfac
48 
49 # Set-up test data
50 z_lowz, gfac_lowz = read_growth_lowz_benchmark_file()
51 z_allz, gfac_allz = read_growth_allz_benchmark_file()
52 
def read_growth_lowz_benchmark_file()
def read_growth_allz_benchmark_file()
def ccl_test_growth.read_growth_lowz_benchmark_file ( )
Read the file containing growth factor benchmarks for the low redshifts.

Definition at line 23 of file ccl_test_growth.py.

Referenced by read_growth_allz_benchmark_file().

24  """
25  Read the file containing growth factor benchmarks for the low redshifts.
26  """
27  # Load data from file
28  dat = np.genfromtxt(join(dirname(__file__),"benchmark/growth_model1-5.txt")).T
29  assert(dat.shape == (6,6))
30 
31  # Split into redshift column and growth(z) columns
32  z = dat[0]
33  gfac = dat[1:]
34  return z, gfac
35 
def read_growth_lowz_benchmark_file()
def ccl_test_growth.test_growth_allz_model_0 ( )

Definition at line 95 of file ccl_test_growth.py.

References compare_growth().

96  i = 0
97  compare_growth(z_allz, gfac_allz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i])
98 
def compare_growth(z, gfac_bench, Omega_v, w0, wa)
def test_growth_allz_model_0()
def ccl_test_growth.test_growth_allz_model_1 ( )

Definition at line 99 of file ccl_test_growth.py.

References compare_growth().

100  i = 1
101  compare_growth(z_allz, gfac_allz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i])
102 
def compare_growth(z, gfac_bench, Omega_v, w0, wa)
def test_growth_allz_model_1()
def ccl_test_growth.test_growth_allz_model_2 ( )

Definition at line 103 of file ccl_test_growth.py.

References compare_growth().

104  i = 2
105  compare_growth(z_allz, gfac_allz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i])
106 
def test_growth_allz_model_2()
def compare_growth(z, gfac_bench, Omega_v, w0, wa)
def ccl_test_growth.test_growth_allz_model_3 ( )

Definition at line 107 of file ccl_test_growth.py.

References compare_growth().

108  i = 3
109  compare_growth(z_allz, gfac_allz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i])
110 
def compare_growth(z, gfac_bench, Omega_v, w0, wa)
def test_growth_allz_model_3()
def ccl_test_growth.test_growth_allz_model_4 ( )

Definition at line 111 of file ccl_test_growth.py.

References compare_growth().

112  i = 4
113  compare_growth(z_allz, gfac_allz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i])
114 
def test_growth_allz_model_4()
def compare_growth(z, gfac_bench, Omega_v, w0, wa)
def ccl_test_growth.test_growth_lowz_model_0 ( )

Definition at line 74 of file ccl_test_growth.py.

References compare_growth().

75  i = 0
76  compare_growth(z_lowz, gfac_lowz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i])
77 
def compare_growth(z, gfac_bench, Omega_v, w0, wa)
def test_growth_lowz_model_0()
def ccl_test_growth.test_growth_lowz_model_1 ( )

Definition at line 78 of file ccl_test_growth.py.

References compare_growth().

79  i = 1
80  compare_growth(z_lowz, gfac_lowz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i])
81 
def compare_growth(z, gfac_bench, Omega_v, w0, wa)
def test_growth_lowz_model_1()
def ccl_test_growth.test_growth_lowz_model_2 ( )

Definition at line 82 of file ccl_test_growth.py.

References compare_growth().

83  i = 2
84  compare_growth(z_lowz, gfac_lowz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i])
85 
def test_growth_lowz_model_2()
def compare_growth(z, gfac_bench, Omega_v, w0, wa)
def ccl_test_growth.test_growth_lowz_model_3 ( )

Definition at line 86 of file ccl_test_growth.py.

References compare_growth().

87  i = 3
88  compare_growth(z_lowz, gfac_lowz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i])
89 
def test_growth_lowz_model_3()
def compare_growth(z, gfac_bench, Omega_v, w0, wa)
def ccl_test_growth.test_growth_lowz_model_4 ( )

Definition at line 90 of file ccl_test_growth.py.

References compare_growth().

91  i = 4
92  compare_growth(z_lowz, gfac_lowz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i])
93 
94 # 0.01 < z < 1000 tests
def test_growth_lowz_model_4()
def compare_growth(z, gfac_bench, Omega_v, w0, wa)
def ccl_test_growth.test_mgrowth ( )
Compare the modified growth function computed by CCL against the exact
result for a particular modification of the growth rate.

Definition at line 115 of file ccl_test_growth.py.

References Catch::Generators.range().

116  """
117  Compare the modified growth function computed by CCL against the exact
118  result for a particular modification of the growth rate.
119  """
120  # Define differential growth rate arrays
121  nz_mg = 128
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])
127 
128  # Define two test cosmologies, without and with modified growth respectively
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)
134 
135  # We have included a growth modification \delta f = K*a, with K==0.1
136  # (arbitrarily). This case has an analytic solution, given by
137  # D(a) = D_0(a)*exp(K*(a-1)). Here we compare the growth computed by CCL
138  # with the analytic solution.
139  a = 1. / (1. + z_mg)
140 
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)
145 
146  f2r = f1 + 0.1*a
147  d2r = d1 * np.exp(0.1*(a-1.))
148 
149  # Check that ratio of calculated and analytic results is within tolerance
150  assert_allclose(d2r, d2, rtol=GROWTH_TOLERANCE)
151  assert_allclose(f2r, f2, rtol=GROWTH_TOLERANCE)
152 
153 
auto range(T const &first, T const &last) -> Generator< T >
Definition: catch.hpp:3156

Variable Documentation

float ccl_test_growth.A_s = 2.1e-9

Definition at line 15 of file ccl_test_growth.py.

int ccl_test_growth.GROWTH_TOLERANCE = 1

Definition at line 6 of file ccl_test_growth.py.

float ccl_test_growth.h = 0.7

Definition at line 14 of file ccl_test_growth.py.

int ccl_test_growth.m_nu = 0

Definition at line 13 of file ccl_test_growth.py.

float ccl_test_growth.n_s = 0.96

Definition at line 16 of file ccl_test_growth.py.

int ccl_test_growth.Neff = 0

Definition at line 12 of file ccl_test_growth.py.

float ccl_test_growth.Omega_b = 0.05

Definition at line 11 of file ccl_test_growth.py.

float ccl_test_growth.Omega_c = 0.25

Definition at line 10 of file ccl_test_growth.py.

ccl_test_growth.Omega_v_vals = np.array([0.7, 0.7, 0.7, 0.65, 0.75])

Definition at line 19 of file ccl_test_growth.py.

ccl_test_growth.w0_vals = np.array([-1.0, -0.9, -0.9, -0.9, -0.9])

Definition at line 20 of file ccl_test_growth.py.

ccl_test_growth.wa_vals = np.array([0.0, 0.0, 0.1, 0.1, 0.1])

Definition at line 21 of file ccl_test_growth.py.