10 #include <boost/any.hpp> 11 #include <boost/program_options.hpp> 18 namespace po = boost::program_options;
25 std::string config_file;
27 unsigned int trans_func_cmd, matter_pwr_cmd, baryons_pwr_cmd, mass_func_cmd;
30 po::options_description
generic(
"Generic options");
32 (
"help,h",
"produce this help message")
33 (
"config,c", po::value<std::string>(&config_file)->default_value(
"INPUT.cfg"),
"configuration file name (optional)")
34 (
"version,v",
"print current version of the program")
38 po::options_description config_mesh(
"Simulation box options");
39 config_mesh.add_options()
40 (
"mesh_num,m", po::value<size_t>(&sim.
box_opt.
mesh_num)->default_value(128),
"number of mesh cells per dimension (potential)")
41 (
"mesh_num_pwr,M", po::value<size_t>(&sim.
box_opt.
mesh_num_pwr)->default_value(256),
"number of mesh cells per dimension (power spectrum)")
42 (
"par_num,p", po::value<size_t>(&sim.
box_opt.
par_num_1d)->default_value(128),
"number of particles per dimension")
43 (
"box_size,L", po::value<FTYPE_t>(&sim.
box_opt.
box_size)->default_value(512,
"512"),
"box size in units of Mpc/h")
46 po::options_description config_integ(
"Integration options");
47 config_integ.add_options()
48 (
"redshift,z", po::value<FTYPE_t>(&sim.
integ_opt.
z_in)->default_value(200.),
"redshift at the start of the simulation")
49 (
"redshift_0,Z", po::value<FTYPE_t>(&sim.
integ_opt.
z_out)->default_value(10.),
"redshift at the end of the simulation")
50 (
"time_step,a", po::value<FTYPE_t>(&sim.
integ_opt.
db)->default_value(0.1,
"0.1"),
"dimensionless time-step (scale factor)")
53 po::options_description config_output(
"Output options");
54 config_output.add_options()
55 (
"print_every", po::value<size_t>(&sim.
out_opt.
print_every)->default_value(1,
"1"),
"save particle positions and power spectrum " 56 "every n-th step, set 0 for no printing")
57 (
"pwr_bins", po::value<size_t>(&sim.
out_opt.
bins_per_decade)->default_value(30),
"number of bins per decade in power spectrum")
58 (
"corr_pt", po::value<size_t>(&sim.
out_opt.
points_per_10_Mpc)->default_value(10),
"number of points per 10 Mpc in correlation function")
59 (
"out_dir,o", po::value<std::string>(&sim.
out_opt.
out_dir)->default_value(
"output/"),
"output folder name")
60 (
"print_par_pos", po::value<bool>(&sim.
out_opt.
print_par_pos)->default_value(
false),
"print particles positions")
61 (
"print_dens", po::value<bool>(&sim.
out_opt.
print_dens)->default_value(
false),
"print density map and histogram")
62 (
"print_pwr", po::value<bool>(&sim.
out_opt.
print_pwr)->default_value(
false),
"print power spectrum")
63 (
"print_extrap_pwr", po::value<bool>(&sim.
out_opt.
print_extrap_pwr)->default_value(
false),
"print extrapolated power spectrum")
64 (
"print_corr", po::value<bool>(&sim.
out_opt.
print_corr)->default_value(
false),
"print correlation function")
65 (
"print_vel_pwr", po::value<bool>(&sim.
out_opt.
print_vel_pwr)->default_value(
false),
"print velocity power spectrum")
68 po::options_description config_app(
"Approximations");
69 config_app.add_options()
70 (
"comp_ZA", po::value<bool>(&sim.
comp_app.
ZA)->default_value(
false),
"compute Zeldovich approximation")
71 (
"comp_TZA", po::value<bool>(&sim.
comp_app.
TZA)->default_value(
false),
"compute Truncated Zeldovich approximation")
72 (
"comp_FF", po::value<bool>(&sim.
comp_app.
FF)->default_value(
false),
"compute Frozen-flow approximation")
73 (
"comp_FP", po::value<bool>(&sim.
comp_app.
FP)->default_value(
false),
"compute Frozen-potential approximation")
74 (
"comp_PM", po::value<bool>(&sim.
comp_app.
PM)->default_value(
false),
"compute Particle-mesh approximation")
75 (
"comp_AA", po::value<bool>(&sim.
comp_app.
AA)->default_value(
false),
"compute Adhesion approximation")
76 (
"comp_FP_pp", po::value<bool>(&sim.
comp_app.
FP_pp)->default_value(
false),
77 "compute Frozen-potential approximation (particle-particle interaction)")
80 po::options_description config_power(
"Cosmological parameters");
81 config_power.add_options()
82 (
"Omega_b,B", po::value<FTYPE_t>(&sim.
cosmo.
Omega_b)->default_value(0.05,
"0.05"),
"density of baryons relative to the critical density")
83 (
"Omega_m,C", po::value<FTYPE_t>(&sim.
cosmo.
Omega_m)->default_value(0.25,
"0.25"),
"density of CDM relative to the critical density")
84 (
"Hubble,H", po::value<FTYPE_t>(&sim.
cosmo.
H0)->default_value(67,
"67"),
"Hubble constant in units of km/s/Mpc")
85 (
"transfer_function", po::value<unsigned int>(&trans_func_cmd)->default_value(3),
"transfer function type")
86 (
"matter_power_spectrum", po::value<unsigned int>(&matter_pwr_cmd)->default_value(1),
"matter power spectrum type")
87 (
"baryons_power_spectrum", po::value<unsigned int>(&baryons_pwr_cmd)->default_value(0),
"baryons power spectrum type")
88 (
"mass_function", po::value<unsigned int>(&mass_func_cmd)->default_value(2),
"mass function type")
89 (
"n_s,n", po::value<FTYPE_t>(&sim.
cosmo.
ns)->default_value(1.),
"spectral index of the scale-free power spectrum")
90 (
"sigma8,s", po::value<FTYPE_t>(&sim.
cosmo.
sigma8)->default_value(1.),
"normalization of the power spectrum at R = 8 Mpc/h")
91 (
"smoothing_k,k", po::value<FTYPE_t>(&k2_G)->default_value(0.),
92 "smoothing wavenumber of TZA in units of h/Mpc, set 0 for ZA")
95 po::options_description config_run(
"Run options");
96 config_run.add_options()
97 (
"num_thread,t", po::value<size_t>(&sim.
run_opt.
nt)->default_value(0),
"number of threads the program will use, set 0 for max. available")
98 (
"num_thread_fftw", po::value<size_t>(&sim.
run_opt.
nt_fftw)->default_value(0),
"number of threads the program will use for FFTW, set 0 for max. available")
99 (
"seed", po::value<size_t>(&sim.
run_opt.
seed)->default_value(0),
"seed to random number generator, use 0 for random")
100 (
"pair", po::value<bool>(&sim.
run_opt.
pair)->default_value(
false),
"if true run two simulations with opposite phases of random field")
101 (
"mlt_runs", po::value<size_t>(&sim.
run_opt.
mlt_runs)->default_value(1),
"how many runs should be simulated (only if seed = 0)")
104 po::options_description mod_grav(
"Modified Gravities");
105 mod_grav.add_options()
106 (
"comp_chi", po::value<bool>(&sim.
comp_app.
chi)->default_value(
false),
"compute chameleon gravity (frozen-potential)")
107 (
"comp_chi_ff", po::value<bool>(&sim.
comp_app.
chi_ff)->default_value(
false),
"compute chameleon gravity (frozen-flow)")
110 po::options_description config_cham(
"Chameleon parameters");
111 config_cham.add_options()
112 (
"chi_beta", po::value<FTYPE_t>(&sim.
chi_opt.
beta)->default_value(1/
sqrt(6),
"(1/6)^1/2"),
"coupling constant")
113 (
"chi_n", po::value<FTYPE_t>(&sim.
chi_opt.
n)->default_value(0.5,
"1/2"),
"chameleon power-law potential exponent,\n0 < n < 1")
114 (
"chi_phi", po::value<FTYPE_t>(&sim.
chi_opt.
phi)->default_value(1E-6,
"1E-6"),
"screening potential")
115 (
"comp_chi_lin", po::value<bool>(&sim.
chi_opt.
linear)->default_value(
false),
"use only linear prediction in k-space")
117 mod_grav.add(config_cham);
119 po::options_description config_test(
"Test options");
120 config_test.add_options()
121 (
"R_sphere", po::value<FTYPE_t>(&sim.
test_opt.
R_sphere)->default_value(1.,
"3.0"),
"radius of a sphere sitting in a vacuum")
122 (
"rho_sphere", po::value<FTYPE_t>(&sim.
test_opt.
rho_sphere)->default_value(2.7,
"1.0"),
"density of a sphere sitting in a vacuum")
123 (
"N_grid", po::value<size_t>(&sim.
test_opt.
N_grid)->default_value(64,
"64"),
"finest grid size")
124 (
"N_min", po::value<size_t>(&sim.
test_opt.
N_min)->default_value(2,
"2"),
"coarsest grid size")
125 (
"step_per_iter", po::value<size_t>(&sim.
test_opt.
step_per_iter)->default_value(5,
"5"),
"print chameleon results after X steps")
126 (
"fine_sweeps", po::value<size_t>(&sim.
test_opt.
fine_sweeps)->default_value(3,
"3"),
"number of sweeps on fine grid")
127 (
"coarse_sweeps", po::value<size_t>(&sim.
test_opt.
coarse_sweeps)->default_value(3,
"3"),
"number of sweeps on coarse grids")
128 (
"max_steps", po::value<size_t>(&sim.
test_opt.
max_steps)->default_value(1,
"1"),
"max number of V-cycles")
129 (
"verbose", po::value<bool>(&sim.
test_opt.
verbose)->default_value(
true,
"true"),
"verbosity")
134 cmdline_options.add(
generic).add(config_mesh).add(config_power).add(config_integ);
135 cmdline_options.add(config_output).add(config_app).add(config_run);
136 cmdline_options.add(mod_grav);
138 config_test.add(cmdline_options);
139 po::variables_map vm;
141 po::store(po::parse_command_line(ac, av, config_test), vm);
144 if (vm.count(
"help")) {
145 std::cout << std::setprecision(3) << cmdline_options;
148 else if (vm.count(
"version")) {
152 else if (vm.count(
"config")) {
153 std::ifstream ifs(config_file.c_str());
155 BOOST_LOG_TRIVIAL(debug) <<
"Using configuration options defined in file " << config_file <<
" (given command line options have higher priority).";
156 po::store(po::parse_config_file(ifs, config_test), vm);
160 BOOST_LOG_TRIVIAL(warning) <<
"Cannot open config file '" << config_file <<
"'. Using default and command lines values.";
164 if (no_run) sim.
reset();
matter_power_spectrum_t matter_power_spectrum_method
: class storing simulation parameters
transfer_function_t transfer_function_method
system include files and for project-specific include files that are used frequently but are changed ...
Grid< NDIM, T > sqrt(Grid< NDIM, T > lhs)
various simulation parameters
baryons_power_spectrum_t baryons_power_spectrum_method
command line arguments manipulation
mass_function_t mass_function_method
void handle_cmd_line(int ac, const char *const av[], Sim_Param &sim)
parse command line arguments