CLASS MANUAL
distortions.c File Reference
#include "distortions.h"
+ Include dependency graph for distortions.c:

Functions

int distortions_init (struct precision *ppr, struct background *pba, struct thermodynamics *pth, struct perturbations *ppt, struct primordial *ppm, struct distortions *psd)
 
int distortions_free (struct distortions *psd)
 
int distortions_constants (struct precision *ppr, struct background *pba, struct thermodynamics *pth, struct distortions *psd)
 
int distortions_set_detector (struct precision *ppr, struct distortions *psd)
 
int distortions_generate_detector (struct precision *ppr, struct distortions *psd)
 
int distortions_read_detector_noisefile (struct precision *ppr, struct distortions *psd)
 
int distortions_indices (struct distortions *psd)
 
int distortions_get_xz_lists (struct precision *ppr, struct background *pba, struct thermodynamics *pth, struct distortions *psd)
 
int distortions_compute_branching_ratios (struct precision *ppr, struct distortions *psd)
 
int distortions_compute_heating_rate (struct precision *ppr, struct background *pba, struct thermodynamics *pth, struct perturbations *ppt, struct primordial *ppm, struct distortions *psd)
 
int distortions_compute_spectral_shapes (struct precision *ppr, struct background *pba, struct thermodynamics *pth, struct distortions *psd)
 
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)
 
int distortions_read_br_data (struct precision *ppr, struct distortions *psd)
 
int distortions_spline_br_data (struct distortions *psd)
 
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)
 
int distortions_free_br_data (struct distortions *psd)
 
int distortions_read_sd_data (struct precision *ppr, struct distortions *psd)
 
int distortions_spline_sd_data (struct distortions *psd)
 
int distortions_interpolate_sd_data (struct distortions *psd, double nu, double *G_T, double *Y_SZ, double *M_mu, double *S, int *index)
 
int distortions_free_sd_data (struct distortions *psd)
 
int distortions_output_heat_titles (struct distortions *psd, char titles[_MAXTITLESTRINGLENGTH_])
 
int distortions_output_heat_data (struct distortions *psd, int number_of_titles, double *data)
 
int distortions_output_sd_titles (struct distortions *psd, char titles[_MAXTITLESTRINGLENGTH_])
 
int distortions_output_sd_data (struct distortions *psd, int number_of_titles, double *data)
 

Detailed Description

Documented module on spectral distortions Matteo Lucca, 31.10.2018 Nils Schoeneberg, 18.02.2019

When using this module please consider citing: Lucca et al. 2019 (JCAP02(2020)026, arXiv:1910.04619) as well as related pioneering works such as: Chluba & Sunyaev 2012 (MNRAS419(2012)1294-1314, arXiv:1109.6552) Chluba 2013 (MNRAS434(2013)352, arXiv:1304.6120) Clube & Jeong 2014 (MNRAS438(2014)2065–2082, arXiv:1306.5751)

Function Documentation

◆ distortions_init()

int distortions_init ( struct precision ppr,
struct background pba,
struct thermodynamics pth,
struct perturbations ppt,
struct primordial ppm,
struct distortions psd 
)

Initialize the distortions structure.

Parameters
pprInput: pointer to precision structure
pbaInput: pointer to background structure
pthInput: pointer to the thermodynamics structure
pptInput: pointer to the perturbations structure
ppmInput: pointer to the primordial structure
psdInput/Output: pointer to initialized distortions structure
Returns
the error status

Set physical constants

Set/Check the distortions detector

Assign values to all indices in the distortions structure

Define z and x arrays

Define branching ratios

Define heating function

Define final spectral distortions

◆ distortions_free()

int distortions_free ( struct distortions psd)

Free all memory space allocated by distortions_init()

Parameters
psdInput: pointer to distortions structure (to be freed)
Returns
the error status

Define local variables

Delete lists

Delete noise file

Delete branching ratios

