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

Go to the source code of this file.

Classes

struct  angpow_data
 

Macros

#define NZ   1024
 
#define Z0_GC   1.0
 
#define SZ_GC   0.02
 
#define NL   499
 
#define CLS_PRECISION   3E-3
 

Functions

void __attribute__ ((weak))
 
static void test_angpow_precision (struct angpow_data *data)
 
void __ctest_angpow_precision_run (struct angpow_data *data)
 

Variables

static struct angpow_data __ctest_angpow_data
 

Macro Definition Documentation

#define CLS_PRECISION   3E-3

Definition at line 11 of file ccl_test_angpow.c.

Referenced by test_angpow_precision().

#define NL   499

Definition at line 9 of file ccl_test_angpow.c.

Referenced by test_angpow_precision().

#define NZ   1024

Definition at line 6 of file ccl_test_angpow.c.

Referenced by test_angpow_precision().

#define SZ_GC   0.02

Definition at line 8 of file ccl_test_angpow.c.

Referenced by test_angpow_precision().

#define Z0_GC   1.0

Definition at line 7 of file ccl_test_angpow.c.

Referenced by test_angpow_precision().

Function Documentation

void __attribute__ ( (weak)  )

Definition at line 32 of file ccl_test_angpow.c.

References ccl_mnu_sum.

32  {
33  data->Omega_c = 0.25;
34  data->Omega_b = 0.05;
35  data->h = 0.7;
36  data->A_s = 2.1e-9;
37  data->n_s = 0.96;
38  data->Omega_v = 0.7;
39  data->Neff=3.046;
40  double mnuval = 0.;
41  data->mnu = &mnuval;
42  data->mnu_type = ccl_mnu_sum;
43  data->w_0 = -1;
44  data->w_a = 0;
45  data->Omega_k = 0;
46 }
void __ctest_angpow_precision_run ( struct angpow_data data)

Definition at line 119 of file ccl_test_angpow.c.

References test_angpow_precision().

119  {
120  test_angpow_precision(data);
121 }
static void test_angpow_precision(struct angpow_data *data)
static void test_angpow_precision ( struct angpow_data data)
static

Definition at line 50 of file ccl_test_angpow.c.

References angpow_data::A_s, ASSERT_TRUE, ccl_angular_cls(), ccl_boltzmann_class, ccl_cl_tracer_free(), ccl_cl_tracer_number_counts(), ccl_cl_workspace_free(), ccl_cl_workspace_new(), ccl_cosmology_create(), ccl_cosmology_free(), ccl_linear, ccl_parameters_create(), CCL_ClTracer::chimax, CCL_ClTracer::chimin, CLS_PRECISION, default_config, angpow_data::h, cl_cmbl_bm::l, ccl_configuration::matter_power_spectrum_method, angpow_data::mnu, angpow_data::mnu_type, angpow_data::n_s, angpow_data::Neff, NL, NZ, angpow_data::Omega_b, angpow_data::Omega_c, ccl_parameters::Omega_g, angpow_data::Omega_k, ccl_parameters::Omega_l, angpow_data::Omega_v, pow(), SZ_GC, ccl_configuration::transfer_function_method, angpow_data::w_0, angpow_data::w_a, and Z0_GC.

Referenced by __ctest_angpow_precision_run().

