51   case (CosmologicalParameter::_Omega_matter_LCDM_):
 
   52     name = 
"Omega_matter_LCDM";
 
   55   case (CosmologicalParameter::_Omega_matter_):
 
   56     name = 
"Omega_matter";
 
   59   case (CosmologicalParameter::_Omega_baryon_):        
 
   60     name = 
"Omega_baryon";
 
   63   case (CosmologicalParameter::_Omega_baryon_h2_):        
 
   64     name = 
"Omega_baryon_h2";
 
   67   case (CosmologicalParameter::_Omega_neutrinos_):      
 
   68     name = 
"Omega_matter";
 
   71   case (CosmologicalParameter::_massless_neutrinos_):   
 
   72     name = 
"massless_neutrinos";
 
   75   case (CosmologicalParameter::_massive_neutrinos_):    
 
   76     name = 
"massive_neutrinos";
 
   79   case (CosmologicalParameter::_neutrino_mass_):    
 
   80     name = 
"neutrino_mass";
 
   83   case (CosmologicalParameter::_Omega_DE_):            
 
   87   case (CosmologicalParameter::_Omega_radiation_):     
 
   88     name = 
"Omega_radiation";
 
   91   case (CosmologicalParameter::_H0_):
 
   95   case (CosmologicalParameter::_hh_):
 
   99   case (CosmologicalParameter::_scalar_amp_):
 
  103   case (CosmologicalParameter::_ln_scalar_amp_):
 
  104     name = 
"ln_scalar_amp";
 
  107   case (CosmologicalParameter::_scalar_pivot_):           
 
  108     name = 
"scalar_pivot";
 
  111   case (CosmologicalParameter::_n_spec_):               
 
  115   case (CosmologicalParameter::_w0_):
 
  119   case (CosmologicalParameter::_wa_):             
 
  123   case (CosmologicalParameter::_fNL_):                  
 
  127   case (CosmologicalParameter::_sigma8_):
 
  131   case (CosmologicalParameter::_tau_):
 
  135   case (CosmologicalParameter::_rs_):
 
  140     ErrorCBL(
"no such a variable in the list!", 
"CosmologicalParameter_name", 
"Cosmology.cpp");
 
  151   if (m_Omega_matter==0) 
ErrorCBL(
"Omega_matter=0!", 
"set_default", 
"Cosmology.cpp");
 
  153   m_Omega_k = 1.-m_Omega_matter-m_Omega_radiation-m_Omega_DE;
 
  154   m_Omega_CDM = m_Omega_matter-m_Omega_baryon-m_Omega_neutrinos;
 
  155   m_H0 = (m_unit) ? 100. : 100.*m_hh;
 
  158   m_RhoZero = rho_m(0.); 
 
  159   m_Pk0_EH = 1., m_Pk0_CAMB = 1., m_Pk0_MPTbreeze = 1., m_Pk0_CLASS = 1.;
 
  165 cbl::cosmology::Cosmology::Cosmology (
const double Omega_matter, 
const double Omega_baryon, 
const double Omega_neutrinos, 
const double massless_neutrinos, 
const int massive_neutrinos, 
const double Omega_DE, 
const double Omega_radiation, 
const double hh, 
const double scalar_amp, 
const double scalar_pivot, 
const double n_spec, 
const double w0, 
const double wa, 
const double fNL, 
const int type_NG, 
const double tau, 
const std::string model, 
const bool unit)
 
  166   : m_Omega_matter(Omega_matter), m_Omega_baryon(Omega_baryon), m_Omega_neutrinos(Omega_neutrinos), m_massless_neutrinos(massless_neutrinos), m_massive_neutrinos(massive_neutrinos), m_Omega_DE(Omega_DE), m_Omega_radiation(Omega_radiation), m_hh(hh), m_sigma8(-1.), m_scalar_amp(scalar_amp), m_scalar_pivot(scalar_pivot), m_n_spec(n_spec), m_w0(w0), m_wa(wa), m_fNL(fNL), m_type_NG(type_NG), m_tau(tau), m_model(model), m_unit(unit)
 
  174   :  m_Omega_neutrinos(0.), m_massless_neutrinos(3.04), m_massive_neutrinos(0.), m_sigma8(-1.), m_n_spec(0.96), m_w0(-1.), m_wa(0.), m_fNL(0.), m_type_NG(1.), m_tau(0.09), m_model(model), m_unit(unit)
 
  282     ErrorCBL(
"the chosen built-in cosmological model is not implemented", 
"Cosmology", 
"Cosmology.cpp");
 
  295   coutCBL << 
"Omega_matter = " << m_Omega_matter << std::endl;
 
  296   coutCBL << 
"Omega_baryon = " << m_Omega_baryon << std::endl;
 
  297   coutCBL << 
"Omega_neutrinos = " << m_Omega_neutrinos << std::endl;
 
  298   coutCBL << 
"massless_neutrinos = " << m_massless_neutrinos << std::endl;
 
  299   coutCBL << 
"massive_neutrinos = " << m_massive_neutrinos << std::endl;
 
  300   coutCBL << 
"Omega_DE = " << m_Omega_DE << std::endl;
 
  301   coutCBL << 
"Omega_radiation = " << m_Omega_radiation << std::endl;
 
  302   coutCBL << 
"Omega_k = " << m_Omega_k << std::endl; 
 
  303   coutCBL << 
"Omega_CDM = " << m_Omega_CDM << std::endl;
 
  304   coutCBL << 
"h = " << m_hh << std::endl;
 
  305   coutCBL << 
