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

Functions

int input_init_from_arguments (int argc, char **argv, struct precision *ppr, struct background *pba, struct thermo *pth, struct perturbs *ppt, struct transfers *ptr, struct primordial *ppm, struct spectra *psp, struct nonlinear *pnl, struct lensing *ple, struct output *pop, ErrorMsg errmsg)
 
int input_init (struct file_content *pfc, struct precision *ppr, struct background *pba, struct thermo *pth, struct perturbs *ppt, struct transfers *ptr, struct primordial *ppm, struct spectra *psp, struct nonlinear *pnl, struct lensing *ple, struct output *pop, ErrorMsg errmsg)
 
int input_read_parameters (struct file_content *pfc, struct precision *ppr, struct background *pba, struct thermo *pth, struct perturbs *ppt, struct transfers *ptr, struct primordial *ppm, struct spectra *psp, struct nonlinear *pnl, struct lensing *ple, struct output *pop, ErrorMsg errmsg)
 
int input_default_params (struct background *pba, struct thermo *pth, struct perturbs *ppt, struct transfers *ptr, struct primordial *ppm, struct spectra *psp, struct nonlinear *pnl, struct lensing *ple, struct output *pop)
 
int input_default_precision (struct precision *ppr)
 
int get_machine_precision (double *smallest_allowed_variation)
 
int class_fzero_ridder (int(*func)(double x, void *param, double *y, ErrorMsg error_message), double x1, double x2, double xtol, void *param, double *Fx1, double *Fx2, double *xzero, int *fevals, ErrorMsg error_message)
 
int input_try_unknown_parameters (double *unknown_parameter, int unknown_parameters_size, void *voidpfzw, double *output, ErrorMsg errmsg)
 
int input_get_guess (double *xguess, double *dxdy, struct fzerofun_workspace *pfzw, ErrorMsg errmsg)
 
int input_find_root (double *xzero, int *fevals, struct fzerofun_workspace *pfzw, ErrorMsg errmsg)
 

Detailed Description

Documented input module.

Julien Lesgourgues, 27.08.2010

Function Documentation

◆ input_init_from_arguments()

int input_init_from_arguments ( int  argc,
char **  argv,
struct precision ppr,
struct background pba,
struct thermo pth,
struct perturbs ppt,
struct transfers ptr,
struct primordial ppm,
struct spectra psp,
struct nonlinear pnl,
struct lensing ple,
struct output pop,
ErrorMsg  errmsg 
)

Use this routine to extract initial parameters from files 'xxx.ini' and/or 'xxx.pre'. They can be the arguments of the main() routine.

If class is embedded into another code, you will probably prefer to call directly input_init() in order to pass input parameters through a 'file_content' structure.

Summary:

  • define local variables
  • –> the final structure with all parameters
  • –> a temporary structure with all input parameters
  • –> a temporary structure with all precision parameters
  • –> a temporary structure with only the root name
  • –> sum of fc_inoput and fc_root
  • –> a pointer to either fc_root or fc_inputroot
  • Initialize the two file_content structures (for input parameters and precision parameters) to some null content. If no arguments are passed, they will remain null and inform init_params() that all parameters take default values.
  • If some arguments are passed, identify eventually some 'xxx.ini' and 'xxx.pre' files, and store their name.
  • if there is an 'xxx.ini' file, read it and store its content.
  • check whether a root name has been set
  • if root has not been set, use root=output/inputfilennameN_
  • if there is an 'xxx.pre' file, read it and store its content.
  • if one or two files were read, merge their contents in a single 'file_content' structure.
  • Finally, initialize all parameters given the input 'file_content' structure. If its size is null, all parameters take their default values.

◆ input_init()

int input_init ( struct file_content *  pfc,
struct precision ppr,
struct background pba,
struct thermo pth,
struct perturbs ppt,
struct transfers ptr,
struct primordial ppm,
struct spectra psp,
struct nonlinear pnl,
struct lensing ple,
struct output pop,
ErrorMsg  errmsg 
)

Initialize each parameter, first to its default values, and then from what can be interpreted from the values passed in the input 'file_content' structure. If its size is null, all parameters keep their default values.

