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

Go to the source code of this file.

Macros

#define OC   0.25
 
#define OB   0.05
 
#define OK   0.00
 
#define ON   0.00
 
#define HH   0.70
 
#define W0   -1.0
 
#define WA   0.00
 
#define NS   0.96
 
#define NORMPS   0.80
 
#define ZD   0.5
 
#define NZ   128
 
#define Z0_GC   0.50
 
#define SZ_GC   0.05
 
#define NL   512
 
#define PS   0.1
 
#define NEFF   3.046
 
#define ELL_MAX_CL   20000
 

Functions

int main (int argc, char **argv)
 

Macro Definition Documentation

#define ELL_MAX_CL   20000

Definition at line 28 of file ccl_corr_sample.c.

Referenced by main().

#define HH   0.70

Definition at line 16 of file ccl_corr_sample.c.

Referenced by main().

#define NEFF   3.046

Definition at line 27 of file ccl_corr_sample.c.

Referenced by main().

#define NL   512

Definition at line 25 of file ccl_corr_sample.c.

#define NORMPS   0.80

Definition at line 20 of file ccl_corr_sample.c.

Referenced by main().

#define NS   0.96

Definition at line 19 of file ccl_corr_sample.c.

Referenced by main().

#define NZ   128

Definition at line 22 of file ccl_corr_sample.c.

Referenced by main().

#define OB   0.05

Definition at line 13 of file ccl_corr_sample.c.

Referenced by main().

#define OC   0.25

Definition at line 12 of file ccl_corr_sample.c.

Referenced by main().

#define OK   0.00

Definition at line 14 of file ccl_corr_sample.c.

Referenced by main().

#define ON   0.00

Definition at line 15 of file ccl_corr_sample.c.

#define PS   0.1

Definition at line 26 of file ccl_corr_sample.c.

#define SZ_GC   0.05

Definition at line 24 of file ccl_corr_sample.c.

Referenced by main().

#define W0   -1.0

Definition at line 17 of file ccl_corr_sample.c.

Referenced by main().

#define WA   0.00

Definition at line 18 of file ccl_corr_sample.c.

Referenced by main().

#define Z0_GC   0.50

Definition at line 23 of file ccl_corr_sample.c.

Referenced by main().

#define ZD   0.5

Definition at line 21 of file ccl_corr_sample.c.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 31 of file ccl_corr_sample.c.

References ccl_angular_cls(), ccl_cl_tracer_free(), ccl_cl_tracer_number_counts_simple(), ccl_cl_workspace_free(), ccl_cl_workspace_new_limber(), CCL_CORR_FFTLOG, CCL_CORR_GG, ccl_correlation(), ccl_cosmology_create(), ccl_cosmology_free(), ccl_log_spacing(), ccl_mnu_sum, ccl_parameters_create(), cl_cmbl_bm::cosmo, default_config, ELL_MAX_CL, HH, ccl_test_distances::mnu, NEFF, NORMPS, NS, NZ, OB, OC, OK, halomod_bm::params, pow(), SZ_GC, w, W0, WA, and Z0_GC.

