-
Notifications
You must be signed in to change notification settings - Fork 30
Code4:input.c
based on https://lesgourg.github.io/class-tour/Tokyo2014/lecture6_input_module.pdf
The input.c
module is incharged of reading the ini and precision files and
of setting to its default those not present in them. The functions that store
the default values are:
-
input_default_params
-
input_default_precision
To understand how input.c
works let's follow the execution path.
-
Read the arguments passed to
./class
. -
Check they are one (and only one) ini-file and at most one precision file.
-
And, in case
root =
was not set in the ini-file, choose a defualt one. -
It stores the file contents in a single structure
file_content
,fc
. In particular, for a numbern
,fc.name[n] = "variable_name"
andfc.value[n] = the_value_of_the_variable
. -
Finally, call
input_init(&fc, ...)
-
Create three arrays with the name of the parameter to be searched for in the
file_content
structure, its corresponding associated parameter used by CLASS and the computation stage needed. -
Look for them in
file_content
. If there is none of them, callinput_read_parameters
; if there is one, run a shooting algorithm:-
Call
input_get_guess(&x1, &dxdy, pfzw, errmsg)
to find our guess for the unknown parameter value. -
Call
input_fzerofun_1d(x1,pfzw,&f1,errmsg);
to evaluatef1 = desired_value - computed_value
. In the particular case of usingOmega_smg
as shooting parameterf = Omega0_smg_desired - Omega0_smg_computed
. -
Change guessing param so that
x2= f*x1*dxdy
, withdxdy = dx/dy
. -
Call
input_fzerofun_1d(x2,pfzw,&f2,errmsg);
. -
If
f1*f2'<0
the root has been bracketed and we exit loop. Elsewise, repeat previous two steps untill it fails more than a certain number of times when it will just exit the loop. -
Run a bisection method. If the root was not bracketed it will finish the hi_class execution with an error.
and, if more than one unknown parameters are present, try a Newton method to find the value of the CLASS associated variables.
-
-
If shooting worked, call
input_read_parameters
; else, turn onpba->shooting_failed
and wait untilbackground.c
to exit hi_class to play nicely with MontePython. -
Set
pba->parameters_tuned_smg = _TRUE_;
.
-
Initialize all paramters with their default values, calling
input_default_params
andinput_default_precision
. -
Overwrite the value of the parameters present in the
file_content
structure,fc
, with their stored value.
Home
Installation
Basic usage
classy: the python wrapper
Introducing new models
The code:
- Code 1: Philosophy and structure
- Code 2: Indexing
- Code 3: Errors
- Code 4: input.c
- Code 5: background.c
- Code 6: thermodynamics.c
- Code 7: perturbations.c
- Code 8: primordial.c
- Code 10: output.c
- Other modules
- classy: classy.pyx and classy.pxd
Examples: