Commit 25009e33 authored by Goran Jelic-Cizmek's avatar Goran Jelic-Cizmek
Browse files

Added YHe parameter

parent 155a2b9d
......@@ -240,6 +240,8 @@ cdef extern from "common.h":
double Omega0_nu
double YHe
int only_cross_correlations
......
......@@ -553,6 +553,25 @@ cdef class Coffe:
self._free_covariance_multipoles()
@property
def YHe(self):
"""
The primordial helium fraction
"""
return self._parameters.YHe
@YHe.setter
def YHe(self, value):
_check_parameter('YHe', value, (int, float), 0, 10)
if not np.allclose(value, self.YHe):
self._parameters.YHe = value
self._free_power_spectrum()
self._free_integrals()
self._free_corrfunc()
self._free_multipoles()
self._free_covariance_multipoles()
@property
def N_ncdm(self):
"""
......
......@@ -472,6 +472,8 @@ typedef struct coffe_parameters_t
double T_cmb, N_ur, m_ncdm, Omega0_nu; /* last one = neutrino energy density fraction */
double YHe; /* helium fraction */
int N_ncdm;
double h; /* Damn you, little h! */
......
......@@ -284,6 +284,9 @@ int parse_external_power_spectrum(
coffe_parameters_t *par
)
{
/* threshold for comparing with zero */
const double EPSILON_ABS = 1e-10;
/* so we don't leak memory */
coffe_free_spline(&par->power_spectrum);
coffe_free_spline(&par->power_spectrum_norm);
......@@ -308,7 +311,7 @@ int parse_external_power_spectrum(
class_start = clock();
struct file_content *fc = (struct file_content *)coffe_malloc(sizeof(struct file_content));
size_t class_parameters_len = 24, counter = 0;
size_t class_parameters_len = 26, counter = 0;
parser_init(fc, class_parameters_len, "", errmsg);
......@@ -333,6 +336,13 @@ int parse_external_power_spectrum(
sprintf(fc->value[counter], "%e", par->N_ur);
++counter;
/* set the helium fraction to a constant value (must be different from zero) */
if (fabs(par->YHe) > EPSILON_ABS){
sprintf(fc->name[counter], "YHe");
sprintf(fc->value[counter], "%e", par->YHe);
++counter;
}
sprintf(fc->name[counter], "Omega_cdm");
sprintf(fc->value[counter], "%e", par->Omega0_cdm);
++counter;
......@@ -635,6 +645,7 @@ int coffe_parse_default_parameters(
par->T_cmb = 2.726;
par->N_ncdm = 1;
par->m_ncdm = 0.00;
par->YHe = 0; /* this indicates the BBN table should be used instead */
/* see eq. (19) of https://arxiv.org/abs/1212.6154 */
par->Omega0_nu = par->m_ncdm / 93.14 / par->h / par->h;
par->Omega0_cdm = par->Omega0_m - par->Omega0_baryon - par->Omega0_nu;
......@@ -1373,6 +1384,7 @@ int coffe_parser_init(
parse_double(conf, "N_ur", &par->N_ur, COFFE_FALSE);
parse_double(conf, "m_ncdm", &par->m_ncdm, COFFE_FALSE);
parse_int(conf, "N_ncdm", &par->N_ncdm, COFFE_FALSE);
parse_double(conf, "YHe", &par->YHe, COFFE_FALSE);
par->Omega0_nu = par->m_ncdm / 93.14 / par->h / par->h;
par->Omega0_cdm = par->Omega0_m - par->Omega0_baryon - par->Omega0_nu;
parse_external_power_spectrum(par);
......
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