Documented cosmology module. More...
#include "header.h"
Functions | |
| int | Cosmology_init (struct Cosmology *Cx, double pk_kmax, double pk_zmax, int nlines, int *line_type, size_t npoints_interp, double M_min, long mode_mf) |
| Allocate memory and initialize the cosmology structure, which includes the CLASS cosmology structure and line strucrure. More... | |
| int | Cosmology_free (struct Cosmology *Cx) |
| Free the memory allocated to cosmology structure. More... | |
| int | CL_Cosmology_initilize (struct Cosmology *Cx, double pk_kmax, double pk_zmax) |
| Allocate memory and initialize the CLASS cosmology structure. More... | |
| int | CL_Cosmology_free (struct Cosmology *Cx) |
| Free the memory allocated to CLASS cosmology structure. More... | |
| struct PS_xtr * | PS_xtrapol_init (struct Cosmology *Cx) |
| Call CLASS and build a 2d interpolator for Plin(k,z), which will be used when building an extrapolator for P(k,z) beyond a given kmax computed by CLASS. More... | |
| int | PS_xtrapol_free (struct PS_xtr *PS_xtrapol) |
| frees the interpolation elements for P_m spline More... | |
| double | PS (struct Cosmology *Cx, double k, double z) |
| Evaluate the extrapolation for matter power spectrum beyond what is calculated by CLASS, same expansion as that used in CORE cosmology librrary (see arXiv:1812.05995) If requested k-value was beyond what is calculated by CLASS, this function extrapolates. More... | |
| double | PS_class (struct Cosmology *Cx, double k, double z, long mode) |
| Call CLASS-V3.1 functions to compute the cdm+b pk (in Mpc**3) for a given k (in 1/Mpc) and z In LIM_FISHER code, we always include massive neutrinos. More... | |
| double | Pk_dlnPk_HV (struct Cosmology *Cx, double k, double z, int mode) |
| Read in the linear power spectrum, used to set the initial conditions of Hidden-Valley sims. More... | |
| double | transfer (struct Cosmology *Cx, double k, double z, int mode) |
| call CLASS-V3.1 to compute transfer function for different species depending on the switch "mode" mode can be set to cdm, baryons or total matter transfer function. More... | |
| double | growth_D (struct Cosmology *Cx, double k, double z) |
| Compute the growth factor D(k,z) for a general case where it can be scale-dependant The scale-dep growth is calculated by taking the ratio of the transfer function at redshift z and zero. More... | |
| double | growth_f (struct Cosmology *Cx, double k, double z) |
| Compute the growth factor D(k,z) by taking the ratio of the transfer function at redshift z and zero. More... | |
| double | scale_indep_growth_D (struct Cosmology *Cx, double z) |
| Compute the growth factor D(k,z) which is scale-indep valid when neutrinos are massless The scale-dep growth is calculated by taking the ratio of the transfer function at redshift z and zero. More... | |
| double | scale_indep_growth_f (struct Cosmology *Cx, double z) |
| Compute the scale-independent growth rate f(z) which is scale-indep valid when neutrinos are massless. More... | |
| double | Hubble (struct Cosmology *Cx, double z) |
| Compute the the hubble rate (exactly the quantity defined by CLASS as index_bg_H in the background module). More... | |
| double | angular_distance (struct Cosmology *Cx, double z) |
| Compute the angular diameter distance (exactly the quantity defined by CLASS as ba.index_bg_ang_distance in the background module). More... | |
| double | comoving_radial_distance (struct Cosmology *Cx, double z) |
| Compute the comoving radial distance More... | |
| double | sig_sq_integrand (double x, void *par) |
| The integrand function passed to qags integrator to compute the variance of the smoothed matter density. More... | |
| double | sig_sq (struct Cosmology *Cx, double z, double R) |
| Compute variance of smoothed matter density fluctuations. More... | |
| double | der_lnsig_sq (struct Cosmology *Cx, double z, double R) |
| Compute the logarithmic derivative of the variance of smoothed matter density fluctuations w.r.t. More... | |
| double | sigma0_sq_integrand (double x, void *par) |
| The integrand function passed to qags integrator to compute the variance of the unsmoothed matter density. More... | |
| double | sigma0_sq (struct Cosmology *Cx, double z, double kmax) |
| Compute variance of unsmoothed matter density fluctuations. More... | |
| double | rhoc (struct Cosmology *Cx, double z) |
| Compute the critical density in unit of M_sun/Mpc^3. More... | |
| double | R_scale (struct Cosmology *Cx, double h_mass) |
| Compute the Lagrangian radius of halos in unit of Mpc , fixing z=0. More... | |
| double | R_scale_wrong (struct Cosmology *Cx, double z, double h_mass) |
| Compute the Lagrangian radius of halos in unit of Mpc at z. More... | |
| double | R_vir (struct Cosmology *Cx, double M) |
| Compute the comoving virial radius of halos in unit of Mpc, which is defined as the radius at which the average density within this radius is Delta X rho_c. More... | |
| double | concentration_cdm (double M, double z) |
| Compute the cold dark matter concentration-mass relation. More... | |
| double | nfw_profile (struct Cosmology *Cx, double k, double M, double z) |
| Compute the NFW halo profile in Fourier space, given by Eq. More... | |
| double | window_rth (double k, double R) |
| Fourier transform of top-hat window in real space. More... | |
| double | window_kth (double k, double R) |
| Top-hat window in Fourier space. More... | |
| double | window_g (double k, double R) |
| Gaussian window. More... | |
| double | derR_window_rth (double k, double R) |
| Derivative w.r.t. More... | |
| double | derR_logwindow_g (double k, double R) |
| Derivative w.r.t smoothing scale of Gaussian window. More... | |
Documented cosmology module.
Azadeh Moradinezhad Dizgah, November 4th 2021
The first routine of this module initalizes the Cosmology structure, which is the main building block of this entire code. This structure includes two sub-structures: the CLASS cosmology structure and line structure. Once the CLASS cosmology is initialized, various useful functions can be directly called from CLASS, example to compute matter power spectrum and transfer function, angular and comoving radii, growth factor and growth rate, variance of matter fluctuations and its derivative. Lastly, the module also includes various window functions and their derivatives.
In summary, the following functions can be called from other modules:
| double angular_distance | ( | struct Cosmology * | Cx, |
| double | z | ||
| ) |
Compute the angular diameter distance (exactly the quantity defined by CLASS as ba.index_bg_ang_distance in the background module).
luminosity distance d_L = (1+z) d_M angular diameter distance d_A = d_M/(1+z) where d_M is the transverse comoving distance, which is equal to comoving distance for flat cosmology and has a dependance on curvature for non-flat cosmologies, as described in lines 849 - 851
| Cx | Input: pointer to Cosmology structure |
| z | Input: redshift to compute the spectrum |
junk

