Commit 0c140ab9 authored by Goran Jelic-Cizmek's avatar Goran Jelic-Cizmek
Browse files

Added A_s parameter

Now the user can choose between A_s and sigma8. Note that the Python interface
doesn't change A_s if sigma8 changes, and vice versa; this is due to the
complexity of implementing such a routine, which would also require the use of
scipy instead of just numpy.
parent 25009e33
......@@ -226,6 +226,8 @@ cdef extern from "common.h":
double sigma8
double A_s
double h
double k_pivot
......
......@@ -493,6 +493,25 @@ cdef class Coffe:
self._free_covariance_multipoles()
@property
def A_s(self):
"""
The amplitude of the primordial power spectrum
"""
return self._parameters.A_s
@A_s.setter
def A_s(self, value):
_check_parameter('A_s', value, (int, float), 0, 2)
if not np.allclose(value, self.A_s):
self._parameters.A_s = value
self._free_power_spectrum()
self._free_integrals()
self._free_corrfunc()
self._free_multipoles()
self._free_covariance_multipoles()
@property
def T_cmb(self):
"""
......
......@@ -470,6 +470,8 @@ typedef struct coffe_parameters_t
double sigma8; /* amplitude of primordial power spectrum sigma8 */
double A_s; /* amplitude of primordial power spectrum A_s */
double T_cmb, N_ur, m_ncdm, Omega0_nu; /* last one = neutrino energy density fraction */
double YHe; /* helium fraction */
......
......@@ -387,9 +387,16 @@ int parse_external_power_spectrum(
sprintf(fc->value[counter], "%e", par->n_s);
++counter;
sprintf(fc->name[counter], "sigma8");
sprintf(fc->value[counter], "%e", par->sigma8);
++counter;
if (fabs(par->A_s) > EPSILON_ABS){
sprintf(fc->name[counter], "A_s");
sprintf(fc->value[counter], "%e", par->A_s);
++counter;
}
else{
sprintf(fc->name[counter], "sigma8");
sprintf(fc->value[counter], "%e", par->sigma8);
++counter;
}
sprintf(fc->name[counter], "alpha_s");
sprintf(fc->value[counter], "%e", 0.0);
......@@ -652,6 +659,7 @@ int coffe_parse_default_parameters(
par->Omega0_de = 1 - (par->Omega0_m + par->Omega0_gamma);
par->k_pivot = 0.05;
par->sigma8 = 0.8156;
par->A_s = 0;
par->n_s = 0.96;
par->b_derivative = 0;
par->f_derivative = 0;
......@@ -1376,7 +1384,17 @@ int coffe_parser_init(
par->pk_type = (enum coffe_pk_type)temp;
}
parse_double(conf, "h", &par->h, COFFE_TRUE);
parse_double(conf, "sigma8", &par->sigma8, COFFE_TRUE);
const int error_sigma8 = parse_double(conf, "sigma8", &par->sigma8, COFFE_FALSE);
const int error_A_s = parse_double(conf, "A_s", &par->A_s, COFFE_FALSE);
if (error_sigma8 == EXIT_SUCCESS && error_A_s == EXIT_SUCCESS){
fprintf(
stderr,
"ERROR: unable to set both sigma8 and A_s simultaneously"
);
exit(EXIT_FAILURE);
}
parse_double(conf, "n_s", &par->n_s, COFFE_TRUE);
parse_double(conf, "k_pivot", &par->k_pivot, COFFE_TRUE);
// new stuff for forecast
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment