56 template<
typename T,
typename U>
59 for(
auto x : map)
if (
x.second == value)
return x.first;
60 throw std::out_of_range(
"Value not found");
66 size_t seed = (
static_cast<long>(rand()) << (
sizeof(
int) * 8)) | rand();
69 if (
char * job_id_str = std::getenv(
"SBATCH_JOBID"))
72 if (
long job_id = atol(job_id_str))
79 BOOST_LOG_TRIVIAL(debug) <<
"Enviromental variable 'SBATCH_JOBID' was not found.";
96 {
"smoothing_k", cosmo.
k2_G},
111 cosmo.
ns = j.
at(
"index").
get<FTYPE_t>();
113 cosmo.
k2_G = j.
at(
"smoothing_k").
get<FTYPE_t>();
116 cosmo.
h = j.
at(
"h").
get<FTYPE_t>();
117 cosmo.
H0 = cosmo.
h * 100;
121 tmp = j.
at(
"transfer_function_method").
get<std::string>();
127 tmp = j.
at(
"matter_power_spectrum_method").
get<std::string>();
133 tmp = j.
at(
"mass_function_method").
get<std::string>();
139 tmp = j.
at(
"baryons_power_spectrum_method").
get<std::string>();
170 {
"redshift", integ_opt.
z_in},
171 {
"redshift_0", integ_opt.
z_out},
172 {
"time_step", integ_opt.
db}
178 integ_opt.
z_in = j.
at(
"redshift").
get<FTYPE_t>();
179 integ_opt.
z_out = j.
at(
"redshift_0").
get<FTYPE_t>();
180 integ_opt.
db = j.
at(
"time_step").
get<FTYPE_t>();
188 {
"viscosity", app_opt.
nu_dim},
189 {
"cut_radius", app_opt.
rs}
197 app_op.
rs = j.
at(
"cut_radius").
get<FTYPE_t>();
203 {
"num_thread", run_opt.
nt},
204 {
"seed", run_opt.
seed},
205 {
"phase", run_opt.
phase},
212 run_opt.
nt = j.
at(
"num_thread").
get<
size_t>();
213 run_opt.
seed = j.
at(
"seed").
get<
size_t>();
237 {
"beta", chi_opt.
beta},
239 {
"phi", chi_opt.
phi},
240 {
"linear", chi_opt.
linear},
246 chi_opt.
beta = j.
at(
"beta").
get<FTYPE_t>();
247 chi_opt.
n = j.
at(
"n").
get<FTYPE_t>();
248 chi_opt.
phi = j.
at(
"phi").
get<FTYPE_t>();
260 {
"N_grid", test_opt.
N_grid},
261 {
"N_min", test_opt.
N_min},
262 {
"rho_b", test_opt.
rho_b}
272 test_opt.
rho_b = j.
at(
"rho_b").
get<FTYPE_t>();
284 double Omega_k = 0.0;
294 mnu, mnu_type, w0, wa, h, norm_pk, n_s, -1, -1, -1, -1, NULL, NULL, status);
338 Cosmo_Param::operator
void*()
const 346 if(nt == 0) nt = omp_get_max_threads();
347 else omp_set_num_threads(nt);
348 if(nt_fftw == 0) nt_fftw = nt;
362 return (mlt_runs != 0);
372 if (pair) phase = !phase;
378 Ng = mesh_num / par_num_1d;
379 Ng_pwr = mesh_num_pwr/par_num_1d;
380 par_num = par_num_1d*par_num_1d*par_num_1d;
381 mass_p_log = std::log10(2.78E11*
pow(box_size/par_num_1d, 3)*cosmo.
Omega_m/cosmo.
h);
387 a_out = 1/(z_out + 1);
392 get_pk_extrap = print_corr|| print_extrap_pwr;
393 get_pwr = get_pk_extrap || print_pwr;
394 get_rho = get_pwr || print_dens;
399 ZA = TZA = FF = FP = AA = FP_pp = chi = chi_ff =
false;
404 return (ZA | TZA | FF | FP | PM | AA | FP_pp | chi | chi_ff);
409 a =
rs / FTYPE_t(0.735);
421 nyquist[
"potential"] = tmp*box_opt.
mesh_num;
423 k_print.lower = 2*tmp;
437 if (this->is_ready())
444 app_opt.init(box_opt);
445 other_par.init(box_opt);
455 try{ run_opt = j.
at(
"run_opt"); }
463 if (
"TZA" == j.at(
"app"))
465 cosmo.truncated_pk =
true;
468 box_opt = j.at(
"box_opt");
471 integ_opt = j.at(
"integ_opt");
472 try{ out_opt = j.at(
"out_opt"); }
474 try {out_opt.out_dir = j.at(
"out_dir"); }
476 out_opt.bins_per_decade = 20;
477 out_opt.points_per_10_Mpc = 10;
479 app_opt = j.at(
"app_opt");
481 app_opt.init(box_opt);
482 other_par.init(box_opt);
485 chi_opt = j.at(
"chi_opt");
486 comp_app.chi = ((
"CHI" == j.at(
"app")));
487 comp_app.chi_ff = ((
"CHI_FF" == j.at(
"app")));
492 std::string err = std::string(oor.
what()) +
" in file '" + file_name +
"'";
493 throw std::out_of_range(err);
501 BOOST_LOG_TRIVIAL(info) <<
"\n" 502 "*********************\n" 503 "SIMULATION PARAMETERS\n" 504 "*********************\n" 505 "Ng:\t\t" << box_opt.Ng <<
"\n" 506 "Num_par:\t" << box_opt.par_num_1d <<
"^3\n" 507 "Num_mesh:\t" << box_opt.mesh_num <<
"^3\n" 508 "Num_mesh_pwr:\t" << box_opt.mesh_num_pwr <<
"^3\n" 509 "Box size:\t" << box_opt.box_size <<
" Mpc/h\n" 510 "Redshift:\t" << integ_opt.z_in <<
" ---> " << integ_opt.z_out <<
"\n" 511 "Pk:\t\t[sigma_8 = " <<
cosmo.sigma8 <<
", ns = " <<
cosmo.ns <<
", k_smooth = " <<
sqrt(
cosmo.k2_G) <<
"]\n" <<
516 "AA:\t\t[nu = " << app_opt.nu_dim <<
" (Mpc/h)^2]\n" <<
517 "LL:\t\t[rs = " << app_opt.rs <<
", a = " << app_opt.a <<
", M = " << app_opt.M <<
", Hc = " << app_opt.Hc <<
"]\n" <<
518 "CHI:\t\t[beta = " << chi_opt.beta <<
", n = " << chi_opt.n <<
", phi = " << chi_opt.phi <<
"\n" <<
519 "num_thread:\t << " << run_opt.nt <<
"\n" <<
520 "Output:\t\t'" << out_opt.out_dir <<
"'\n";
524 std::string file_name = out +
"sim_param.json";
525 std::ofstream o(file_name);
528 {
"box_opt", box_opt},
529 {
"integ_opt", integ_opt},
531 {
"app_opt", app_opt},
532 {
"run_opt", run_opt},
533 {
"out_opt", out_opt},
534 {
"k_nyquist", other_par.nyquist},
537 if (comp_app.chi | comp_app.chi_ff) j[
"chi_opt"] = chi_opt;
538 if (app ==
"test") j[
"test_opt"] = test_opt;
540 o << std::setw(2) << j << std::endl;
558 bool is_ready =
true;
559 is_ready &= run_opt.is_ready();
560 is_ready &= comp_app.is_ready();
functions handling output of the program
void ccl_set_debug_policy(CCLDebugModePolicy debug_policy)
void norm_pwr(Cosmo_Param &cosmo)
< end of anonymous namespace (private definitions)
static ccl_cosmology * ccl_cosmology_create_flat_lcdm(double Omega_c, double Omega_b, double h, double norm_pk, double n_s, ccl_configuration config, int *status)
handle cosmological functions like power spectrum, growth, etc.
a class to store JSON values
matter_power_spectrum_t matter_power_spectrum_method
const std::map< std::string, transfer_function_t > transfer_function_method
void to_json(json &j, const Cosmo_Param &cosmo)
< end of anonymous namespace (private definitions)
T find_value(const std::map< T, U > &map, const U &value)
exception indicating access out of the defined range
reference at(size_type idx)
access specified array element with bounds checking
transfer_function_t transfer_function_method
const char * what() const noexceptoverride
returns the explanatory string
double mass_p_log
logarithm of particle mass in
void init(const Box_Opt &)
cosmological & CCL parameters
basic_json get() const
get special-case overload
const std::map< std::string, matter_power_spectrum_t > matter_power_spectrum_method
Grid< NDIM, T > sqrt(Grid< NDIM, T > lhs)
ccl_cosmology * ccl_cosmology_create(ccl_parameters params, ccl_configuration config)
void init()
lazy constructor
static CCL_BEGIN_DECLS double x[111][8]
various simulation parameters
const std::map< std::string, baryons_power_spectrum_t > baryons_power_spectrum_method
void ccl_cosmology_free(ccl_cosmology *cosmo)
baryons_power_spectrum_t baryons_power_spectrum_method
command line arguments manipulation
void ccl_set_error_policy(CCLErrorPolicy error_policy)
basic functions to work with mesh
void from_json(const json &j, Cosmo_Param &cosmo)
mass_function_t mass_function_method
const ccl_configuration default_config
float pow(float base, unsigned long int exp)
void init(const Box_Opt &)
basic_json<> json
default JSON class
auto value(T const &val) -> Generator< T >
const std::map< std::string, mass_function_t > mass_function_method
void init(const Cosmo_Param &cosmo)
ccl_parameters ccl_parameters_create(double Omega_c, double Omega_b, double Omega_k, double Neff, double *mnu, ccl_mnu_convention mnu_type, double w0, double wa, double h, double norm_pk, double n_s, double bcm_log10Mc, double bcm_etab, double bcm_ks, int nz_mgrowth, double *zarr_mgrowth, double *dfarr_mgrowth, int *status)
void handle_cmd_line(int ac, const char *const av[], Sim_Param &sim)
parse command line arguments
double norm_growth_factor(const Cosmo_Param &cosmo)
when computing growth factor outside CCL range we need to normalize the growth factor; ...