These two arrays must contain the strings of names to be searched for and the corresponding new parameter

  • Do we need to fix unknown parameters?
  • –> input_auxillary_target_conditions() takes care of the case where for instance Omega_dcdmdr is set to 0.0.
  • case with unknown parameters
  • –> go through all cases with unknown parameters:
  • –> Read all parameters from tuned pfc
  • –> Set status of shooting
  • –> Free arrays allocated
  • case with no unknown parameters
  • –> just read all parameters from input pfc:
  • eventually write all the read parameters in a file, unread parameters in another file, and warnings about unread parameters

◆ input_read_parameters()

int input_read_parameters ( struct file_content *  pfc,
struct precision ppr,
struct background pba,
struct thermo pth,
struct perturbs ppt,
struct transfers ptr,
struct primordial ppm,
struct spectra psp,
struct nonlinear pnl,
struct lensing ple,
struct output pop,
ErrorMsg  errmsg 
)

Summary:

  • define local variables
  • set all parameters (input and precision) to default values
  • if entries passed in file_content structure, carefully read and interpret each of them, and tune the relevant input parameters accordingly

Knowing the gauge from the very beginning is useful (even if this could be a run not requiring perturbations at all: even in that case, knowing the gauge is important e.g. for fixing the sampling in momentum space for non-cold dark matter)

(a) background parameters

  • scale factor today (arbitrary)
  • h (dimensionless) and [ $ H_0/c$] in $ Mpc^{-1} = h / 2997.9... = h * 10^5 / c $
  • Omega_0_g (photons) and T_cmb
  • Omega0_g = rho_g / rho_c0, each of them expressed in $ Kg/m/s^2 $
  • rho_g = (4 sigma_B / c) $ T^4 $
  • rho_c0 $ = 3 c^2 H_0^2 / (8 \pi G) $
  • Omega_0_b (baryons)
  • Omega_0_ur (ultra-relativistic species / massless neutrino)
  • Omega_0_cdm (CDM)
  • Omega_0_dcdmdr (DCDM)
  • Read Omega_ini_dcdm or omega_ini_dcdm
  • Read Gamma in same units as H0, i.e. km/(s Mpc)
  • non-cold relics (ncdm)
  • Omega_0_k (effective fractional density of curvature)
  • Set curvature parameter K
  • Set curvature sign
  • Omega_0_lambda (cosmological constant), Omega0_fld (dark energy fluid), Omega0_scf (scalar field)
  • –> (flag3 == FALSE) || (param3 >= 0.) explained: it means that either we have not read Omega_scf so we are ignoring it (unlike lambda and fld!) OR we have read it, but it had a positive value and should not be used for filling. We now proceed in two steps: 1) set each Omega0 and add to the total for each specified component. 2) go through the components in order {lambda, fld, scf} and fill using first unspecified component.
  • Test that the user have not specified Omega_scf = -1 but left either Omega_lambda or Omega_fld unspecified:
  • Read parameters describing scalar field potential
  • Assign shooting parameter

(b) assign values to thermodynamics cosmological parameters

  • primordial helium fraction
  • recombination parameters
  • reionization parametrization
  • reionization parameters if reio_parametrization=reio_camb
  • reionization parameters if reio_parametrization=reio_bins_tanh
  • reionization parameters if reio_parametrization=reio_many_tanh
  • reionization parameters if reio_parametrization=reio_many_tanh
  • energy injection parameters from CDM annihilation/decay

(c) define which perturbations and sources should be computed, and down to which scale

(d) define the primordial spectrum

(e) parameters for final spectra

(f) parameter related to the non-linear spectra computation

(g) amount of information sent to standard output (none if all set to zero)

(h) all precision parameters

  • (h.1.) parameters related to the background
  • (h.2.) parameters related to the thermodynamics
  • (h.3.) parameters related to the perturbations
  • —> Include ur and ncdm shear in tensor computation?
  • —> derivatives of baryon sound speed only computed if some non-minimal tight-coupling schemes is requested
  • (h.4.) parameter related to the primordial spectra
  • (h.5.) parameter related to the transfer functions
  • (h.6.) parameters related to nonlinear calculations
  • (h.7.) parameter related to lensing

