Closed pasq-cat closed 2 years ago
Hi @Rockdeldiablo,
Try passing it within extra_args
instead. The parameter values in the params
block must be floats or functions. Let us know whether it works!
@JesusTorrado Hi , thanks for the advice, it actually worked for the CLP case, but i got errors in the LRS case that i didn't get with class:
[classy] Importing local CLASS from '/home/pasquale/Documenti/class_public/'. [classy] Initialized! [mcmc] Getting initial point... (this may take a few seconds) [classy] ERROR Serious error setting parameters or computing results. The parameters passed were {'A_s': 2.1096843541402204e-09, 'n_s': 0.9596304447630893, '100theta_s': 1.0419851109969605, 'omega_b': 0.02232934984579731, 'omega_cdm': 0.11932177393089169, 'm_ncdm': 0.06, 'w0_fld': -0.9697904479820014, 'wa_fld': -0.0439339879994118, 'Omega_Lambda': 0.0, 'tau_reio': 0.06032438609964339} and {'N_ncdm': 1, 'N_ur': 2.0328, 'fluid_equation_of_state': 'LRS', 'output': ''}. To see the original CLASS' error traceback, make 'debug: True'. [classy] ERROR Serious error setting parameters or computing results. The parameters passed were {'A_s': 2.115641683170898e-09, 'n_s': 0.9696622923862939, '100theta_s': 1.0412783700099566, 'omega_b': 0.022314289354474673, 'omega_cdm': 0.11901162440385196, 'm_ncdm': 0.06, 'w0_fld': -0.9643041922676895, 'wa_fld': 0.01067827263957695, 'Omega_Lambda': 0.0, 'tau_reio': 0.06588872216506923} and {'N_ncdm': 1, 'N_ur': 2.0328, 'fluid_equation_of_state': 'LRS', 'output': ''}. To see the original CLASS' error traceback, make 'debug: True'. [classy] ERROR Serious error setting parameters or computing results. The parameters passed were {'A_s': 2.1128119234359723e-09, 'n_s': 0.9665499244775799, '100*theta_s': 1.042025680113818, 'omega_b': 0.022244669827657305, 'omega_cdm': 0.11918836210183668, 'm_ncdm': 0.06, 'w0_fld': -0.9669670565125368, 'wa_fld': -0.09398703849893869, 'Omega_Lambda': 0.0, 'tau_reio': 0.05323826284155562} and {'N_ncdm': 1, 'N_ur': 2.0328, 'fluid_equation_of_state': 'LRS', 'output': ''}. To see the original CLASS' error traceback, make 'debug: True'.
etc etc
---------------------------------------------------------------------------
LoggedError Traceback (most recent call last)
/tmp/ipykernel_9097/93674339.py in <module>
5 from cobaya.run import run
6
----> 7 updated_info, sampler = run(info_from_yaml)
~/anaconda3/lib/python3.9/site-packages/cobaya/run.py in run(info_or_yaml_or_file, packages_path, output, debug, stop_at_error, resume, force, no_mpi, test, override)
141 updated_info = recursive_update(updated_info, model.info())
142 out.check_and_dump_info(None, updated_info, check_compatible=False)
--> 143 sampler = sampler_class(updated_info["sampler"][sampler_name],
144 model, out, name=sampler_name,
145 packages_path=info.get("packages_path"))
~/anaconda3/lib/python3.9/site-packages/cobaya/sampler.py in __init__(self, info_sampler, model, output, packages_path, name)
266 pass
267 self._set_rng()
--> 268 self.initialize()
269 model.set_cache_size(self._get_requested_cache_size())
270 # Add to the updated info some values which are
~/anaconda3/lib/python3.9/site-packages/cobaya/samplers/mcmc/mcmc.py in initialize(self)
154 self.log.info("Getting initial point... (this may take a few seconds)")
155 initial_point, results = \
--> 156 self.model.get_valid_point(max_tries=self.max_tries.value,
157 random_state=self._rng)
158 # If resuming but no existing chain, assume failed run and ignore blocking
~/anaconda3/lib/python3.9/site-packages/cobaya/model.py in get_valid_point(self, max_tries, ignore_fixed_ref, random_state)
474 "likelihood. Set 'ref' to a different point "
475 "or a pdf.")
--> 476 raise LoggedError(self.log, "Could not find random point giving finite "
477 "posterior after %g tries", max_tries)
478 return initial_point, results
LoggedError: Could not find random point giving finite posterior after 320 tries
i will post down here what i did for the LRS (linear redshift w= w0 +wa*z) model(i tried to follow the clp example since i don't know much about the c language):
1) in background.h i wrote:
enum equation_of_state {CLP,EDE,LRS};
2) in input.c i wrote:
if (pba->Omega0_fld != 0.) {
/** 8.a.1) PPF approximation */
/* Read */
class_call(parser_read_string(pfc,"use_ppf",&string1,&flag1,errmsg),
errmsg,
errmsg);
if (flag1 == _TRUE_){
if(string_begins_with(string1,'y') || string_begins_with(string1,'Y')){
pba->use_ppf = _TRUE_;
class_read_double("c_gamma_over_c_fld",pba->c_gamma_over_c_fld);
}
else {
pba->use_ppf = _FALSE_;
}
}
/** 8.a.2) Equation of state */
/* Read */
class_call(parser_read_string(pfc,"fluid_equation_of_state",&string1,&flag1,errmsg),
errmsg,
errmsg);
/* Complete set of parameters */
if (flag1 == _TRUE_) {
if ((strstr(string1,"CLP") != NULL) || (strstr(string1,"clp") != NULL )) {
pba->fluid_equation_of_state = CLP;
}
else if ((strstr(string1,"LRS") != NULL) || (strstr(string1,"lrs") != NULL)) {
pba->fluid_equation_of_state = LRS;
}
else if ((strstr(string1,"EDE") != NULL) || (strstr(string1,"ede") != NULL)) {
pba->fluid_equation_of_state = EDE;
}
else {
class_stop(errmsg,"incomprehensible input '%s' for the field 'fluid_equation_of_state'",string1);
}
}
if (pba->fluid_equation_of_state == CLP) {
/** 8.a.2.2) Equation of state of the fluid in 'CLP' case */
/* Read */
class_read_double("w0_fld",pba->w0_fld);
class_read_double("wa_fld",pba->wa_fld);
class_read_double("cs2_fld",pba->cs2_fld);
}
if (pba->fluid_equation_of_state == LRS) {
/** 8.a.2.2) Equation of state of the fluid in 'LRS' case */
/* Read */
class_read_double("w0_fld",pba->w0_fld);
class_read_double("wa_fld",pba->wa_fld);
class_read_double("cs2_fld",pba->cs2_fld);
}
if (pba->fluid_equation_of_state == EDE) {
/** 8.a.2.3) Equation of state of the fluid in 'EDE' case */
/* Read */
class_read_double("w0_fld",pba->w0_fld);
class_read_double("Omega_EDE",pba->Omega_EDE);
class_read_double("cs2_fld",pba->cs2_fld);
}
}
3) in background.c i added the 3 functions
*w_fld = pba->w0_fld - pba->wa_fld/a + pba->wa_fld ;
*dw_over_da_fld = pba->wa_fld/(a*a) ;
*integral_fld = 3.*( pba->wa_fld -(1. + pba->w0_fld + pba->wa_fld ) *log(a) - pba->wa_fld/a) ;
break;
which i derived earlier. The last one should be the integral between a and a0 of 3*(1+w(a))/a da with a0 = 1, as the instructions in the comment said. I don't know if it's a class issue or cobaya, but with ./class testrls.ini i get no errors or warnings
i have a local installation of class which has been modified to include a linear redshift model (LRS) and a squared redshift model (SRS). Everythings seems to work when i type ./class testlrs.ini but when i try to use jupyter+cobaya together with my definition of dark energy model i get an error. As an example, i used cobaya-cosmo-generator to generate a cosmo-g.yaml file for a clp model and then i modified it by including the line
fluid_equation_of_state: LRS
The result looks like this
Initially i thought there was something wrong with my definition LRS but then i tested
fluid_equation_of_state: CLP
and it also fail:[tools] ERROR Failed to load external function: 'NameError("name 'CLP' is not defined")'
NameError Traceback (most recent call last) ~/anaconda3/lib/python3.9/site-packages/cobaya/tools.py in get_external_function(string_or_function, name) 374 with PythonPath(os.curdir, when="import_module" in string_or_function): --> 375 function = eval(string_or_function, scope) 376 except Exception as e:
~/anaconda3/lib/python3.9/site-packages/cobaya/tools.py in
so i think there is something wrong with the .yaml file itself. Any advice?