"scalar_amp = " << m_scalar_amp << std::endl;
 
  306   coutCBL << 
"scalar_pivot = " << m_scalar_pivot << std::endl;
 
  307   coutCBL << 
"n_spec = " << m_n_spec << std::endl;
 
  308   coutCBL << 
"w0 = " << m_w0 << std::endl;
 
  309   coutCBL << 
"wa = " << m_wa << std::endl;
 
  310   coutCBL << 
"fNL = " << m_fNL << std::endl;
 
  311   coutCBL << 
"type_NG = " << m_type_NG << std::endl;
 
  312   coutCBL << 
"tau = " << m_tau << std::endl;
 
  326     param_value = m_Omega_matter;
 
  330     return m_Omega_matter;
 
  334     param_value = m_Omega_baryon;
 
  338     param_value = m_Omega_baryon*m_hh*m_hh;
 
  342     param_value = m_Omega_neutrinos;
 
  346     param_value = m_massless_neutrinos;
 
  350     param_value = m_massive_neutrinos;
 
  354     param_value = neutrino_mass();
 
  358     param_value = m_Omega_DE;
 
  362     param_value = m_Omega_radiation;
 
  374     param_value = m_scalar_amp;
 
  378     param_value = log(1.e10*m_scalar_amp);
 
  382     param_value = m_scalar_pivot;
 
  386     param_value = m_n_spec;
 
  402     param_value = m_sigma8;
 
  414     ErrorCBL(
"no such a variable in the list!", 
"value", 
"Cosmology.cpp");
 
  441     set_OmegaB_h2(value);
 
  445     set_OmegaNu(value, m_massless_neutrinos, m_massive_neutrinos);
 
  449     set_OmegaNu(m_Omega_neutrinos, value, m_massive_neutrinos);
 
  453     set_OmegaNu(m_Omega_neutrinos, m_massless_neutrinos, 
int(value));
 
  457     set_OmegaNu(Omega_neutrinos(value), m_massless_neutrinos, m_massive_neutrinos);
 
  465     set_Omega_radiation(value);
 
  473     set_hh(value, 
false); 
 
  477     set_scalar_amp(value);
 
  481     set_scalar_amp(exp(value)*1.e-10);
 
  485     set_scalar_pivot(value);
 
  517     ErrorCBL(
"no such a variable in the list!", 
"set_parameter", 
"Cosmology.cpp");
 
  527   for (
size_t i=0; i<parameter.size(); i++)
 
  528     set_parameter(parameter[i], value[i]);
 
  537   return m_w0+m_wa*redshift/(1.+redshift);
 
  548   return pow((1.+redshift),3.*(1.+m_w0+m_wa))*exp(-3.*m_wa*redshift/(1.+redshift)); 
 
  563   return sqrt(m_Omega_matter*pow((1.+redshift), 3)+m_Omega_DE*f_DE(redshift)+m_Omega_k*pow((1.+redshift), 2)+m_Omega_radiation*pow(1.+redshift, 4));
 
  572   return m_H0*EE(redshift);
 
  581   return m_Omega_matter/EE2(redshift)*(1.+redshift)*(1.+redshift)*(1.+redshift);
 
  590   return m_Omega_DE/EE2(redshift)*f_DE(redshift);
 
  599   return m_Omega_radiation/EE2(redshift)*pow(1.+redshift,4.);
 
  608   return m_Omega_matter/(z_eq+1.);
 
  617   return m_Omega_k/EE2(redshift)*(1.+redshift)*(1.+redshift);
 
  626   return m_Omega_neutrinos/EE2(redshift)*(1.+redshift)*(1.+redshift)*(1.+redshift);
 
  635   return (m_Omega_radiation*pow(1.+redshift,4.)+m_Omega_matter*pow(1.+redshift,3.)+m_Omega_DE*f_DE(redshift)*pow(1.+redshift,4.))/EE2(redshift);
 
  644   if (m_hh<1.e-33) 
ErrorCBL(
"m_hh should be >0", 
"Omega_neutrinos", 
"Cosmology.cpp");
 
  645   return Mnu/(93.14*pow(m_hh, 2));
 
  654   if (m_hh<1.e-33) 