(i) Write values in file

  • (i.1.) shall we write background quantities in a file?
  • (i.2.) shall we write thermodynamics quantities in a file?
  • (i.3.) shall we write perturbation quantities in files?
  • (i.4.) shall we write primordial spectra in a file?

◆ input_default_params()

int input_default_params ( struct background pba,
struct thermo pth,
struct perturbs ppt,
struct transfers ptr,
struct primordial ppm,
struct spectra psp,
struct nonlinear pnl,
struct lensing ple,
struct output pop 
)

All default parameter values (for input parameters)

Parameters
pbaInput: pointer to background structure
pthInput: pointer to thermodynamics structure
pptInput: pointer to perturbation structure
ptrInput: pointer to transfer structure
ppmInput: pointer to primordial structure
pspInput: pointer to spectra structure
pnlInput: pointer to nonlinear structure
pleInput: pointer to lensing structure
popInput: pointer to output structure
Returns
the error status

Define all default parameter values (for input parameters) for each structure:

  • background structure
  • thermodynamics structure
  • perturbation structure
  • primordial structure
  • transfer structure
  • output structure
  • spectra structure
  • nonlinear structure
  • lensing structure
  • nonlinear structure
  • all verbose parameters

◆ input_default_precision()

int input_default_precision ( struct precision ppr)

Initialize the precision parameter structure.

All precision parameters used in the other modules are listed here and assigned here a default value.

Parameters
pprInput/Output: a precision_params structure pointer
Returns
the error status

Initialize presicion parameters for different structures:

  • parameters related to the background
  • parameters related to the thermodynamics
  • parameters related to the perturbations
  • parameter related to the primordial spectra
  • parameter related to the transfer functions
  • parameters related to spectra module
  • parameters related to nonlinear module
  • parameter related to lensing
  • automatic estimate of machine precision

◆ get_machine_precision()

int get_machine_precision ( double *  smallest_allowed_variation)

Automatically computes the machine precision.

Parameters
smallest_allowed_variationa pointer to the smallest allowed variation

Returns the smallest allowed variation (minimum epsilon * TOLVAR)

◆ class_fzero_ridder()

int class_fzero_ridder ( int(*)(double x, void *param, double *y, ErrorMsg error_message)  func,
double  x1,
double  x2,
double  xtol,
void *  param,
double *  Fx1,
double *  Fx2,
double *  xzero,
int *  fevals,
ErrorMsg  error_message 
)

Using Ridders' method, return the root of a function func known to lie between x1 and x2. The root, returned as zriddr, will be found to an approximate accuracy xtol.

◆ input_try_unknown_parameters()

int input_try_unknown_parameters ( double *  unknown_parameter,
int  unknown_parameters_size,
void *  voidpfzw,
double *  output,
ErrorMsg  errmsg 
)

Summary:

  • Call the structures
  • Do computations
  • In case scalar field is used to fill, pba->Omega0_scf is not equal to pfzw->target_value[i].
  • Free structures
  • Set filecontent to unread

◆ input_get_guess()

int input_get_guess ( double *  xguess,
double *  dxdy,
struct fzerofun_workspace *  pfzw,
ErrorMsg  errmsg 
)

Summary:

  • Here we should write reasonable guesses for the unknown parameters. Also estimate dxdy, i.e. how the unknown parameter responds to the known. This can simply be estimated as the derivative of the guess formula.
  • Update pb to reflect guess
    • This guess is arbitrary, something nice using WKB should be implemented.
  • Version 2: use a fit: xguess[index_guess] = 1.77835*pow(ba.Omega0_scf,-2./7.); dxdy[index_guess] = -0.5081*pow(ba.Omega0_scf,-9./7.);
  • Version 3: use attractor solution
  • This works since correspondence is Omega_ini_dcdm -> Omega_dcdmdr and omega_ini_dcdm -> omega_dcdmdr
  • Deallocate everything allocated by input_read_parameters

◆ input_find_root()

int input_find_root ( double *  xzero,
int *  fevals,
struct fzerofun_workspace *  pfzw,
ErrorMsg  errmsg 
)

Summary:

  • Fisrt we do our guess
  • Do linear hunt for boundaries
  • root has been bracketed
  • Find root using Ridders method. (Exchange for bisection if you are old-school.)