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

Go to the source code of this file.

Classes

struct  growth_hiz_data
 

Macros

#define GROWTH_HIZ_TOLERANCE   6.0e-6
 

Functions

static void read_growth_hiz_test_file (double z[7], double gf[3][7])
 
void __attribute__ ((weak))
 
static void compare_growth_hiz (int model, struct growth_hiz_data *data)
 
void __ctest_growth_hiz_model_1_run (struct growth_hiz_data *data)
 
void __ctest_growth_hiz_model_2_run (struct growth_hiz_data *data)
 
void __ctest_growth_hiz_model_3_run (struct growth_hiz_data *data)
 

Variables

static struct growth_hiz_data __ctest_growth_hiz_data
 

Macro Definition Documentation

#define GROWTH_HIZ_TOLERANCE   6.0e-6

Definition at line 7 of file ccl_test_growth_hiz.c.

Referenced by compare_growth_hiz().

Function Documentation

void __attribute__ ( (weak)  )

Definition at line 52 of file ccl_test_growth_hiz.c.

References ccl_mnu_sum, and read_growth_hiz_test_file().

52  {
53  // Values that are the same for all 3 models
54  data->Omega_c = 0.25;
55  data->Omega_b = 0.05;
56  data->h = 0.7;
57  data->A_s = 2.1e-9;
58  data->n_s = 0.96;
59  data->Neff=0;
60  double mnuval = 0.;
61  data->mnu= &mnuval;
62  data->mnu_type = ccl_mnu_sum;
63 
64 
65  // Values that are different for the different models
66  double Omega_v[3] = { 0.7, 0.7, 0.7};
67  double w_0[3] = { -1.0, -0.9, -0.9};
68  double w_a[3] = { 0.0, 0.0, 0.1};
69 
70  // Fill in the values from these constant arrays.
71  for (int i=0; i<3; i++) {
72  data->Omega_v[i] = Omega_v[i];
73  data->w_0[i] = w_0[i];
74  data->w_a[i] = w_a[i];
75  data->Omega_k[i] = 1.0 - data->Omega_c - data->Omega_b - data->Omega_v[i];
76  }
77 
78  // The file of benchmark data.
79  read_growth_hiz_test_file(data->z, data->gf);
80 }
static void read_growth_hiz_test_file(double z[7], double gf[3][7])
void __ctest_growth_hiz_model_1_run ( struct growth_hiz_data data)

Definition at line 107 of file ccl_test_growth_hiz.c.

References compare_growth_hiz().

107  {
108  int model = 0;
109  compare_growth_hiz(model, data);
110 }
static void compare_growth_hiz(int model, struct growth_hiz_data *data)
void __ctest_growth_hiz_model_2_run ( struct growth_hiz_data data)

Definition at line 112 of file ccl_test_growth_hiz.c.

References compare_growth_hiz().

112  {
113  int model = 1;
114  compare_growth_hiz(model, data);
115 }
static void compare_growth_hiz(int model, struct growth_hiz_data *data)
void __ctest_growth_hiz_model_3_run ( struct growth_hiz_data data)

Definition at line 117 of file ccl_test_growth_hiz.c.

References compare_growth_hiz().

117  {
118  int model = 2;
119  compare_growth_hiz(model, data);
120 }
static void compare_growth_hiz(int model, struct growth_hiz_data *data)
static void compare_growth_hiz ( int  model,
struct growth_hiz_data data 
)
static

Definition at line 82 of file ccl_test_growth_hiz.c.

References growth_hiz_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_hiz_data::gf, GROWTH_HIZ_TOLERANCE, growth_hiz_data::h, growth_hiz_data::mnu, growth_hiz_data::mnu_type, growth_hiz_data::n_s, growth_hiz_data::Neff, growth_hiz_data::Omega_b, growth_hiz_data::Omega_c, ccl_parameters::Omega_g, growth_hiz_data::Omega_k, ccl_parameters::Omega_k, ccl_parameters::Omega_l, ccl_parameters::Omega_m, halomod_bm::params, ccl_cosmology::status_message, growth_hiz_data::w_0, growth_hiz_data::w_a, and growth_hiz_data::z.

Referenced by __ctest_growth_hiz_model_1_run(), __ctest_growth_hiz_model_2_run(), and __ctest_growth_hiz_model_3_run().

83 {
84  int status=0;
85  // Make the parameter set from the input data
86  // Values of some parameters depend on the model index
87  ccl_parameters params = ccl_parameters_create(data->Omega_c, data->Omega_b, data->Omega_k[model], data->Neff, data->mnu, data->mnu_type, data->w_0[model], data->w_a[model], data->h, data->A_s, data->n_s,-1,-1,-1,-1,NULL,NULL, &status);
88  params.Omega_g=0; //enforce no radiation
89  params.Omega_l = 1.-params.Omega_m-params.Omega_k; //reomcpute Omega_l without radiation
90  // Make a cosmology object from the parameters with the default configuration
92  ASSERT_NOT_NULL(cosmo);
93 
94  // Compare to benchmark data
95  for (int j=0; j<7; j++) {
96  double a = 1/(1.+data->z[j]);
97  double gf_ij=ccl_growth_factor_unnorm(cosmo,a, &status);
98  if (status) printf("%s\n",cosmo->status_message);
99  double absolute_tolerance = GROWTH_HIZ_TOLERANCE*data->gf[model][j];
100  if (fabs(absolute_tolerance)<1e-12) absolute_tolerance = 1e-12;
101  ASSERT_DBL_NEAR_TOL(data->gf[model][j], gf_ij, absolute_tolerance);
102  }
103 
104  ccl_cosmology_free(cosmo);
105 }
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)
double Omega_l
Definition: ccl_core.h:63
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_HIZ_TOLERANCE
void ccl_cosmology_free(ccl_cosmology *cosmo)
Definition: ccl_core.c:829
dictionary params
Definition: halomod_bm.py:27
#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
double Omega_k
Definition: ccl_core.h:22
double Omega_m
Definition: ccl_core.h:21
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_hiz_test_file ( double  z[7],
double  gf[3][7] 
)
static

Definition at line 29 of file ccl_test_growth_hiz.c.

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

Referenced by __attribute__().

30 {
31  //Growth is normalized to ~a at early times
32  FILE * f = fopen("./tests/benchmark/growth_hiz_model1-3.txt", "r");
33  ASSERT_NOT_NULL(f);
34 
35  // Ignore header line
36  char str[1024];
37  char* rtn;
38  rtn = fgets(str, 1024, f);
39 
40  // File is fixed format - five rows and six columns
41  for (int i=0; i<7; i++) {
42  int count = fscanf(f, "%le %le %le %le\n", &z[i],
43  &gf[0][i], &gf[1][i], &gf[2][i]);
44  // Check that all the stuff in the benchmark is there
45  ASSERT_EQUAL(4, count);
46  }
47  fclose(f);
48 }
size_t count(InputIterator first, InputIterator last, T const &item)
Definition: catch.hpp:2747
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_hiz_data __ctest_growth_hiz_data
static

Definition at line 107 of file ccl_test_growth_hiz.c.