Delete heating functions

Delete distortion shapes

Delete distortion amplitudes

Delete total distortion

◆ distortions_constants()

int distortions_constants ( struct precision ppr,
struct background pba,
struct thermodynamics pth,
struct distortions psd 
)

Calculate physical constant.

Parameters
pprInput: pointer to precision structure
pbaInput: pointer to background structure
pthInput: pointer to thermodynamics structure
psdInput: pointer to the distortions structure
Returns
the error status

Define unit conventions

Define transition redshifts z_muy and z_th

◆ distortions_set_detector()

int distortions_set_detector ( struct precision ppr,
struct distortions psd 
)

Check wether the detector name and the detector properties are a valid combination.

There are four options for the user

defined_name = true, defined_detector = true Meaning: The user requests a specific detector with specific settings --> Check that the detector exists and has the same settings

defined_name = true, defined_detector = false Meaning: The user requests a specific detector --> Check that the detector exists and use the given settings

defined_name = false, defined_detector = true Meaning: The user requests specific settings, but does not name their detector --> Check that the settings exists, or create them

defined_name = false, defined_detector = false Meaning: The user just wants the default detector and settings --> Just use the default settings and skip this function

Parameters
pprInput: pointer to precision structure
psdInput/Output: pointer to initialized distortions structure
Returns
the error status

Local variables

Open file

◆ distortions_generate_detector()

int distortions_generate_detector ( struct precision ppr,
struct distortions psd 
)

Evaluate branching ratios, spectral shapes, E and S vectors for a given detector as described in external/distortions/README using generate_PCA_files.py.

Parameters
pprInput: pointer to precision structure
psdInput: pointer to the distortions structure
Returns
the error status

Define local variables

◆ distortions_read_detector_noisefile()

int distortions_read_detector_noisefile ( struct precision ppr,
struct distortions psd 
)

Reads the external detector noise file containing the array of frequencies and the detector accuracies Assumed to be in units of [GHz] and [10^-26 W/m^2/Hz/sr] respectively

Parameters
pprInput: pointer to the precisions structure
psdInput: pointer to the distortions structure
Returns
the error status

Define local variables

Open file

Read header

Read number of lines, infer size of arrays and allocate them

Read parameters

◆ distortions_indices()

int distortions_indices ( struct distortions psd)

Assign value to each relevant index in vectors of distortions quantities.

Parameters
psdInput: pointer to distortions structure
Returns
the error status

Define local variables

Define indeces for tables - br_table defined in distortions_compute_branching_ratios,

  • sd_parameter_table and
  • sd_table defined in distortions_compute_spectral_shapes

◆ distortions_get_xz_lists()

int distortions_get_xz_lists ( struct precision ppr,
struct background pba,
struct thermodynamics pth,
struct distortions psd 
)

Calculate redshift and frequency vectors and weights for redshift integral.

Parameters
pprInput: pointer to precision structure
pbaInput: pointer to background structure
pthInput: pointer to the thermodynamics structure
psdInput/Output: pointer to initialized distortions structure
Returns
the error status

Define local variables

Define and allocate z array

Define and allocate integrating weights for z array

Define and allocate x array

Define and allocate integrating weights for x array

◆ distortions_compute_branching_ratios()

int distortions_compute_branching_ratios ( struct precision ppr,
struct distortions psd 
)

Calculate branching ratios.

Computing the full evolution of the thermal history of the universe is rather time consuming and mathematically challenging. It is therefore not implemented here. However, there are (at least) 5 levels of possible approximatin to evaluate the SD branching ratios (see also Chluba 2016 for useful discussion) 1) Use a sharp transition at z_mu-y and no distortions before z_th ('branching approx'=sharp_sharp) 2) Use a sharp transition at z_mu-y and a soft transition at z_th ('branching approx'=sharp_soft) 3) Use a soft transition at a_mu-y and z_th as described in Chluba 2013 ('branching approx'=soft_soft) In this case, the user must be aware that energy conservation is violated and no residuals are taken into consideration. 4) Use a soft transition at a_mu-y and z_th imposing conservation of energy ('branching approx'=soft_soft_cons) 5) Use a PCA method as described in Chluba & Jeong 2014 ('branching approx'=exact) In this case, the definition of the BRs is detector dependent and the user has therefore to specify the detector type and corresponding characteristics.

