CLASS MANUAL
thermodynamics.h
Go to the documentation of this file.
1 
3 #ifndef __THERMODYNAMICS__
4 #define __THERMODYNAMICS__
5 
6 #include "background.h"
7 //#include "arrays.h"
8 //#include "helium.h"
9 //#include "hydrogen.h"
10 
16  recfast,
17  hyrec
18 };
19 
30 };
31 
39 };
40 
45 #define f1(x) (-0.75*x*(x*x/3.-1.)+0.5)
46 #define f2(x) (x*x*(0.5-x/3.)*6.)
57 struct thermo
58 {
64 
65  double YHe;
69  enum reionization_parametrization reio_parametrization;
71  enum reionization_z_or_tau reio_z_or_tau;
73  double tau_reio;
75  double z_reio;
95  double * binned_reio_z;
97  double * binned_reio_xe;
105  double * many_tanh_z;
107  double * many_tanh_xe;
113  double annihilation;
117  double decay;
129  double annihilation_z;
146 
150 
166  int th_size;
169 
173 
174  int tt_size;
175  double * z_table;
179 
183 
187 
188 
192 
193  double z_rec;
194  double tau_rec;
195  double rs_rec;
196  double ds_rec;
197  double ra_rec;
198  double da_rec;
199  double rd_rec;
200  double z_d;
201  double tau_d;
202  double ds_d;
203  double rs_d;
204  double tau_cut;
208 
212 
216 
220 
221  double tau_ini;
224 
228 
229  double n_e;
232 
238 
239  short inter_normal;
243 
247 
250  ErrorMsg error_message;
253 
254 };
255 
264 
268 
274  int re_size;
277 
281 
282  int rt_size;
286 
291 
292  double CDB;
293  double CR;
294  double CK;
295  double CL;
296  double CT;
297  double fHe;
298  double CDB_He;
299  double CK_He;
300  double CL_He;
301  double fu;
302  double H_frac;
303  double Tnow;
304  double Nnow;
305  double Bfact;
306  double CB1;
307  double CB1_He1;
308  double CB1_He2;
309  double H0;
310  double YHe;
312  /* parameters for energy injection */
313 
314  double annihilation;
318  double decay;
330  double annihilation_z;
347 
348 };
349 
357 struct reionization {
358 
362 
370  int re_size;
373 
377 
378  int rt_size;
382 
386 
390 
394 
395  /* parameters used by reio_camb */
396 
406  /* parameters used by reio_bins_tanh and reio_many_tanh */
407 
413  /* parameters used by all schemes */
414 
418 
425 
429 
433 
434 };
435 
441 
442  /* structures containing fixed input parameters (indices, ...) */
443  struct background * pba;
444  struct precision * ppr;
445  struct recombination * preco;
446 
447  /* workspace */
448  double * pvecback;
449 
450 };
451 
452 /**************************************************************/
453 /* @cond INCLUDE_WITH_DOXYGEN */
454 /*
455  * Boilerplate for C++
456  */
457 #ifdef __cplusplus
458 extern "C" {
459 #endif
460 
462  struct background * pba,
463  struct thermo * pth,
464  double z,
465  short inter_mode,
466  int * last_index,
467  double * pvecback,
468  double * pvecthermo
469  );
470 
472  struct precision * ppr,
473  struct background * pba,
474  struct thermo * pth
475  );
476 
478  struct thermo * pthermo
479  );
480 
482  struct thermo * pthermo,
483  struct recombination * preco,
484  struct reionization * preio
485  );
486 
488  struct precision * ppr,
489  struct background * pba,
490  struct thermo * pth
491  );
492 
494  struct precision * ppr,
495  struct background * pba,
496  struct recombination * preco,
497  double z,
498  double * energy_rate,
499  ErrorMsg error_message
500  );
501 
503  struct precision * ppr,
504  struct background * pba,
505  struct recombination * preco,
506  double z,
507  double * energy_rate,
508  ErrorMsg error_message
509  );
510 
512  double z,
513  struct thermo * pth,
514  struct reionization * preio,
515  double * xe
516  );
517 
519  struct precision * ppr,
520  struct background * pba,
521  struct thermo * pth,
522  struct recombination * preco,
523  struct reionization * preio,
524  double * pvecback
525  );
526 
528  struct precision * ppr,
529  struct background * pba,
530  struct thermo * pth,
531  struct recombination * preco,
532  struct reionization * preio,
533  double * pvecback
534  );
535 
537  struct precision * ppr,
538  struct thermo * pth,
539  struct recombination * preco,
540  double z,
541  double * xe);
542 
544  struct precision * ppr,
545  struct background * pba,
546  struct thermo * pth,
547  struct recombination * prec,
548  double * pvecback
549  );
550 
552  struct precision * ppr,
553  struct background * pba,
554  struct thermo * pth,
555  struct recombination * prec,
556  double * pvecback
557  );
558 
560  struct precision * ppr,
561  struct background * pba,
562  struct thermo * pth,
563  struct recombination * prec,
564  double * pvecback
565  );
566 
568  double z,
569  double * y,
570  double * dy,
571  void * fixed_parameters,
572  ErrorMsg error_message
573  );
574 
576  struct precision * ppr,
577  struct thermo * pth,
578  struct recombination * preco,
579  struct reionization * preio
580  );
581 
582  int thermodynamics_output_titles(struct background * pba,
583  struct thermo *pth,
584  char titles[_MAXTITLESTRINGLENGTH_]
585  );
586 
587  int thermodynamics_output_data(struct background * pba,
588  struct thermo *pth,
589  int number_of_titles,
590  double *data
591  );
592 
593  int thermodynamics_tanh(double x,
594  double center,
595  double before,
596  double after,
597  double width,
598  double * result);
599 
600 #ifdef __cplusplus
601 }
602 #endif
603 
604 /**************************************************************/
605 
611 
612 #define _BBN_ -1
613 
615 
621 
622 #define _m_e_ 9.10938215e-31
623 #define _m_p_ 1.672621637e-27
624 #define _m_H_ 1.673575e-27
625 #define _not4_ 3.9715
626 #define _sigma_ 6.6524616e-29
629 
630 
635 
636 #define _RECFAST_INTEG_SIZE_ 3
637 
638 #define _Lambda_ 8.2245809
639 #define _Lambda_He_ 51.3
640 #define _L_H_ion_ 1.096787737e7
641 #define _L_H_alpha_ 8.225916453e6
642 #define _L_He1_ion_ 1.98310772e7
643 #define _L_He2_ion_ 4.389088863e7
644 #define _L_He_2s_ 1.66277434e7
645 #define _L_He_2p_ 1.71134891e7
646 #define _A2P_s_ 1.798287e9 /*updated like in recfast 1.4*/
647 #define _A2P_t_ 177.58e0 /*updated like in recfast 1.4*/
648 #define _L_He_2Pt_ 1.690871466e7 /*updated like in recfast 1.4*/
649 #define _L_He_2St_ 1.5985597526e7 /*updated like in recfast 1.4*/
650 #define _L_He2St_ion_ 3.8454693845e6 /*updated like in recfast 1.4*/
651 #define _sigma_He_2Ps_ 1.436289e-22 /*updated like in recfast 1.4*/
652 #define _sigma_He_2Pt_ 1.484872e-22 /*updated like in recfast 1.4*/
653 
655 
661 
662 #define _a_PPB_ 4.309
663 #define _b_PPB_ -0.6166
664 #define _c_PPB_ 0.6703
665 #define _d_PPB_ 0.5300
666 #define _T_0_ pow(10.,0.477121) /* from recfast 1.4 */
667 #define _a_VF_ pow(10.,-16.744)
668 #define _b_VF_ 0.711
669 #define _T_1_ pow(10.,5.114)
670 #define _a_trip_ pow(10.,-16.306) /* from recfast 1.4 */
671 #define _b_trip_ 0.761 /* from recfast 1.4 */
672 
674 
678 /* @endcond */
680 
681 #define _YHE_BIG_ 0.5
682 #define _YHE_SMALL_ 0.01
683 #define _Z_REC_MAX_ 2000.
684 #define _Z_REC_MIN_ 500.
685 
687 
688 #endif
int index_re_cb2
Definition: thermodynamics.h:366
int thermodynamics_merge_reco_and_reio(struct precision *ppr, struct thermo *pth, struct recombination *preco, struct reionization *preio)
Definition: thermodynamics.c:3428
short has_on_the_spot
Definition: thermodynamics.h:316
short inter_normal
Definition: thermodynamics.h:239
double rs_rec
Definition: thermodynamics.h:195
double tau_ini
Definition: thermodynamics.h:221
int index_re_dkappadtau
Definition: thermodynamics.h:367
double CB1_He2
Definition: thermodynamics.h:308
int index_th_tau_d
Definition: thermodynamics.h:153
double CB1_He1
Definition: thermodynamics.h:307
Definition: background.h:25
int index_th_ddcb2
Definition: thermodynamics.h:163
double da_rec
Definition: thermodynamics.h:198
int rt_size
Definition: thermodynamics.h:378
int index_reio_width
Definition: thermodynamics.h:399
int index_re_xe
Definition: thermodynamics.h:270
double CDB_He
Definition: thermodynamics.h:298
Definition: thermodynamics.h:27
reionization_z_or_tau
Definition: thermodynamics.h:36
int index_th_dddkappa
Definition: thermodynamics.h:155
int index_reio_first_z
Definition: thermodynamics.h:409
double tau_free_streaming
Definition: thermodynamics.h:213
double decay
Definition: thermodynamics.h:318
int index_reio_first_xe
Definition: thermodynamics.h:410
int th_size
Definition: thermodynamics.h:166
int index_re_Tb
Definition: thermodynamics.h:365
double annihilation_zmax
Definition: thermodynamics.h:134
int index_reio_step_sharpness
Definition: thermodynamics.h:411
int thermodynamics_indices(struct thermo *pth, struct recombination *preco, struct reionization *preio)
Definition: thermodynamics.c:853
int re_size
Definition: thermodynamics.h:370
double annihilation
Definition: thermodynamics.h:314
double CT
Definition: thermodynamics.h:296
double reionization_width
Definition: thermodynamics.h:83
ErrorMsg error_message
Definition: thermodynamics.h:250
int thermodynamics_reionization_function(double z, struct thermo *pth, struct reionization *preio, double *xe)
Definition: thermodynamics.c:1420
double Tnow
Definition: thermodynamics.h:303
Definition: thermodynamics.h:26
double ds_rec
Definition: thermodynamics.h:196
double annihilation_variation
Definition: thermodynamics.h:119
double YHe
Definition: thermodynamics.h:65
Definition: thermodynamics.h:57
int index_re_cb2
Definition: thermodynamics.h:272
int thermodynamics_free(struct thermo *pth)
Definition: thermodynamics.c:831
reionization_parametrization
Definition: thermodynamics.h:24
int re_size
Definition: thermodynamics.h:274
double CK_He
Definition: thermodynamics.h:299
double annihilation_z
Definition: thermodynamics.h:129
int index_th_dg
Definition: thermodynamics.h:158
double CK
Definition: thermodynamics.h:294
double n_e
Definition: thermodynamics.h:229
double z_d
Definition: thermodynamics.h:200
int index_th_xe
Definition: thermodynamics.h:151
int thermodynamics_init(struct precision *ppr, struct background *pba, struct thermo *pth)
Definition: thermodynamics.c:251
int index_reio_xe_after
Definition: thermodynamics.h:401
Definition: thermodynamics.h:29
double tau_rec
Definition: thermodynamics.h:194
int index_re_z
Definition: thermodynamics.h:363
int thermodynamics_get_xe_before_reionization(struct precision *ppr, struct thermo *pth, struct recombination *preco, double z, double *xe)
Definition: thermodynamics.c:1611
short has_on_the_spot
Definition: thermodynamics.h:115
int index_th_r_d
Definition: thermodynamics.h:165
int thermodynamics_helium_from_bbn(struct precision *ppr, struct background *pba, struct thermo *pth)
Definition: thermodynamics.c:1040
double angular_rescaling
Definition: thermodynamics.h:205
double * thermodynamics_table
Definition: thermodynamics.h:176
int thermodynamics_recombination_with_recfast(struct precision *ppr, struct background *pba, struct thermo *pth, struct recombination *preco, double *pvecback)
Definition: thermodynamics.c:2772
double fHe
Definition: thermodynamics.h:297
double annihilation_z
Definition: thermodynamics.h:330
int thermodynamics_at_z(struct background *pba, struct thermo *pth, double z, short inter_mode, int *last_index, double *pvecback, double *pvecthermo)
Definition: thermodynamics.c:97
int index_th_ddg
Definition: thermodynamics.h:159
double annihilation_zmax
Definition: thermodynamics.h:335
Definition: thermodynamics.h:440
int index_re_Tb
Definition: thermodynamics.h:271
int thermodynamics_derivs_with_recfast(double z, double *y, double *dy, void *parameters_and_workspace, ErrorMsg error_message)
Definition: thermodynamics.c:3167
double * z_table
Definition: thermodynamics.h:175
int index_re_z
Definition: thermodynamics.h:269
double * reionization_table
Definition: thermodynamics.h:379
double CDB
Definition: thermodynamics.h:292
int index_reio_xe_before
Definition: thermodynamics.h:400
double ds_d
Definition: thermodynamics.h:202
double annihilation_f_halo
Definition: thermodynamics.h:142
double rs_d
Definition: thermodynamics.h:203
int index_th_Tb
Definition: thermodynamics.h:160
double YHe
Definition: thermodynamics.h:310
int index_th_g
Definition: thermodynamics.h:157
double * d2thermodynamics_dz2_table
Definition: thermodynamics.h:184
int index_th_exp_m_kappa
Definition: thermodynamics.h:156
Definition: thermodynamics.h:38
int index_reio_exponent
Definition: thermodynamics.h:398
int index_th_ddkappa
Definition: thermodynamics.h:154
double tau_reio
Definition: thermodynamics.h:73
double annihilation
Definition: thermodynamics.h:113
short compute_cb2_derivatives
Definition: thermodynamics.h:77
int index_reio_start
Definition: thermodynamics.h:415
double annihilation_f_halo
Definition: thermodynamics.h:343
int index_reco_when_reio_start
Definition: thermodynamics.h:430
Definition: thermodynamics.h:28
double tau_cut
Definition: thermodynamics.h:204
int index_helium_fullreio_fraction
Definition: thermodynamics.h:402
int index_helium_fullreio_redshift
Definition: thermodynamics.h:403
double reionization_exponent
Definition: thermodynamics.h:85
int thermodynamics_reionization(struct precision *ppr, struct background *pba, struct thermo *pth, struct recombination *preco, struct reionization *preio, double *pvecback)
Definition: thermodynamics.c:1654
double helium_fullreio_width
Definition: thermodynamics.h:89
double * binned_reio_xe
Definition: thermodynamics.h:97
Definition: thermodynamics.h:25
Definition: thermodynamics.h:357
double annihilation_zmin
Definition: thermodynamics.h:138
double * binned_reio_z
Definition: thermodynamics.h:95
Definition: thermodynamics.h:263
double annihilation_variation
Definition: thermodynamics.h:320
double * reionization_parameters
Definition: thermodynamics.h:421
int thermodynamics_onthespot_energy_injection(struct precision *ppr, struct background *pba, struct recombination *preco, double z, double *energy_rate, ErrorMsg error_message)
Definition: thermodynamics.c:1265
double CL_He
Definition: thermodynamics.h:300
double ra_rec
Definition: thermodynamics.h:197
int index_reio_redshift
Definition: thermodynamics.h:397
double annihilation_z_halo
Definition: thermodynamics.h:143
double * many_tanh_z
Definition: thermodynamics.h:105
int index_th_rate
Definition: thermodynamics.h:164
recombination_algorithm
Definition: thermodynamics.h:15
double rd_rec
Definition: thermodynamics.h:199
double z_rec
Definition: thermodynamics.h:193
int index_helium_fullreio_width
Definition: thermodynamics.h:404
int index_re_xe
Definition: thermodynamics.h:364
int index_th_cb2
Definition: thermodynamics.h:161
double CB1
Definition: thermodynamics.h:306
int index_th_dcb2
Definition: thermodynamics.h:162
Definition: thermodynamics.h:37
double H0
Definition: thermodynamics.h:309
short compute_damping_scale
Definition: thermodynamics.h:79
double CR
Definition: thermodynamics.h:293
int index_re_dkappadz
Definition: thermodynamics.h:368
int index_th_dkappa
Definition: thermodynamics.h:152
double annihilation_zmin
Definition: thermodynamics.h:339
double * recombination_table
Definition: thermodynamics.h:283
int thermodynamics_recombination(struct precision *ppr, struct background *pba, struct thermo *pth, struct recombination *preco, double *pvecback)
Definition: thermodynamics.c:2416
int reio_num_params
Definition: thermodynamics.h:422
Definition: common.h:345
double fu
Definition: thermodynamics.h:301
double H_frac
Definition: thermodynamics.h:302
int thermodynamics_recombination_with_hyrec(struct precision *ppr, struct background *pba, struct thermo *pth, struct recombination *preco, double *pvecback)
Definition: thermodynamics.c:2465
double Nnow
Definition: thermodynamics.h:304
int thermodynamics_energy_injection(struct precision *ppr, struct background *pba, struct recombination *preco, double z, double *energy_rate, ErrorMsg error_message)
Definition: thermodynamics.c:1329
double z_reio
Definition: thermodynamics.h:75
short thermodynamics_verbose
Definition: thermodynamics.h:248
double Bfact
Definition: thermodynamics.h:305
double * many_tanh_xe
Definition: thermodynamics.h:107
int binned_reio_num
Definition: thermodynamics.h:93
double binned_reio_step_sharpness
Definition: thermodynamics.h:99
double annihilation_z_halo
Definition: thermodynamics.h:344
int thermodynamics_reionization_sample(struct precision *ppr, struct background *pba, struct thermo *pth, struct recombination *preco, struct reionization *preio, double *pvecback)
Definition: thermodynamics.c:2088
int thermodynamics_output_titles(struct background *pba, struct thermo *pth, char titles[_MAXTITLESTRINGLENGTH_])
Definition: thermodynamics.c:3503
int rt_size
Definition: thermodynamics.h:282
double reionization_optical_depth
Definition: thermodynamics.h:387
double decay
Definition: thermodynamics.h:117
short inter_closeby
Definition: thermodynamics.h:240
double many_tanh_width
Definition: thermodynamics.h:109
double CL
Definition: thermodynamics.h:295
int index_re_dkappadtau
Definition: thermodynamics.h:273
double tau_d
Definition: thermodynamics.h:201
int reio_num_z
Definition: thermodynamics.h:408
int tt_size
Definition: thermodynamics.h:174
int index_re_d3kappadz3
Definition: thermodynamics.h:369
double helium_fullreio_redshift
Definition: thermodynamics.h:87
int many_tanh_num
Definition: thermodynamics.h:103