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

Go to the source code of this file.

Macros

#define NREL   3.046
 
#define NMAS   0
 
#define MNU   0.0
 

Functions

void write_Pk_CLASS (int i_model)
 
int main (void)
 

Macro Definition Documentation

#define MNU   0.0

Definition at line 8 of file write_CLASS_benchmark.c.

Referenced by main(), and write_Pk_CLASS().

#define NMAS   0

Definition at line 7 of file write_CLASS_benchmark.c.

Referenced by write_Pk_CLASS().

#define NREL   3.046

Definition at line 6 of file write_CLASS_benchmark.c.

Referenced by write_Pk_CLASS().

Function Documentation

int main ( void  )

Definition at line 63 of file write_CLASS_benchmark.c.

References write_Pk_CLASS().

63  {
64  for (int i = 1; i < 7; i++){
65  write_Pk_CLASS(i);
66  }
67 }
void write_Pk_CLASS(int i_model)
void write_Pk_CLASS ( int  i_model)

Definition at line 10 of file write_CLASS_benchmark.c.

References ccl_cosmology_create(), ccl_cosmology_free(), ccl_cosmology_write_power_class_z(), ccl_parameters_create(), cl_cmbl_bm::cosmo, default_config, ccl_test_distances::h, MNU, ccl_test_distances::n_s, NMAS, NREL, ccl_test_distances::Omega_b, ccl_test_distances::Omega_c, ccl_parameters::Omega_g, halomod_bm::params, ccl_test_power::sigma8, and z.

Referenced by main().

11 {
12  int status=0;
13  char fname[256];
14  FILE *f;
15  int i_model_vec[6]={1,3,5,6,8,10}; //The emulator cosmologies we can compare to
16  double z = 0.0;
17 
18  double *sigma8;
19  double *Omega_c;
20  double *Omega_b;
21  double *n_s;
22  double *h;
23  double *w_0;
24  double *w_a;
25  sigma8=malloc(6*sizeof(double));
26  Omega_c=malloc(6*sizeof(double));
27  Omega_b=malloc(6*sizeof(double));
28  n_s=malloc(6*sizeof(double));
29  h=malloc(6*sizeof(double));
30  w_0=malloc(6*sizeof(double));
31  w_a=malloc(6*sizeof(double));
32 
33  sprintf(fname,"./tests/benchmark/emu_cosmologies.txt");
34  f=fopen(fname,"r");
35  if(f==NULL) {
36  fprintf(stderr,"Error opening file %s\n",fname);
37  exit(1);
38  }
39 
40  for(int i=0;i<6;i++) {
41 
42  status=fscanf(f,"%le %le %le %le %le %le %le\n",&Omega_c[i],&Omega_b[i],&h[i],&sigma8[i],&n_s[i],&w_0[i],&w_a[i]);
43  if(status!=7) {
44  fprintf(stderr,"Error reading file %s, line %d\n",fname,i);
45  exit(1);
46  }
47  }
48  fclose(f);
49 
50 
52  status = 0;
53  //None of the current cosmologies being checked include neutrinos
54  ccl_parameters params = ccl_parameters_create(Omega_c[i_model-1],Omega_b[i_model-1],0.0,NREL, NMAS, MNU,w_0[i_model-1],w_a[i_model-1],h[i_model-1],sigma8[i_model-1],n_s[i_model-1],-1,NULL,NULL, &status);
55  params.Omega_g=0;
56  ccl_cosmology * cosmo = ccl_cosmology_create(params, config);
57  sprintf(fname,"./tests/benchmark/CLASS_Pk_M%d.txt",i_model_vec[i_model-1]);
58  ccl_cosmology_write_power_class_z(fname, cosmo, z, &status);
59  printf("Wrote %s, status = %d\n", fname,status);
60  ccl_cosmology_free(cosmo);
61 }
double Omega_g
Definition: ccl_core.h:53
#define NMAS
ccl_cosmology * ccl_cosmology_create(ccl_parameters params, ccl_configuration config)
Definition: ccl_core.c:173
#define NREL
CCL_BEGIN_DECLS void ccl_cosmology_write_power_class_z(char *filename, ccl_cosmology *cosmo, double z, int *status)
Definition: ccl_power.c:596
void ccl_cosmology_free(ccl_cosmology *cosmo)
Definition: ccl_core.c:829
dictionary params
Definition: halomod_bm.py:27
static double z[8]
const ccl_configuration default_config
Definition: ccl_core.c: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
#define MNU