CLASS MANUAL
|
#include "background.h"
Functions | |
int | background_at_z (struct background *pba, double z, enum vecback_format return_format, enum interpolation_method inter_mode, int *last_index, double *pvecback) |
int | background_at_tau (struct background *pba, double tau, enum vecback_format return_format, enum interpolation_method inter_mode, int *last_index, double *pvecback) |
int | background_tau_of_z (struct background *pba, double z, double *tau) |
int | background_z_of_tau (struct background *pba, double tau, double *z) |
int | background_functions (struct background *pba, double a, double *pvecback_B, enum vecback_format return_format, double *pvecback) |
int | background_w_fld (struct background *pba, double a, double *w_fld, double *dw_over_da_fld, double *integral_fld) |
int | background_varconst_of_z (struct background *pba, double z, double *alpha, double *me) |
int | background_init (struct precision *ppr, struct background *pba) |
int | background_free (struct background *pba) |
int | background_free_noinput (struct background *pba) |
int | background_free_input (struct background *pba) |
int | background_indices (struct background *pba) |
int | background_ncdm_distribution (void *pbadist, double q, double *f0) |
int | background_ncdm_test_function (void *pbadist, double q, double *test) |
int | background_ncdm_init (struct precision *ppr, struct background *pba) |
int | background_ncdm_momenta (double *qvec, double *wvec, int qsize, double M, double factor, double z, double *n, double *rho, double *p, double *drho_dM, double *pseudo_p) |
int | background_ncdm_M_from_Omega (struct precision *ppr, struct background *pba, int n_ncdm) |
int | background_checks (struct precision *ppr, struct background *pba) |
int | background_solve (struct precision *ppr, struct background *pba) |
int | background_initial_conditions (struct precision *ppr, struct background *pba, double *pvecback, double *pvecback_integration, double *loga_ini) |
int | background_find_equality (struct precision *ppr, struct background *pba) |
int | background_output_titles (struct background *pba, char titles[_MAXTITLESTRINGLENGTH_]) |
int | background_output_data (struct background *pba, int number_of_titles, double *data) |
int | background_derivs (double loga, double *y, double *dy, void *parameters_and_workspace, ErrorMsg error_message) |
int | background_sources (double loga, double *y, double *dy, int index_loga, void *parameters_and_workspace, ErrorMsg error_message) |
int | background_timescale (double loga, void *parameters_and_workspace, double *timescale, ErrorMsg error_message) |
int | background_output_budget (struct background *pba) |
double | V_e_scf (struct background *pba, double phi) |
double | V_p_scf (struct background *pba, double phi) |
double | V_scf (struct background *pba, double phi) |
Documented background module
Deals with the cosmological background evolution. This module has two purposes:
The overall logic in this module is the following:
So, we define the following routines:
Later in the code:
In order to save time, background_at_tau() ans background_at_z() can be called in three modes: short_info, normal_info, long_info (returning only essential quantities, or useful quantities, or rarely useful quantities). Each line in the interpolation table is a vector whose first few elements correspond to the short_info format; a larger fraction contribute to the normal format; and the full vector corresponds to the long format. The guideline is that short_info returns only geometric quantities like a, H, H'; normal format returns quantities strictly needed at each step in the integration of perturbations; long_info returns quantities needed only occasionally.
In summary, the following functions can be called from other modules:
For units and normalisation conventions, there are two guiding principles:
1) All quantities are expressed in natural units in which everything is in powers of Mpc, e.g.:
2) New since v3.0: all quantities that should normally scale with some power of a_0^n are renormalised by a_0^{-n}, in order to be independent of a_0, e.g.
int background_at_z | ( | struct background * | pba, |
double | z, | ||
enum vecback_format | return_format, | ||
enum interpolation_method | inter_mode, | ||
int * | last_index, | ||
double * | pvecback | ||
) |
Background quantities at given redshift z.
Evaluates all background quantities at a given value of redshift by reading the pre-computed table and interpolating.
pba | Input: pointer to background structure (containing pre-computed table) |
z | Input: redshift |
return_format | Input: format of output vector (short_info, normal_info, long_info) |
inter_mode | Input: interpolation mode (normal or closeby) |
last_index | Input/Output: index of the previous/current point in the interpolation array (input only for closeby mode, output for both) |
pvecback | Output: vector (assumed to be already allocated) |
Summary:
int background_at_tau | ( | struct background * | pba, |
double | tau, | ||
enum vecback_format | return_format, | ||
enum interpolation_method | inter_mode, | ||
int * | last_index, | ||
double * | pvecback | ||
) |
Background quantities at given conformal time tau.
Evaluates all background quantities at a given value of conformal time by reading the pre-computed table and interpolating.
pba | Input: pointer to background structure (containing pre-computed table) |
tau | Input: value of conformal time |
return_format | Input: format of output vector (short_info, normal_info, long_info) |
inter_mode | Input: interpolation mode (normal or closeby) |
last_index | Input/Output: index of the previous/current point in the interpolation array (input only for closeby mode, output for both) |
pvecback | Output: vector (assumed to be already allocated) |
Summary:
int background_tau_of_z | ( | struct background * | pba, |
double | z, | ||
double * | tau | ||
) |
Conformal time at given redshift.
Returns tau(z) by interpolation from pre-computed table.
pba | Input: pointer to background structure |
z | Input: redshift |
tau | Output: conformal time |
Summary:
int background_z_of_tau | ( | struct background * | pba, |
double | tau, | ||
double * | z | ||
) |
Redshift at given conformal time.
Returns z(tau) by interpolation from pre-computed table.
pba | Input: pointer to background structure |
tau | Input: conformal time |
z | Output: redshift |
Summary:
int background_functions | ( | struct background * | pba, |
double | a, | ||
double * | pvecback_B, | ||
enum vecback_format | return_format, | ||
double * | pvecback | ||
) |
Function evaluating all background quantities which can be computed analytically as a function of a and of {B} quantities (see discussion at the beginning of this file).
pba | Input: pointer to background structure |
a | Input: scale factor (in fact, with our normalisation conventions, this is (a/a_0) ) |
pvecback_B | Input: vector containing all {B} quantities |
return_format | Input: format of output vector |
pvecback | Output: vector of background quantities (assumed to be already allocated) |
Summary:
<– This depends on a_prime_over_a, so we cannot add it now!
See e.g. Eq. A6 in 1811.00904.
The contribution of scf was not added to dp_dloga, add p_scf_prime here:
int background_w_fld | ( | struct background * | pba, |
double | a, | ||
double * | w_fld, | ||
double * | dw_over_da_fld, | ||
double * | integral_fld | ||
) |
Single place where the fluid equation of state is defined. Parameters of the function are passed through the background structure. Generalisation to arbitrary functions should be simple.
pba | Input: pointer to background structure |
a | Input: current value of scale factor (in fact, with our conventions, of (a/a_0)) |
w_fld | Output: equation of state parameter w_fld(a) |
dw_over_da_fld | Output: function dw_fld/da |
integral_fld | Output: function |
note: of course you can generalise these formulas to anything, defining new parameters pba->w..._fld. Just remember that so far, HyRec explicitely assumes that w(a)= w0 + wa (1-a/a0); but Recfast does not assume anything
int background_varconst_of_z | ( | struct background * | pba, |
double | z, | ||
double * | alpha, | ||
double * | me | ||
) |
Single place where the variation of fundamental constants is defined. Parameters of the function are passed through the background structure. Generalisation to arbitrary functions should be simple.
pba | Input: pointer to background structure |
z | Input: current value of redhsift |
alpha | Output: fine structure constant relative to its current value |
me | Output: effective electron mass relative to its current value |
int background_init | ( | struct precision * | ppr, |
struct background * | pba | ||
) |
Initialize the background structure, and in particular the background interpolation table.
ppr | Input: pointer to precision structure |
pba | Input/Output: pointer to initialized background structure |
Summary:
int background_free | ( | struct background * | pba | ) |
Free all memory space allocated by background_init() and by input_read_parameters().
pba | Input: pointer to background structure (to be freed) |
int background_free_noinput | ( | struct background * | pba | ) |
Free only the memory space NOT allocated through input_read_parameters(), but through background_init()
pba | Input: pointer to background structure (to be freed) |
int background_free_input | ( | struct background * | pba | ) |
Free pointers inside background structure which were allocated in input_read_parameters()
pba | Input: pointer to background structure |
int background_indices | ( | struct background * | pba | ) |
Assign value to each relevant index in vectors of background quantities.
pba | Input: pointer to background structure |
Summary:
int background_ncdm_distribution | ( | void * | pbadist, |
double | q, | ||
double * | f0 | ||
) |
This is the routine where the distribution function f0(q) of each ncdm species is specified (it is the only place to modify if you need a partlar f0(q))
pbadist | Input: structure containing all parameters defining f0(q) |
q | Input: momentum |
f0 | Output: phase-space distribution |
Next enter your analytic expression(s) for the p.s.d.'s. If you need different p.s.d.'s for different species, put each p.s.d inside a condition, like for instance: if (n_ncdm==2) {*f0=...}. Remember that n_ncdm = 0 refers to the first species.
This form is only appropriate for approximate studies, since in reality the chemical potentials are associated with flavor eigenstates, not mass eigenstates. It is easy to take this into account by introducing the mixing angles. In the later part (not read by the code) we illustrate how to do this.
int background_ncdm_test_function | ( | void * | pbadist, |
double | q, | ||
double * | test | ||
) |
This function is only used for the purpose of finding optimal quadrature weights. The logic is: if we can accurately convolve f0(q) with this function, then we can convolve it accurately with any other relevant function.
pbadist | Input: structure containing all background parameters |
q | Input: momentum |
test | Output: value of the test function test(q) |
Using a + bq creates problems for otherwise acceptable distributions which diverges as or for
int background_ncdm_init | ( | struct precision * | ppr, |
struct background * | pba | ||
) |
This function finds optimal quadrature weights for each ncdm species
ppr | Input: precision structure |
pba | Input/Output: background structure |
Automatic q-sampling for this species
Manual q-sampling for this species. Same sampling used for both perturbation and background sampling, since this will usually be a high precision setting anyway
int background_ncdm_momenta | ( | double * | qvec, |
double * | wvec, | ||
int | qsize, | ||
double | M, | ||
double | factor, | ||
double | z, | ||
double * | n, | ||
double * | rho, | ||
double * | p, | ||
double * | drho_dM, | ||
double * | pseudo_p | ||
) |
For a given ncdm species: given the quadrature weights, the mass and the redshift, find background quantities by a quick weighted sum over. Input parameters passed as NULL pointers are not evaluated for speed-up
qvec | Input: sampled momenta |
wvec | Input: quadrature weights |
qsize | Input: number of momenta/weights |
M | Input: mass |
factor | Input: normalization factor for the p.s.d. |
z | Input: redshift |
n | Output: number density |
rho | Output: energy density |
p | Output: pressure |
drho_dM | Output: derivative used in next function |
pseudo_p | Output: pseudo-pressure used in perturbation module for fluid approx |
Summary:
int background_ncdm_M_from_Omega | ( | struct precision * | ppr, |
struct background * | pba, | ||
int | n_ncdm | ||
) |
When the user passed the density fraction Omega_ncdm or omega_ncdm in input but not the mass, infer the mass with Newton iteration method.
ppr | Input: precision structure |
pba | Input/Output: background structure |
n_ncdm | Input: index of ncdm species |
int background_checks | ( | struct precision * | ppr, |
struct background * | pba | ||
) |
Perform some check on the input background quantities, and send to standard output some information about them
ppr | Input: pointer to precision structure |
pba | Input: pointer to initialized background structure |
int background_solve | ( | struct precision * | ppr, |
struct background * | pba | ||
) |
This function integrates the background over time, allocates and fills the background table
ppr | Input: precision structure |
pba | Input/Output: background structure |
Summary:
int background_initial_conditions | ( | struct precision * | ppr, |
struct background * | pba, | ||
double * | pvecback, | ||
double * | pvecback_integration, | ||
double * | loga_ini | ||
) |
Assign initial values to background integrated variables.
ppr | Input: pointer to precision structure |
pba | Input: pointer to background structure |
pvecback | Input: vector of background quantities used as workspace |
pvecback_integration | Output: vector of background quantities to be integrated, returned with proper initial values |
loga_ini | Output: value of loga (in fact with our conventions log(a/a_0)) at initial time |
Summary:
If we have ncdm species, perhaps we need to start earlier than the standard value for the species to be relativistic. This could happen for some WDM models.
f = -Omega_rad+pow(pow(Omega_rad,3./2.)+0.5*pow(a,6)*pvecback_integration[pba->index_bi_rho_dcdm]*pba->Gamma_dcdm/pow(pba->H0,3),2./3.);
but it is not numerically stable for very small f which is always the case. Instead we use the Taylor expansion of this equation, which is equivalent to ignoring f(a) in the Hubble rate.
There is also a space reserved for a future case where dr is not sourced by dcdm
TODO:
int background_find_equality | ( | struct precision * | ppr, |
struct background * | pba | ||
) |
Find the time of radiation/matter equality and store characteristic quantitites at that time in the background structure..
ppr | Input: pointer to precision structure |
pba | Input/Output: pointer to background structure |
int background_output_titles | ( | struct background * | pba, |
char | titles[_MAXTITLESTRINGLENGTH_] | ||
) |
Subroutine for formatting background output
pba | Input: pointer to background structure |
titles | Ouput: name of columns when printing the background table |
int background_output_data | ( | struct background * | pba, |
int | number_of_titles, | ||
double * | data | ||
) |
Subroutine for writing the background output
pba | Input: pointer to background structure |
number_of_titles | Input: number of background quantities to print at each time step |
data | Ouput: 1d array storing all the background table |
Stores quantities
int background_derivs | ( | double | loga, |
double * | y, | ||
double * | dy, | ||
void * | parameters_and_workspace, | ||
ErrorMsg | error_message | ||
) |
Subroutine evaluating the derivative with respect to loga of quantities which are integrated (tau, t, etc).
This is one of the few functions in the code which is passed to the generic_integrator() routine. Since generic_integrator() should work with functions passed from various modules, the format of the arguments is a bit special:
loga | Input: current value of log(a) |
y | Input: vector of variable |
dy | Output: its derivative (already allocated) |
parameters_and_workspace | Input: pointer to fixed parameters (e.g. indices) |
error_message | Output: error message |
Summary:
int background_sources | ( | double | loga, |
double * | y, | ||
double * | dy, | ||
int | index_loga, | ||
void * | parameters_and_workspace, | ||
ErrorMsg | error_message | ||
) |
At some step during the integraton of the background equations, this function extracts the qantities that we want to keep memory of, and stores them in a row of the background table (as well as extra tables: z_table, tau_table).
This is one of the few functions in the code which is passed to the generic_integrator() routine. Since generic_integrator() should work with functions passed from various modules, the format of the arguments is a bit special:
loga | Input: current value of log(a) |
y | Input: current vector of integrated quantities (with index_bi) |
dy | Input: current derivative of y w.r.t log(a) |
index_loga | Input: index of the log(a) value within the background_table |
parameters_and_workspace | Input/output: fixed parameters (e.g. indices), workspace, background structure where the output is written... |
error_message | Output: error message |
-> compute all other quantities depending only on a + {B} variables and get them stored in one row of background_table The value of {B} variables in pData are also copied to pvecback.
int background_timescale | ( | double | loga, |
void * | parameters_and_workspace, | ||
double * | timescale, | ||
ErrorMsg | error_message | ||
) |
Evalute the typical timescale for the integration of he background over loga=log(a/a_0). This is only required for rkck, but not for the ndf15 evolver.
The evolver will take steps equal to this value times ppr->background_integration_stepsize. Since our variable of integration is loga, and the time steps are (delta a)/a, the reference timescale is precisely one, i.e., the code will take some steps such that (delta a)/a = ppr->background_integration_stepsize.
The argument list is predetermined by the format of generic_evolver; however in this particular case, they are never used.
This is one of the few functions in the code which is passed to the generic_integrator() routine. Since generic_integrator() should work with functions passed from various modules, the format of the arguments is a bit special:
loga | Input: current value of log(a/a_0) |
parameters_and_workspace | Input: fixed parameters (e.g. indices), workspace, approximation used, etc. |
timescale | Output: perturbation variation timescale |
error_message | Output: error message |
int background_output_budget | ( | struct background * | pba | ) |
Function outputting the fractions Omega of the total critical density today, and also the reduced fractions omega=Omega*h*h
It also prints the total budgets of non-relativistic, relativistic, and other contents, and of the total
pba | Input: Pointer to background structure |
double V_e_scf | ( | struct background * | pba, |
double | phi | ||
) |
Scalar field potential and its derivatives with respect to the field _scf For Albrecht & Skordis model: 9908085
TODO:
Numerical derivatives may further serve as a consistency check.
The units of phi, tau in the derivatives and the potential V are the following:
double V_p_scf | ( | struct background * | pba, |
double | phi | ||
) |
parameters and functions for the polynomial coefficient (polynomial bump)
double scf_alpha = 2;
double scf_B = 34.8;
double scf_A = 0.01; (values for their Figure 2)
double V_scf | ( | struct background * | pba, |
double | phi | ||
) |
Fianlly we can obtain the overall potential