| int CL_Cosmology_free | ( | struct Cosmology * | Cx | ) |
Free the memory allocated to CLASS cosmology structure.
| Cx | Input: pointer to Cosmology structure |

| int CL_Cosmology_initilize | ( | struct Cosmology * | Cx, |
| double | pk_kmax, | ||
| double | pk_zmax | ||
| ) |
Allocate memory and initialize the CLASS cosmology structure.
| Cx | Input: pointer to Cosmology structure |
| pk_kmax | Input: kmax for computation of matter power spectrum by CLASS |
| pk_zmax | Input: zmax for computation of matter power spectrum by CLASS |
pivot scale in unit of 1/Mpc

| double comoving_radial_distance | ( | struct Cosmology * | Cx, |
| double | z | ||
| ) |
Compute the comoving radial distance
| Cx | Input: pointer to Cosmology structure |
| z | Input: redshift to compute the spectrum |
junk

| double concentration_cdm | ( | double | M, |
| double | z | ||
| ) |
Compute the cold dark matter concentration-mass relation.
| M | Input: halo mass in unit of solar mass |
| z | Input: redshift of interest |

| int Cosmology_free | ( | struct Cosmology * | Cx | ) |
Free the memory allocated to cosmology structure.
| Cx | Input: pointer to Cosmology structure |


