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;
184  short is_allocated;
187 
188 };
189 
190 /*************************************************************************************************************/
191 /* @cond INCLUDE_WITH_DOXYGEN */
192 /*
193  * Boilerplate for C++
194  */
195 #ifdef __cplusplus
196 extern "C" {
197 #endif
198 
199  /* Main functions */
200  int distortions_init(struct precision * ppr,
201  struct background * pba,
202  struct thermodynamics * pth,
203  struct perturbations * ppt,
204  struct primordial * ppm,
205  struct distortions * psd);
206 
207  int distortions_constants(struct precision* ppr,
208  struct background * pba,
209  struct thermodynamics * pth,
210  struct distortions * psd);
211 
212  int distortions_free(struct distortions * psd);
213 
214  /* PCA decomposition (branching ratios and spectral shapes) for unknown detector */
215  int distortions_generate_detector(struct precision * ppr,
216  struct distortions * psd);
217 
218  int distortions_set_detector(struct precision * ppr,
219  struct distortions* psd);
220 
222  struct distortions * psd);
223 
224  /* Indices and lists */
225  int distortions_indices(struct distortions * psd);
226 
227  int distortions_get_xz_lists(struct precision * ppr,
228  struct background* pba,
229  struct thermodynamics* pth,
230  struct distortions* psd);
231 
232  /* The main computation methods */
234  struct distortions* psd);
235 
237  struct background* pba,
238  struct thermodynamics * pth,
239  struct perturbations * ppt,
240  struct primordial * ppm,
241  struct distortions * psd);
242 
244  struct background * pba,
245  struct thermodynamics * pth,
246  struct distortions * psd);
247 
248  /* Additional sources of distortions due to recombination and LSS formation */
249  int distortions_add_effects_reio(struct background * pba,
250  struct thermodynamics * pth,
251  struct distortions * psd,
252  double T_e,
253  double Dtau,
254  double beta,
255  double beta_z,
256  double x,
257  double * y_reio,
258  double * DI);
259 
260  /* PCA decomposition (branching ratios and spectral shapes) for known detector */
261  int distortions_read_br_data(struct precision * ppr,
262  struct distortions * psd);
263  int distortions_spline_br_data(struct distortions* psd);
265  double z,
266  double* f_g,
267  double* f_y,
268  double* f_mu,
269  double* E,
270  int * last_index);
271  int distortions_free_br_data(struct distortions * psd);
272 
273  int distortions_read_sd_data(struct precision * ppr,
274  struct distortions * psd);
275  int distortions_spline_sd_data(struct distortions* psd);
277  double nu,
278  double * G_T,
279  double * Y_SZ,
280  double * M_mu,
281  double * S,
282  int * index);
283  int distortions_free_sd_data(struct distortions * psd);
284 
285  /* Output */
286  int distortions_output_heat_titles(struct distortions * psd, char titles[_MAXTITLESTRINGLENGTH_]);
287  int distortions_output_heat_data(struct distortions * psd,
288  int number_of_titles,
289  double * data);
290 
291  int distortions_output_sd_titles(struct distortions * psd, char titles[_MAXTITLESTRINGLENGTH_]);
292  int distortions_output_sd_data(struct distortions * psd,
293  int number_of_titles,
294  double * data);
295 
296 #ifdef __cplusplus
297 }
298 #endif
299 
300 /**************************************************************/
301 
302 
303 #endif
304 /* @endcond */
Definition: common.h:406
int distortions_read_detector_noisefile(struct precision *ppr, struct distortions *psd)
Definition: distortions.c:445
int distortions_output_sd_data(struct distortions *psd, int number_of_titles, double *data)
Definition: distortions.c:1962
int distortions_constants(struct precision *ppr, struct background *pba, struct thermodynamics *pth, struct distortions *psd)
Definition: distortions.c:151
int distortions_read_sd_data(struct precision *ppr, struct distortions *psd)
Definition: distortions.c:1645
int distortions_compute_spectral_shapes(struct precision *ppr, struct background *pba, struct thermodynamics *pth, struct distortions *psd)
Definition: distortions.c:890
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:1562
int distortions_compute_branching_ratios(struct precision *ppr, struct distortions *psd)
Definition: distortions.c:646
int distortions_output_sd_titles(struct distortions *psd, char titles[_MAXTITLESTRINGLENGTH_])
Definition: distortions.c:1927
int distortions_free_sd_data(struct distortions *psd)
Definition: distortions.c:1862
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:1800
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:784
int distortions_spline_br_data(struct distortions *psd)
Definition: distortions.c:1492
int distortions_free(struct distortions *psd)
Definition: distortions.c:96
int distortions_output_heat_titles(struct distortions *psd, char titles[_MAXTITLESTRINGLENGTH_])
Definition: distortions.c:1884
int distortions_get_xz_lists(struct precision *ppr, struct background *pba, struct thermodynamics *pth, struct distortions *psd)
Definition: distortions.c:541
int distortions_free_br_data(struct distortions *psd)
Definition: distortions.c:1622
int distortions_read_br_data(struct precision *ppr, struct distortions *psd)
Definition: distortions.c:1412
int distortions_indices(struct distortions *psd)
Definition: distortions.c:513
int distortions_spline_sd_data(struct distortions *psd)
Definition: distortions.c:1730
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:1902
int distortions_set_detector(struct precision *ppr, struct distortions *psd)
Definition: distortions.c:200
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:1147
int distortions_generate_detector(struct precision *ppr, struct distortions *psd)
Definition: distortions.c:374
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
short is_allocated
Definition: distortions.h:184
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: background.h:44
Definition: thermodynamics.h:59