Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
params.hpp
Go to the documentation of this file.
1 
9 #pragma once
10 #include "stdafx.h"
11 #include <ccl_defs.h>
12 #include <ccl_config.h>
13 #include <ccl_core.h>
14 #include <map>
15 #include "precision.hpp"
16 
23 {
24 public:
25  // CONSTRUCTORS, DESTRUCTOR
26  void init();
27  Cosmo_Param();
28  ~Cosmo_Param();
29 
30  // CCL VARIABLES
33 
34  // COSMOLOGY (flat LCDM)
35  FTYPE_t ns, k2_G, sigma8;
36  FTYPE_t Omega_m, Omega_b, H0, h;
37  FTYPE_t Omega_c() const { return Omega_m - Omega_b; }
38  FTYPE_t Omega_L() const { return 1 - Omega_m; }
39 
40  // TRUNCATION OF INITIAL POWER SPECTRUM
41  bool truncated_pk = false;
42 
43  // PRECOMPUTED VALUES
44  FTYPE_t D_norm;
45 
46  // DEALING WITH GSL 'void* param'
47  explicit operator void*() const;
48 };
49 
55 struct Box_Opt {
56  void init(const Cosmo_Param& cosmo);
57  /* cmd args */
58  size_t par_num_1d, mesh_num, mesh_num_pwr;
59  FTYPE_t box_size;
60  /* derived param*/
61  size_t par_num, Ng, Ng_pwr;
62  FTYPE_t mass_p_log;
63 };
64 
70 struct Integ_Opt {
71  void init();
72  FTYPE_t z_in, z_out, db;
73  FTYPE_t a_in, a_out;
74 };
75 
76 
82 struct Out_Opt {
83  void init();
84  /* cmd args */
85  size_t print_every, bins_per_decade, points_per_10_Mpc;
86  std::string out_dir; //< where to save output of the simulation
87  bool print_par_pos, print_dens, print_pwr, print_extrap_pwr, print_corr, print_vel_pwr;
88  /* derived param*/
89  bool get_rho, get_pwr, get_pk_extrap;
90 };
91 
92 
98 struct Comp_App {
99  /* cmd args */
100  bool ZA, TZA, FF, FP, AA, FP_pp; //< approximations
101  bool PM; //< PM codes
102  bool chi, chi_ff; //< modified gravities
103  void reset();
104  bool is_ready();
105 };
106 
107 
113 struct App_Opt {
114  void init(const Box_Opt&);
115  /* cmd args */
116  FTYPE_t nu, rs;
117  /* derived param*/
118  FTYPE_t Hc, a, nu_dim;
119  size_t M;
120 };
121 
122 
128 struct Run_Opt {
129  void init();
130  void reset();
131  bool is_ready();
132  bool simulate();
133  /* cmd args */
134  size_t nt, nt_fftw, mlt_runs;
135  size_t seed;
136  bool pair;
137  /* other*/
138  bool phase = true;
139 };
140 
146 struct Test_Opt {
147  /* cmd args */
148  FTYPE_t R_sphere, rho_sphere;
149  size_t fine_sweeps, coarse_sweeps, max_steps, step_per_iter;
150  size_t N_grid, N_min;
151  bool verbose;
152 
153  /* derived param*/
154  FTYPE_t rho_b;
155 };
156 
157 // define Range outside because of SWIG
163 struct Range { FTYPE_t lower, upper; };
164 
170 struct Other_par {
171  void init(const Box_Opt&);
172  // k-range where to use (linear) interpolation and k-range in which print 'pwr_spec_extrap_*'
174  Range k_print, x_corr;
175  std::map<std::string,FTYPE_t> nyquist; //< Nyquist frequencies of potential mesh, analyses mesh and particle separation
176 };
177 
183 struct Chi_Opt {
184  /* cmd args */
185  FTYPE_t beta, n, phi;
186  bool linear;
187 };
188 
194 {
195 public:
196  // CONSTRUCTOR
197  Sim_Param(){}; //< from simpy and partial initialization
198  Sim_Param(int ac, const char* const av[]); //< load from command line arguments
199  Sim_Param(std::string file_name); //< load from sim_param.json file
200 
201  // VARIABLES
212 
213  // METHODS
214  void print_info(std::string out, std::string app) const;
215  void print_info() const;
216  FTYPE_t x_0() const{return box_opt.box_size/box_opt.mesh_num;}
217  FTYPE_t x_0_pwr() const{return box_opt.box_size/box_opt.mesh_num_pwr;}
218  bool simulate() { return run_opt.simulate(); }
219  void reset();
220  bool is_ready();
221 };
Chi_Opt chi_opt
Definition: params.hpp:210
Sim_Param()
Definition: params.hpp:197
double box_size
Definition: params.hpp:59
ccl_cosmology * cosmo
Definition: params.hpp:32
bool simulate()
Definition: params.hpp:218
testing options
Definition: params.hpp:146
size_t par_num
Definition: params.hpp:61
specify which approximations are run
Definition: params.hpp:98
Box_Opt box_opt
Definition: params.hpp:202
double h
Definition: params.hpp:36
chameleon options
Definition: params.hpp:183
double D_norm
Definition: params.hpp:44
: class storing simulation parameters
Definition: params.hpp:193
size_t mesh_num_pwr
Definition: params.hpp:58
Comp_App comp_app
Definition: params.hpp:205
ccl_configuration config
Definition: params.hpp:31
size_t M
Definition: params.hpp:119
size_t nt_fftw
Definition: params.hpp:134
size_t step_per_iter
Definition: params.hpp:149
bool linear
Definition: params.hpp:186
run options
Definition: params.hpp:128
double Omega_b
Definition: params.hpp:36
double nu_dim
Definition: params.hpp:118
size_t par_num_1d
Definition: params.hpp:58
double mass_p_log
logarithm of particle mass in
Definition: params.hpp:62
system include files and for project-specific include files that are used frequently but are changed ...
double rho_sphere
Definition: params.hpp:148
double Omega_L() const
Definition: params.hpp:38
cosmological & CCL parameters
Definition: params.hpp:22
Cosmo_Param cosmo
Definition: params.hpp:206
double upper
Definition: params.hpp:163
bool pair
Definition: params.hpp:136
double H0
Definition: params.hpp:36
static double beta[2][28][8]
Definition: ccl_emu17.c:32
void init()
lazy constructor
Definition: params.cpp:305
bool chi_ff
Definition: params.hpp:102
double x_0_pwr() const
Definition: params.hpp:217
other parameters
Definition: params.hpp:170
Test_Opt test_opt
Definition: params.hpp:211
Integ_Opt integ_opt
Definition: params.hpp:203
Out_Opt out_opt
Definition: params.hpp:204
Range x_corr
Definition: params.hpp:174
size_t print_every
Definition: params.hpp:85
std::map< std::string, double > nyquist
Definition: params.hpp:175
double Omega_c() const
Definition: params.hpp:37
bool get_rho
Definition: params.hpp:89
double z_out
Definition: params.hpp:72
bool PM
Definition: params.hpp:101
lower and upper boundaries
Definition: params.hpp:163
double k2_G
Definition: params.hpp:35
approximations options
Definition: params.hpp:113
single / double / long double definitions
bool ZA
Definition: params.hpp:100
integration options
Definition: params.hpp:70
size_t seed
Definition: params.hpp:135
double ns
Definition: params.hpp:35
Run_Opt run_opt
Definition: params.hpp:208
bool truncated_pk
Definition: params.hpp:41
double Omega_m
Definition: params.hpp:36
~Cosmo_Param()
Definition: params.cpp:330
bool print_vel_pwr
Definition: params.hpp:87
double x_0() const
Definition: params.hpp:216
double phi
Definition: params.hpp:185
double rho_b
Definition: params.hpp:154
size_t mesh_num
Definition: params.hpp:58
App_Opt app_opt
Definition: params.hpp:207
std::string out_dir
Definition: params.hpp:86
output options
Definition: params.hpp:82
double a_out
derived parameters
Definition: params.hpp:73
size_t N_min
Definition: params.hpp:150
bool simulate()
Definition: params.cpp:365
Other_par other_par
Definition: params.hpp:209
simulation box options
Definition: params.hpp:55
double sigma8
Definition: params.hpp:35
bool verbose
Definition: params.hpp:151
double rs
Definition: params.hpp:116