Skip to content
ardok-m edited this page Sep 13, 2017 · 5 revisions

Code 5: background.c

based on https://lesgourg.github.io/class-tour/Tokyo2014/lecture8_background.pdf and the documentation in the module itself.

First of all, a reminder about units. CLASS uses the following convention:

  • c = 1.
  • The Planck Mass, M_P = 1/\sqrt{8\piG} = 1.
  • All quantities are in some power of Mpc.
  • The energy densities and pressures are scaled by 1/(3*M_P^2) = 1/3; e.g. rho_CLASS = *rho_physical. Then H^2 = \sum_i rho_i - K/a^2

Important remark: in hi_class, for the time being, modified gravity models have K = 0.

Let's start saying that background.c has a detailed description at the beginning which will be, mainly, what will be written here. A piece of it are the following lines describing what this module is for:

 * Deals with the cosmological background evolution.
 * This module has two purposes:
 *
 * - at the beginning, to initialize the background, i.e. to integrate
 *    the background equations, and store all background quantities
 *    as a function of conformal time inside an interpolation table.
 *
 * - to provide routines which allow other modules to evaluate any
 *    background quantity for a given value of the conformal time (by
 *    interpolating within the interpolation table), or to find the
 *    correspondance between redhsift and conformal time.

In addition, each function have some documentation lines before them explaining what they are for and how to use them.

Recall that all stored values are saved in the background structre, ba (see Code 1: Philosophy and structure) and that, along the code, and specially from others modules, we will access its contents through a pointer called, pba.

It is important to remark that all equation in this module are written in a model independent way. To do so, we realize that background evolution have different kind of parameters that can be grouped in the following three blocks:

  • Parameters {A} are those which can be directly expressed as a function of some variables in {B}.
  • Parameters {B} are those which need to be integrated over time.
  • Parameters {C} also need to be integrated over time but are not used in {A}.

Some examples are:

  • LCDM:

    • {A} = {ρ_i, p_i, H, ...}
    • {B} = {a}
    • {C} = {t, r_s , D}
  • Quintessence:

    • {A} = {ρ_i, p_i, H, ..., V_φ, ρ_φ, p_φ}
    • {B} = {a, φ, φ_0}

How to work with background.c: its functions.

  • Internal functions:

    • background_functions() returns all background quantities {A} as a function of quantities {B}.

    • background_solve() integrates {B} and {C} w.r.t. conformal time, requiring several calls to background_functions(). As we said, the results are stored in the background structure.

    • There are several others used by them which we will not detail here. Some special remark is deserved by the hi_class specific functions:

      • background_gravity_functions() fills the Horndeski part of background_functions(). New models are implemented here.
      • background_gravity_parameters() prints information about the specific modified gravity model used when ./class is run.
    • Background output is prepared by:

      • background_output_titles() which give the appropiate format. The column titles are defined here.
      • background_output_data() which fills the formatted data table to be used by output.c.
  • Intermodule functions:

    • background_init() initializes the module and computes the background variables filling ba.
    • background_at_tau() returns the background quantities at a specific conformal time interpolating between the computed values. In addition, it accepts three modes:
      • short_info: return only geometric quantities like a, H, H'.
      • normal_info: return quantities strictly needed at each step in the integration of perturbations.
      • long_info: return also rarely useful quantities. Each mode return a growing piece of the interpolation vector: first elemens are for short_info, next ones contribute for normal_info and the full vector is for long_info.
    • background_tau_of_z() returns the conformal time at given redshift.
    • background_free() frees the used structures.

Dynamical indices

In background.c there are two kind of dynamical indices:

  • Those for variables in the table ({A}, {B}, {C}) declared in include/background.h inside the background structure to ensure others modules can used them. For example, ba.index_bg_a and ba.bg_size.

  • Those for the ODE dy[i] = f(y[j]), i.e. for variables {B}, {C}. They are declared in include/background.h but outside the background structure. They cannot be accessed outside background.c. For example, index_bi_a or index_bi_M_pl_smg.