All quantities are stored in the table br_table.

Parameters
pprInput: pointer to the precision structure
psdInput: pointer to the distortions structure
Returns
the error status

Define local variables

Allocate space for branching ratios in br_table

Calulate branching ratios

◆ distortions_compute_heating_rate()

int distortions_compute_heating_rate ( struct precision ppr,
struct background pba,
struct thermodynamics pth,
struct perturbations ppt,
struct primordial ppm,
struct distortions psd 
)

Import heating rates from heating structure.

Parameters
pprInput: pointer to precision structure
pbaInput: pointer to background structure
pthInput: pointer to the thermodynamics structure
pptInput: pointer to the perturbations structure
ppmInput: pointer to the primordial structure
psdInput: pointer to the distortions structure
Returns
the error status

Define local variables

Update heating table with second order contributions

Allocate space for background vector

Allocate space for total heating function

Import quantities from background structure

Import heat from non-injection structure

Add heat from injection structure

Calculate total heating rate

Update heating table with second order contributions

◆ distortions_compute_spectral_shapes()

int distortions_compute_spectral_shapes ( struct precision ppr,
struct background pba,
struct thermodynamics pth,
struct distortions psd 
)

Calculate spectral amplitudes and corresponding distortions.

The calculation has been done according to Chluba & Jeong 2014 (arxiv:1306.5751). All quantities are stored in the tables sd_parameter_table and sd_table.

Parameters
pprInput: pointer to precision structure
pbaInput: pointer to background structure
pthInput: pointer to thermodynamics structure
psdInput: pointer to the distortions structure
Returns
the error status

Define local variables

Allocate space for spectral distortion amplitude in table sd_parameter_table

Compute distortion amplitudes corresponding to each branching ratio (g, y and mu)

Allocate space for distortions shapes in distortions_table

Calculate spectral shapes

Compute distortion amplitude for residual parameter epsilon

Allocate space for final spectral distortion

Calculate spectral distortions according to Chluba & Jeong 2014 (arxiv:1306.5751, Eq. (11))

Include additional sources of distortions

Compute total heating

Print found parameters

◆ distortions_add_effects_reio()

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 
)

Compute relativistic contribution from reionization and structure formation according to 1) Nozawa et al. 2005 (up to order 3 in theta_e) or 2) Chluba et al. 2012 (up to order ? in ?). Note that, for the moment, this appoximation is only valid for cluster temperatures lower than few KeV.

Parameters
pbaInput: pointer to background structure
pthInput: pointer to thermodynamics structure
psdInput: pointer to the distortions structure
T_eInput: electron temperature in keV
DtauInput: optical depth
betaInput: peculiar velocity of the cluster
beta_zInput: peculiar velocity of the cluster with respect to the line-of-sight
xInput: dimensionless frequency
y_reioOutput: y-parameter
DI_reioOutput: spectral distortion
Returns
the error status

Define local variables

Thermal SZ effect (TSZ)

Non-relativistic TSZ

Relativistic TSZ

Kinematic SZ effect (kSZ)

Total distortion

◆ distortions_read_br_data()

int distortions_read_br_data ( struct precision ppr,
struct distortions psd 
)

Reads the external file branching_ratios calculated according to Chluba & Jeong 2014

Parameters
pprInput: pointer to precision structure
psdInput: pointer to the distortions structure
Returns
the error status

Define local variables

Open file

Read header

Read number of lines, infer size of arrays and allocate them