| int Cosmology_init | ( | struct Cosmology * | Cx, |
| double | pk_kmax, | ||
| double | pk_zmax, | ||
| int | nlines, | ||
| int * | line_type, | ||
| size_t | npoints_interp, | ||
| double | M_min, | ||
| long | mode_mf | ||
| ) |
Allocate memory and initialize the cosmology structure, which includes the CLASS cosmology structure and line strucrure.
| Cx | Input: pointer to Cosmology structure |
| pk_kmax | Input: kmax for computation of matter power spectrum by CLASS |
| pk_zmax | Input: zmax for computation of matter power spectrum by CLASS |
| nlines | Input: number of lines whose properties we want to compute |
| line_type | Inpute: name of the line to compute. It can be set to CII, CO10, CO21, CO32, CO43, CO54, CO65 |
| npoints_interp | Input: number of points in redshift for interpolation of line properties |
| M_min | Input: minimum halo mass for mass integrals |
| mode_mf | Inpute: theoretical model of halo mass function to use. It can be set to sheth-Tormen (ST), Tinker (TR) or Press-Schecter (PSC) |


| double der_lnsig_sq | ( | struct Cosmology * | Cx, |
| double | z, | ||
| double | R | ||
| ) |
Compute the logarithmic derivative of the variance of smoothed matter density fluctuations w.r.t.
smoothing scale
| Cx | Input: pointer to Cosmology structure |
| z | Input: redshift to compute the spectrum |
| R | Input: smoothing scale in unit of Mpc |

| double derR_logwindow_g | ( | double | k, |
| double | R | ||
| ) |
Derivative w.r.t smoothing scale of Gaussian window.
| k | Input: wavenumber in unit of 1/Mpc |
| R | Input: smoothing scale in unit of Mpc |
| double derR_window_rth | ( | double | k, |
| double | R | ||
| ) |
Derivative w.r.t.
smoothing scale of the Fourier transform of top-hat window in real space
| k | Input: wavenumber in unit of 1/Mpc |
| R | Input: smoothing scale in unit of Mpc |
| double growth_D | ( | struct Cosmology * | Cx, |
| double | k, | ||
| double | z | ||
| ) |
Compute the growth factor D(k,z) for a general case where it can be scale-dependant The scale-dep growth is calculated by taking the ratio of the transfer function at redshift z and zero.
cdm, baryon and total matter.
| Cx | Input: pointer to Cosmology structure |
| k | Input: wavenumbber in unit of 1/Mpc |
| z | Input: redshift to compute the spectrum |


| double growth_f | ( | struct Cosmology * | Cx, |
| double | k, | ||
| double | z | ||
| ) |
Compute the growth factor D(k,z) by taking the ratio of the transfer function at redshift z and zero.
For a general case growth rate can be scale-dependant
| Cx | Input: pointer to Cosmology structure |
| k | Input: wavenumbber in unit of 1/Mpc |
| z | Input: redshift to compute the spectrum |


| double Hubble | ( | struct Cosmology * | Cx, |
| double | z | ||
| ) |
Compute the the hubble rate (exactly the quantity defined by CLASS as index_bg_H in the background module).
| Cx | Input: pointer to Cosmology structure |
| z | Input: redshift to compute the spectrum |
junk

| double nfw_profile | ( | struct Cosmology * | Cx, |
| double | k, | ||
| double | M, | ||
| double | z | ||
| ) |
Compute the NFW halo profile in Fourier space, given by Eq.
3.7 of 2004.09515 The profile is normalized to unity at k->0, (see fig 3 of 1003.4740)
| Cx | Input: pointer to Cosmology structure |
| k | Input: wavenumber in unit of 1/Mpc |
| M | Input: halo mass in unit of solar mass |
| z | Input: redshift of interest |
rho_s is computed by enforcing int dr r^2 u(r) = 1

