2019-05-07 01:05:16 +02:00
|
|
|
#pragma once
|
2020-03-29 14:49:17 +02:00
|
|
|
/*******************************************************************************\
|
|
|
|
cosmology_parameters.hh - This file is part of MUSIC2 -
|
|
|
|
a code to generate initial conditions for cosmological simulations
|
|
|
|
|
|
|
|
CHANGELOG (only majors, for details see repo):
|
|
|
|
06/2019 - Oliver Hahn - first implementation
|
|
|
|
\*******************************************************************************/
|
2019-05-07 01:05:16 +02:00
|
|
|
|
2020-03-29 14:49:17 +02:00
|
|
|
#include <physical_constants.hh>
|
2019-05-07 01:05:16 +02:00
|
|
|
#include <config_file.hh>
|
|
|
|
|
2020-03-29 14:49:17 +02:00
|
|
|
namespace cosmology
|
|
|
|
{
|
2019-05-07 01:05:16 +02:00
|
|
|
//! structure for cosmological parameters
|
2020-03-29 14:49:17 +02:00
|
|
|
struct parameters
|
2019-05-07 01:05:16 +02:00
|
|
|
{
|
2020-03-29 14:49:17 +02:00
|
|
|
|
2019-05-07 01:05:16 +02:00
|
|
|
double
|
|
|
|
Omega_m, //!< baryon+dark matter density
|
|
|
|
Omega_b, //!< baryon matter density
|
|
|
|
Omega_DE, //!< dark energy density (cosmological constant or parameterised)
|
|
|
|
Omega_r, //!< photon + relativistic particle density
|
|
|
|
Omega_k, //!< curvature density
|
|
|
|
H0, //!< Hubble constant in km/s/Mpc
|
2020-03-29 14:49:17 +02:00
|
|
|
h, //!< hubble parameter
|
2019-05-07 01:05:16 +02:00
|
|
|
nspect, //!< long-wave spectral index (scale free is nspect=1)
|
|
|
|
sigma8, //!< power spectrum normalization
|
2020-03-29 14:49:17 +02:00
|
|
|
Tcmb, //!< CMB temperature (used to set Omega_r)
|
|
|
|
Neff, //!< effective number of neutrino species (used to set Omega_r)
|
2019-05-07 01:05:16 +02:00
|
|
|
w_0, //!< dark energy equation of state parameter 1: w = w0 + a * wa
|
|
|
|
w_a, //!< dark energy equation of state parameter 2: w = w0 + a * wa
|
|
|
|
|
|
|
|
// below are helpers to store additional information
|
2020-03-29 14:49:17 +02:00
|
|
|
dplus, //!< linear perturbation growth factor
|
|
|
|
f, //!< growth factor logarithmic derivative
|
|
|
|
pnorm, //!< actual power spectrum normalisation factor
|
2019-05-07 01:05:16 +02:00
|
|
|
sqrtpnorm, //!< sqrt of power spectrum normalisation factor
|
2020-03-29 14:49:17 +02:00
|
|
|
vfact; //!< velocity<->displacement conversion factor in Zel'dovich approx.
|
2019-05-07 01:05:16 +02:00
|
|
|
|
2020-04-03 07:04:41 +02:00
|
|
|
parameters() = delete;
|
2020-04-04 01:24:05 +02:00
|
|
|
|
|
|
|
parameters( const parameters& ) = default;
|
|
|
|
|
2020-03-29 14:49:17 +02:00
|
|
|
explicit parameters(ConfigFile cf)
|
2019-05-07 01:05:16 +02:00
|
|
|
{
|
2020-03-29 14:49:17 +02:00
|
|
|
H0 = cf.GetValue<double>("cosmology", "H0");
|
|
|
|
h = H0 / 100.0;
|
|
|
|
|
|
|
|
nspect = cf.GetValue<double>("cosmology", "nspec");
|
|
|
|
|
2019-05-07 01:05:16 +02:00
|
|
|
Omega_b = cf.GetValue<double>("cosmology", "Omega_b");
|
2020-03-29 14:49:17 +02:00
|
|
|
|
2019-05-07 01:05:16 +02:00
|
|
|
Omega_m = cf.GetValue<double>("cosmology", "Omega_m");
|
2020-03-29 14:49:17 +02:00
|
|
|
|
2019-05-07 01:05:16 +02:00
|
|
|
Omega_DE = cf.GetValue<double>("cosmology", "Omega_L");
|
2020-03-29 14:49:17 +02:00
|
|
|
|
2019-05-07 01:05:16 +02:00
|
|
|
w_0 = cf.GetValueSafe<double>("cosmology", "w0", -1.0);
|
2020-03-29 14:49:17 +02:00
|
|
|
|
2019-05-07 01:05:16 +02:00
|
|
|
w_a = cf.GetValueSafe<double>("cosmology", "wa", 0.0);
|
|
|
|
|
2020-04-02 12:45:24 +02:00
|
|
|
Tcmb = cf.GetValueSafe<double>("cosmology", "Tcmb", 2.7255);
|
2020-03-29 14:49:17 +02:00
|
|
|
|
2020-04-02 12:45:24 +02:00
|
|
|
Neff = cf.GetValueSafe<double>("cosmology", "Neff", 3.046);
|
2019-05-07 01:05:16 +02:00
|
|
|
|
|
|
|
sigma8 = cf.GetValue<double>("cosmology", "sigma_8");
|
2020-03-29 14:49:17 +02:00
|
|
|
|
|
|
|
// calculate energy density in ultrarelativistic species from Tcmb and Neff
|
|
|
|
double Omega_gamma = 4 * phys_const::sigma_SI / std::pow(phys_const::c_SI, 3) * std::pow(Tcmb, 4.0) / phys_const::rhocrit_h2_SI / (h * h);
|
|
|
|
double Omega_nu = Neff * Omega_gamma * 7. / 8. * std::pow(4. / 11., 4. / 3.);
|
|
|
|
Omega_r = Omega_gamma + Omega_nu;
|
|
|
|
|
2020-04-02 12:45:24 +02:00
|
|
|
if (cf.GetValueSafe<bool>("cosmology", "ZeroRadiation", false))
|
2020-03-29 14:49:17 +02:00
|
|
|
{
|
|
|
|
Omega_r = 0.0;
|
|
|
|
}
|
2020-04-02 12:45:24 +02:00
|
|
|
#if 1
|
|
|
|
// assume zero curvature, take difference from dark energy
|
|
|
|
Omega_DE += 1.0 - Omega_m - Omega_DE - Omega_r;
|
2020-04-03 07:04:41 +02:00
|
|
|
Omega_k = 0.0;
|
2020-04-02 12:45:24 +02:00
|
|
|
#else
|
|
|
|
// allow for curvature
|
2020-03-29 14:49:17 +02:00
|
|
|
Omega_k = 1.0 - Omega_m - Omega_DE - Omega_r;
|
2020-04-02 12:45:24 +02:00
|
|
|
#endif
|
|
|
|
|
2020-04-04 01:24:05 +02:00
|
|
|
dplus = 0.0;
|
|
|
|
pnorm = 0.0;
|
|
|
|
vfact = 0.0;
|
|
|
|
|
2020-04-04 20:27:51 +02:00
|
|
|
music::ilog << "-------------------------------------------------------------------------------" << std::endl;
|
|
|
|
music::ilog << "Cosmological parameters are: " << std::endl;
|
|
|
|
music::ilog << " H0 = " << std::setw(16) << H0 << "sigma_8 = " << std::setw(16) << sigma8 << std::endl;
|
|
|
|
music::ilog << " Omega_c = " << std::setw(16) << Omega_m-Omega_b << "Omega_b = " << std::setw(16) << Omega_b << std::endl;
|
2020-04-02 12:45:24 +02:00
|
|
|
if (!cf.GetValueSafe<bool>("cosmology", "ZeroRadiation", false)){
|
2020-04-04 20:27:51 +02:00
|
|
|
music::ilog << " Omega_g = " << std::setw(16) << Omega_gamma << "Omega_nu = " << std::setw(16) << Omega_nu << std::endl;
|
2020-04-02 12:45:24 +02:00
|
|
|
}else{
|
2020-04-04 20:27:51 +02:00
|
|
|
music::ilog << " Omega_r = " << std::setw(16) << Omega_r << std::endl;
|
2020-04-02 12:45:24 +02:00
|
|
|
}
|
2020-04-04 20:27:51 +02:00
|
|
|
music::ilog << " Omega_DE = " << std::setw(16) << Omega_DE << "nspect = " << std::setw(16) << nspect << std::endl;
|
|
|
|
music::ilog << " w0 = " << std::setw(16) << w_0 << "w_a = " << std::setw(16) << w_a << std::endl;
|
2019-05-07 01:05:16 +02:00
|
|
|
|
2020-04-04 01:24:05 +02:00
|
|
|
if( Omega_r > 0.0 )
|
|
|
|
{
|
2020-04-04 20:27:51 +02:00
|
|
|
music::wlog << "Radiation enabled, using Omega_r=" << Omega_r << " internally."<< std::endl;
|
|
|
|
music::wlog << "Make sure your sim code supports this..." << std::endl;
|
2020-04-04 01:24:05 +02:00
|
|
|
}
|
2019-05-07 01:05:16 +02:00
|
|
|
}
|
|
|
|
|
2020-03-29 14:49:17 +02:00
|
|
|
};
|
|
|
|
} // namespace cosmology
|