35 #include "recombination.Recfast.h"
36 #include "cosmology.Recfast.h"
49 double ombh2 = m_Omega_baryon*m_hh*m_hh;
50 double omdmh2 = m_Omega_CDM*m_hh*m_hh;
51 double g1 = 0.0783*pow(ombh2,-0.238)/(1.+39.5*pow(ombh2,0.763));
52 double g2 = 0.560/(1+21.1*pow(ombh2,1.81));
53 double zdec = 1048*(1.+0.00124*pow(ombh2,-0.738))*(1.+g1*pow(ombh2+omdmh2,g2));
64 double wb = m_Omega_baryon*m_hh*m_hh;
66 double dNeff = m_massless_neutrinos+m_massive_neutrinos-3.046;
67 double dNeff2 = dNeff*dNeff;
69 double Yp = 0.2311+0.9520*wb-11.27*wb2+dNeff*(0.01356+0.008581*wb-0.1810*wb2)+dNeff2*(-0.0009795-0.001370*wb+0.01746*wb2);
71 vector<double> params(14);
73 double zstart=1.0e+4, zend=0.001;
80 params[5] = m_Omega_matter;
81 params[6] = m_Omega_baryon;
82 params[7] = m_Omega_DE;
83 params[8] = m_Omega_k;
85 params[10] = m_massless_neutrinos+m_massive_neutrinos;
92 vector<double> zarr(npz), Xe_H(npz), Xe_He(npz), Xe(npz), TM(npz);
94 Xe_frac(¶ms[0], &zarr[0], &Xe_H[0], &Xe_He[0], &Xe[0], &TM[0], 0);
101 double rho_b = m_Omega_baryon*rho_cr;
103 double R = 3./4*rho_b/rho_rad;
105 double Np = rho_b*(1.-Yp)/
par::mp;
106 double kthom = 6.6524616e-29;
108 vector<double> zz(npz), dtau(npz), tau(npz);
109 for(
int i=0; i<npz; i++){
110 zz[i] = zarr[npz-1-i];
111 double a = 1./(1+zz[i]);
112 dtau[i] = Xe[npz-1-i]*Np*kthom/R*a/(HHc*EE(zz[i]));
117 auto integrand = [&] (
double redshift) {
return interp_dtau(redshift);};
119 auto func = [&] (
double redshift)
143 if (method_Pk==
"EisensteinHu")
146 else if (method_Pk==
"CAMB")
150 return ErrorCBL(
" the input parameter method_Pk is not allowed!",
"rs",
"BAO.cpp");
160 double Om0h2 = m_Omega_matter*pow(m_hh,2);
161 double Ombh2 = m_Omega_baryon*pow(m_hh,2);
162 double Tratio = T_CMB/2.7;
164 double zeq = 2.5*pow(10.,4)*Om0h2*pow(Tratio,-4);
165 double keq = 7.46*pow(10.,-2)*Om0h2*pow(Tratio,-2);
167 double b1 = 0.313 * pow(Om0h2,-0.419) * (1.+0.607*pow(Om0h2,0.674));
168 double b2 = 0.238 * pow(Om0h2,0.223);
170 double zdrag = 1291.*(pow(Om0h2,0.251)/(1.+0.659*pow(Om0h2,0.828)))*(1.+b1*pow(Ombh2,b2));
172 double Rd = 31.5*Ombh2*pow(Tratio,-4)*pow(10.,3)/zdrag;
173 double Req = 31.5*Ombh2*pow(Tratio,-4)*pow(10.,3)/zeq;
175 double rs = 2.*pow(3.*keq,-1)*pow(6./Req,0.5)*log((pow(1.+Rd,0.5)+pow(Rd+Req,0.5))/(1.+pow(Req,0.5)));
176 return ((m_unit) ? rs*m_hh : rs);
185 double wcb= m_Omega_matter*pow(m_hh,2);
186 double wb= m_Omega_baryon*pow(m_hh,2);
187 double wnu = m_Omega_neutrinos*pow(m_hh,2);
189 double rd = 55.154*exp(-72.3*pow(wnu+0.0006,2))/(pow(wcb,0.25351)*pow(wb,0.12807));
190 return ((m_unit) ? rd*m_hh : rd);
199 return rs(method_Pk, T_CMB)/((m_unit) ? D_V(redshift)/m_hh : D_V(redshift));
208 return ((m_unit) ? D_V(redshift)/m_hh : D_V(redshift))*1.e2*sqrt(m_Omega_matter*m_hh*m_hh)/(
par::cc*redshift);
217 double rho_b = 3.*pow(100.*m_hh/
par::cc, 2)*m_Omega_baryon;
223 double R = 3./4*rho_b/rho_rad/(1+redshift);
224 double cs = 1./sqrt(3.*(1.+R));
234 double redshift=1./a-1;
236 double zeq = 2.5e4*m_Omega_matter*m_hh*m_hh*pow(T_CMB/2.7,-4);
237 double a_eq = 1./(1+zeq);
240 if(m_Omega_radiation ==0)
241 factor = sqrt(m_Omega_matter*(a+a_eq)+m_Omega_k*a*a+m_Omega_DE*f_DE(redshift)*pow(a,4));
243 factor = a*a*EE(redshift);
245 return sound_speed(redshift, T_CMB)/factor;
254 function<double(
double)> integrand = bind(&Cosmology::rs_integrand,
this, std::placeholders::_1, T_CMB);
255 double a = 1./(1+redshift);
267 vector<double> kk, Pk;
268 run_CAMB(kk, Pk,
false, redshift);
269 for(
size_t i=0; i<kk.size(); i++){
270 kk[i] = pow(10., kk[i]);
271 Pk[i] = pow(10., Pk[i]);
278 double rsCAMB = rs_CAMB();
279 vector<double> boundaries = {rsCAMB-5, rsCAMB+5};
288 rpeak = xi_interp.
root_D1v(boundaries[0], boundaries[1], 0, 1.e-10);
290 if ((rpeak<boundaries[1]) && (rpeak > boundaries[0]))
292 else if (rpeak==boundaries[1])
302 boundaries[1] = boundaries[0];
303 boundaries[0] = boundaries[1]-10;
306 rdip = xi_interp.
root_D1v(boundaries[0], boundaries[1], 0, 1.e-10);
308 if ((rdip<boundaries[1]) &&(rdip > boundaries[0]))
310 else if (rdip==boundaries[1])
316 return {0.5*(rdip+rpeak), rdip, rpeak};
std::vector< double > linear_point(const double redshift, const double rmin=60., const double rmax=150., const int nbinr=100, const std::string interpType="Spline")
the linear point
double rs_EH(const double T_CMB=par::TCMB) const
the sound horizon at the drag epoch predicted by Eisentein & Hu 1998
double z_drag() const
redshift of drag epoch
double rs_integrand(const double redshift, const double T_CMB=2.7255) const
the sound horizon integrand
double rs_CAMB() const
the sound horizon at the drag epoch estimated with CAMB [http://camb.info/], analytical formula by Au...
double sound_speed(const double redshift, const double T_CMB=2.7255) const
the sound speed
double ys(const double redshift, const std::string method_Pk, const double T_CMB=par::TCMB) const
the fiducial cosmology independent ratio rs/DV, valid choices for method_Pk are: EisensteinHu [http:/...
double rs() const
get the sound horizon at recombination
double Az(const double redshift) const
the acoustic parameter
double z_decoupling() const
redshift at wich occurs baryon photon decoupling
double root_D1v(const double x_low, const double x_up, const double fx0=0, const double rel_err=1.e-2, const double abs_err=1.e-6)
find roots with GSL brent method for the first derivative
static const double kilo
conversion factor
static const double pi
: the ratio of a circle's circumference to its diameter
static const double sSB
: the Stefan-Boltzmann constant, the factor relating the emissive power of a black body to the fourth...
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 TCMB
: the present day CMB temperature [K]
static const double mp
: the mass of the proton [kg]
std::vector< double > transform_FFTlog(const std::vector< double > yy, const int dir, const std::vector< double > xx, const std::vector< double > fx, const double mu=0, const double q=0, const double kr=1, const int kropt=0)
wrapper of the FFTlog to compute the discrete Fourier sine or cosine transform of a logarithmically...
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::vector< T > linear_bin_vector(const size_t nn, const T min, const T max)
fill a std::vector with linearly spaced values
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