CLASS MANUAL
background.h
Go to the documentation of this file.
1 
3 #ifndef __BACKGROUND__
4 #define __BACKGROUND__
5 
6 #include "common.h"
7 #include "quadrature.h"
8 #include "growTable.h"
9 #include "arrays.h"
10 #include "dei_rkck.h"
11 #include "parser.h"
12 
15 enum equation_of_state {CLP,EDE};
16 
17 
20 enum varconst_dependence {varconst_none,varconst_instant};
21 
24 enum vecback_format {short_info, normal_info, long_info};
25 
30 enum interpolation_method {inter_normal, inter_closeby};
31 
43 struct background
44 {
57 
58  double H0;
59  double h;
61  double Omega0_g;
62  double T_cmb;
64  double Omega0_b;
66  double Omega0_ur;
68  double Omega0_cdm;
70  double Omega0_idm;
73  double Omega0_idr;
74  double T_idr;
76  double Omega0_dcdmdr;
77  double Omega_ini_dcdm;
78  double Gamma_dcdm;
79  double tau_dcdm;
80 
81  int N_ncdm;
82  /* the following parameters help to define tabulated ncdm p-s-d passed in file */
83  char * ncdm_psd_files;
84  int * got_files;
85  /* the following parameters help to define the analytical ncdm phase space distributions (p-s-d) */
88  double * M_ncdm;
89  double * m_ncdm_in_eV;
90  double * Omega0_ncdm, Omega0_ncdm_tot;
91  double * T_ncdm,T_ncdm_default;
93  double * ksi_ncdm, ksi_ncdm_default;
95  double * deg_ncdm, deg_ncdm_default;
99  double * ncdm_qmax;
101  double Omega0_k;
103  double Omega0_lambda;
104  double Omega0_fld;
105  double Omega0_scf;
106  short use_ppf;
110  double w0_fld;
111  double wa_fld;
112  double cs2_fld;
114  double Omega_EDE;
115  double * scf_parameters;
118  double phi_ini_scf;
121  double varconst_alpha;
122  double varconst_me;
127 
128 
132 
133  double age;
134  double conformal_age;
135  double K;
136  int sgnK;
137  double Neff;
138  double Omega0_dcdm;
139  double Omega0_dr;
140  double Omega0_m;
141  double Omega0_r;
142  double Omega0_de;
143  double Omega0_nfsm;
144  double a_eq;
145  double H_eq;
146  double z_eq;
147  double tau_eq;
150 
151 
155 
162  /* end of vector in short format, now quantities in normal format */
163 
195  /* end of vector in normal format, now quantities in long format */
196 
213  int bg_size;
216 
217 
221 
222  int bt_size;
223  double * loga_table;
224  double * tau_table;
225  double * z_table;
226  double * background_table;
229 
230 
234 
235  double * d2tau_dz2_table;
236  double * d2z_dtau2_table;
240 
241 
254 
267  int bi_B_size;
268  int bi_size;
271 
281 
282  short has_cdm;
283  short has_idm;
284  short has_dcdm;
285  short has_dr;
286  short has_scf;
287  short has_ncdm;
288  short has_lambda;
289  short has_fld;
290  short has_ur;
291  short has_idr;
293  short has_varconst;
296 
297 
303 
305  double ** q_ncdm_bg;
306  double ** w_ncdm_bg;
307  double ** q_ncdm;
308  double ** w_ncdm;
309  double ** dlnf0_dlnq_ncdm;
311  int * q_size_ncdm;
312  double * factor_ncdm;
315 
319 
321  ErrorMsg shooting_error;
325  ErrorMsg error_message;
327  short is_allocated;
329 };
330 
331 
337 
338  /* structures containing fixed input parameters (indices, ...) */
339  struct background * pba;
340 
341  /* workspace */
342  double * pvecback;
343 
344 };
345 
351 
352  /* structures containing fixed input parameters (indices, ...) */
353  struct background * pba;
354 
355  /* Additional parameters */
356 
357  /* Index of current distribution function */
358  int n_ncdm;
359 
360  /* Used for interpolating in file of tabulated p-s-d: */
361  int tablesize;
362  double *q;
363  double *f0;
364  double *d2f0;
365  int last_index;
366 
367 };
368 
369 /**************************************************************/
370 /* @cond INCLUDE_WITH_DOXYGEN */
371 /*
372  * Boilerplate for C++
373  */
374 #ifdef __cplusplus
375 extern "C" {
376 #endif
377 
378  int background_at_z(
379  struct background *pba,
380  double a_rel,
381  enum vecback_format return_format,
382  enum interpolation_method inter_mode,
383  int * last_index,
384  double * pvecback
385  );
386 
387  int background_at_tau(
388  struct background *pba,
389  double tau,
390  enum vecback_format return_format,
391  enum interpolation_method inter_mode,
392  int * last_index,
393  double * pvecback
394  );
395 
397  struct background *pba,
398  double z,
399  double * tau
400  );
401 
403  struct background *pba,
404  double tau,
405  double * z
406  );
407 
409  struct background *pba,
410  double a_rel,
411  double * pvecback_B,
412  enum vecback_format return_format,
413  double * pvecback
414  );
415 
416  int background_w_fld(
417  struct background * pba,
418  double a,
419  double * w_fld,
420  double * dw_over_da_fld,
421  double * integral_fld);
422 
424  struct background* pba,
425  double z,
426  double* alpha,
427  double* me
428  );
429 
430  int background_init(
431  struct precision *ppr,
432  struct background *pba
433  );
434 
435  int background_free(
436  struct background *pba
437  );
438 
440  struct background *pba
441  );
442 
444  struct background *pba
445  );
446 
447  int background_indices(
448  struct background *pba
449  );
450 
452  void *pba,
453  double q,
454  double * f0
455  );
456 
458  void *pba,
459  double q,
460  double * test
461  );
462 
464  struct precision *ppr,
465  struct background *pba
466  );
467 
469  double * qvec,
470  double * wvec,
471  int qsize,
472  double M,
473  double factor,
474  double z,
475  double * n,
476  double * rho,
477  double * p,
478  double * drho_dM,
479  double * pseudo_p
480  );
481 
483  struct precision *ppr,
484  struct background *pba,
485  int species
486  );
487 
488  int background_checks(
489  struct precision * ppr,
490  struct background *pba
491  );
492 
493  int background_solve(
494  struct precision *ppr,
495  struct background *pba
496  );
497 
499  struct precision *ppr,
500  struct background *pba,
501  double * pvecback,
502  double * pvecback_integration,
503  double * loga_ini
504  );
505 
507  struct precision *ppr,
508  struct background *pba
509  );
510 
511 
512  int background_output_titles(struct background * pba,
513  char titles[_MAXTITLESTRINGLENGTH_]
514  );
515 
517  struct background *pba,
518  int number_of_titles,
519  double *data);
520 
521  int background_derivs(
522  double loga,
523  double * y,
524  double * dy,
525  void * parameters_and_workspace,
526  ErrorMsg error_message
527  );
528 
529  int background_sources(
530  double loga,
531  double * y,
532  double * dy,
533  int index_loga,
534  void * parameters_and_workspace,
535  ErrorMsg error_message
536  );
537 
539  double loga,
540  void * parameters_and_workspace,
541  double * timescale,
542  ErrorMsg error_message
543  );
544 
546  struct background* pba
547  );
548 
550  double V_scf(
551  struct background *pba,
552  double phi
553  );
554 
555  double dV_scf(
556  struct background *pba,
557  double phi
558  );
559 
560  double ddV_scf(
561  struct background *pba,
562  double phi
563  );
564 
566  double Q_scf(
567  struct background *pba,
568  double phi,
569  double phi_prime
570  );
571 
572 #ifdef __cplusplus
573 }
574 #endif
575 
576 /**************************************************************/
577 
583 
584 #define _Mpc_over_m_ 3.085677581282e22
585 /* remark: CAMB uses 3.085678e22: good to know if you want to compare with high accuracy */
586 
587 #define _Gyr_over_Mpc_ 3.06601394e2
589 #define _c_ 2.99792458e8
590 #define _G_ 6.67428e-11
591 #define _eV_ 1.602176487e-19
593 /* parameters entering in Stefan-Boltzmann constant sigma_B */
594 #define _k_B_ 1.3806504e-23
595 #define _h_P_ 6.62606896e-34
596 /* remark: sigma_B = 2 pi^5 k_B^4 / (15h^3c^2) = 5.670400e-8
597  = Stefan-Boltzmann constant in W/m^2/K^4 = Kg/K^4/s^3 */
598 
600 
606 
607 #define _h_BIG_ 1.5
608 #define _h_SMALL_ 0.3
609 #define _omegab_BIG_ 0.039
610 #define _omegab_SMALL_ 0.005
613 
619 
620 #define _SCALE_BACK_ 0.1
624 #define _PSD_DERIVATIVE_EXP_MIN_ -30
625 #define _PSD_DERIVATIVE_EXP_MAX_ 2
627 #define _zeta3_ 1.2020569031595942853997381615114499907649862923404988817922
628 #define _zeta5_ 1.0369277551433699263313654864570341680570809195019128119741
631 
632 
633 #endif
634 /* @endcond */
int background_output_titles(struct background *pba, char titles[_MAXTITLESTRINGLENGTH_])
Definition: background.c:2422
int background_output_data(struct background *pba, int number_of_titles, double *data)
Definition: background.c:2492
int background_checks(struct precision *ppr, struct background *pba)
Definition: background.c:1735
int background_varconst_of_z(struct background *pba, double z, double *alpha, double *me)
Definition: background.c:766
int background_functions(struct background *pba, double a, double *pvecback_B, enum vecback_format return_format, double *pvecback)
Definition: background.c:371
int background_output_budget(struct background *pba)
Definition: background.c:2781
int background_initial_conditions(struct precision *ppr, struct background *pba, double *pvecback, double *pvecback_integration, double *loga_ini)
Definition: background.c:2131
int background_ncdm_distribution(void *pbadist, double q, double *f0)
Definition: background.c:1205
int background_w_fld(struct background *pba, double a, double *w_fld, double *dw_over_da_fld, double *integral_fld)
Definition: background.c:664
int background_at_z(struct background *pba, double z, enum vecback_format return_format, enum interpolation_method inter_mode, int *last_index, double *pvecback)
Definition: background.c:132
int background_ncdm_test_function(void *pbadist, double q, double *test)
Definition: background.c:1342
int background_free(struct background *pba)
Definition: background.c:863
int background_ncdm_M_from_Omega(struct precision *ppr, struct background *pba, int n_ncdm)
Definition: background.c:1667
int background_free_input(struct background *pba)
Definition: background.c:910
int background_free_noinput(struct background *pba)
Definition: background.c:888
int background_ncdm_init(struct precision *ppr, struct background *pba)
Definition: background.c:1367
int background_sources(double loga, double *y, double *dy, int index_loga, void *parameters_and_workspace, ErrorMsg error_message)
Definition: background.c:2690
int background_tau_of_z(struct background *pba, double z, double *tau)
Definition: background.c:268
int background_indices(struct background *pba)
Definition: background.c:963
int background_z_of_tau(struct background *pba, double tau, double *z)
Definition: background.c:318
int background_derivs(double loga, double *y, double *dy, void *parameters_and_workspace, ErrorMsg error_message)
Definition: background.c:2583
int background_at_tau(struct background *pba, double tau, enum vecback_format return_format, enum interpolation_method inter_mode, int *last_index, double *pvecback)
Definition: background.c:230
int background_timescale(double loga, void *parameters_and_workspace, double *timescale, ErrorMsg error_message)
Definition: background.c:2759
double V_scf(struct background *pba, double phi)
Definition: background.c:2985
int background_solve(struct precision *ppr, struct background *pba)
Definition: background.c:1871
int background_find_equality(struct precision *ppr, struct background *pba)
Definition: background.c:2345
int background_ncdm_momenta(double *qvec, double *wvec, int qsize, double M, double factor, double z, double *n, double *rho, double *p, double *drho_dM, double *pseudo_p)
Definition: background.c:1600
int background_init(struct precision *ppr, struct background *pba)
Definition: background.c:805
varconst_dependence
Definition: background.h:20
equation_of_state
Definition: background.h:15
vecback_format
Definition: background.h:24
interpolation_method
Definition: background.h:30
Definition: common.h:406
Definition: background.h:336
Definition: background.h:350
Definition: background.h:44
double Gamma_dcdm
Definition: background.h:78
int index_bg_phi_prime_scf
Definition: background.h:177
int index_bg_rho_tot
Definition: background.h:189
double Omega0_ncdm_tot
Definition: background.h:90
double * M_ncdm
Definition: background.h:88
int N_ncdm
Definition: background.h:81
int index_bg_rho_b
Definition: background.h:165
int index_bi_phi_prime_scf
Definition: background.h:259
double Omega0_ur
Definition: background.h:66
int index_bg_Omega_r
Definition: background.h:193
double T_ncdm_default
Definition: background.h:91
double * scf_parameters
Definition: background.h:115
int bg_size
Definition: background.h:213
double Omega0_idr
Definition: background.h:73
double h
Definition: background.h:59
int index_bg_p_ncdm1
Definition: background.h:186
int index_bg_conf_distance
Definition: background.h:199
double * tau_table
Definition: background.h:224
int index_bi_rho_dcdm
Definition: background.h:255
short attractor_ic_scf
Definition: background.h:116
int index_bg_w_fld
Definition: background.h:170
char * ncdm_psd_files
Definition: background.h:83
double * z_table
Definition: background.h:225
double Omega0_g
Definition: background.h:61
double Omega0_dr
Definition: background.h:139
short has_ncdm
Definition: background.h:287
double T_idr
Definition: background.h:74
int index_bg_varc_alpha
Definition: background.h:208
double Omega_ini_dcdm
Definition: background.h:77
double ** w_ncdm_bg
Definition: background.h:306
int index_bg_D
Definition: background.h:205
short has_fld
Definition: background.h:289
int * ncdm_quadrature_strategy
Definition: background.h:304
double Omega0_dcdmdr
Definition: background.h:76
double Omega0_k
Definition: background.h:101
double tau_eq
Definition: background.h:147
double age
Definition: background.h:133
int index_bg_rs
Definition: background.h:203
short shooting_failed
Definition: background.h:320
int index_bi_rho_dr
Definition: background.h:256
double * background_table
Definition: background.h:226
double deg_ncdm_default
Definition: background.h:95
double Omega0_scf
Definition: background.h:105
short has_varconst
Definition: background.h:293
int * ncdm_input_q_size
Definition: background.h:98
int index_bg_rho_crit
Definition: background.h:197
double Omega0_de
Definition: background.h:142
double varconst_transition_redshift
Definition: background.h:124
double varconst_me
Definition: background.h:122
int scf_parameters_size
Definition: background.h:120
short has_idr
Definition: background.h:291
int index_bg_p_prime_scf
Definition: background.h:183
int index_bg_H
Definition: background.h:159
double * loga_table
Definition: background.h:223
int index_bg_a
Definition: background.h:156
enum varconst_dependence varconst_dep
Definition: background.h:123
int bg_size_short
Definition: background.h:211
double Omega0_dcdm
Definition: background.h:138
double * ncdm_psd_parameters
Definition: background.h:86
double Neff
Definition: background.h:137
int index_bg_rho_ur
Definition: background.h:172
int index_bg_rho_lambda
Definition: background.h:168
int bg_size_normal
Definition: background.h:212
int index_bi_tau
Definition: background.h:263
double * m_ncdm_in_eV
Definition: background.h:89
double * d2background_dloga2_table
Definition: background.h:237
double ** dlnf0_dlnq_ncdm
Definition: background.h:309
int bi_size
Definition: background.h:268
double Omega_EDE
Definition: background.h:114
short background_verbose
Definition: background.h:323
int index_bi_D_prime
Definition: background.h:265
short use_ppf
Definition: background.h:106
int index_bg_varc_me
Definition: background.h:209
double ksi_ncdm_default
Definition: background.h:93
int index_bi_D
Definition: background.h:264
int index_bi_phi_scf
Definition: background.h:258
short has_ur
Definition: background.h:290
double K
Definition: background.h:135
double * factor_ncdm
Definition: background.h:312
int index_bg_V_scf
Definition: background.h:178
double Omega0_fld
Definition: background.h:104
double cs2_fld
Definition: background.h:112
enum equation_of_state fluid_equation_of_state
Definition: background.h:109
int index_bg_p_tot
Definition: background.h:190
double z_eq
Definition: background.h:146
double w0_fld
Definition: background.h:110
int index_bg_phi_scf
Definition: background.h:176
int index_bg_rho_scf
Definition: background.h:181
int index_bi_time
Definition: background.h:261
short has_curvature
Definition: background.h:292
short is_allocated
Definition: background.h:327
double Omega0_cdm
Definition: background.h:68
double a_eq
Definition: background.h:144
int index_bi_rs
Definition: background.h:262
int bt_size
Definition: background.h:222
double ** q_ncdm_bg
Definition: background.h:305
int index_bi_rho_fld
Definition: background.h:257
double H0
Definition: background.h:58
double c_gamma_over_c_fld
Definition: background.h:108
double T_cmb
Definition: background.h:62
int * got_files
Definition: background.h:84
double phi_ini_scf
Definition: background.h:118
double Omega0_r
Definition: background.h:141
double Omega0_nfsm
Definition: background.h:143
int bi_B_size
Definition: background.h:267
int sgnK
Definition: background.h:136
double Omega0_b
Definition: background.h:64
double Omega0_idm
Definition: background.h:70
double * d2z_dtau2_table
Definition: background.h:236
int index_bg_rho_cdm
Definition: background.h:166
double phi_prime_ini_scf
Definition: background.h:119
ErrorMsg error_message
Definition: background.h:325
int index_bg_rho_idr
Definition: background.h:171
int index_bg_rho_idm
Definition: background.h:167
int index_bg_H_prime
Definition: background.h:160
double ** q_ncdm
Definition: background.h:307
int index_bg_rho_fld
Definition: background.h:169
int index_bg_rho_ncdm1
Definition: background.h:185
double wa_fld
Definition: background.h:111
short has_dcdm
Definition: background.h:284
short has_scf
Definition: background.h:286
double * d2tau_dz2_table
Definition: background.h:235
int index_bg_dV_scf
Definition: background.h:179
int index_bg_pseudo_p_ncdm1
Definition: background.h:187
double Omega0_lambda
Definition: background.h:103
short has_idm
Definition: background.h:283
double Omega0_m
Definition: background.h:140
double H_eq
Definition: background.h:145
int index_bg_rho_dr
Definition: background.h:174
int index_bg_lum_distance
Definition: background.h:201
short has_lambda
Definition: background.h:288
int index_bg_Omega_m
Definition: background.h:198
int index_bg_f
Definition: background.h:206
double * ncdm_qmax
Definition: background.h:99
int index_bg_ang_distance
Definition: background.h:200
ErrorMsg shooting_error
Definition: background.h:321
int index_bg_rho_g
Definition: background.h:164
short has_dr
Definition: background.h:285
int index_bg_p_tot_prime
Definition: background.h:191
double ** w_ncdm
Definition: background.h:308
int index_bg_p_scf
Definition: background.h:182
int index_bg_time
Definition: background.h:202
double conformal_age
Definition: background.h:134
int * q_size_ncdm_bg
Definition: background.h:310
int * q_size_ncdm
Definition: background.h:311
short has_cdm
Definition: background.h:282
int index_bg_ddV_scf
Definition: background.h:180
int index_bg_rho_dcdm
Definition: background.h:173
int scf_tuning_index
Definition: background.h:117
double varconst_alpha
Definition: background.h:121