Read parameters

◆ distortions_spline_br_data()

int distortions_spline_br_data ( struct distortions psd)

Spline the quantitites read in distortions_read_br_data

Parameters
psdInput: pointer to the distortions structure
Returns
the error status

Allocate second derivatives

Spline branching ratios

◆ distortions_interpolate_br_data()

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 
)

Interpolate the quantitites splined in distortions_spline_br_data

Parameters
psdInput: pointer to the distortions structure
zInput: redshift
f_gOutput: branching ratio for temperature shift
f_yOutput: branching ratio for y distortions
f_muOutput: branching ratio for mu-distortions
f_EOutput: branching ratio for residuals (multipole expansion)
last_indexOutput: multipole of PCA expansion for f_E
Returns
the error status

Define local variables

Find z position

Evaluate corresponding values for the branching ratios

◆ distortions_free_br_data()

int distortions_free_br_data ( struct distortions psd)

Free from distortions_read_br_data and distortions_spline_br_data

Parameters
psdInput: pointer to distortions structure (to be freed)
Returns
the error status

◆ distortions_read_sd_data()

int distortions_read_sd_data ( struct precision ppr,
struct distortions psd 
)

Reads the external file distortions_shapes calculated according to Chluba & Jeong 2014

Parameters
pprInput: pointer to precision structure
psdInput: pointer to the distortions structure
Returns
the error status

Define local variables

Open file

Read header

Read number of lines, infer size of arrays and allocate them

Read parameters

◆ distortions_spline_sd_data()

int distortions_spline_sd_data ( struct distortions psd)

Spline the quantitites read in distortions_read_sd_data

Parameters
psdInput: pointer to the distortions structure
Returns
the error status

Allocate second derivatievs

Spline branching ratios

◆ distortions_interpolate_sd_data()

int distortions_interpolate_sd_data ( struct distortions psd,
double  nu,
double *  G_T,
double *  Y_SZ,
double *  M_mu,
double *  S,
int *  index 
)

Interpolate the quantitites splined in distortions_spline_sd_data

Parameters
psdInput: pointer to the distortions structure
nuInput: dimnetionless frequency
G_TOutput: shape of temperature shift
Y_SZOutput: shape of y distortions
M_muOutput: shape of mu-distortions
SOutput: shape of residuals (multipole expansion)
indexOutput: multipole of PCA expansion for S
Returns
the error status

Define local variables

Find z position

Evaluate corresponding values for the branching ratios

◆ distortions_free_sd_data()

int distortions_free_sd_data ( struct distortions psd)

Free from distortions_read_sd_data and distortions_spline_sd_data

Parameters
psdInput: pointer to distortions structure (in which some fields should be freed)
Returns
the error status

◆ distortions_output_heat_titles()

int distortions_output_heat_titles ( struct distortions psd,
char  titles[_MAXTITLESTRINGLENGTH_] 
)

Define title of columns in the heat output

Parameters
psdInput: pointer to distortions structure
titlesOutput: title of each column in the output

◆ distortions_output_heat_data()

int distortions_output_heat_data ( struct distortions psd,
int  number_of_titles,
double *  data 
)

Store data in the heat output

Parameters
psdInput/Output: pointer to distortions structure
number_of_titlesInput: numbert of column in the output
dataInput: data to be stored

◆ distortions_output_sd_titles()

int distortions_output_sd_titles ( struct distortions psd,
char  titles[_MAXTITLESTRINGLENGTH_] 
)

Define title of columns in the spectral distortion output

Parameters
psdInput: pointer to distortions structure
titlesOutput: title of each column in the output

◆ distortions_output_sd_data()

int distortions_output_sd_data ( struct distortions psd,
int  number_of_titles,
double *  data 
)

Store data in the distortion output

Parameters
psdInput/Output: pointer to distortions structure
number_of_titlesInput: numbert of column in the output
dataInput: data to be stored