| double Pk_dlnPk_HV | ( | struct Cosmology * | Cx, |
| double | k, | ||
| double | z, | ||
| int | mode | ||
| ) |
Read in the linear power spectrum, used to set the initial conditions of Hidden-Valley sims.
Input k is in unit of 1/Mpc. First convert it to h/Mpc, and also convert the final matter power spectrum in unit of (Mpc/h)^3
| Cx | Input: pointer to Cosmology structure |
| k | Input: wavenumbber in unit of 1/Mpc |
| z | Input: redshift to compute the spectrum |
| mode | Input: switch to decide whether to evaluate the interpolator of the power spectrum or free the interpolator |

| double PS | ( | struct Cosmology * | Cx, |
| double | k, | ||
| double | z | ||
| ) |
Evaluate the extrapolation for matter power spectrum beyond what is calculated by CLASS, same expansion as that used in CORE cosmology librrary (see arXiv:1812.05995) If requested k-value was beyond what is calculated by CLASS, this function extrapolates.
| Cx | Input: pointer to Cosmology structure |
| k | Input: wavenumbber in unit of 1/Mpc |
| z | Input: redshift to compute the spectrum |


| double PS_class | ( | struct Cosmology * | Cx, |
| double | k, | ||
| double | z, | ||
| long | mode | ||
| ) |
Call CLASS-V3.1 functions to compute the cdm+b pk (in Mpc**3) for a given k (in 1/Mpc) and z In LIM_FISHER code, we always include massive neutrinos.
In this case, to compute the galaxy power spectrum, we should use cdm+b pk. Therefore hete when calling PS_class, we always get cdm+b pk, i.e. set &Cx -> ccs.fo.index_pk_cb. If you wanted to set neutrinos to be massless, you should replace this index by &Cx -> ccs.fo.index_pk_m The older routine of CLASS-v2.7, spectra_pk_at_k_and_z(), is replaced by fourier_pk_at_k_and_z(),
Input k is in unit of 1/Mpc. First convert it to h/Mpc, and also convert the final matter power spectrum in unit of (Mpc/h)^3
| Cx | Input: pointer to Cosmology structure |
| k | Input: wavenumbber in unit of 1/Mpc |
| z | Input: redshift to compute the spectrum |
| mode | Input: switch to decide whether to compute linear (LPOWER) or nonlinear (NLPOWER) spectrum |

| int PS_xtrapol_free | ( | struct PS_xtr * | PS_xtrapol | ) |
frees the interpolation elements for P_m spline
| PS_xtrapol | Input: pointer to the structure containing the interpolation pointers |

Call CLASS and build a 2d interpolator for Plin(k,z), which will be used when building an extrapolator for P(k,z) beyond a given kmax computed by CLASS.
| Cx | Input: pointer to Cosmology structure |


| double R_scale | ( | struct Cosmology * | Cx, |
| double | h_mass | ||
| ) |
Compute the Lagrangian radius of halos in unit of Mpc , fixing z=0.
| Cx | Input: pointer to Cosmology structure |
| h_mass | Input: halo mass in unit of solar mass |


| double R_scale_wrong | ( | struct Cosmology * | Cx, |
| double | z, | ||
| double | h_mass | ||
| ) |
Compute the Lagrangian radius of halos in unit of Mpc at z.
| Cx | Input: pointer to Cosmology structure |
| z | Input: redshift |
| h_mass | Input: halo mass in unit of solar mass |

| double R_vir | ( | struct Cosmology * | Cx, |
| double | M | ||
| ) |
Compute the comoving virial radius of halos in unit of Mpc, which is defined as the radius at which the average density within this radius is Delta X rho_c.
| Cx | Input: pointer to Cosmology structure |
| M | Input: halo mass in unit of solar mass |