32 {
33  // Use the default configuration, plus the cosmological parameters that were
34  // defined above
35  int status=0;
36 
37  double mnuval=0.;
38  double* mnu;
39  mnu = &mnuval;
41 
44  W0, WA, HH, NORMPS, NS, -1, -1, -1, -1,
45  NULL, NULL, &status);
46  ccl_cosmology *cosmo = ccl_cosmology_create(params,config);
47 
48  // Create example number density and bias for tracer
49  double z_arr_gc[NZ], nz_arr_gc[NZ], bz_arr[NZ];
50  for(int i=0; i < NZ; i++) {
51  z_arr_gc[i] = Z0_GC - 5.*SZ_GC + 10.*SZ_GC*(i + 0.5)/NZ;
52  nz_arr_gc[i] = exp(-0.5*pow((z_arr_gc[i] - Z0_GC) / SZ_GC, 2));
53  bz_arr[i] = 1. + z_arr_gc[i];
54  }
55 
56  // Define a galaxy clustering tracer and calculate C_ell's
57  double l_logstep = 1.05;
58  double l_linstep = 5.;
59  CCL_ClWorkspace *w=ccl_cl_workspace_new_limber(ELL_MAX_CL+1,l_logstep,l_linstep,&status);
60  //CCL_ClTracer *tr_nc_1=ccl_cl_tracer_number_counts_simple(cosmo,nz,zarr_1,pzarr_1,nz,zarr_1,bzarr,&status);
62  NZ, z_arr_gc, nz_arr_gc,
63  NZ, z_arr_gc, bz_arr,
64  &status);
65  int il;
66  double *clarr = malloc(ELL_MAX_CL*sizeof(double));
67  int *ilarr = malloc(ELL_MAX_CL*sizeof(int));
68  double *larr = malloc(ELL_MAX_CL*sizeof(double));
69  for(il=0; il < ELL_MAX_CL; il++)
70  // Calculate auto-correlation of this tracer
71  larr[il] = il;
72  ccl_angular_cls(cosmo, w, ct_gc, ct_gc, ELL_MAX_CL, ilarr, clarr, &status);
73 
74  // Define cosine tapering, to reduce ringing. The first two numbers are
75  // [lmin, lmax] for the low-ell taper, and the last two are [lmin, lmax] for
76  // the high-ell taper.
77  double taper_cl_limits[4] = {1, 2, 10000, 15000};
78 
79  double *clustering_corr, *theta;
80  int ntheta = 15;
81  theta = ccl_log_spacing(0.01, 5., ntheta); // New array with log spacing
82  clustering_corr = malloc(ntheta*sizeof(double));
83 
84  // Calculate correlation function from angular power spectrum
85  ccl_correlation(cosmo, ELL_MAX_CL, larr, clarr,
86  ntheta, theta, clustering_corr,
87  CCL_CORR_GG, 0, taper_cl_limits,
88  CCL_CORR_FFTLOG, &status);
89 
90  // Print results
91  for(int it=0; it < ntheta; it++)
92  printf("%le %le\n", theta[it], clustering_corr[it]);
93 
94  // Free tracers and other allocated memory
96  ccl_cl_tracer_free(ct_gc);
97  ccl_cosmology_free(cosmo);
98  free(clustering_corr);
99  free(ilarr);
100  free(larr);
101  free(clarr);
102 
103  return 0;
104 }
#define W0
#define OC
#define Z0_GC
#define SZ_GC
#define ELL_MAX_CL
double * ccl_log_spacing(double xmin, double xmax, int N)
Definition: ccl_utils.c:102
#define WA
void ccl_cl_tracer_free(CCL_ClTracer *clt)
Definition: ccl_cls.c:592
#define OK
CCL_ClWorkspace * ccl_cl_workspace_new_limber(int lmax, double l_logstep, int l_linstep, int *status)
Definition: ccl_cls.c:124
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
CCL_ClTracer * ccl_cl_tracer_number_counts_simple(ccl_cosmology *cosmo, int nz_n, double *z_n, double *n, int nz_b, double *z_b, double *b, int *status)
Definition: ccl_cls.c:633
void ccl_cosmology_free(ccl_cosmology *cosmo)
Definition: ccl_core.c:829
dictionary params
Definition: halomod_bm.py:27
#define CCL_CORR_GG
#define CCL_CORR_FFTLOG
CCL_BEGIN_DECLS void ccl_correlation(ccl_cosmology *cosmo, int n_ell, double *ell, double *cls, int n_theta, double *theta, double *wtheta, int corr_type, int do_taper_cl, double *taper_cl_limits, int flag_method, int *status)
#define NZ
#define NORMPS
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
#define OB
#define NEFF
#define NS
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
static double w[2][28][111]
Definition: ccl_emu17.c:33
#define HH