CCL: /home/chisarie/Documents/lsst_ccl/CCL/include/ccl_core.h Source File

CCL

ccl_core.h
Go to the documentation of this file.
1
3 #pragma once
4 #include "gsl/gsl_spline.h"
5 #include "gsl/gsl_interp2d.h"
6 #include "gsl/gsl_spline2d.h"
7 #include "ccl_config.h"
8 #include "ccl_constants.h"
9 #include <stdbool.h>
10
11 // Macros for replacing relative paths
12 #define EXPAND_STR(s) STRING(s)
13 #define STRING(s) #s
14
18 typedef struct ccl_parameters {
19
20 // Densities: CDM, baryons, total matter, neutrinos, curvature
21 double Omega_c;
22 double Omega_b;
23 double Omega_m;
24 double Omega_k;
25 double sqrtk; //TODO check
26 int k_sign;
29 // Dark Energy
30 double w0;
31 double wa;
32
33 // Hubble parameters
34 double H0;
35 double h;
36
37 // Neutrino properties
38 // At the moment, only support equal-mass massive neutrinos (cannot have two different masses)
39 double N_nu_mass; // Number of different species of massive neutrinos
40 double N_nu_rel; // Neff massless
41 double mnu; // total mass of massive neutrinos
42 double Omega_n_mass; // Omega_nu for MASSIVE neutrinos
43 double Omega_n_rel; // Omega_nu for MASSLESS neutrinos
44
45 //double Neff_partial[CCL_MAX_NU_SPECIES];
46 //double mnu[CCL_MAX_NU_SPECIES];
47
48 // Primordial power spectra
49 double A_s;
50 double n_s;
51
52 // Radiation parameters
53 double Omega_g;
54 double T_CMB;
55
56 // Derived parameters
57 double sigma_8;
58 double Omega_l;
59 double z_star;
60
61 //Modified growth rate
62 bool has_mgrowth;
63 int nz_mgrowth;
64 double *z_mgrowth;
65 double *df_mgrowth;
66 } ccl_parameters;
67
68
72 typedef struct ccl_data{
73 // These are all functions of the scale factor a.
74
75 // Distances are defined in Mpc
76 double growth0;
77 gsl_spline * chi;
78 gsl_spline * growth;
79 gsl_spline * fgrowth;
80 gsl_spline * E;
81 gsl_spline * achi;
82
83 // All these splines use the same accelerator so that
84 // if one calls them successively with the same a value
85 // they will be much faster.
86 gsl_interp_accel *accelerator;
87 gsl_interp_accel *accelerator_achi;
88 gsl_interp_accel *accelerator_m;
89 gsl_interp_accel *accelerator_d;
90 //TODO: it seems like we're not really using this accelerator, and we should
91 gsl_interp_accel *accelerator_k;
92
93 // Function of Halo mass M
94
95 gsl_spline * logsigma;
96 gsl_spline * dlnsigma_dlogm;
97
98 // splines for halo mass function
99 gsl_spline * alphahmf;
100 gsl_spline * betahmf;
101 gsl_spline * gammahmf;
102 gsl_spline * phihmf;
103 gsl_spline * etahmf;
104
105 // These are all functions of the wavenumber k and the scale factor a.
106 gsl_spline2d * p_lin;
107 gsl_spline2d * p_nl;
108 double k_min; //k_min [1/Mpc] <- minimum wavenumber that the power spectrum has been computed to
109
110 } ccl_data;
111
115 typedef struct ccl_cosmology
116 {
117 ccl_parameters params;
118 ccl_configuration config;
119 ccl_data data;
120
121 bool computed_distances;
122 bool computed_growth;
123 bool computed_power;
124 bool computed_sigma;
125 bool computed_hmfparams;
126
127 int status;
128 //this is optional - less tedious than tracking all numerical values for status in error handler function
129 char status_message[500];
130
131 // other flags?
132 } ccl_cosmology;
133
134
135 // Initialization and life cycle of objects
136 void ccl_cosmology_read_config(void);
137 ccl_cosmology * ccl_cosmology_create(ccl_parameters params, ccl_configuration config);
138
139
140 // Helper functions to create ccl_cosmology structs directly given a set of params
141 ccl_cosmology * ccl_cosmology_create_with_params(
142 double Omega_c, double Omega_b, double Omega_k, double N_nu_rel, double N_nu_mass, double mnu,
143 double w0, double wa, double h, double norm_pk, double n_s,
144 int nz_mgrowth, double *zarr_mgrowth, double *dfarr_mgrowth,
145 ccl_configuration config, int *status);
146
147 ccl_cosmology * ccl_cosmology_create_with_lcdm_params(
148 double Omega_c, double Omega_b, double Omega_k, double h,
149 double norm_pk, double n_s,
150 ccl_configuration config, int *status);
151
152 // User-facing creation routines
173 ccl_parameters ccl_parameters_create(double Omega_c, double Omega_b, double Omega_k, double N_nu_rel, double N_nu_mass, double mnu, double w0, double wa, double h, double norm_pk, double n_s,int nz_mgrowth,double *zarr_mgrowth,double *dfarr_mgrowth, int *status);
174
175 // Specific sub-models
187 ccl_parameters ccl_parameters_create_flat_lcdm(double Omega_c, double Omega_b, double h, double norm_pk, double n_s, int *status);
188
201 ccl_parameters ccl_parameters_create_flat_wcdm(double Omega_c, double Omega_b, double w0, double h, double norm_pk, double n_s, int *status);
202
216 ccl_parameters ccl_parameters_create_flat_wacdm(double Omega_c, double Omega_b, double w0,double wa, double h, double norm_pk, double n_s, int *status);
217
232 ccl_parameters ccl_parameters_create_lcdm(double Omega_c, double Omega_b, double Omega_k, double h, double norm_pk, double n_s, int *status);
233
234 ccl_parameters ccl_parameters_create_flat_lcdm_nu(double Omega_c, double Omega_b, double h, double norm_pk, double n_s, double N_nu_rel, double N_nu_mass, double mnu, int *status);
235 ccl_parameters ccl_parameters_create_flat_wcdm_nu(double Omega_c, double Omega_b, double w0, double h, double norm_pk, double n_s, double N_nu_rel, double N_nu_mass, double mnu, int *status);
236 ccl_parameters ccl_parameters_create_flat_wacdm_nu(double Omega_c, double Omega_b, double w0,double wa, double h, double norm_pk, double n_s, double N_nu_rel, double N_nu_mass, double mnu, int *status);
237 ccl_parameters ccl_parameters_create_lcdm_nu(double Omega_c, double Omega_b, double Omega_k, double h, double norm_pk, double n_s, double N_nu_rel, double N_nu_mass, double mnu, int *status);
238
244 void ccl_cosmology_free(ccl_cosmology * cosmo);
245
254 void ccl_cosmology_compute_distances(ccl_cosmology * cosmo,int *status);
255
264 void ccl_cosmology_compute_growth(ccl_cosmology * cosmo, int * status);
265
274 void ccl_cosmology_compute_power(ccl_cosmology * cosmo, int* status);
ccl_data::accelerator_m
gsl_interp_accel * accelerator_m
Definition: ccl_core.h:88
ccl_cosmology::computed_power
bool computed_power
Definition: ccl_core.h:123
ccl_configuration
Definition: ccl_config.h:70
ccl_parameters::Omega_g
double Omega_g
Definition: ccl_core.h:53
ccl_parameters::N_nu_mass
double N_nu_mass
Definition: ccl_core.h:39
ccl_cosmology_compute_power
void ccl_cosmology_compute_power(ccl_cosmology *cosmo, int *status)
Definition: ccl_power.c:953
ccl_parameters::df_mgrowth
double * df_mgrowth
Definition: ccl_core.h:65
ccl_data::growth0
double growth0
Definition: ccl_core.h:76
ccl_parameters_create_lcdm_nu
ccl_parameters ccl_parameters_create_lcdm_nu(double Omega_c, double Omega_b, double Omega_k, double h, double norm_pk, double n_s, double N_nu_rel, double N_nu_mass, double mnu, int *status)
Definition: ccl_core.c:389
ccl_parameters::has_mgrowth
bool has_mgrowth
Definition: ccl_core.h:62
ccl_parameters::Omega_b
double Omega_b
Definition: ccl_core.h:22
ccl_cosmology::params
ccl_parameters params
Definition: ccl_core.h:117
ccl_parameters::N_nu_rel
double N_nu_rel
Definition: ccl_core.h:40
ccl_parameters::H0
double H0
Definition: ccl_core.h:34
ccl_data
Definition: ccl_core.h:72
ccl_data::k_min
double k_min
Definition: ccl_core.h:108
ccl_parameters::Omega_n_mass
double Omega_n_mass
Definition: ccl_core.h:42
ccl_parameters::k_sign
int k_sign
Definition: ccl_core.h:26
ccl_parameters
Definition: ccl_core.h:18
ccl_parameters::n_s
double n_s
Definition: ccl_core.h:50
ccl_parameters::h
double h
Definition: ccl_core.h:35
ccl_cosmology
struct ccl_cosmology ccl_cosmology
ccl_parameters::w0
double w0
Definition: ccl_core.h:30
ccl_parameters::Omega_l
double Omega_l
Definition: ccl_core.h:58
ccl_data::betahmf
gsl_spline * betahmf
Definition: ccl_core.h:100
ccl_parameters::mnu
double mnu
Definition: ccl_core.h:41
ccl_parameters::z_mgrowth
double * z_mgrowth
Definition: ccl_core.h:64
ccl_parameters_create_flat_wcdm
ccl_parameters ccl_parameters_create_flat_wcdm(double Omega_c, double Omega_b, double w0, double h, double norm_pk, double n_s, int *status)
Definition: ccl_core.c:407
ccl_data::alphahmf
gsl_spline * alphahmf
Definition: ccl_core.h:99
ccl_data::accelerator_d
gsl_interp_accel * accelerator_d
Definition: ccl_core.h:89
ccl_parameters_create_flat_lcdm_nu
ccl_parameters ccl_parameters_create_flat_lcdm_nu(double Omega_c, double Omega_b, double h, double norm_pk, double n_s, double N_nu_rel, double N_nu_mass, double mnu, int *status)
Definition: ccl_core.c:355
ccl_cosmology_compute_distances
void ccl_cosmology_compute_distances(ccl_cosmology *cosmo, int *status)
Definition: ccl_background.c:283
ccl_cosmology_create_with_lcdm_params
ccl_cosmology * ccl_cosmology_create_with_lcdm_params(double Omega_c, double Omega_b, double Omega_k, double h, double norm_pk, double n_s, ccl_configuration config, int *status)
Definition: ccl_core.c:197
ccl_data::p_lin
gsl_spline2d * p_lin
Definition: ccl_core.h:106
ccl_parameters::A_s
double A_s
Definition: ccl_core.h:49
ccl_cosmology_create
ccl_cosmology * ccl_cosmology_create(ccl_parameters params, ccl_configuration config)
Definition: ccl_core.c:101
ccl_data::accelerator_achi
gsl_interp_accel * accelerator_achi
Definition: ccl_core.h:87
ccl_parameters_create
ccl_parameters ccl_parameters_create(double Omega_c, double Omega_b, double Omega_k, double N_nu_rel, double N_nu_mass, double mnu, double w0, double wa, double h, double norm_pk, double n_s, int nz_mgrowth, double *zarr_mgrowth, double *dfarr_mgrowth, int *status)
Definition: ccl_core.c:282
ccl_parameters_create_flat_wacdm_nu
ccl_parameters ccl_parameters_create_flat_wacdm_nu(double Omega_c, double Omega_b, double w0, double wa, double h, double norm_pk, double n_s, double N_nu_rel, double N_nu_mass, double mnu, int *status)
Definition: ccl_core.c:456
ccl_data::chi
gsl_spline * chi
Definition: ccl_core.h:77
ccl_parameters::sqrtk
double sqrtk
Definition: ccl_core.h:25
ccl_cosmology_read_config
void ccl_cosmology_read_config(void)
Definition: ccl_core.c:29
ccl_data::E
gsl_spline * E
Definition: ccl_core.h:80
ccl_data::phihmf
gsl_spline * phihmf
Definition: ccl_core.h:102
ccl_cosmology_create_with_params
ccl_cosmology * ccl_cosmology_create_with_params(double Omega_c, double Omega_b, double Omega_k, double N_nu_rel, double N_nu_mass, double mnu, double w0, double wa, double h, double norm_pk, double n_s, int nz_mgrowth, double *zarr_mgrowth, double *dfarr_mgrowth, ccl_configuration config, int *status)
Definition: ccl_core.c:162
ccl_parameters::Omega_n_rel
double Omega_n_rel
Definition: ccl_core.h:43
ccl_data::p_nl
gsl_spline2d * p_nl
Definition: ccl_core.h:107
ccl_parameters::T_CMB
double T_CMB
Definition: ccl_core.h:54
ccl_cosmology_free
void ccl_cosmology_free(ccl_cosmology *cosmo)
Definition: ccl_core.c:517
ccl_data::achi
gsl_spline * achi
Definition: ccl_core.h:81
ccl_data::accelerator_k
gsl_interp_accel * accelerator_k
Definition: ccl_core.h:91
ccl_parameters_create_lcdm
ccl_parameters ccl_parameters_create_lcdm(double Omega_c, double Omega_b, double Omega_k, double h, double norm_pk, double n_s, int *status)
Definition: ccl_core.c:372
ccl_data::logsigma
gsl_spline * logsigma
Definition: ccl_core.h:95
ccl_data::accelerator
gsl_interp_accel * accelerator
Definition: ccl_core.h:86
ccl_parameters_create_flat_wcdm_nu
ccl_parameters ccl_parameters_create_flat_wcdm_nu(double Omega_c, double Omega_b, double w0, double h, double norm_pk, double n_s, double N_nu_rel, double N_nu_mass, double mnu, int *status)
Definition: ccl_core.c:425
ccl_data::fgrowth
gsl_spline * fgrowth
Definition: ccl_core.h:79
ccl_cosmology::computed_growth
bool computed_growth
Definition: ccl_core.h:122
ccl_data::gammahmf
gsl_spline * gammahmf
Definition: ccl_core.h:101
ccl_cosmology::computed_hmfparams
bool computed_hmfparams
Definition: ccl_core.h:125
ccl_parameters::Omega_c
double Omega_c
Definition: ccl_core.h:21
ccl_cosmology_compute_growth
void ccl_cosmology_compute_growth(ccl_cosmology *cosmo, int *status)
Definition: ccl_background.c:445
ccl_cosmology
Definition: ccl_core.h:115
ccl_data::dlnsigma_dlogm
gsl_spline * dlnsigma_dlogm
Definition: ccl_core.h:96
ccl_cosmology::status
int status
Definition: ccl_core.h:127
ccl_parameters_create_flat_wacdm
ccl_parameters ccl_parameters_create_flat_wacdm(double Omega_c, double Omega_b, double w0, double wa, double h, double norm_pk, double n_s, int *status)
Definition: ccl_core.c:440
ccl_parameters::nz_mgrowth
int nz_mgrowth
Definition: ccl_core.h:63
ccl_cosmology::computed_distances
bool computed_distances
Definition: ccl_core.h:121
ccl_cosmology::config
ccl_configuration config
Definition: ccl_core.h:118
ccl_parameters::Omega_k
double Omega_k
Definition: ccl_core.h:24
ccl_constants.h
ccl_data::etahmf
gsl_spline * etahmf
Definition: ccl_core.h:103
ccl_parameters_create_flat_lcdm
ccl_parameters ccl_parameters_create_flat_lcdm(double Omega_c, double Omega_b, double h, double norm_pk, double n_s, int *status)
Definition: ccl_core.c:337
ccl_parameters::Omega_m
double Omega_m
Definition: ccl_core.h:23
ccl_parameters
struct ccl_parameters ccl_parameters
ccl_config.h
ccl_data::growth
gsl_spline * growth
Definition: ccl_core.h:78
ccl_data
struct ccl_data ccl_data
ccl_cosmology::data
ccl_data data
Definition: ccl_core.h:119
ccl_parameters::sigma_8
double sigma_8
Definition: ccl_core.h:57
ccl_parameters::z_star
double z_star
Definition: ccl_core.h:59
ccl_cosmology::computed_sigma
bool computed_sigma
Definition: ccl_core.h:124
ccl_parameters::wa
double wa
Definition: ccl_core.h:31