| double rhoc | ( | struct Cosmology * | Cx, |
| double | z | ||
| ) |
Compute the critical density in unit of M_sun/Mpc^3.
| Cx | Input: pointer to Cosmology structure |
| z | Input: redshift to compute the spectrum |
E (a) = H(a)^2/H0^2
G is in unit of m^3 kg^-1 s^-2, conversion factor from m to Mpc
To convert to solar mass


| double scale_indep_growth_D | ( | struct Cosmology * | Cx, |
| double | z | ||
| ) |
Compute the growth factor D(k,z) which is scale-indep valid when neutrinos are massless The scale-dep growth is calculated by taking the ratio of the transfer function at redshift z and zero.
The scale-indep growth is computed by CLASS directly
| Cx | Input: pointer to Cosmology structure |
| z | Input: redshift to compute the spectrum |
junk
| double scale_indep_growth_f | ( | struct Cosmology * | Cx, |
| double | z | ||
| ) |
Compute the scale-independent growth rate f(z) which is scale-indep valid when neutrinos are massless.
| Cx | Input: pointer to Cosmology structure |
| z | Input: redshift to compute the spectrum |
junk
| double sig_sq | ( | struct Cosmology * | Cx, |
| double | z, | ||
| double | R | ||
| ) |
Compute variance of smoothed matter density fluctuations.
The function sigma0_integrand() defines the integrand and sigma0_sq() computes the k-integral
| Cx | Input: pointer to Cosmology structure |
| z | Input: redshift to compute the spectrum |
| R | Input: smoothing scale |


| double sig_sq_integrand | ( | double | x, |
| void * | par | ||
| ) |
The integrand function passed to qags integrator to compute the variance of the smoothed matter density.
| x | Input: integration variable |
| par | Input: integration parmaeters |


| double sigma0_sq | ( | struct Cosmology * | Cx, |
| double | z, | ||
| double | kmax | ||
| ) |
Compute variance of unsmoothed matter density fluctuations.
The function sigma0_integrand() defines the integrand and sigma0_sq() computes the k-integral
| Cx | Input: pointer to Cosmology structure |
| kmax | Input: maximum wavenumber in unit of 1/Mpc |
| z | Input: redshift to compute the spectrum |


| double sigma0_sq_integrand | ( | double | x, |
| void * | par | ||
| ) |
The integrand function passed to qags integrator to compute the variance of the unsmoothed matter density.
| x | Input: integration variable |
| par | Input: integration parmaeters |


| double transfer | ( | struct Cosmology * | Cx, |
| double | k, | ||
| double | z, | ||
| int | mode | ||
| ) |
call CLASS-V3.1 to compute transfer function for different species depending on the switch "mode" mode can be set to cdm, baryons or total matter transfer function.
The older routine of CLASS-v2.7, spectra_tk_at_k_and_z(), is replaced by perturbations_sources_at_k_and_z(), which evaluates the matter transfer functions at a given value of k and z
| Cx | Input: pointer to Cosmology structure |
| k | Input: wavenumbber in unit of 1/Mpc |
| z | Input: redshift to compute the spectrum |
| mode | Input: switch to decide which species to consider, can be set to cdm, baryons or total matter transfer function. |

| double window_g | ( | double | k, |
| double | R | ||
| ) |
Gaussian window.
| k | Input: wavenumber in unit of 1/Mpc |
| R | Input: smoothing scale in unit of Mpc |
| double window_kth | ( | double | k, |
| double | R | ||
| ) |
Top-hat window in Fourier space.
| k | Input: wavenumber in unit of 1/Mpc |
| R | Input: smoothing scale in unit of Mpc |
| double window_rth | ( | double | k, |
| double | R | ||
| ) |
Fourier transform of top-hat window in real space.
| k | Input: wavenumber in unit of 1/Mpc |
| R | Input: smoothing scale in unit of Mpc |
