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

Go to the source code of this file.

Macros

#define NZ   1024
 
#define Z0_GC   1.0
 
#define SZ_GC   0.02
 
#define NL   499
 

Functions

int main (int argc, char **argv)
 

Macro Definition Documentation

#define NL   499

Definition at line 9 of file angpow_benchmarks.c.

Referenced by main().

#define NZ   1024

Definition at line 6 of file angpow_benchmarks.c.

Referenced by main().

#define SZ_GC   0.02

Definition at line 8 of file angpow_benchmarks.c.

Referenced by main().

#define Z0_GC   1.0

Definition at line 7 of file angpow_benchmarks.c.

Referenced by main().

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 11 of file angpow_benchmarks.c.

References ccl_test_distances::A_s, ccl_angular_cls(), ccl_boltzmann_class, ccl_cl_tracer_free(), ccl_cl_tracer_number_counts(), ccl_cl_workspace_free(), ccl_cosmology_create(), ccl_cosmology_free(), ccl_linear, ccl_mnu_sum, ccl_parameters_create(), CCL_ClTracer::chimax, CCL_ClTracer::chimin, default_config, ccl_test_distances::h, ccl_configuration::matter_power_spectrum_method, ccl_test_distances::mnu, ccl_test_distances::n_s, ccl_test_distances::Neff, NL, NZ, ccl_test_distances::Omega_b, ccl_test_distances::Omega_c, ccl_parameters::Omega_g, ccl_parameters::Omega_l, pow(), norm_params::status, SZ_GC, ccl_configuration::transfer_function_method, and Z0_GC.

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
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
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
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