CLASS MANUAL
distortions.h
Go to the documentation of this file.
1 
6 #ifndef __DISTORTIONS__
7 #define __DISTORTIONS__
8 
9 #include "arrays.h"
10 #include "background.h"
11 #include "thermodynamics.h"
12 #include "perturbations.h"
13 #include "primordial.h"
14 #include "noninjection.h"
15 
16 #define _MAX_DETECTOR_NAME_LENGTH_ 100
17 typedef char DetectorName[_MAX_DETECTOR_NAME_LENGTH_];
18 typedef char DetectorFileName[_FILENAMESIZE_+_MAX_DETECTOR_NAME_LENGTH_+256];
19 
22 enum br_approx {bra_sharp_sharp,bra_sharp_soft,bra_soft_soft,bra_soft_soft_cons,bra_exact};
23 
27 enum reio_approx {sd_reio_Nozawa, sd_reio_Chluba};
28 
35 {
42 
47  DetectorFileName sd_detector_file_name;
49  DetectorName sd_detector_name;
58  double sd_add_y;
59  double sd_add_mu;
62 
66 
67  /* Parameters related to redshift (z) sampling */
68  double z_muy;
69  double z_th;
71  double z_min;
72  double z_max;
73  int z_size;
74  double z_delta;
75  double * z;
77  double * z_weights;
79  /* Can be specified if no noisefile */
80  double x_min;
81  double x_max;
82  double x_delta;
84  /* Will always be specified */
85  int x_size;
86  double * x;
87  double * x_weights;
89  /* Unit conversions */
90  double x_to_nu;
91  double DI_units;
93  /* File names for the PCA */
94  char sd_detector_noise_file[2*_FILENAMESIZE_+_MAX_DETECTOR_NAME_LENGTH_+256];
95  DetectorFileName sd_PCA_file_generator;
96  DetectorFileName sd_detector_list_file;
99  /* Tables storing branching ratios, distortions amplitudes and spectral distoritons for all types of distortios */
100  double ** br_table;
102  double ** sd_shape_table;
103  double ** sd_table;
105  /* indices for the type of distortion */
110  int type_size;
112  /* Total distortion amplitude for residual distortions */
113  double epsilon;
114 
115  /* Total heating function */
116  double * dQrho_dz_tot;
117 
118  /* Total heating rate */
119  double Drho_over_rho;
120 
121  /* Total spectral distortion */
122  double * DI;
124  /* Variables to read, allocate and interpolate external file branching_ratios_exact.dat */
125  double * br_exact_z;
128  double * f_g_exact;
129  double * ddf_g_exact;
130  double * f_y_exact;
131  double * ddf_y_exact;
132  double * f_mu_exact;
133  double * ddf_mu_exact;
135  double * E_vec;
136  double * ddE_vec;
139  /* Variable to read, allocate and interpolate external file PCA_distortions_schape.dat */
140  double * PCA_nu;
141  int PCA_Nnu;
143  double * PCA_G_T;
144  double * ddPCA_G_T;
145  double * PCA_Y_SZ;
146  double * ddPCA_Y_SZ;
147  double * PCA_M_mu;
148  double * ddPCA_M_mu;
150  double * S_vec;
151  double * ddS_vec;
155  double * delta_Ic_array;
158 
159 
163 
178  struct noninjection ni;
182  ErrorMsg error_message;
185 
186 };
187 
188 /*************************************************************************************************************/
189 /* @cond INCLUDE_WITH_DOXYGEN */
190 /*
191  * Boilerplate for C++
192  */
193 #ifdef __cplusplus
194 extern "C" {
195 #endif
196 
197  /* Main functions */
198  int distortions_init(struct precision * ppr,
199  struct background * pba,
200  struct thermodynamics * pth,
201  struct perturbations * ppt,
202  struct primordial * ppm,
203  struct distortions * psd);
204 
205  int distortions_constants(struct precision* ppr,
206  struct background * pba,
207  struct thermodynamics * pth,
208  struct distortions * psd);
209 
210  int distortions_free(struct distortions * psd);
211 
212  /* PCA decomposition (branching ratios and spectral shapes) for unknown detector */
213  int distortions_generate_detector(struct precision * ppr,
214  struct distortions * psd);
215 
216  int distortions_set_detector(struct precision * ppr,
217  struct distortions* psd);
218 
220  struct distortions * psd);
221 
222  /* Indices and lists */
223  int distortions_indices(struct distortions * psd);
224 
225  int distortions_get_xz_lists(struct precision * ppr,
226  struct background* pba,
227  struct thermodynamics* pth,
228  struct distortions* psd);
229 
230  /* The main computation methods */
232  struct distortions* psd);
233 
235  struct background* pba,
236  struct thermodynamics * pth,
237  struct perturbations * ppt,
238  struct primordial * ppm,
239  struct distortions * psd);
240 
242  struct background * pba,
243  struct thermodynamics * pth,
244  struct distortions * psd);
245 
246  /* Additional sources of distortions due to recombination and LSS formation */
247  int distortions_add_effects_reio(struct background * pba,
248  struct thermodynamics * pth,
249  struct distortions * psd,
250  double T_e,
251  double Dtau,
252  double beta,
253  double beta_z,
254  double x,
255  double * y_reio,
256  double * DI);
257 
258  /* PCA decomposition (branching ratios and spectral shapes) for known detector */
259  int distortions_read_br_data(struct precision * ppr,
260  struct distortions * psd);
261  int distortions_spline_br_data(struct distortions* psd);
263  double z,
264  double* f_g,
265  double* f_y,
266  double* f_mu,
267  double* E,
268  int * last_index);
269  int distortions_free_br_data(struct distortions * psd);
270 
271  int distortions_read_sd_data(struct precision * ppr,
272  struct distortions * psd);
273  int distortions_spline_sd_data(struct distortions* psd);
275  double nu,
276  double * G_T,
277  double * Y_SZ,
278  double * M_mu,
279  double * S,
280  int * index);
281  int distortions_free_sd_data(struct distortions * psd);
282 
283  /* Output */
284  int distortions_output_heat_titles(struct distortions * psd, char titles[_MAXTITLESTRINGLENGTH_]);
285  int distortions_output_heat_data(struct distortions * psd,
286  int number_of_titles,
287  double * data);
288 
289  int distortions_output_sd_titles(struct distortions * psd, char titles[_MAXTITLESTRINGLENGTH_]);
290  int distortions_output_sd_data(struct distortions * psd,
291  int number_of_titles,
292  double * data);
293 
294 #ifdef __cplusplus
295 }
296 #endif
297 
298 /**************************************************************/
299 
300 
301 #endif
302 /* @endcond */
Definition: background.h:48
Definition: common.h:378
int distortions_read_detector_noisefile(struct precision *ppr, struct distortions *psd)
Definition: distortions.c:442
int distortions_output_sd_data(struct distortions *psd, int number_of_titles, double *data)
Definition: distortions.c:1959
int distortions_constants(struct precision *ppr, struct background *pba, struct thermodynamics *pth, struct distortions *psd)
Definition: distortions.c:148
int distortions_read_sd_data(struct precision *ppr, struct distortions *psd)
Definition: distortions.c:1642
int distortions_compute_spectral_shapes(struct precision *ppr, struct background *pba, struct thermodynamics *pth, struct distortions *psd)
Definition: distortions.c:887
int distortions_interpolate_br_data(struct distortions *psd, double z, double *f_g, double *f_y, double *f_mu, double *f_E, int *last_index)
Definition: distortions.c:1559
int distortions_compute_branching_ratios(struct precision *ppr, struct distortions *psd)
Definition: distortions.c:643
int distortions_output_sd_titles(struct distortions *psd, char titles[_MAXTITLESTRINGLENGTH_])
Definition: distortions.c:1924
int distortions_free_sd_data(struct distortions *psd)
Definition: distortions.c:1859
int distortions_interpolate_sd_data(struct distortions *psd, double nu, double *G_T, double *Y_SZ, double *M_mu, double *S, int *index)
Definition: distortions.c:1797
int distortions_compute_heating_rate(struct precision *ppr, struct background *pba, struct thermodynamics *pth, struct perturbations *ppt, struct primordial *ppm, struct distortions *psd)
Definition: distortions.c:781
int distortions_spline_br_data(struct distortions *psd)
Definition: distortions.c:1489
int distortions_free(struct distortions *psd)
Definition: distortions.c:94
int distortions_output_heat_titles(struct distortions *psd, char titles[_MAXTITLESTRINGLENGTH_])
Definition: distortions.c:1881
int distortions_get_xz_lists(struct precision *ppr, struct background *pba, struct thermodynamics *pth, struct distortions *psd)
Definition: distortions.c:538
int distortions_free_br_data(struct distortions *psd)
Definition: distortions.c:1619
int distortions_read_br_data(struct precision *ppr, struct distortions *psd)
Definition: distortions.c:1409
int distortions_indices(struct distortions *psd)
Definition: distortions.c:510
int distortions_spline_sd_data(struct distortions *psd)
Definition: distortions.c:1727
int distortions_init(struct precision *ppr, struct background *pba, struct thermodynamics *pth, struct perturbations *ppt, struct primordial *ppm, struct distortions *psd)
Definition: distortions.c:27
int distortions_output_heat_data(struct distortions *psd, int number_of_titles, double *data)
Definition: distortions.c:1899
int distortions_set_detector(struct precision *ppr, struct distortions *psd)
Definition: distortions.c:197
int distortions_add_effects_reio(struct background *pba, struct thermodynamics *pth, struct distortions *psd, double T_e, double Dtau, double beta, double beta_z, double x, double *y_reio, double *DI_reio)
Definition: distortions.c:1144
int distortions_generate_detector(struct precision *ppr, struct distortions *psd)
Definition: distortions.c:371
int index_type_PCA
Definition: distortions.h:109
int S_vec_size
Definition: distortions.h:152
int has_detector_file
Definition: distortions.h:169
double * x
Definition: distortions.h:86
double * ddE_vec
Definition: distortions.h:136
int has_noninjected
Definition: distortions.h:176
reio_approx
Definition: distortions.h:27
double * PCA_Y_SZ
Definition: distortions.h:145
struct noninjection ni
Definition: distortions.h:178
double ** sd_table
Definition: distortions.h:103
double * br_exact_z
Definition: distortions.h:125
double * ddPCA_G_T
Definition: distortions.h:144
double sd_detector_nu_delta
Definition: distortions.h:52
int index_type_y
Definition: distortions.h:108
double * PCA_G_T
Definition: distortions.h:143
double sd_detector_delta_Ic
Definition: distortions.h:54
double * E_vec
Definition: distortions.h:135
ErrorMsg error_message
Definition: distortions.h:182
DetectorFileName sd_detector_file_name
Definition: distortions.h:47
int br_exact_Nz
Definition: distortions.h:126
int E_vec_size
Definition: distortions.h:137
double * S_vec
Definition: distortions.h:150
double * ddf_y_exact
Definition: distortions.h:131
double sd_add_y
Definition: distortions.h:58
double * PCA_M_mu
Definition: distortions.h:147
double * f_mu_exact
Definition: distortions.h:132
int has_user_defined_detector
Definition: distortions.h:166
double * z_weights
Definition: distortions.h:77
int PCA_Nnu
Definition: distortions.h:141
double DI_units
Definition: distortions.h:91
DetectorFileName sd_PCA_file_generator
Definition: distortions.h:95
double * sd_parameter_table
Definition: distortions.h:101
double x_max
Definition: distortions.h:81
double * ddf_mu_exact
Definition: distortions.h:133
double * f_y_exact
Definition: distortions.h:130
double ** br_table
Definition: distortions.h:100
double sd_detector_nu_min
Definition: distortions.h:50
int sd_branching_approx
Definition: distortions.h:43
double * z
Definition: distortions.h:75
char sd_detector_noise_file[2 *_FILENAMESIZE_+_MAX_DETECTOR_NAME_LENGTH_+256]
Definition: distortions.h:94
int has_user_defined_name
Definition: distortions.h:167
double sd_detector_nu_max
Definition: distortions.h:51
double x_to_nu
Definition: distortions.h:90
int sd_PCA_size
Definition: distortions.h:45
int include_only_exotic
Definition: distortions.h:173
DetectorName sd_detector_name
Definition: distortions.h:49
int z_size
Definition: distortions.h:73
int has_distortions
Definition: distortions.h:164
enum reio_approx sd_reio_type
Definition: distortions.h:56
double z_min
Definition: distortions.h:71
double z_max
Definition: distortions.h:72
DetectorFileName sd_detector_list_file
Definition: distortions.h:96
double * DI
Definition: distortions.h:122
double * delta_Ic_array
Definition: distortions.h:155
int has_SZ_effect
Definition: distortions.h:171
int sd_detector_bin_number
Definition: distortions.h:53
double * ddf_g_exact
Definition: distortions.h:129
double z_muy
Definition: distortions.h:68
double z_th
Definition: distortions.h:69
int type_size
Definition: distortions.h:110
int index_type_mu
Definition: distortions.h:107
double z_delta
Definition: distortions.h:74
br_approx
Definition: distortions.h:22
double * ddPCA_Y_SZ
Definition: distortions.h:146
double * f_g_exact
Definition: distortions.h:128
double x_min
Definition: distortions.h:80
double ** sd_shape_table
Definition: distortions.h:102
int x_size
Definition: distortions.h:85
int include_g_distortion
Definition: distortions.h:174
double sd_add_mu
Definition: distortions.h:59
double * PCA_nu
Definition: distortions.h:140
double * x_weights
Definition: distortions.h:87
short distortions_verbose
Definition: distortions.h:180
double * ddPCA_M_mu
Definition: distortions.h:148
double x_delta
Definition: distortions.h:82
int index_type_g
Definition: distortions.h:106
double * ddS_vec
Definition: distortions.h:151
Definition: distortions.h:35
Definition: perturbations.h:98
Definition: primordial.h:79
Definition: thermodynamics.h:59