51 {
52  // Status flag
53  int status =0;
54 
55  // Initialize cosmological parameters
59  ccl_parameters ccl_params = ccl_parameters_create(data->Omega_c, data->Omega_b, data->Omega_k, data->Neff, data->mnu, data->mnu_type,data->w_0, data->w_a, data->h, data->A_s, data->n_s,-1,-1,-1,-1,NULL,NULL, &status);
60  ccl_params.Omega_g=0.;
61  ccl_params.Omega_l=data->Omega_v;
62 
63  // Initialize cosmology object given cosmo params
64  ccl_cosmology *ccl_cosmo=ccl_cosmology_create(ccl_params,ccl_config);
65 
66  // Create tracers for angular power spectra
67  double z_arr_gc[NZ],nz_arr_gc[NZ],bz_arr[NZ];
68  for(int i=0;i<NZ;i++)
69  {
70  z_arr_gc[i]=Z0_GC-5*SZ_GC+10*SZ_GC*(i+0.5)/NZ;
71  nz_arr_gc[i]=exp(-0.5*pow((z_arr_gc[i]-Z0_GC)/SZ_GC,2));
72  bz_arr[i]=1;
73  }
74 
75  // Galaxy clustering tracer
76  bool has_rsd = true;
77  bool has_magnification = false;
78  CCL_ClTracer *ct_gc_A=ccl_cl_tracer_number_counts(ccl_cosmo,has_rsd,has_magnification,NZ,z_arr_gc,nz_arr_gc,NZ,z_arr_gc,bz_arr,-1,NULL,NULL, &status);
79  CCL_ClTracer *ct_gc_B=ccl_cl_tracer_number_counts(ccl_cosmo,has_rsd,has_magnification,NZ,z_arr_gc,nz_arr_gc,NZ,z_arr_gc,bz_arr,-1,NULL,NULL, &status);
80 
81  int *ells=malloc(NL*sizeof(int));
82  double *cells_gg_angpow=malloc(NL*sizeof(double));
83  for(int ii=0;ii<NL;ii++)
84  ells[ii]=ii;
85 
86 
87  // Workspaces
88  double linstep = 40;
89  double logstep = 1.15;
90  double dchi = (ct_gc_A->chimax-ct_gc_A->chimin)/1000.;
91  CCL_ClWorkspace *wap=ccl_cl_workspace_new(NL+1,2*ells[NL-1],logstep,linstep,&status);
92 
93  // Compute C_ell
94  ccl_angular_cls(ccl_cosmo,wap,ct_gc_A,ct_gc_A,NL,ells,cells_gg_angpow,&status);
95  double rel_precision = 0.;
96  FILE *f=fopen("./tests/benchmark/angpow_gg.txt","r");
97  for(int ii=2;ii<NL;ii++) {
98  int l;
99  double ratio,cl_gg_nl,cl_gg_ap=cells_gg_angpow[ii];
100  int stat=fscanf(f,"%d %lE",&l,&cl_gg_nl);
101  ASSERT_TRUE(l==ells[ii]);
102  ASSERT_TRUE(stat==2);
103  ratio = fabs(cl_gg_nl-cl_gg_ap)/cl_gg_nl;
104  rel_precision += ratio;
105  }
106  fclose(f);
107  rel_precision /= NL;
108  ASSERT_TRUE(rel_precision < CLS_PRECISION);
109 
110  //Free up tracers
111  ccl_cl_tracer_free(ct_gc_A);
112  ccl_cl_tracer_free(ct_gc_B);
113  free(ells);
115  free(cells_gg_angpow);
116  ccl_cosmology_free(ccl_cosmo);
117 }
double Omega_g
Definition: ccl_core.h:53
#define NZ
#define SZ_GC
ccl_mnu_convention mnu_type
matter_power_spectrum_t matter_power_spectrum_method
Definition: ccl_config.h:112
#define ASSERT_TRUE(real)
Definition: ctest.h:142
void ccl_cl_tracer_free(CCL_ClTracer *clt)
Definition: ccl_cls.c:592
double Omega_l
Definition: ccl_core.h:63
transfer_function_t transfer_function_method
Definition: ccl_config.h:111
int * status
Definition: ccl_redshifts.c:41
void ccl_angular_cls(ccl_cosmology *cosmo, CCL_ClWorkspace *w, CCL_ClTracer *clt1, CCL_ClTracer *clt2, int nl_out, int *l, double *cl, int *status)
Definition: ccl_cls.c:943
ccl_cosmology * ccl_cosmology_create(ccl_parameters params, ccl_configuration config)
Definition: ccl_core.c:173
#define NL
void ccl_cosmology_free(ccl_cosmology *cosmo)
Definition: ccl_core.c:829
#define CLS_PRECISION
CCL_ClWorkspace * ccl_cl_workspace_new(int lmax, int l_limber, double l_logstep, int l_linstep, int *status)
Definition: ccl_cls.c:65
#define Z0_GC
CCL_ClTracer * ccl_cl_tracer_number_counts(ccl_cosmology *cosmo, int has_rsd, int has_magnification, int nz_n, double *z_n, double *n, int nz_b, double *z_b, double *b, int nz_s, double *z_s, double *s, int *status)
Definition: ccl_cls.c:622
const ccl_configuration default_config
Definition: ccl_core.c:21
float pow(float base, unsigned long int exp)
Definition: precision.hpp:39
void ccl_cl_workspace_free(CCL_ClWorkspace *w)
Definition: ccl_cls.c:59
double chimax
Definition: ccl_cls.h:34
double chimin
Definition: ccl_cls.h:35
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
double * mnu

Variable Documentation

struct angpow_data __ctest_angpow_data
static

Definition at line 119 of file ccl_test_angpow.c.