Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
angpow_benchmarks.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <math.h>
4 #include "ccl.h"
5 
6 #define NZ 1024
7 #define Z0_GC 1.0
8 #define SZ_GC 0.02
9 #define NL 499
10 
11 int main(int argc,char **argv)
12 {
13  double Omega_c = 0.25;
14  double Omega_b = 0.05;
15  double h = 0.7;
16  double A_s = 2.1e-9;
17  double n_s = 0.96;
18  double Omega_v = 0.7;
19  double Neff=3.046;
20  double mnu = 0.;
22  double w_0 = -1;
23  double w_a = 0;
24  double Omega_k = 0;
25 
26  // Status flag
27  int status =0;
28 
29  // Initialize cosmological parameters
33  ccl_parameters ccl_params = ccl_parameters_create(Omega_c, Omega_b, Omega_k, Neff,
34  &mnu, mnu_type,w_0, w_a, h, A_s,
35  n_s,-1,-1,-1,-1,NULL,NULL, &status);
36  ccl_params.Omega_g=0.;
37  ccl_params.Omega_l=Omega_v;
38 
39  // Initialize cosmology object given cosmo params
40  ccl_cosmology *ccl_cosmo=ccl_cosmology_create(ccl_params,ccl_config);
41 
42  // Create tracers for angular power spectra
43  double z_arr_gc[NZ],nz_arr_gc[NZ],bz_arr[NZ];
44  for(int i=0;i<NZ;i++)
45  {
46  z_arr_gc[i]=Z0_GC-5*SZ_GC+10*SZ_GC*(i+0.5)/NZ;
47  nz_arr_gc[i]=exp(-0.5*pow((z_arr_gc[i]-Z0_GC)/SZ_GC,2));
48  bz_arr[i]=1;
49  }
50 
51  // Galaxy clustering tracer
52  bool has_rsd = true;
53  bool has_magnification = false;
54  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);
55  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);
56 
57  int *ells=malloc(NL*sizeof(int));
58  double *cells_gg_native=malloc(NL*sizeof(double));
59  for(int ii=0;ii<NL;ii++)
60  ells[ii]=ii;
61 
62 
63  // Workspaces
64  double linstep = 40;
65  double logstep = 1.15;
66  double dchi = (ct_gc_A->chimax-ct_gc_A->chimin)/1000.;
67  double dlk = 0.003;
68  double zmin = 0.05;
69  CCL_ClWorkspace *wnl=ccl_cl_workspace_default(NL+1,2*ells[NL-1],CCL_NONLIMBER_METHOD_NATIVE,logstep,linstep,dchi,dlk,zmin,&status);
70 
71  // Compute C_ell
72  ccl_angular_cls(ccl_cosmo,wnl,ct_gc_B,ct_gc_B,NL,ells,cells_gg_native,&status);
73  FILE *f=fopen("angpow_gg.txt","w");
74  for(int ii=2;ii<NL;ii++)
75  fprintf(f,"%d %lE\n",ells[ii],cells_gg_native[ii]);
76  fclose(f);
77 
78  //Free up tracers
79  ccl_cl_tracer_free(ct_gc_A);
80  ccl_cl_tracer_free(ct_gc_B);
81  free(ells);
83  free(cells_gg_native);
84  ccl_cosmology_free(ccl_cosmo);
85 
86  return 0;
87 }
double Omega_g
Definition: ccl_core.h:53
#define Z0_GC
matter_power_spectrum_t matter_power_spectrum_method
Definition: ccl_config.h:112
#define NL
void ccl_cl_tracer_free(CCL_ClTracer *clt)
Definition: ccl_cls.c:592
double Omega_l
Definition: ccl_core.h:63
#define SZ_GC
transfer_function_t transfer_function_method
Definition: ccl_config.h:111
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
ccl_mnu_convention
Definition: ccl_core.h:142
void ccl_cosmology_free(ccl_cosmology *cosmo)
Definition: ccl_core.c:829
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
int main(int argc, char **argv)
double chimax
Definition: ccl_cls.h:34
double chimin
Definition: ccl_cls.h:35
#define NZ
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