Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
ccl_test_growth_allz.c File Reference
#include "ccl.h"
#include "ctest.h"
#include <stdio.h>
#include <math.h>
Include dependency graph for ccl_test_growth_allz.c:

Go to the source code of this file.

Classes

struct  growth_allz_data
 

Macros

#define GROWTH_TOLERANCE   1.0e-4
 
#define N_Z   10
 
#define N_MODEL   5
 

Functions

static void read_growth_test_file (const char *filename, double z[10], double gf[10][5])
 
void __attribute__ ((weak))
 
static void compare_growth (int model, struct growth_allz_data *data)
 
void __ctest_growth_allz_model_1_run (struct growth_allz_data *data)
 
void __ctest_growth_allz_model_2_run (struct growth_allz_data *data)
 
void __ctest_growth_allz_model_3_run (struct growth_allz_data *data)
 
void __ctest_growth_allz_model_4_run (struct growth_allz_data *data)
 
void __ctest_growth_allz_model_5_run (struct growth_allz_data *data)
 

Variables

static struct growth_allz_data __ctest_growth_allz_data
 

Macro Definition Documentation

#define GROWTH_TOLERANCE   1.0e-4

Definition at line 7 of file ccl_test_growth_allz.c.

Referenced by compare_growth().

#define N_MODEL   5

Definition at line 10 of file ccl_test_growth_allz.c.

Referenced by __attribute__().

#define N_Z   10

Definition at line 9 of file ccl_test_growth_allz.c.

Referenced by compare_growth(), and read_growth_test_file().

Function Documentation

void __attribute__ ( (weak)  )

Definition at line 62 of file ccl_test_growth_allz.c.

References ccl_mnu_sum, N_MODEL, and read_growth_test_file().

62  {
63  // Values that are the same for all 5 models
64  data->Omega_c = 0.25;
65  data->Omega_b = 0.05;
66  data->h = 0.7;
67  data->A_s = 2.1e-9;
68  data->n_s = 0.96;
69  data->Neff=0;
70  double mnuval = 0.;
71  data->mnu= &mnuval;
72  data-> mnu_type = ccl_mnu_sum;
73 
74 
75  // Values that are different for the different models
76  double Omega_v[N_MODEL] = { 0.7, 0.7, 0.7, 0.65, 0.75 };
77  double w_0[N_MODEL] = { -1.0, -0.9, -0.9, -0.9, -0.9 };
78  double w_a[N_MODEL] = { 0.0, 0.0, 0.1, 0.1, 0.1 };
79 
80  // Fill in the values from these constant arrays.
81  for (int i=0; i<N_MODEL; i++) {
82  data->Omega_v[i] = Omega_v[i];
83  data->w_0[i] = w_0[i];
84  data->w_a[i] = w_a[i];
85  data->Omega_k[i] = 1.0 - data->Omega_c - data->Omega_b - data->Omega_v[i];
86  }
87 
88  // The file of benchmark data.
89  read_growth_test_file("./tests/benchmark/growth_cosmomad_allz.txt", data->z, data->gf);
90 }
static void read_growth_test_file(const char *filename, double z[10], double gf[10][5])
#define N_MODEL
void __ctest_growth_allz_model_1_run ( struct growth_allz_data data)

Definition at line 121 of file ccl_test_growth_allz.c.

References compare_growth().

121  {
122  int model = 0;
123  compare_growth(model, data);
124 }
static void compare_growth(int model, struct growth_allz_data *data)
void __ctest_growth_allz_model_2_run ( struct growth_allz_data data)

Definition at line 126 of file ccl_test_growth_allz.c.

References compare_growth().

126  {
127  int model = 1;
128  compare_growth(model, data);
129 }
static void compare_growth(int model, struct growth_allz_data *data)
void __ctest_growth_allz_model_3_run ( struct growth_allz_data data)

Definition at line 131 of file ccl_test_growth_allz.c.

References compare_growth().

131  {
132  int model = 2;
133  compare_growth(model, data);
134 }
static void compare_growth(int model, struct growth_allz_data *data)
void __ctest_growth_allz_model_4_run ( struct growth_allz_data data)

Definition at line 136 of file ccl_test_growth_allz.c.

References compare_growth().

136  {
137  int model = 3;
138  compare_growth(model, data);
139 }
static void compare_growth(int model, struct growth_allz_data *data)
void __ctest_growth_allz_model_5_run ( struct growth_allz_data data)

Definition at line 141 of file ccl_test_growth_allz.c.

References compare_growth().

141  {
142  int model = 4;
143  compare_growth(model, data);
144 }
static void compare_growth(int model, struct growth_allz_data *data)
static void compare_growth ( int  model,
struct growth_allz_data data 
)
static

Definition at line 92 of file ccl_test_growth_allz.c.

