CLASS MANUAL
|
#include "perturbations.h"
Functions | |
int | perturb_sources_at_tau (struct perturbs *ppt, int index_md, int index_ic, int index_type, double tau, double *psource) |
int | perturb_init (struct precision *ppr, struct background *pba, struct thermo *pth, struct perturbs *ppt) |
int | perturb_free (struct perturbs *ppt) |
int | perturb_indices_of_perturbs (struct precision *ppr, struct background *pba, struct thermo *pth, struct perturbs *ppt) |
int | perturb_timesampling_for_sources (struct precision *ppr, struct background *pba, struct thermo *pth, struct perturbs *ppt) |
int | perturb_get_k_list (struct precision *ppr, struct background *pba, struct thermo *pth, struct perturbs *ppt) |
int | perturb_workspace_init (struct precision *ppr, struct background *pba, struct thermo *pth, struct perturbs *ppt, int index_md, struct perturb_workspace *ppw) |
int | perturb_workspace_free (struct perturbs *ppt, int index_md, struct perturb_workspace *ppw) |
int | perturb_solve (struct precision *ppr, struct background *pba, struct thermo *pth, struct perturbs *ppt, int index_md, int index_ic, int index_k, struct perturb_workspace *ppw) |
int | perturb_prepare_output (struct background *pba, struct perturbs *ppt) |
int | perturb_find_approximation_number (struct precision *ppr, struct background *pba, struct thermo *pth, struct perturbs *ppt, int index_md, double k, struct perturb_workspace *ppw, double tau_ini, double tau_end, int *interval_number, int *interval_number_of) |
int | perturb_find_approximation_switches (struct precision *ppr, struct background *pba, struct thermo *pth, struct perturbs *ppt, int index_md, double k, struct perturb_workspace *ppw, double tau_ini, double tau_end, double precision, int interval_number, int *interval_number_of, double *interval_limit, int **interval_approx) |
int | perturb_vector_init (struct precision *ppr, struct background *pba, struct thermo *pth, struct perturbs *ppt, int index_md, int index_ic, double k, double tau, struct perturb_workspace *ppw, int *pa_old) |
int | perturb_vector_free (struct perturb_vector *pv) |
int | perturb_initial_conditions (struct precision *ppr, struct background *pba, struct perturbs *ppt, int index_md, int index_ic, double k, double tau, struct perturb_workspace *ppw) |
int | perturb_approximations (struct precision *ppr, struct background *pba, struct thermo *pth, struct perturbs *ppt, int index_md, double k, double tau, struct perturb_workspace *ppw) |
int | perturb_timescale (double tau, void *parameters_and_workspace, double *timescale, ErrorMsg error_message) |
int | perturb_einstein (struct precision *ppr, struct background *pba, struct thermo *pth, struct perturbs *ppt, int index_md, double k, double tau, double *y, struct perturb_workspace *ppw) |
int | perturb_total_stress_energy (struct precision *ppr, struct background *pba, struct thermo *pth, struct perturbs *ppt, int index_md, double k, double *y, struct perturb_workspace *ppw) |
int | perturb_sources (double tau, double *y, double *dy, int index_tau, void *parameters_and_workspace, ErrorMsg error_message) |
int | perturb_print_variables (double tau, double *y, double *dy, void *parameters_and_workspace, ErrorMsg error_message) |
int | perturb_derivs (double tau, double *y, double *dy, void *parameters_and_workspace, ErrorMsg error_message) |
int | perturb_tca_slip_and_shear (double *y, void *parameters_and_workspace, ErrorMsg error_message) |
Documented perturbation module
Julien Lesgourgues, 23.09.2010
Deals with the perturbation evolution. This module has two purposes:
Hence the following functions can be called from other modules:
int perturb_sources_at_tau | ( | struct perturbs * | ppt, |
int | index_md, | ||
int | index_ic, | ||
int | index_type, | ||
double | tau, | ||
double * | psource | ||
) |
Source function at a given conformal time tau.
Evaluate source functions at given conformal time tau by reading the pre-computed table and interpolating.
ppt | Input: pointer to perturbation structure containing interpolation tables |
index_md | Input: index of requested mode |
index_ic | Input: index of requested initial condition |
index_type | Input: index of requested source function type |
tau | Input: any value of conformal time |
psource | Output: vector (already allocated) of source function as a function of k |
Summary:
int perturb_init | ( | struct precision * | ppr, |
struct background * | pba, | ||
struct thermo * | pth, | ||
struct perturbs * | ppt | ||
) |
Initialize the perturbs structure, and in particular the table of source functions.
Main steps:
ppr | Input: pointer to precision structure |
pba | Input: pointer to background structure |
pth | Input: pointer to thermodynamics structure |
ppt | Output: Initialized perturbation structure |
Summary:
int perturb_free | ( | struct perturbs * | ppt | ) |
Free all memory space allocated by perturb_init().
To be called at the end of each run, only when no further calls to perturb_sources_at_tau() are needed.
ppt | Input: perturbation structure to be freed |
Stuff related to perturbations output:
int perturb_indices_of_perturbs | ( | struct precision * | ppr, |
struct background * | pba, | ||
struct thermo * | pth, | ||
struct perturbs * | ppt | ||
) |
Initialize all indices and allocate most arrays in perturbs structure.
ppr | Input: pointer to precision structure |
pba | Input: pointer to background structure |
pth | Input: pointer to thermodynamics structure |
ppt | Input/Output: Initialized perturbation structure |
Summary:
int perturb_timesampling_for_sources | ( | struct precision * | ppr, |
struct background * | pba, | ||
struct thermo * | pth, | ||
struct perturbs * | ppt | ||
) |
Define time sampling for source functions.
For each type, compute the list of values of tau at which sources will be sampled. Knowing the number of tau values, allocate all arrays of source functions.
ppr | Input: pointer to precision structure |
pba | Input: pointer to background structure |
pth | Input: pointer to thermodynamics structure |
ppt | Input/Output: Initialized perturbation structure |
Summary:
int perturb_get_k_list | ( | struct precision * | ppr, |
struct background * | pba, | ||
struct thermo * | pth, | ||
struct perturbs * | ppt | ||
) |
Define the number of comoving wavenumbers using the information passed in the precision structure.
ppr | Input: pointer to precision structure |
pba | Input: pointer to background structure |
pth | Input: pointer to thermodynamics structure |
ppt | Input: pointer to perturbation structure |
Summary:
int perturb_workspace_init | ( | struct precision * | ppr, |
struct background * | pba, | ||
struct thermo * | pth, | ||
struct perturbs * | ppt, | ||
int | index_md, | ||
struct perturb_workspace * | ppw | ||
) |
Initialize a perturb_workspace structure. All fields are allocated here, with the exception of the perturb_vector '–>pv' field, which is allocated separately in perturb_vector_init. We allocate one such perturb_workspace structure per thread and per mode (scalar/../tensor). Then, for each thread, all initial conditions and wavenumbers will use the same workspace.
ppr | Input: pointer to precision structure |
pba | Input: pointer to background structure |
pth | Input: pointer to the thermodynamics structure |
ppt | Input: pointer to the perturbation structure |
index_md | Input: index of mode under consideration (scalar/.../tensor) |
ppw | Input/Output: pointer to perturb_workspace structure which fields are allocated or filled here |
Summary:
int perturb_workspace_free | ( | struct perturbs * | ppt, |
int | index_md, | ||
struct perturb_workspace * | ppw | ||
) |
Free the perturb_workspace structure (with the exception of the perturb_vector '–>pv' field, which is freed separately in perturb_vector_free).
ppt | Input: pointer to the perturbation structure |
index_md | Input: index of mode under consideration (scalar/.../tensor) |
ppw | Input: pointer to perturb_workspace structure to be freed |
int perturb_solve | ( | struct precision * | ppr, |
struct background * | pba, | ||
struct thermo * | pth, | ||
struct perturbs * | ppt, | ||
int | index_md, | ||
int | index_ic, | ||
int | index_k, | ||
struct perturb_workspace * | ppw | ||
) |
Solve the perturbation evolution for a given mode, initial condition and wavenumber, and compute the corresponding source functions.
For a given mode, initial condition and wavenumber, this function finds the time ranges over which the perturbations can be described within a given approximation. For each such range, it initializes (or redistributes) perturbations using perturb_vector_init(), and integrates over time. Whenever a "source sampling time" is passed, the source terms are computed and stored in the source table using perturb_sources().
ppr | Input: pointer to precision structure |
pba | Input: pointer to background structure |
pth | Input: pointer to the thermodynamics structure |
ppt | Input/Output: pointer to the perturbation structure (output source functions S(k,tau) written here) |
index_md | Input: index of mode under consideration (scalar/.../tensor) |
index_ic | Input: index of initial condition under consideration (ad, iso...) |
index_k | Input: index of wavenumber |
ppw | Input: pointer to perturb_workspace structure containing index values and workspaces |
Summary:
int perturb_prepare_output | ( | struct background * | pba, |
struct perturbs * | ppt | ||
) |
Write titles for all perturbations that we would like to print/store.
int perturb_find_approximation_number | ( | struct precision * | ppr, |
struct background * | pba, | ||
struct thermo * | pth, | ||
struct perturbs * | ppt, | ||
int | index_md, | ||
double | k, | ||
struct perturb_workspace * | ppw, | ||
double | tau_ini, | ||
double | tau_end, | ||
int * | interval_number, | ||
int * | interval_number_of | ||
) |
For a given mode and wavenumber, find the number of intervals of time between tau_ini and tau_end such that the approximation scheme (and the number of perturbation equations) is uniform.
ppr | Input: pointer to precision structure |
pba | Input: pointer to background structure |
pth | Input: pointer to the thermodynamics structure |
ppt | Input: pointer to the perturbation structure |
index_md | Input: index of mode under consideration (scalar/.../tensor) |
k | Input: index of wavenumber |
ppw | Input: pointer to perturb_workspace structure containing index values and workspaces |
tau_ini | Input: initial time of the perturbation integration |
tau_end | Input: final time of the perturbation integration |
interval_number | Output: total number of intervals |
interval_number_of | Output: number of intervals with respect to each particular approximation |
Summary:
int perturb_find_approximation_switches | ( | struct precision * | ppr, |
struct background * | pba, | ||
struct thermo * | pth, | ||
struct perturbs * | ppt, | ||
int | index_md, | ||
double | k, | ||
struct perturb_workspace * | ppw, | ||
double | tau_ini, | ||
double | tau_end, | ||
double | precision, | ||
int | interval_number, | ||
int * | interval_number_of, | ||
double * | interval_limit, | ||
int ** | interval_approx | ||
) |
For a given mode and wavenumber, find the values of time at which the approximation changes.
ppr | Input: pointer to precision structure |
pba | Input: pointer to background structure |
pth | Input: pointer to the thermodynamics structure |
ppt | Input: pointer to the perturbation structure |
index_md | Input: index of mode under consideration (scalar/.../tensor) |
k | Input: index of wavenumber |
ppw | Input: pointer to perturb_workspace structure containing index values and workspaces |
tau_ini | Input: initial time of the perturbation integration |
tau_end | Input: final time of the perturbation integration |
precision | Input: tolerance on output values |
interval_number | Input: total number of intervals |
interval_number_of | Input: number of intervals with respect to each particular approximation |
interval_limit | Output: value of time at the boundary of the intervals: tau_ini, tau_switch1, ..., tau_end |
interval_approx | Output: value of approximations in each interval |
Summary:
int perturb_vector_init | ( | struct precision * | ppr, |
struct background * | pba, | ||
struct thermo * | pth, | ||
struct perturbs * | ppt, | ||
int | index_md, | ||
int | index_ic, | ||
double | k, | ||
double | tau, | ||
struct perturb_workspace * | ppw, | ||
int * | pa_old | ||
) |
Initialize the field '–>pv' of a perturb_workspace structure, which is a perturb_vector structure. This structure contains indices and values of all quantities which need to be integrated with respect to time (and only them: quantities fixed analytically or obeying constraint equations are NOT included in this vector). This routine distinguishes between two cases:
–> the input pa_old is set to the NULL pointer:
This happens when we start integrating over a new wavenumber and we want to set initial conditions for the perturbations. Then, it is assumed that ppw–>pv is not yet allocated. This routine allocates it, defines all indices, and then fills the vector ppw–>pv–>y with the initial conditions defined in perturb_initial_conditions.
–> the input pa_old is not set to the NULL pointer and describes some set of approximations:
This happens when we need to change approximation scheme while integrating over a given wavenumber. The new approximation described by ppw–>pa is then different from pa_old. Then, this routine allocates a new vector with a new size and new index values; it fills this vector with initial conditions taken from the previous vector passed as an input in ppw–>pv, and eventually with some analytic approximations for the new variables appearing at this time; then the new vector comes in replacement of the old one, which is freed.
ppr | Input: pointer to precision structure |
pba | Input: pointer to background structure |
pth | Input: pointer to the thermodynamics structure |
ppt | Input: pointer to the perturbation structure |
index_md | Input: index of mode under consideration (scalar/.../tensor) |
index_ic | Input: index of initial condition under consideration (ad, iso...) |
k | Input: wavenumber |
tau | Input: conformal time |
ppw | Input/Output: workspace containing in input the approximation scheme, the background/thermodynamics/metric quantities, and eventually the previous vector y; and in output the new vector y. |
pa_old | Input: NULL is we need to set y to initial conditions for a new wavenumber; points towards a perturb_approximations if we want to switch of approximation. |
Summary:
int perturb_vector_free | ( | struct perturb_vector * | pv | ) |
Free the perturb_vector structure.
pv | Input: pointer to perturb_vector structure to be freed |
int perturb_initial_conditions | ( | struct precision * | ppr, |
struct background * | pba, | ||
struct perturbs * | ppt, | ||
int | index_md, | ||
int | index_ic, | ||
double | k, | ||
double | tau, | ||
struct perturb_workspace * | ppw | ||
) |
For each mode, wavenumber and initial condition, this function initializes in the vector all values of perturbed variables (in a given gauge). It is assumed here that all values have previously been set to zero, only non-zero values are set here.
ppr | Input: pointer to precision structure |
pba | Input: pointer to background structure |
ppt | Input: pointer to the perturbation structure |
index_md | Input: index of mode under consideration (scalar/.../tensor) |
index_ic | Input: index of initial condition under consideration (ad, iso...) |
k | Input: wavenumber |
tau | Input: conformal time |
ppw | Input/Output: workspace containing in input the approximation scheme, the background/thermodynamics/metric quantities, and eventually the previous vector y; and in output the new vector y. |
Summary:
–> Declare local variables
–> For scalars
–> For tensors
tensor initial conditions take into account the fact that scalar (resp. tensor) 's are related to the real space power spectrum of curvature (resp. of the tensor part of metric perturbations)
In momentum space it is conventional to use the modes R(k) and h(k) where the quantity h obeying to the equation of propagation:
and the power spectra in real space and momentum space are related through:
where and
are the dimensionless spectrum of curvature R, and F is a function of k2/K, where K is the curvature parameter. F is equal to one in flat space (K=0), and coming from the contraction of the laplacian eigentensor
with itself. We will give F explicitly below.
Similarly the scalar (S) and tensor (T) 's are given by
The usual convention for the tensor-to-scalar ratio at pivot scale = 16 epsilon in single-field inflation is such that for constant
and
,
so
A priori it would make sense to say that for a power-law primordial spectrum there is an extra factor (and eventually running and so on and so forth...)
However it has been shown that the minimal models of inflation in a negatively curved bubble lead to . In open models it is customary to define the tensor tilt in a non-flat universe as a deviation from this behavior rather than from true scale-invariance in the above sense.
Hence we should have
where the brackets
mean "if K<0"
Then
In the code, it is then a matter of choice to write:
or:
We choose this last option, such that the primordial and spectra module differ minimally in flat and non-flat space. Then we must impose
The factor F is found to be given by:
Introducing as usual and using qdq = kdk this gives
Using qdq = kdk this is equivalent to
Finally, introducing and sgnK=SIGN(k)
, this could also be written
Equation (43,44) of Hu, Seljak, White, Zaldarriaga is equivalent to absorbing the above factor in the definition of the primordial spectrum. Since the initial condition should be written in terms of k rather than nu, they should read
We leave the freedom to multiply by an arbitrary number ppr->gw_ini. The standard convention corresponding to standard definitions of r, ,
is however ppr->gw_ini=1.
int perturb_approximations | ( | struct precision * | ppr, |
struct background * | pba, | ||
struct thermo * | pth, | ||
struct perturbs * | ppt, | ||
int | index_md, | ||
double | k, | ||
double | tau, | ||
struct perturb_workspace * | ppw | ||
) |
Evaluate background/thermodynamics at , infer useful flags / time scales for integrating perturbations.
Evaluate background quantities at , as well as thermodynamics for scalar mode; infer useful flags and time scales for integrating the perturbations:
So, in general, min_time_scale = .
However, if and
, we can use the tight-coupling regime for photons and write equations in such way that the time scale
becomes irrelevant (no effective mass term in
). Then, the smallest scale in the equations is only
. In practise, it is sufficient to use only the condition
.
Also, if and
, we can switch off radiation perturbations (i.e. switch on the free-streaming approximation) and then the smallest scale is simply
.
ppr | Input: pointer to precision structure |
pba | Input: pointer to background structure |
pth | Input: pointer to thermodynamics structure |
ppt | Input: pointer to the perturbation structure |
index_md | Input: index of mode under consideration (scalar/.../tensor) |
k | Input: wavenumber |
tau | Input: conformal time |
ppw | Input/Output: in output contains the approximation to be used at this time |
Summary:
int perturb_timescale | ( | double | tau, |
void * | parameters_and_workspace, | ||
double * | timescale, | ||
ErrorMsg | error_message | ||
) |
Compute typical timescale over which the perturbation equations vary. Some integrators (e.g. Runge-Kunta) benefit from calling this routine at each step in order to adapt the next step.
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:
tau | Input: conformal time |
parameters_and_workspace | Input: fixed parameters (e.g. indices), workspace, approximation used, etc. |
timescale | Output: perturbation variation timescale (given the approximation used) |
error_message | Output: error message |
Summary:
int perturb_einstein | ( | struct precision * | ppr, |
struct background * | pba, | ||
struct thermo * | pth, | ||
struct perturbs * | ppt, | ||
int | index_md, | ||
double | k, | ||
double | tau, | ||
double * | y, | ||
struct perturb_workspace * | ppw | ||
) |
Compute metric perturbations (those not integrated over time) using Einstein equations
ppr | Input: pointer to precision structure |
pba | Input: pointer to background structure |
pth | Input: pointer to thermodynamics structure |
ppt | Input: pointer to the perturbation structure |
index_md | Input: index of mode under consideration (scalar/.../tensor) |
k | Input: wavenumber |
tau | Input: conformal time |
y | Input: vector of perturbations (those integrated over time) (already allocated) |
ppw | Input/Output: in output contains the updated metric perturbations |
Summary:
int perturb_total_stress_energy | ( | struct precision * | ppr, |
struct background * | pba, | ||
struct thermo * | pth, | ||
struct perturbs * | ppt, | ||
int | index_md, | ||
double | k, | ||
double * | y, | ||
struct perturb_workspace * | ppw | ||
) |
Summary:
int perturb_sources | ( | double | tau, |
double * | y, | ||
double * | dy, | ||
int | index_tau, | ||
void * | parameters_and_workspace, | ||
ErrorMsg | error_message | ||
) |
Compute the source functions (three terms for temperature, one for E or B modes, 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:
tau | Input: conformal time |
y | Input: vector of perturbations |
dy | Input: vector of time derivative of perturbations |
index_tau | Input: index in the array tau_sampling |
parameters_and_workspace | Input/Output: in input, all parameters needed by perturb_derivs, in output, source terms |
error_message | Output: error message |
Summary:
int perturb_print_variables | ( | double | tau, |
double * | y, | ||
double * | dy, | ||
void * | parameters_and_workspace, | ||
ErrorMsg | error_message | ||
) |
When testing the code or a cosmological model, it can be useful to output perturbations at each step of integration (and not just the delta's at each source sampling point, which is achieved simply by asking for matter transfer functions). Then this function can be passed to the generic_evolver routine.
By default, instead of passing this function to generic_evolver, one passes a null pointer. Then this function is just not used.
tau | Input: conformal time |
y | Input: vector of perturbations |
dy | Input: vector of its derivatives (already allocated) |
parameters_and_workspace | Input: fixed parameters (e.g. indices) |
error_message | Output: error message |
Summary:
int perturb_derivs | ( | double | tau, |
double * | y, | ||
double * | dy, | ||
void * | parameters_and_workspace, | ||
ErrorMsg | error_message | ||
) |
Compute derivative of all perturbations to be integrated
For each mode (scalar/vector/tensor) and each wavenumber k, this function computes the derivative of all values in the vector of perturbed variables to be integrated.
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:
tau | Input: conformal time |
y | Input: vector of perturbations |
dy | Output: vector of its derivatives (already allocated) |
parameters_and_workspace | Input/Output: in input, fixed parameters (e.g. indices); in output, background and thermo quantities evaluated at tau. |
error_message | Output: error message |
Summary:
int perturb_tca_slip_and_shear | ( | double * | y, |
void * | parameters_and_workspace, | ||
ErrorMsg | error_message | ||
) |
Summary: