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 spatial_curvature {flat,open,closed};
16 
19 enum equation_of_state {CLP,EDE};
20 
21 
24 enum varconst_dependence {varconst_none,varconst_instant};
25 
28 enum vecback_format {short_info, normal_info, long_info};
29 
34 enum interpolation_method {inter_normal, inter_closeby};
35 
47 struct background
48 {
61 
62  double H0;
63  double h;
65  double Omega0_g;
66  double T_cmb;
68  double Omega0_b;
70  double Omega0_ur;
72  double Omega0_cdm;
74  double Omega0_idm;
77  double Omega0_idr;
78  double T_idr;
80  double Omega0_dcdmdr;
81  double Omega_ini_dcdm;
82  double Gamma_dcdm;
83  double tau_dcdm;
84 
85  int N_ncdm;
86  /* the following parameters help to define tabulated ncdm p-s-d passed in file */
87  char * ncdm_psd_files;
88  int * got_files;
89  /* the following parameters help to define the analytical ncdm phase space distributions (p-s-d) */
92  double * M_ncdm;
93  double * m_ncdm_in_eV;
94  double * Omega0_ncdm, Omega0_ncdm_tot;
95  double * T_ncdm,T_ncdm_default;
97  double * ksi_ncdm, ksi_ncdm_default;
99  double * deg_ncdm, deg_ncdm_default;
103  double * ncdm_qmax;
105  double Omega0_k;
107  double Omega0_lambda;
108  double Omega0_fld;
109  double Omega0_scf;
110  short use_ppf;
114  double w0_fld;
115  double wa_fld;
116  double cs2_fld;
118  double Omega_EDE;
119  double * scf_parameters;
122  double phi_ini_scf;
125  double varconst_alpha;
126  double varconst_me;
131 
132 
136 
137  double age;
138  double conformal_age;
139  double K;
140  int sgnK;
141  double Neff;
142  double Omega0_dcdm;
143  double Omega0_dr;
144  double Omega0_m;
145  double Omega0_r;
146  double Omega0_de;
147  double Omega0_nfsm;
148  double a_eq;
149  double H_eq;
150  double z_eq;
151  double tau_eq;
154 
155 
159 
166  /* end of vector in short format, now quantities in normal format */
167 
199  /* end of vector in normal format, now quantities in long format */
200 
217  int bg_size;
220 
221 
225 
226  int bt_size;
227  double * loga_table;
228  double * tau_table;
229  double * z_table;
230  double * background_table;
233 
234 
238 
239  double * d2tau_dz2_table;
240  double * d2z_dtau2_table;
244 
245 
258 
271  int bi_B_size;
272  int bi_size;
275 
285 
286  short has_cdm;
287  short has_idm;
288  short has_dcdm;
289  short has_dr;
290  short has_scf;
291  short has_ncdm;
292  short has_lambda;
293  short has_fld;
294  short has_ur;
295  short has_idr;
297  short has_varconst;
300 
301 
307 
309  double ** q_ncdm_bg;
310  double ** w_ncdm_bg;
311  double ** q_ncdm;
312  double ** w_ncdm;
313  double ** dlnf0_dlnq_ncdm;
315  int * q_size_ncdm;
316  double * factor_ncdm;
319 
323 
325  ErrorMsg shooting_error;
329  ErrorMsg error_message;
332 };
333 
334 
340 
341  /* structures containing fixed input parameters (indices, ...) */
342  struct background * pba;
343 
344  /* workspace */
345  double * pvecback;
346 
347 };
348 
354 
355  /* structures containing fixed input parameters (indices, ...) */
356  struct background * pba;
357 
358  /* Additional parameters */
359 
360  /* Index of current distribution function */
361  int n_ncdm;
362 
363  /* Used for interpolating in file of tabulated p-s-d: */
364  int tablesize;
365  double *q;
366  double *f0;
367  double *d2f0;
368  int last_index;
369 
370 };
371 
372 /**************************************************************/
373 /* @cond INCLUDE_WITH_DOXYGEN */
374 /*
375  * Boilerplate for C++
376  */
377 #ifdef __cplusplus
378 extern "C" {
379 #endif
380 
381  int background_at_z(
382  struct background *pba,
383  double a_rel,
384  enum vecback_format return_format,
385  enum interpolation_method inter_mode,
386  int * last_index,
387  double * pvecback
388  );
389 
390  int background_at_tau(
391  struct background *pba,
392  double tau,
393  enum vecback_format return_format,
394  enum interpolation_method inter_mode,
395  int * last_index,
396  double * pvecback
397  );
398 
400  struct background *pba,
401  double z,
402  double * tau
403  );
404 
406  struct background *pba,
407  double tau,
408  double * z
409  );
410 
412  struct background *pba,
413  double a_rel,
414  double * pvecback_B,
415  enum vecback_format return_format,
416  double * pvecback
417  );
418 
419  int background_w_fld(
420  struct background * pba,
421  double a,
422  double * w_fld,
423  double * dw_over_da_fld,
424  double * integral_fld);
425 
427  struct background* pba,
428  double z,
429  double* alpha,
430  double* me
431  );
432 
433  int background_init(
434  struct precision *ppr,
435  struct background *pba
436  );
437 
438  int background_free(
439  struct background *pba
440  );
441 
443  struct background *pba
444  );
445 
447  struct background *pba
448  );
449 
450  int background_indices(
451  struct background *pba
452  );
453 
455  void *pba,
456  double q,
457  double * f0
458  );
459 
461  void *pba,
462  double q,
463  double * test
464  );
465 
467  struct precision *ppr,
468  struct background *pba
469  );
470 
472  double * qvec,
473  double * wvec,
474  int qsize,
475  double M,
476  double factor,
477  double z,
478  double * n,
479  double * rho,
480  double * p,
481  double * drho_dM,
482  double * pseudo_p
483  );
484 
486  struct precision *ppr,
487  struct background *pba,
488  int species
489  );
490 
491  int background_checks(
492  struct precision * ppr,
493  struct background *pba
494  );
495 
496  int background_solve(
497  struct precision *ppr,
498  struct background *pba
499  );
500 
502  struct precision *ppr,
503  struct background *pba,
504  double * pvecback,
505  double * pvecback_integration,
506  double * loga_ini
507  );
508 
510  struct precision *ppr,
511  struct background *pba
512  );
513 
514 
515  int background_output_titles(struct background * pba,
516  char titles[_MAXTITLESTRINGLENGTH_]
517  );
518 
520  struct background *pba,
521  int number_of_titles,
522  double *data);
523 
524  int background_derivs(
525  double loga,
526  double * y,
527  double * dy,
528  void * parameters_and_workspace,
529  ErrorMsg error_message
530  );
531 
532  int background_sources(
533  double loga,
534  double * y,
535  double * dy,
536  int index_loga,
537  void * parameters_and_workspace,
538  ErrorMsg error_message
539  );
540 
542  double loga,
543  void * parameters_and_workspace,
544  double * timescale,
545  ErrorMsg error_message
546  );
547 
549  struct background* pba
550  );
551 
553  double V_scf(
554  struct background *pba,
555  double phi
556  );
557 
558  double dV_scf(
559  struct background *pba,
560  double phi
561  );
562 
563  double ddV_scf(
564  struct background *pba,
565  double phi
566  );
567 
569  double Q_scf(
570  struct background *pba,
571  double phi,
572  double phi_prime
573  );
574 
575 #ifdef __cplusplus
576 }
577 #endif
578 
579 /**************************************************************/
580 
586 
587 #define _Mpc_over_m_ 3.085677581282e22
588 /* remark: CAMB uses 3.085678e22: good to know if you want to compare with high accuracy */
589 
590 #define _Gyr_over_Mpc_ 3.06601394e2
592 #define _c_ 2.99792458e8
593 #define _G_ 6.67428e-11
594 #define _eV_ 1.602176487e-19
596 /* parameters entering in Stefan-Boltzmann constant sigma_B */
597 #define _k_B_ 1.3806504e-23
598 #define _h_P_ 6.62606896e-34
599 /* remark: sigma_B = 2 pi^5 k_B^4 / (15h^3c^2) = 5.670400e-8
600  = Stefan-Boltzmann constant in W/m^2/K^4 = Kg/K^4/s^3 */
601 
603 
609 
610 #define _h_BIG_ 1.5
611 #define _h_SMALL_ 0.3
612 #define _omegab_BIG_ 0.039
613 #define _omegab_SMALL_ 0.005
616 
622 
623 #define _SCALE_BACK_ 0.1
627 #define _PSD_DERIVATIVE_EXP_MIN_ -30
628 #define _PSD_DERIVATIVE_EXP_MAX_ 2
630 #define _zeta3_ 1.2020569031595942853997381615114499907649862923404988817922
631 #define _zeta5_ 1.0369277551433699263313654864570341680570809195019128119741
634 
635 
636 #endif
637 /* @endcond */
int background_output_titles(struct background *pba, char titles[_MAXTITLESTRINGLENGTH_])
Definition: background.c:2419
int background_output_data(struct background *pba, int number_of_titles, double *data)
Definition: background.c:2489
int background_checks(struct precision *ppr, struct background *pba)
Definition: background.c:1732
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:2778
int background_initial_conditions(struct precision *ppr, struct background *pba, double *pvecback, double *pvecback_integration, double *loga_ini)
Definition: background.c:2128
int background_ncdm_distribution(void *pbadist, double q, double *f0)
Definition: background.c:1201
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:1338
int background_free(struct background *pba)
Definition: background.c:861
int background_ncdm_M_from_Omega(struct precision *ppr, struct background *pba, int n_ncdm)
Definition: background.c:1664
int background_free_input(struct background *pba)
Definition: background.c:906
int background_free_noinput(struct background *pba)
Definition: background.c:884
int background_ncdm_init(struct precision *ppr, struct background *pba)
Definition: background.c:1363
int background_sources(double loga, double *y, double *dy, int index_loga, void *parameters_and_workspace, ErrorMsg error_message)
Definition: background.c:2687
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:959
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:2580
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:2756
double V_scf(struct background *pba, double phi)
Definition: background.c:2982
int background_solve(struct precision *ppr, struct background *pba)
Definition: background.c:1868
int background_find_equality(struct precision *ppr, struct background *pba)
Definition: background.c:2342
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:1597
int background_init(struct precision *ppr, struct background *pba)
Definition: background.c:805
double Gamma_dcdm
Definition: background.h:82
int index_bg_phi_prime_scf
Definition: background.h:181
int index_bg_rho_tot
Definition: background.h:193
double Omega0_ncdm_tot
Definition: background.h:94
spatial_curvature
Definition: background.h:15
int N_ncdm
Definition: background.h:85
int index_bg_rho_b
Definition: background.h:169
int index_bi_phi_prime_scf
Definition: background.h:263
double ** dlnf0_dlnq_ncdm
Definition: background.h:313
double * scf_parameters
Definition: background.h:119
double Omega0_ur
Definition: background.h:70
int index_bg_Omega_r
Definition: background.h:197
double T_ncdm_default
Definition: background.h:95
int bg_size
Definition: background.h:217
double * m_ncdm_in_eV
Definition: background.h:93
double Omega0_idr
Definition: background.h:77
double h
Definition: background.h:63
double * z_table
Definition: background.h:229
int * ncdm_quadrature_strategy
Definition: background.h:308
int index_bg_p_ncdm1
Definition: background.h:190
int index_bg_conf_distance
Definition: background.h:203
int index_bi_rho_dcdm
Definition: background.h:259
int * got_files
Definition: background.h:88
short attractor_ic_scf
Definition: background.h:120
int index_bg_w_fld
Definition: background.h:174
double Omega0_g
Definition: background.h:65
double Omega0_dr
Definition: background.h:143
short has_ncdm
Definition: background.h:291
double T_idr
Definition: background.h:78
int index_bg_varc_alpha
Definition: background.h:212
double Omega_ini_dcdm
Definition: background.h:81
int index_bg_D
Definition: background.h:209
short has_fld
Definition: background.h:293
double Omega0_dcdmdr
Definition: background.h:80
double Omega0_k
Definition: background.h:105
double tau_eq
Definition: background.h:151
double age
Definition: background.h:137
int index_bg_rs
Definition: background.h:207
short shooting_failed
Definition: background.h:324
int index_bi_rho_dr
Definition: background.h:260
double deg_ncdm_default
Definition: background.h:99
double Omega0_scf
Definition: background.h:109
short has_varconst
Definition: background.h:297
int * q_size_ncdm_bg
Definition: background.h:314
double ** w_ncdm_bg
Definition: background.h:310
int index_bg_rho_crit
Definition: background.h:201
double Omega0_de
Definition: background.h:146
double varconst_transition_redshift
Definition: background.h:128
double varconst_me
Definition: background.h:126
varconst_dependence
Definition: background.h:24
int scf_parameters_size
Definition: background.h:124
short has_idr
Definition: background.h:295
int index_bg_p_prime_scf
Definition: background.h:187
int index_bg_H
Definition: background.h:163
int index_bg_a
Definition: background.h:160
enum varconst_dependence varconst_dep
Definition: background.h:127
int bg_size_short
Definition: background.h:215
double Omega0_dcdm
Definition: background.h:142
double Neff
Definition: background.h:141
int index_bg_rho_ur
Definition: background.h:176
int index_bg_rho_lambda
Definition: background.h:172
double * ncdm_qmax
Definition: background.h:103
int bg_size_normal
Definition: background.h:216
int index_bi_tau
Definition: background.h:267
double * d2tau_dz2_table
Definition: background.h:239
equation_of_state
Definition: background.h:19
int bi_size
Definition: background.h:272
double Omega_EDE
Definition: background.h:118
short background_verbose
Definition: background.h:327
int index_bi_D_prime
Definition: background.h:269
short use_ppf
Definition: background.h:110
int index_bg_varc_me
Definition: background.h:213
double ksi_ncdm_default
Definition: background.h:97
int index_bi_D
Definition: background.h:268
double * d2z_dtau2_table
Definition: background.h:240
int index_bi_phi_scf
Definition: background.h:262
short has_ur
Definition: background.h:294
double * loga_table
Definition: background.h:227
double K
Definition: background.h:139
int index_bg_V_scf
Definition: background.h:182
double ** w_ncdm
Definition: background.h:312
double Omega0_fld
Definition: background.h:108
double cs2_fld
Definition: background.h:116
enum equation_of_state fluid_equation_of_state
Definition: background.h:113
int index_bg_p_tot
Definition: background.h:194
double z_eq
Definition: background.h:150
double w0_fld
Definition: background.h:114
double * factor_ncdm
Definition: background.h:316
double * ncdm_psd_parameters
Definition: background.h:90
int index_bg_phi_scf
Definition: background.h:180
int index_bg_rho_scf
Definition: background.h:185
int index_bi_time
Definition: background.h:265
short has_curvature
Definition: background.h:296
double * M_ncdm
Definition: background.h:92
double Omega0_cdm
Definition: background.h:72
double a_eq
Definition: background.h:148
int index_bi_rs
Definition: background.h:266
double * d2background_dloga2_table
Definition: background.h:241
double * background_table
Definition: background.h:230
int bt_size
Definition: background.h:226
char * ncdm_psd_files
Definition: background.h:87
int index_bi_rho_fld
Definition: background.h:261
double H0
Definition: background.h:62
double c_gamma_over_c_fld
Definition: background.h:112
int * q_size_ncdm
Definition: background.h:315
double T_cmb
Definition: background.h:66
vecback_format
Definition: background.h:28
double phi_ini_scf
Definition: background.h:122
double Omega0_r
Definition: background.h:145
double Omega0_nfsm
Definition: background.h:147
int bi_B_size
Definition: background.h:271
int sgnK
Definition: background.h:140
double Omega0_b
Definition: background.h:68
double Omega0_idm
Definition: background.h:74
int index_bg_rho_cdm
Definition: background.h:170
double phi_prime_ini_scf
Definition: background.h:123
ErrorMsg error_message
Definition: background.h:329
int index_bg_rho_idr
Definition: background.h:175
int index_bg_rho_idm
Definition: background.h:171
int index_bg_H_prime
Definition: background.h:164
int index_bg_rho_fld
Definition: background.h:173
int index_bg_rho_ncdm1
Definition: background.h:189
double wa_fld
Definition: background.h:115
short has_dcdm
Definition: background.h:288
short has_scf
Definition: background.h:290
double ** q_ncdm_bg
Definition: background.h:309
int index_bg_dV_scf
Definition: background.h:183
double * tau_table
Definition: background.h:228
int index_bg_pseudo_p_ncdm1
Definition: background.h:191
interpolation_method
Definition: background.h:34
double Omega0_lambda
Definition: background.h:107
short has_idm
Definition: background.h:287
double Omega0_m
Definition: background.h:144
double H_eq
Definition: background.h:149
int index_bg_rho_dr
Definition: background.h:178
int index_bg_lum_distance
Definition: background.h:205
short has_lambda
Definition: background.h:292
int index_bg_Omega_m
Definition: background.h:202
int index_bg_f
Definition: background.h:210
int index_bg_ang_distance
Definition: background.h:204
ErrorMsg shooting_error
Definition: background.h:325
int index_bg_rho_g
Definition: background.h:168
short has_dr
Definition: background.h:289
int index_bg_p_tot_prime
Definition: background.h:195
int index_bg_p_scf
Definition: background.h:186
double ** q_ncdm
Definition: background.h:311
int index_bg_time
Definition: background.h:206
double conformal_age
Definition: background.h:138
int * ncdm_input_q_size
Definition: background.h:102
short has_cdm
Definition: background.h:286
int index_bg_ddV_scf
Definition: background.h:184
int index_bg_rho_dcdm
Definition: background.h:177
int scf_tuning_index
Definition: background.h:121
double varconst_alpha
Definition: background.h:125
Definition: background.h:48
Definition: background.h:339
Definition: background.h:353
Definition: common.h:378