References growth_allz_data::A_s, ASSERT_DBL_NEAR_TOL, ASSERT_NOT_NULL, ccl_cosmology_create(), ccl_cosmology_free(), ccl_growth_factor_unnorm(), ccl_parameters_create(), cl_cmbl_bm::cosmo, default_config, growth_allz_data::gf, GROWTH_TOLERANCE, growth_allz_data::h, growth_allz_data::mnu, growth_allz_data::mnu_type, growth_allz_data::n_s, N_Z, growth_allz_data::Neff, growth_allz_data::Omega_b, growth_allz_data::Omega_c, ccl_parameters::Omega_g, growth_allz_data::Omega_k, halomod_bm::params, ccl_cosmology::status_message, growth_allz_data::w_0, growth_allz_data::w_a, and growth_allz_data::z.

Referenced by __ctest_growth_allz_model_1_run(), __ctest_growth_allz_model_2_run(), __ctest_growth_allz_model_3_run(), __ctest_growth_allz_model_4_run(), and __ctest_growth_allz_model_5_run().

93 {
94  int status=0;
95  // Make the parameter set from the input data
96  // Values of some parameters depend on the model index
97  ccl_parameters params = ccl_parameters_create(data->Omega_c, data->Omega_b, data->Omega_k[model],
98  data->Neff, data->mnu, data->mnu_type,
99  data->w_0[model], data->w_a[model],
100  data->h, data->A_s, data->n_s,
101  -1,-1,-1,-1,NULL,NULL, &status);
102  params.Omega_g=0;
103  // Make a cosmology object from the parameters with the default configuration
105  ASSERT_NOT_NULL(cosmo);
106 
107  // Compare to benchmark data
108  for (int i=0; i<N_Z; i++) {
109  double a = 1/(1.+data->z[i]);
110  double gf_ccl=ccl_growth_factor_unnorm(cosmo, a, &status);
111  if (status) printf("%s\n",cosmo->status_message);
112 
113  double absolute_tolerance = GROWTH_TOLERANCE*data->gf[i][model];
114  if (fabs(absolute_tolerance)<1e-12) absolute_tolerance = 1e-12;
115  ASSERT_DBL_NEAR_TOL(data->gf[i][model], gf_ccl, absolute_tolerance);
116  }
117 
118  ccl_cosmology_free(cosmo);
119 }
double Omega_g
Definition: ccl_core.h:53
ccl_mnu_convention mnu_type
double ccl_growth_factor_unnorm(ccl_cosmology *cosmo, double a, int *status)
int * status
Definition: ccl_redshifts.c:41
ccl_cosmology * ccl_cosmology_create(ccl_parameters params, ccl_configuration config)
Definition: ccl_core.c:173
#define GROWTH_TOLERANCE
void ccl_cosmology_free(ccl_cosmology *cosmo)
Definition: ccl_core.c:829
dictionary params
Definition: halomod_bm.py:27
#define N_Z
#define ASSERT_DBL_NEAR_TOL(exp, real, tol)
Definition: ctest.h:152
const ccl_configuration default_config
Definition: ccl_core.c:21
#define ASSERT_NOT_NULL(real)
Definition: ctest.h:139
ccl_parameters ccl_parameters_create(double Omega_c, double Omega_b, double Omega_k, double Neff, double *mnu, ccl_mnu_convention mnu_type, double w0, double wa, double h, double norm_pk, double n_s, double bcm_log10Mc, double bcm_etab, double bcm_ks, int nz_mgrowth, double *zarr_mgrowth, double *dfarr_mgrowth, int *status)
Definition: ccl_core.c:294
char status_message[500]
Definition: ccl_core.h:136
static void read_growth_test_file ( const char *  filename,
double  z[10],
double  gf[10][5] 
)
static

Definition at line 32 of file ccl_test_growth_allz.c.

References ASSERT_EQUAL, ASSERT_NOT_NULL, Catch::Matchers::Vector::Detail::count(), N_Z, and z.

Referenced by __attribute__().

33 {
34  //Growth is normalized to ~a at early times
35  FILE * f = fopen(filename, "r");
36  ASSERT_NOT_NULL(f);
37 
38  // Ignore header line
39  fscanf(f, "%*[^\n]\n", NULL);
40 
41  double val;
42  // Read the file
43  for(int i_z=0; i_z<N_Z; i_z++) {
44  for(int i_model=0; i_model<N_MODEL+1; i_model++) {
45  int count = fscanf(f, "%le", &val);
46  // Check that all the value was read successfully
47  ASSERT_EQUAL(1, count);
48  if(i_model == 0) {
49  // The first column holds the redshift values
50  z[i_z] = val;
51  }
52  else {
53  gf[i_z][i_model-1] = val;
54  }
55  }
56  }
57  fclose(f);
58 }
size_t count(InputIterator first, InputIterator last, T const &item)
Definition: catch.hpp:2747
#define N_MODEL
#define N_Z
static double z[8]
#define ASSERT_EQUAL(exp, real)
Definition: ctest.h:121
#define ASSERT_NOT_NULL(real)
Definition: ctest.h:139

Variable Documentation

static struct growth_allz_data __ctest_growth_allz_data
static

Definition at line 121 of file ccl_test_growth_allz.c.