ErrorCBL(
"m_hh should be >0", 
"neutrino_mass", 
"Cosmology.cpp");
 
  655   return m_Omega_neutrinos*93.14*pow(m_hh, 2);
 
  664   if (m_w0==-1. and m_wa==0. and m_Omega_neutrinos==0.)
 
  665     return pow(OmegaM(redshift), 0.545);
 
  669     const double a_in = 1.e-8;
 
  670     double ff = (m_Omega_radiation==0.) ? 1. : (a_in/m_Omega_radiation*m_Omega_matter)/(a_in/m_Omega_radiation*m_Omega_matter+2./3.); 
 
  672     auto func = [&] (
const double y, 
double &dyda, 
const double ln_aa)
 
  674           const double zz = 1./exp(ln_aa)-1.;
 
  675           dyda = -y*y-y*(1.-0.5*(OmegaM(zz)+OmegaR(zz)+(1.+3.*m_w0+3.*m_wa*zz/(1.+zz))*OmegaDE(zz)))+1.5*OmegaM(zz); 
 
  679     typedef boost::numeric::odeint::runge_kutta_dopri5<double> stepper_type;
 
  681     boost::numeric::odeint::integrate_adaptive(make_controlled(1e-8, 1e-8, stepper_type() ),
 
  682                            func, ff, log(a_in), log(1./(1.+redshift)), prec);
 
  693   auto func = [prec, 
this] (
const double aa) { 
return linear_growth_rate(1./aa-1., prec)/aa; };
 
  704   if (m_w0==-1. and m_wa==0. and m_Omega_neutrinos==0.) {
 
  705     const double aa = 1./(1.+redshift);
 
  707     auto func = [&] (
const double aa) { 
return pow(aa*EE(1./aa-1.),-3.); };
 
  713     return ErrorCBL(
"the current implementation is valid only for LCDM cosmologies", 
"DD", 
"Cosmology.cpp", ExitCode::_workInProgress_);
 
  722   return DD(redshift)*(1.+redshift);
 
  732     ErrorCBL(
"sigma8 at z=0 is not set!", 
"sigma8", 
"Cosmology.cpp");
 
  734   return m_sigma8*DN(redshift);
 
  743   if (redshift<0) 
ErrorCBL(
"redshift have to be >=0!", 
"D_C", 
"Cosmology.cpp");
 
  747   if (m_model==
"LCDM") {
 
  748     function<double(
double)> integrand = bind(&
Cosmology::EE_inv, 
this, std::placeholders::_1);
 
  754     string dir = path.
DirCosmo()+
"Cosmology/Tables/dc_cDE/";
 
  756     if (m_model==
"LCDM_Baldi_wmap7") file_in = dir+
"LCDM-wmap7-comovingdist.dat"; 
 
  757     else if (m_model==
"EXP005_Baldi_wmap7") file_in = dir+
"EXP005-wmap7-comovingdist.dat";
 
  758     else if (m_model==
"EXP010e2_Baldi_wmap7") file_in = dir+
"EXP010e2-wmap7-comovingdist.dat";
 
  759     else if (m_model==
"LCDM_Baldi_CoDECS") file_in = dir+
"LCDM_CoDECS-comovingdist.dat"; 
 
  760     else if (m_model==
"EXP001_Baldi_CoDECS") file_in = dir+
"EXP001_CoDECS-comovingdist.dat";
 
  761     else if (m_model==
"EXP002_Baldi_CoDECS") file_in = dir+
"EXP002_CoDECS-comovingdist.dat";
 
  762     else if (m_model==
"EXP003_Baldi_CoDECS") file_in = dir+
"EXP003_CoDECS-comovingdist.dat";
 
  763     else if (m_model==
"EXP008e3_Baldi_CoDECS") file_in = dir+
"EXP008e3_CoDECS-comovingdist.dat";
 
  764     else if (m_model==
"EXP010e2_Baldi_CoDECS") file_in = dir+
"EXP010e2_CoDECS-comovingdist.dat";
 
  765     else if (m_model==
"SUGRA003_Baldi_CoDECS") file_in = dir+
"SUGRA003_CoDECS-comovingdist.dat";
 
  766     else { 
ErrorCBL(
"model = " + m_model + 
"!", 
"D_C", 
"Cosmology.cpp"); }
 
  768     ifstream fin(file_in.c_str()); 
checkIO(fin, file_in); 
 
  771     vector<double> Redshift, dc;
 
  772     while (fin >>Red>>DC) {
 
  773       Redshift.push_back(Red);
 
  776     fin.clear(); fin.close();
 
  797   string File_table = path.
DirCosmo()+
"Cosmology/Tables/dc/"+file_table;
 
  800   fin.open (File_table.c_str());
 
  803     ofstream fout(File_table.c_str()); 
checkIO(fout, File_table); 
 
  805     double delta_z = (z_max-z_min)/step;
 
  807     double z2 = z_min+delta_z;
 
  809     for (
int i=0; i<step; i++) {
 
  810       double zmean = (z1+z2)*0.5;
 
  811       fout <<zmean<<
"   "<<D_C(zmean)<<endl;
 
  812       z1 = z2; z2 += delta_z;
 
  815     fout.clear(); fout.close(); 
coutCBL <<
"I wrote the file: "<<File_table<<endl;
 
  817   fin.clear(); fin.close();
 
  819   fin.open(File_table.c_str());
 
  821   while (fin >>Red>>DC) {
 
  822     Redshift.push_back(Red);
 
  825   fin.clear(); fin.close();
 
  834   if (m_Omega_k>1.e-10) 
 
  835     return m_D_H/sqrt(m_Omega_k)*sinh(sqrt(m_Omega_k)*D_C(redshift)/m_D_H);
 
  837   else if (fabs(m_Omega_k)<1.e-10) 
 
  838     return D_C(redshift);
 
  841     return m_D_H/sqrt(-m_Omega_k)*sin(sqrt(-m_Omega_k)*D_C(redshift)/m_D_H);
 
  850   return D_M(redshift)/(1.+redshift);
 
  860     ErrorCBL(
"the implemented formula is not correct for Omega_k<0!", 
"D_A", 
"Cosmology.cpp");
 
  862   const double _z1 = (z1<z2) ? z1 : z2;
 
  863   const double _z2 = (z1<z2) ? z2 : z1;
 
  865   const double D1 = D_M(_z1);
 
  866   const double D2 = D_M(_z2);
 
  868   return 1./(1.+_z2)*(D2*sqrt(1.+m_Omega_k*pow(D1/m_D_H, 2))-D1*sqrt(1.+m_Omega_k*pow(D2/m_D_H, 2)));
 
  877   return (1.+redshift)*D_M(redshift);
 
  886   return pow(pow(D_M(redshift),2)*
par::cc*redshift/HH(redshift),1./3.);
 
  895   return D_M(redshift)*HH(redshift)/
par::cc;
 
  904   if (distance_type==
"DC")
 
  905     return D_C(redshift);
 
  907   else if (distance_type==
"DL")
 
  908     return D_L(redshift);
 
  910   else if (distance_type==
"DA")
 
  911     return D_A(redshift);
 
  913   else if (distance_type==
"Dv")
 
  914     return D_V(redshift);
 
  916   else if (distance_type==
"Dvrs")
 
  917     return D_V(redshift)/rs_CAMB();
 
  919   else if (distance_type==
"rsDv")
 
  920     return rs_CAMB()/D_V(redshift);
 
  923     ErrorCBL(
"no such a distance type!", 
"Distance", 
"Cosmology.cpp");
 
  934   function<double(
double)> integrand = bind(&
Cosmology::EE_inv2, 
this, std::placeholders::_1);
 
  940   return 1./(m_hh*100.)*tt*Mpc/Gyr;
 
  949   function<double(
double)> integrand = bind(&
Cosmology::EE_inv3, 
this, std::placeholders::_1);
 
  951   double aa = 1./(1.+redshift);
 
  957   return 1./(m_hh*100.)*tt*Mpc/Gyr;
 
  966   return m_Omega_matter*pow((1.+redshift),3)+m_Omega_DE*f_DE(redshift)+m_Omega_k*pow((1.+redshift),2)+m_Omega_radiation*pow(1.+redshift,4);
 
  975   if (m_wa!=0) 
ErrorCBL(
"w_a!=0", 
"qq", 
"Cosmology.cpp", ExitCode::_workInProgress_);
 
  977   double aa = 1./(1.+redshift);
 
  978   return (m_Omega_matter*aa+2.*m_Omega_radiation+(1.+3.*m_w0)*m_Omega_DE*pow(aa,1.-3.*m_w0))/(2.*EE2(redshift));
 
  987   return -pow(HH(redshift),2)*(1.+qq(redshift));
 
  996   if (m_wa!=0) 
ErrorCBL(
"w_a!=0", 
"z_acc", 
"Cosmology.cpp", ExitCode::_workInProgress_);
 
  998   double z_acc = pow(-(1.+3.*m_w0)*m_Omega_DE/m_Omega_matter,-1./(3.*m_w0))-1.;
 
  999   if (std::isnan(z_acc)) 
ErrorCBL(
"", 
"z_acc", 
"Cosmology.cpp");
 
 1010   if (m_wa!=0) 
ErrorCBL(
"w_a!=0", 
"z_eq", 
"Cosmology.cpp", ExitCode::_workInProgress_);
 
 1011   return pow(m_Omega_DE/m_Omega_matter,-1./(3.*m_w0))-1.;
 
 1020   return 2.5e+4*m_Omega_matter*m_hh*m_hh*pow((T_CMB/2.7),-4.);
 
 1029   return (mag_lim-5.*log10(D_L(z_max)))-25.;
 
 1038   return 4.*
par::pi*flux*pow(D_L(redshift),2);
 
 1049     WarningMsgCBL(
"prec has been set to 1.e-5", 
"Redshift", 
"Cosmology.h");
 
 1053   double redshift = -1.;
 
 1055   if (m_model==
"LCDM") {
 
 1056     function<double(
double)> func = bind(&
Cosmology::D_C, 
this, std::placeholders::_1);
 
 1061     WarningMsgCBL(
"the quantity prec is not used", 
"Redshift", 
"Cosmology.h");
 
 1064     string dir = path.
DirCosmo()+
"Cosmology/Tables/dc_cDE/";
 
 1067     if (m_model==
"LCDM_Baldi_wmap7") file_in = dir+
"LCDM-wmap7-comovingdist.dat"; 
 
 1068     else if (m_model==
"EXP005_Baldi_wmap7") file_in = dir+
"EXP005-wmap7-comovingdist.dat";
 
 1069     else if (m_model==
"EXP010e2_Baldi_wmap7") file_in = dir+
"EXP010e2-wmap7-comovingdist.dat";
 
 1070     else if (m_model==
"LCDM_Baldi_CoDECS") file_in = dir+
"LCDM_CoDECS-comovingdist.dat"; 
 
 1071     else if (m_model==
"EXP001_Baldi_CoDECS") file_in = dir+
"EXP001_CoDECS-comovingdist.dat";
 
 1072     else if (m_model==
"EXP002_Baldi_CoDECS") file_in = dir+
"EXP002_CoDECS-comovingdist.dat";
 
 1073     else if (m_model==
"EXP003_Baldi_CoDECS") file_in = dir+
"EXP003_CoDECS-comovingdist.dat";
 
 1074     else if (m_model==
"EXP008e3_Baldi_CoDECS") file_in = dir+
"EXP003_CoDECS-comovingdist.dat";
 
 1075     else if (m_model==
"EXP010e2_Baldi_CoDECS") file_in = dir+
"EXP010e2_CoDECS-comovingdist.dat";
 
 1076     else if (m_model==
"SUGRA003_Baldi_CoDECS") file_in = dir+
"SUGRA003_CoDECS-comovingdist.dat";
 
 1077     else { 
ErrorCBL(
"model = " + m_model + 
"!", 
"Redshift", 
"Cosmology.cpp"); }
 
 1079     ifstream fin(file_in.c_str()); 
checkIO(fin, file_in); 
 
 1082     vector<double> Redshift, dc;
 
 1083     while (fin >> Red >> DC) {
 
 1084       Redshift.push_back(Red);
 
 1085       dc.push_back(m_D_H*DC);
 
 1087     fin.clear(); fin.close();
 
 1091     if (err/redshift>0.1) 
ErrorCBL(
"", 
"Redshift", 
"Cosmology.cpp");
 
 1103   if (m_model!=
"LCDM") 
 
 1104     ErrorCBL(
"this method works only for a LambdaCDM universe", 
"Redshift_LCDM", 
"Cosmology.cpp");
 
 1108     WarningMsgCBL(
"prec has been set to 1.e-5", 
"Redshift_LCDM", 
"Cosmology.h");
 
 1112   double fact = 1./(
par::cc/100.); 
 
 1114   double D_c = d_c * fact; 
 
 1119   double z0 = max(max(z1_guess, D_c), 4./pow(sqrt(m_Omega_matter)*D_c-2.,2)-1.); 
 
 1121   double z1 = (D_c<2.) ? min(z2_guess, 4./pow(D_c-2.,2)-1.) : z2_guess; 
 
 1133   double d0 = DC(z0)*fact;
 
 1136     z0 = D_c/d0*z0/EE(z0);
 
 1140   double d1 = DC(z1)*fact;
 
 1142     z1 = EE(z1)*D_c/d1*z1;
 
 1149   double diffz = z1-z0;
 
 1150   double diffd = d1-d0;
 
 1151   double prec2 = 2.*Prec; 
 
 1153   while (diffz>prec2 && diffd>0.) {
 
 1154     z1 = z0+(D_c-d0)*(diffz/diffd); 
 
 1156     z0 = z0+EE(z0)*(D_c-d0); 
 
 1171   if (m_model!=
"LCDM") 
ErrorCBL(
"model!=LCDM", 
"Redshift_time", 
"Cosmology.cpp", ExitCode::_workInProgress_);
 
 1173   double prec = 0.0001;
 
 1185   const double Area_steradians = Area*pow(
par::pi/180., 2);
 
 1187   return 4./3.*
par::pi*fabs(pow(D_C(z1), 3)-pow(D_C(z2), 3))*Area_steradians/(4.*
par::pi);
 
 1198   return Volume(z1, z2, Area);
 
 1207   const double DDMM = D_M(zz);
 
 1209   if (m_Omega_k>1.e-10) 
 
 1210     return (4*
par::pi*pow(m_D_H, 3)/(2*m_Omega_k))*(DDMM/m_D_H*sqrt(1+m_Omega_k*pow(DDMM/m_D_H, 2))-pow(fabs(m_Omega_k), -0.5)*asinh(sqrt(fabs(m_Omega_k))*DDMM/m_D_H));
 
 1212   else if (fabs(m_Omega_k)<1.e-10) 
 
 1213     return 4*
par::pi*pow(DDMM, 3)/3;
 
 1216     return (4*
par::pi*pow(m_D_H, 3)/(2*m_Omega_k))*(DDMM/m_D_H*sqrt(1+m_Omega_k*pow(DDMM/m_D_H, 2))-pow(fabs(m_Omega_k), -0.5)*asin(sqrt(fabs(m_Omega_k))*DDMM/m_D_H));
 
 1225   double Area_steradians = Area*pow(
par::pi/180.,2);
 
 1226   double dcz2 = pow(3*Volume/Area_steradians+pow(D_C(z_min),3),1./3);
 
 1228   function<double(
double)> func = bind(&
Cosmology::D_C, 
this, std::placeholders::_1);
 
 1239   double conv = (angle_rad) ? 1. : 3282.80635; 
 
 1241   return m_D_H*pow((1.+redshift)*D_A(redshift),2)/EE(redshift)/
conv;
 
 1250   return 1.686*(1.+0.012299*log10(OmegaM(redshift))); 
 
 1263   if (!m_unit && unit1) HHc /= m_hh;
 
 1268   return 3.*pow(HHc, 2)/(8.*
par::pi*GNc);
 
 1276   return rho_crit(redshift, unit1) * ((!nu) ? OmegaM(redshift) : OmegaM(redshift)-OmegaNu(redshift));
 
 1285   if (author==
"BryanNorman") {
 
 1286     const double xx = OmegaM(redshift)-1.;
 
 1288     if (fabs(m_Omega_DE)<1.e-30)
 
 1291     else if (fabs(m_Omega_k)<1.e-30)
 
 1294     else return ErrorCBL(
"cosmological parameters not allowed for the current implementation", 
"Delta_c", 
"Cosmology.cpp");
 
 1297   else if (author==
"Eke") {
 
 1298     if (fabs(m_Omega_DE)<1.e-30)
 
 1299       return 178.*pow(OmegaM(redshift), 0.30);
 
 1301     else if (fabs(m_Omega_k)<1.e-30)
 
 1302       return 178.*pow(OmegaM(redshift), 0.45);
 
 1304     else return ErrorCBL(
"cosmological parameters not allowed for the current implementation", 
"Delta_c", 
"Cosmology.cpp");
 
 1307   else if (author==
"NakamuraSuto") {
 
 1308     if (fabs(m_Omega_DE)<1.e-30) {
 
 1309       const double x = pow(1./m_Omega_matter-1., 1./3.)/(1.+redshift);
 
 1310       return 18.*pow(
par::pi, 2)*(1+0.4093*pow(x, 2.7152))*OmegaM(redshift);
 
 1312     else return ErrorCBL(
"cosmological parameters not allowed for the current implementation", 
"Delta_c", 
"Cosmology.cpp");
 
 1315   else return ErrorCBL(
"author not allowed", 
"Delta_c", 
"Cosmology.cpp");
 
 1324   return 4./3.*
par::pi*pow(r_vir, 3)*Delta_c(redshift, author)*rho_crit(redshift, unit1);
 
 1333   return pow(3*M_vir/(4.*
par::pi*Delta_c(redshift, author)*rho_crit(redshift, unit1)), 1./3.);
 
 1342   const double a = -1.119*log10(Delta_c(redshift, author))+3.537;
 
 1343   const double b = -0.967*log10(Delta_c(redshift, author))+2.181;
 
 1353   if (m_model!=
"LCDM" || fabs(m_Omega_k)>1.e-10) 
 
 1354     ErrorCBL(
"this method works only for a flat LambdaCDM universe; it does not work for non-standard dark energy or non-flat models", 
"D_C_LCDM", 
"Cosmology.h");
 
 1357     WarningMsgCBL(
"this function works only at low enough redshifts where &Omega<SUB>r</SUB> is negligible", 
"D_C_LCDM",
"Cosmology.h");
 
 1359   double CC = 1./pow(3.,0.25)/(pow(m_Omega_matter,1./3.)*pow(1.-m_Omega_matter,1./6.));
 
 1360   double f_m = (1.-sqrt(3.))*pow((1.-m_Omega_matter)/m_Omega_matter,1./3.);
 
 1361   double f_p = (1.+sqrt(3.))*pow((1.-m_Omega_matter)/m_Omega_matter,1./3.);
 
 1362   double phi0 = acos((1.+f_m)/(1.+f_p));
 
 1363   double F_phi0 = m_elf_dz(phi0);
 
 1365   double aa = 1./(1.+redshift);
 
 1366   double phi1 = acos((1.+f_m*aa)/(1.+f_p*aa));
 
 1368   return CC*(F_phi0-m_elf_dz(phi1))*2997.9199*m_t_H*100.;
 
 1377   int jj = round(phi/M_PI);
 
 1378   double phi0 = phi-jj*M_PI;
 
 1381   double ss = phi0/abs(phi0);
 
 1385   double phiS = 1.249;
 
 1387   double phic = 1.5707963-phi0; 
 
 1390     return ss*m_asn_dz(sin(phi0))+jj*5.5361264;
 
 1392     double cc = sin(phic);
 
 1394     double d2 = 0.066987298 + 0.93301270 * xx;
 
 1396       return ss*(2.7680632-m_asn_dz(
cc/sqrt(d2)))+jj*5.5361264;
 
 1398       double vv = 0.066987298 * (1.-xx);
 
 1399       if (vv < xx*d2) 
return ss*m_acn_dz(
cc);
 
 1400       else return ss*m_acn_dz(sqrt(vv/d2)) + jj*5.5361264;
 
 1413   for (
int j=1; j<10; j++) {
 
 1414     if (xx > 0.5) 
return pp*m_asn_dz(sqrt(1.-xx));
 
 1415     double dd = sqrt(0.066987298+0.93301270*xx);
 
 1416     xx = (sqrt(xx)+dd)/(1.+dd);
 
 1420   ErrorCBL(
"too many half argument transformations of cn", 
"m_acn_dz", 
"Cosmology.cpp");
 
 1431   double yA = 0.153532;
 
 1435     return ss*m_serf_dz(yy);
 
 1438   for (
int j=1; j<10; j++) {
 
 1439     yy /= ((1.+sqrt(1.-yy))*(1.+sqrt(1.-0.93301270*yy)));
 
 1442       return pp*sqrt(yy)*m_serf_dz(yy);
 
 1445   return ErrorCBL(
"too many half argument transformations of sn", 
"m_asn_dz", 
"Cosmology.cpp");
 
 1454   return (1.+yy*(0.32216878+yy*(0.18693909+yy*(0.12921048+yy*(0.097305732+yy*(0.077131543+yy*0.063267775+yy*(0.053185339+yy*(0.045545557+yy*0.039573617))))))));
 
 1465   if (redshift>2) 
ErrorCBL(
"The concentration-mass relation by Duffy et al. has been tested only at z<2", 
"concentration_NFW_Duffy", 
"Cosmology.cpp");
 
 1467   if (halo_def==
"200") {
 
 1473   else if (halo_def==
"vir") {
 
 1479   else if (halo_def==
"mean") {
 
 1484     else return ErrorCBL(
"halo_def not allowed!", 
"concentration_NFW_Duffy", 
"Cosmology.cpp");
 
 1486   const double Mpivot = 2.e12; 
 
 1488   return AA*pow(
Mass/Mpivot, BB)*pow(1.+redshift, CC);
 
#define coutCBL
CBL print message.
std::string DirCosmo()
get the directory where the CosmoBolognaLbi are stored
double rho_crit(const double redshift, const bool unit1=false) const
the critical cosmic density
double EE_inv3(const double aa) const
inverse of the auxiliary function used to compute the Hubble function integrand of the cosmic time
double DN(const double redshift, const double redshift_norm=0., const double prec=1.e-4) const
the normalised amplitude of the growing mode at a given redshift,
double m_hh
: the Hubble parameter,
void set_parameters(const std::vector< CosmologicalParameter > parameter, const std::vector< double > value)
set the value of some cosmological paramters
double c_vir(const double c200, const double redshift, const std::string author="BryanNorman") const
virial halo concentration given
double neutrino_mass() const
the total neutrino mass
double m_scalar_pivot
the scalar pivot k in
double rho_m(const double redshift=0., const bool unit1=false, const bool nu=false) const
the mean cosmic background density
double Mag_Volume_limited(const double z_max=1., const double mag_lim=-20.) const
maximum absolute magnitude to have a volume-limited catalogue
double Omega(const double redshift=0.) const
the cosmic density at a given redshift
double m_Omega_radiation
: the radiation density at z=0
double Delta_c(const double redshift, const std::string author="BryanNorman") const
the critical overdensity
double m_n_spec
: the primordial spectral index
double z_acc() const
redshift at which the Universe begins to accelerate
double gg(const double redshift=0.) const
the linear growth factor at a given redshift,
double D_C_LCDM(const double redshift) const
the comoving line-of-sight distance at a given redshift
double m_Omega_baryon
: the baryon density at z=0
void set_parameter(const CosmologicalParameter parameter, const double value)
set the value of one cosmological paramter
double w_CPL(const double redshift=0.) const
the DE equation of state in the CPL parameterisation, as a function of redshift
double m_elf_dz(const double phi) const
the incomplete elliptic integral
double sigma8() const
get the private member Cosmology::m_sigma8
double max_redshift(const double Volume, const double Area, const double z_min) const
maximum redshift for a given volume, sky area and minimum redshift
double Volume(const double z1, const double z2, const double Area) const
comoving volume for a given redshift range and sky area
double EE(const double redshift=0.) const
auxiliary function used to compute the Hubble function
double F_AP(const double redshift) const
F_AP, the ALCOCK-PACZYNSKI distortion parameter.
double D_V(const double redshift) const
the average distance at a given redshift, used to rescale the correlation function
double z_eq_rad(const double T_CMB=2.7255) const
redshift of matter-radiation equality
double qq(const double redshift=0.) const
the deceleration parameter at a given redshift
double m_massless_neutrinos
: the effective number (for QED + non-instantaneous decoupling)
double deltac(const double redshift) const
spherical collapse density threshold at a given redshift
double OmegaR(const double redshift=0.) const
the radiation density at a given redshift
Cosmology(const double Omega_matter=0.27, const double Omega_baryon=0.046, const double Omega_neutrinos=0., const double massless_neutrinos=3.04, const int massive_neutrinos=0, const double Omega_DE=0.73, const double Omega_radiation=0., const double hh=0.7, const double scalar_amp=2.46e-9, const double scalar_pivot=0.05, const double n_spec=0.96, const double w0=-1., const double wa=0., const double fNL=0., const int type_NG=1, const double tau=0.09, const std::string model="LCDM", const bool unit=true)
constructor
double Omega_neutrinos() const
get the private member Cosmology::m_Omega_neutrinos
double dV_dZdOmega(const double redshift, const bool angle_rad) const
the derivative of the comoving volume, d2V/(dz*dΩ) at a given redshift
double m_asn_dz(const double ss) const
the inverse sine amplitude of the Jacobian elliptic function
double m_Omega_neutrinos
: the density of massive neutrinos at z=0
double HH(const double redshift=0.) const
the Hubble function
double EE2(const double redshift=0.) const
auxiliary function used to compute the deceleration parameter
double m_acn_dz(const double cc) const
the inverse cosine amplitude of the Jacobian elliptic function
double D_A(const double redshift) const
the angular diameter distance at a given redshift
double Redshift(const double d_c=1., const double z1_guess=0., const double z2_guess=10., const double prec=0.0001) const
redshift at a given comoving distance
void print_parameters() const
print the values of the private members on the screen
double EE_inv2(const double redshift=0.) const
inverse of the auxiliary function used to compute the Hubble function, integrand of the lookback time
double m_serf_dz(const double yy) const
the inverse truncated series necessary to compute sn-1(s|m) in ASN_DZ
double f_DE(const double redshift=0.) const
auxiliary function used to compute the Hubble function
double cosmic_time(const double redshift=0.) const
cosmic time at a given redshift
double m_Omega_DE
: the dark energy density at z=0
double lookback_time(const double redshift=0.) const
lookback time at a given redshift
double Redshift_LCDM(const double d_c=1., const double z1_guess=0., const double z2_guess=10., const bool go_fast=1, const double prec=0.0001) const
redshift at a given comoving distance
void set_default()
internal function to set default values
double Redshift_time(const double time, const double z1_guess, const double z2_guess) const
redshift at a given cosmic time
double EE_inv(const double redshift=0.) const
inverse of the auxiliary function used to compute the Hubble function integrand of the comoving dista...
double Lum_bol(const double redshift=0., const double flux=1.) const
bolometric luminosity
double OmegaR_zeq(const double z_eq=3395.) const
the radiation density, as a function of the redshift of radiation-matter equality
double Hdot(const double redshift=0.) const
derivative of the Hubble function at a given redshift
double m_scalar_amp
: the initial scalar amplitude of the power spectrum
double m_Omega_matter
: the density of baryons, cold dark matter and massive neutrinos (in units of the critical density) a...
double M_vir(const double r_vir, const double redshift, const std::string author="BryanNorman", const bool unit1=false) const
the virial mass, given the virial radius and the redshift
double D_C(const double redshift) const
the comoving line-of-sight distance at a given redshift
void D_C_table(const std::string file_table, const double z_min, const double z_max, const int step, std::vector< double > &Redshift, std::vector< double > &dc) const
create a table of [redshift, comoving line-of-sight distance]
double D_L(const double redshift) const
the luminosity distance at a given redshift
double OmegaK(const double redshift=0.) const
the density of curvature energy at a given redshift
double linear_growth_rate(const double redshift, const double prec=1.e-4) const
the linear growth rate at a given redshift,
double r_vir(const double M_vir, const double redshift, const std::string author="BryanNorman", const bool unit1=false) const
the virial radius, given the virial mass and the redshift
double Distance(const double redshift, const std::string distance_type) const
the distance at a given redshift
double OmegaNu(const double redshift=0.) const
the neutrino density at a given redshift
int m_massive_neutrinos
the number of degenerate massive neutrino species
double OmegaM(const double redshift=0.) const
the matter density at a given redshift
double D_M(const double redshift) const
the comoving transverse distance at a given redshift
double m_tau
: Thomson scattering optical depth due to reionization
double OmegaDE(const double redshift=0.) const
the dark energy density at a given redshift
double DD(const double redshift) const
the amplitude of the growing mode at a given redshift,
double value(const CosmologicalParameter parameter) const
get the private member specified by the enum CosmologicalParameter
double z_eq() const
redshift of matter-dark energy equality
double concentration_NFW_Duffy(const double Mass, const double redshift, const std::string halo_def="vir") const
the halo concentration-mass relation for NFW prfile and Duffy model
static const double mega
conversion factor
static const char fDP3[]
conversion symbol for: double -> std::string
static const double giga
conversion factor
static const char fINT[]
conversion symbol for: int -> std::string
static const double kilo
conversion factor
static const double pi
: the ratio of a circle's circumference to its diameter
static const double pc
: the parsec, defined as 1au/1arc sec [m]
static const double GN
: the Newtonian constant of gravitation [m3 Kg-1 s-2]
static const double cc
: the speed of light in vacuum (the value is exact) [km/sec]
static const double yr
: one year [s]
static const double Msol
: the solar mass [kg]
CosmologicalParameter
the cosmological parameters
@ _sigma8_
: the power spectrum normalisation
@ _massive_neutrinos_
the number of degenerate massive neutrino species
@ _hh_
: the Hubble constant at z=0 divided by 100
@ _H0_
: the Hubble constant at z=0 [km/sec/Mpc]
@ _Omega_baryon_h2_
: the baryon density times  at z=0
@ _ln_scalar_amp_
: the logarithm of 1e10 times the initial scalar amplitude of the power spectrum
@ _Omega_radiation_
: the radiation density at z=0
@ _massless_neutrinos_
: the effective number (for QED + non-instantaneous decoupling)
@ _Omega_matter_LCDM_
: the density of baryons, cold dark matter and massive neutrinos (in units of the critical density) a...
@ _fNL_
: the non-Gaussian amplitude
@ _neutrino_mass_
the total neutrino mass
@ _scalar_pivot_
the scalar pivot k in
@ _Omega_baryon_
: the baryon density at z=0
@ _scalar_amp_
: the initial scalar amplitude of the power spectrum
@ _wa_
: the parameter of the dark energy equation of state (CPL parameterisation)
@ _Omega_matter_
: the density of baryons, cold dark matter and massive neutrinos (in units of the critical density) a...
@ _w0_
: the parameter of the dark energy equation of state (CPL parameterisation)
@ _tau_
: Thomson scattering optical depth due to reionization
@ _Omega_DE_
: the dark energy density at z=0
@ _Omega_neutrinos_
: the density of massive neutrinos at z=0
@ _n_spec_
: the primordial spectral index
CosmologicalModel
built-in cosmological models
@ _Planck15_TT_
Planck collaboration 2015, paper XIII: Table 4, TT+lowP+lensing.
@ _WMAP7_
Komatsu et al. 2011: Table 1, WMAP Seven-year Mean.
@ _Planck13_
Planck collaboration 2013, paper XVI: Table 3, Planck+WP.
@ _WMAP5_
Komatsu et al. 2009: Table 1, WMAP 5 Year Mean.
@ _Planck18_
Planck collaboration 2018, Paper VI: Table 2, TT,TE,EE+lowE+lensing.
@ _Planck15_
Planck collaboration 2015, paper XIII: Table 4, TT,TE,EE+lowP+lensing.
@ _WMAP9_
Hinshaw et al. 2013: Table 3, WMAP-only Nine-year.
std::string CosmologicalParameter_name(const CosmologicalParameter parameter)
name of the cosmological parameter
double GSL_root_brent(gsl_function Func, const double low_guess, const double up_guess, const double rel_err=1.e-3, const double abs_err=0)
function to find roots using GSL qag method
double GSL_integrate_qag(gsl_function Func, const double a, const double b, const double rel_err=1.e-3, const double abs_err=0, const int limit_size=1000, const int rule=6)
integral, computed using the GSL qag method
The global namespace of the  CosmoBolognaLib
std::string conv(const T val, const char *fact)
convert a number to a std::string
T Mass(const T RR, const T Rho)
the mass of a sphere of a given radius and density
double haversine_distance(const double ra1, const double ra2, const double dec1, const double dec2)
the haversine angular separation
void checkIO(const std::ifstream &fin, const std::string file="NULL")
check if an input file can be opened
int ErrorCBL(const std::string msg, const std::string functionCBL, const std::string fileCBL, const cbl::glob::ExitCode exitCode=cbl::glob::ExitCode::_error_)
throw an exception: it is used for handling exceptions inside the CosmoBolognaLib
double interpolated(const double _xx, const std::vector< double > xx, const std::vector< double > yy, const std::string type)
1D interpolation
double degrees(const double angle, const CoordinateUnits inputUnits=CoordinateUnits::_radians_)
conversion to degrees
void WarningMsgCBL(const std::string msg, const std::string functionCBL, const std::string fileCBL)
internal CBL warning message