Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
app_var.cpp
Go to the documentation of this file.
1 
8 #include "app_var.hpp"
9 #include "core_out.h"
10 #include "core_app.h"
11 #include "core_mesh.h"
12 
13 #include <algorithm>
14 #include <iomanip>
15 #include <sstream>
16 
17 namespace {
18 const char *humanSize(uint64_t bytes){
19  char const *suffix[] = {"B", "KB", "MB", "GB", "TB"};
20  char length = sizeof(suffix) / sizeof(suffix[0]);
21 
22  size_t i = 0;
23  double dblBytes = bytes;
24 
25  if (bytes > 1024) {
26  for (i = 0; (bytes / 1024) > 0 && i<length-1; i++, bytes /= 1024)
27  dblBytes = bytes / 1024.0;
28  }
29 
30  static char output[200];
31  sprintf(output, "%.02lf %s", dblBytes, suffix[i]);
32  return output;
33 }
34 
35 void print_mem(uint64_t memory_alloc)
36 {
37  BOOST_LOG_TRIVIAL(debug) << "Allocated " << humanSize(memory_alloc) << " of memory.";
38 }
39 
45 class Tracking
46 {
47 public:
48  // CONSTRUCTOR
49  Tracking(size_t sqr_num_track_par, size_t par_num_per_dim)
50  {
51  set_par_ids(sqr_num_track_par, par_num_per_dim);
52  }
53 
54  // METHODS
55  size_t get_num_track_par() const
56  {
57  return par_ids.size();
58  }
59 
60  size_t get_num_steps() const
61  {
62  return par_pos.size();
63  }
64 
65  template <class T> void update_track_par(const std::vector<T>& particles)
66  {
67  std::vector<Particle_x<FTYPE_t>> par_pos_step;
68  par_pos_step.reserve(par_ids.size());
69  for (size_t i=0; i < par_ids.size(); i++){
70  par_pos_step.emplace_back(particles[par_ids[i]].position);
71  }
72  par_pos.push_back(par_pos_step);
73  }
74 
75  void print_track_par(const Sim_Param &sim, std::string out_dir, std::string suffix) const
76  {
77  out_dir += "par_cut/";
78  std::string file_name = out_dir + "track_par_pos" + suffix + ".dat";
79  Ofstream File(file_name);
80 
81  FTYPE_t x,y,z;
82  const FTYPE_t x_0 = sim.x_0();
83  BOOST_LOG_TRIVIAL(debug) << "Writing positons of " << par_ids.size() << " tracked particles into file " << file_name;
84  File << "# This file contains positions of particles in units [Mpc/h].\n"
85  "# x [Mpc/h]\tz [Mpc/h]";
86  for (size_t i=0; i < par_ids.size(); i++){
87  for (const auto& par_pos_step : par_pos){
88  x = par_pos_step[i].position[0];
89  y = par_pos_step[i].position[1];
90  z = par_pos_step[i].position[2];
91  File << x*x_0 << "\t" << z*x_0 << "\t" << y*x_0 << "\n";
92  }
93  File << "\n\n";
94  }
95  }
96 
97 private:
98  void set_par_ids(size_t sqr_num_track_par, size_t par_num_per_dim)
99  {
100  size_t num_track_par = sqr_num_track_par*sqr_num_track_par;
101  par_ids.reserve(num_track_par);
102  size_t x, y, z;
103  FTYPE_t s;
104  y = par_num_per_dim / 2; // middle of the cube
105  s = par_num_per_dim / FTYPE_t(4*(sqr_num_track_par+1)); // quarter of the cube
106  for (size_t i=1; i<=sqr_num_track_par;i++)
107  {
108  z = (size_t)(s*i);
109  for (size_t j=1; j<=sqr_num_track_par;j++)
110  {
111  x = (size_t)(s*j);
112  par_ids.push_back(x*par_num_per_dim*par_num_per_dim+y*par_num_per_dim+z);
113  }
114  }
115  }
116 
117  // VARIABLES
118  std::vector<size_t> par_ids;
119  std::vector<std::vector<Particle_x<FTYPE_t>>> par_pos;
120 };
121 
122 // ******************************
123 }// * END OF ANONYMOUS NAMESPACE *
124 // ******************************
125 
131 template <class T>
132 class App_Var<T>::Impl
133 {
134 public:
135  // CONSTRUCTOR
136  Impl(const Sim_Param &sim, const std::string& app_short, const std::string& app_long):
137  step(0), print_every(sim.out_opt.print_every),
138  app_str(app_short), app_long(app_long), z_suffix_const("_" + app_short + "_"), out_dir_app(std_out_dir(app_short + "_run/", sim)),
139  track(4, sim.box_opt.par_num_1d),
140  a(sim.integ_opt.a_in), a_out(sim.integ_opt.a_out), da(sim.integ_opt.db),
141  is_init_pwr_spec_0(false), is_init_vel_pwr_spec_0(false)
142  {}
143 
144  // ALLOCATE MEMORY
145  uint64_t alloc_mesh_vec(App_Var<T>& APP)
146  {
147  APP.app_field.reserve(3);
148  APP.power_aux.reserve(3);
149  for(size_t i = 0; i < 3; i++){
150  APP.app_field.emplace_back(APP.sim.box_opt.mesh_num);
151  APP.power_aux.emplace_back(APP.sim.box_opt.mesh_num_pwr);
152  }
153 
154  return sizeof(FTYPE_t)*(APP.app_field[0].length*APP.app_field.size()+APP.power_aux[0].length*APP.power_aux.size());
155  }
156 
157  uint64_t alloc_bin_spec(App_Var<T>& APP)
158  {
159  size_t bin_num = (size_t)ceil(log10(APP.sim.box_opt.mesh_num_pwr)*APP.sim.out_opt.bins_per_decade);
160  APP.pwr_spec_binned.reserve(bin_num);
161  APP.pwr_spec_binned_0.reserve(bin_num);
162  APP.vel_pwr_spec_binned_0.reserve(bin_num);
163 
164  return sizeof(FTYPE_t)*APP.pwr_spec_binned.dim()*APP.pwr_spec_binned.size()*3;
165  }
166 
167  uint64_t alloc_bin_corr(App_Var<T>& APP)
168  {
169  size_t bin_num = (size_t)ceil((APP.sim.other_par.x_corr.upper - APP.sim.other_par.x_corr.lower)/ 10. * APP.sim.out_opt.points_per_10_Mpc);
170  APP.corr_func_binned.reserve(bin_num);
171 
172  return sizeof(FTYPE_t)*APP.corr_func_binned.dim()*APP.corr_func_binned.size();
173  }
174 
176  {
177  APP.particles.resize(APP.sim.box_opt.par_num); //< use resize instead of reserve for initialization of particles
178  return sizeof(T)*APP.sim.box_opt.par_num;
179  }
180 
182  {
183  const Sim_Param& sim = APP.sim; // get rid of 'APP.sim'
184 
185  if (!FFTW_PLAN_OMP_INIT()){
186  throw std::runtime_error("Errors during multi-thread initialization");
187  }
189 
190 
191 
192  const size_t N_pot = sim.box_opt.mesh_num;
193  const size_t N_pwr = sim.box_opt.mesh_num_pwr;
194 
195  APP.p_F = FFTW_PLAN_R2C(N_pot, N_pot, N_pot, APP.app_field[0].real(), APP.app_field[0].complex(), FFTW_ESTIMATE);
196  APP.p_B = FFTW_PLAN_C2R(N_pot, N_pot, N_pot, APP.app_field[0].complex(), APP.app_field[0].real(), FFTW_ESTIMATE);
197  APP.p_F_pwr = FFTW_PLAN_R2C(N_pwr, N_pwr, N_pwr, APP.power_aux[0].real(), APP.power_aux[0].complex(), FFTW_ESTIMATE);
198  APP.p_B_pwr = FFTW_PLAN_C2R(N_pwr, N_pwr, N_pwr, APP.power_aux[0].complex(), APP.power_aux[0].real(), FFTW_ESTIMATE);
199  }
200 
201  /*********************
202  * INITIAL CONDITIONS *
203  *********************/
204 
206  {
207  set_pert_pos(APP.sim, APP.sim.integ_opt.a_in, APP.particles, APP.app_field);
208  }
209 
211  {
212  /* Generating the right density distribution in k-space */
213  gen_rho_dist_k(APP.sim, APP.app_field[0], APP.p_F);
214 
215  /* Print input power spectrum (one realisation), before Zel`dovich push */
216  if (print_every && APP.sim.out_opt.print_pwr) print_input_realisation(APP);
217 
218  /* Computing initial potential in k-space */
219  gen_pot_k(APP.app_field[0], APP.power_aux[0]);
220 
221  /* Computing displacement in k-space */
222  gen_displ_k(APP.app_field, APP.power_aux[0]);
223 
224  /* Computing displacement in q-space */
225  BOOST_LOG_TRIVIAL(debug) << "Computing displacement in q-space...";
227 
228  /* Set initial positions of particles (with or without velocities) */
229  set_init_pos(APP);
230  }
231 
232  // PUBLIC PRINTING
233  const std::string app_str, app_long, z_suffix_const, out_dir_app;
234 
235  void print_sim_name() const
236  {
237  std::string app_long_upper(app_long);
238  std::transform(app_long_upper.begin(), app_long_upper.end(), app_long_upper.begin(), ::toupper);
239  BOOST_LOG_TRIVIAL(info) << "Starting: " << app_long_upper;
240  }
241 
242  void print_end()
243  {
244  BOOST_LOG_TRIVIAL(info) << app_long << " ended successfully.";
245  }
246 
247  std::string z_suffix() const
248  {
249  std::stringstream z_suffix_num;
250  z_suffix_num << std::fixed << std::setprecision(2) << z();
251  return z_suffix_const + "z" + z_suffix_num.str();
252  }
253 
255  {
256  /* Print input power spectrum (one realisation), before Zel`dovich push */
257  pwr_spec_k_init(APP.app_field[0], APP.power_aux[0]);
258  gen_pow_spec_binned_init(APP.sim, APP.power_aux[0], APP.app_field[0].length/2, APP.pwr_spec_binned_0);
259  pwr_spec_input.init(APP.pwr_spec_binned_0);
260  print_pow_spec(APP.pwr_spec_binned_0, out_dir_app, z_suffix_const + "init");
261  }
262 
264  {
265  const Out_Opt& out_opt = APP.sim.out_opt;
266 
267  /* Printing positions */
268  if (out_opt.print_par_pos) print_position(APP);
269 
270  /* Get discrete density from particles */
271  if (out_opt.get_rho) get_rho_from_par(APP.particles, APP.power_aux[0], APP.sim);
272 
273  /* Printing density */
274  if (out_opt.print_dens) print_density(APP);
275 
276  /* Compute power spectrum and bin it */
277  if (out_opt.get_pwr) get_binned_power_spec(APP);
278 
279  /* Printing power spectrum */
280  if (out_opt.print_pwr) print_power_spec(APP);
281 
282  /* Extrapolate power spectrum beyond range of simulation box */
283  if (out_opt.get_pk_extrap){
284  const Extrap_Pk<FTYPE_t, 2> P_k(APP.pwr_spec_binned, APP.sim);
285  /* Print extrapolated power spectrum */
286  if (out_opt.print_extrap_pwr) print_extrap_pwr(APP, P_k);
287  /* Printing correlation function */
288  if (out_opt.print_corr) print_corr(APP, P_k);
289  }
290 
291  /* Velocity power spectrum */
292  if (out_opt.print_vel_pwr && get_vel_from_par(APP.particles, APP.power_aux, APP.sim)) print_vel_pwr(APP);
293  }
294 
295  // CREATE WORKING DIRECTORY STRUCTURE
296  void create_work_dir(const Out_Opt& out_opt)
297  {
298  create_dir(out_dir_app + "log/");
299  if (print_every)
300  {
301  if (out_opt.print_corr) create_dir(out_dir_app + "corr_func/");
302  if (out_opt.print_par_pos) create_dir(out_dir_app + "par_cut/");
303  if (out_opt.print_pwr)
304  {
305  create_dir(out_dir_app + "pwr_diff/");
306  create_dir(out_dir_app + "pwr_spec/");
307  }
308  if (out_opt.print_dens)
309  {
310  create_dir(out_dir_app + "rho_bin/");
311  create_dir(out_dir_app + "rho_map/");
312  }
313 
314  if (out_opt.print_vel_pwr)
315  {
316  create_dir(out_dir_app + "vel_pwr_diff/");
317  create_dir(out_dir_app + "vel_pwr_spec/");
318  }
319  }
320  }
321 
322  // INTEGRATION
323  FTYPE_t a, a_out, da;
324 
326  {
327  print_init(APP); // WARNING: power_aux[0] is modified
328  while(integrate())
329  {
330  BOOST_LOG_TRIVIAL(info) << "Starting computing step with z = " << z() << " (a = " << a << ")";
331  APP.upd_pos();
332  track.update_track_par(APP.particles);
333  if (printing()) APP.print_output();
334  upd_time();
335  }
336  print_info(APP.sim);
337  }
338 
339 private:
340  // PRIVATE PRINTING
341  unsigned int print_every, step;
342  Tracking track;
344 
345  bool printing() const
346  {
347  return print_every ? ((step % print_every) == 0) or (a == a_out) : false ;
348  }
349 
350  void print_info(const Sim_Param& sim) const
351  {
352  sim.print_info(out_dir_app, app_str);
353  }
354 
355  void print_position(const App_Var<T>& APP) const
356  {/* Printing positions */
357  print_par_pos_cut_small(APP.particles, APP.sim, out_dir_app, z_suffix());
358  track.print_track_par(APP.sim, out_dir_app, z_suffix());
359  }
360 
361  void print_density(App_Var<T>& APP) const
362  {/* Printing density */
363  gen_dens_binned(APP.power_aux[0], APP.dens_binned, APP.sim);
364  print_rho_map(APP.power_aux[0], APP.sim, out_dir_app, z_suffix());
365  print_dens_bin(APP.dens_binned, out_dir_app, z_suffix());
366  }
367 
369  {/* Compute power spectrum and bin it */
371  pwr_spec_k(APP.power_aux[0], APP.power_aux[0]);
373  }
374 
376  {/* Printing power spectrum */
377  print_pow_spec(APP.pwr_spec_binned, out_dir_app, "_par" + z_suffix());
378  if (!is_init_pwr_spec_0){
380  D_init = growth_factor(a, APP.sim.cosmo);
381  is_init_pwr_spec_0 = true;
382  }
383  FTYPE_t D_now = growth_factor(a, APP.sim.cosmo);
384  print_pow_spec_diff(APP.pwr_spec_binned, APP.pwr_spec_binned_0, D_now / D_init, out_dir_app, "_par" + z_suffix());
385  print_pow_spec_diff(APP.pwr_spec_binned, pwr_spec_input, D_now, out_dir_app, "_input" + z_suffix());
386  print_pow_spec_diff(APP.pwr_spec_binned, APP.pwr_spec_binned_0, pwr_spec_input, D_now, D_init,
387  out_dir_app, "_hybrid" + z_suffix());
388  }
389 
390 
391  void print_extrap_pwr(App_Var<T>& APP, const Extrap_Pk<FTYPE_t, 2>& P_k) const
392  {/* Print extrapolated power spectrum */
394  print_pow_spec(APP.pwr_spec_binned, out_dir_app, "_extrap" + z_suffix());
395  }
396 
397  void print_corr(App_Var<T>& APP, const Extrap_Pk<FTYPE_t, 2>& P_k) const
398  {/* Printing correlation function */
400  print_corr_func(APP.corr_func_binned, out_dir_app, "_gsl_qawf_par" + z_suffix());
402  print_corr_func(APP.corr_func_binned, out_dir_app, "_gsl_qawf_lin" + z_suffix());
403  }
404 
406  {/* Print velocity power spectrum */
408  vel_pwr_spec_k(APP.power_aux, APP.power_aux[0]);
410  print_vel_pow_spec(APP.pwr_spec_binned, out_dir_app, z_suffix());
411  if (!is_init_vel_pwr_spec_0){
413  is_init_vel_pwr_spec_0 = true;
414  dDda_init = growth_change(a, APP.sim.cosmo);
415  }
416  print_vel_pow_spec_diff(APP.pwr_spec_binned, APP.vel_pwr_spec_binned_0, growth_change(a, APP.sim.cosmo) / dDda_init, out_dir_app, z_suffix());
417  }
418 
420  {
421  /* Setting initial (binned) power spectrum, WARNING: power_aux[0] is modified */
422  track.update_track_par(APP.particles);
423  if (print_every) APP.print_output();
424  upd_time();
425  }
426 
427  // INTEGRATION
428  FTYPE_t D_init, dDda_init;
429  bool is_init_pwr_spec_0, is_init_vel_pwr_spec_0;
430 
431  bool integrate() const
432  {
433  return (a <= a_out) && (da > 0);
434  }
435 
436  void upd_time()
437  {
438  step++;
439  if ((a_out - a) < da) da = a_out - a;
440  a += da;
441  }
442 
443 
444  FTYPE_t z() const
445  {
446  return 1/a - 1;
447  }
448 };
449 
450 template <class T>
451 App_Var<T>::App_Var(const Sim_Param &sim, const std::string& app_short, const std::string& app_long):
452  m_impl(new Impl(sim, app_short, app_long)), sim(sim), dens_binned(500)
453 {
454  // EFFICIENTLY ALLOCATE MEMORY
455  memory_alloc = m_impl->alloc_mesh_vec(*this); // app_field, power_aux
456  memory_alloc += m_impl->alloc_bin_spec(*this); // pwr_spec_binned, pwr_spec_binned_0, vel_pwr_spec_binned_0
457  memory_alloc += m_impl->alloc_bin_corr(*this); // corr_func_binned
458  memory_alloc += m_impl->alloc_particles(*this); // particles
459 
460  // CREAT SUBDIR STRUCTURE
461  m_impl->create_work_dir(sim.out_opt);
462 
463  // FFTW PREPARATION
464  m_impl->fftw_prep(*this); // fftw omp, fftw plans
465 }
466 
467 template <class T>
469 { // FFTW CLEANUP
475 }
476 
477 template <class T>
479 {
480  // print simulation name
481  m_impl->print_sim_name();
482 
483  // print memory usage
485 
486  // set initial conditions
487  m_impl->set_init_cond(*this);
488 
489  // CIC correction of potential (if not overriden)
491 
492  // integration
493  m_impl->integration(*this);
494 
495  // end of simulation
496  m_impl->print_end();
497 }
498 
499 template <class T>
501 {
502  cosmo.truncated_pk = false;
503 }
504 
505 template <class T>
506 void App_Var<T>::pot_corr(std::vector<Mesh>& vel_field, Mesh& pot_k)
507 {
508  /* Computing displacement in k-space with CIC opt */
509  gen_displ_k_cic(vel_field, pot_k);
510 
511  /* Computing force in q-space */
512  BOOST_LOG_TRIVIAL(debug) << "Computing force in q-space...";
513  fftw_execute_dft_c2r_triple(p_B, vel_field);
514 }
515 
516 template <class T>
518 {
519  m_impl->print_output(*this);
520 }
521 
522 template <class T>
523 FTYPE_t App_Var<T>::a()
524 {
525  return m_impl->a;
526 }
527 
528 template <class T>
530 {
531  return a() - da()/2.;
532 }
533 
534 template <class T>
535 FTYPE_t App_Var<T>::da()
536 {
537  return m_impl->da;
538 }
539 
540 template <class T>
541 std::string App_Var<T>::get_out_dir() const
542 {
543  return m_impl->out_dir_app;
544 }
545 
546 template <class T>
547 std::string App_Var<T>::get_z_suffix() const
548 {
549  return m_impl->z_suffix();
550 }
551 
552 template class App_Var<Particle_x<FTYPE_t>>;
553 template class App_Var<Particle_v<FTYPE_t>>;
void print_rho_map(const Mesh &delta, const Sim_Param &sim, std::string out_dir, std::string suffix)
Definition: core_out.cpp:317
void gen_pow_spec_binned_from_extrap(const Sim_Param &sim, const P &P_k, Data_Vec< T, N > &pwr_spec_binned)
Definition: core_app.cpp:478
class containing core variables and methods for approximations
Definition: app_var.hpp:41
bool print_pwr
Definition: params.hpp:87
double a_in
Definition: params.hpp:73
virtual void pot_corr(std::vector< Mesh > &vel_field, Mesh &pot_k)
Definition: app_var.cpp:506
Interp_obj pwr_spec_input
Definition: app_var.cpp:343
void print_vel_pow_spec_diff(const Data_Vec< double, 2 > &pwr_spec_binned, const Data_Vec< double, 2 > &pwr_spec_binned_0, double dDda, std::string out_dir, std::string suffix)
Definition: core_out.cpp:294
bool is_init_vel_pwr_spec_0
Definition: app_var.cpp:429
bool get_vel_from_par(const std::vector< Particle_v< double >> &particles, std::vector< Mesh > &vel_field, const Sim_Param &sim)
Definition: core_app.cpp:300
void print_output(App_Var< T > &APP)
Definition: app_var.cpp:263
std::string std_out_dir(const std::string &pre_subdir, const Sim_Param &sim)
Definition: core_out.cpp:53
size_t par_num
Definition: params.hpp:61
void get_rho_from_par(const std::vector< T > &particles, Mesh &rho, const Sim_Param &sim)
Definition: core_app.cpp:278
void print_position(const App_Var< T > &APP) const
Definition: app_var.cpp:355
void gen_rho_dist_k(const Sim_Param &sim, Mesh &rho, const FFTW_PLAN_TYPE &p_F)
Generate density distributions in k-space.
Definition: core_app.cpp:267
void gen_corr_func_binned_gsl_qawf_lin(const Sim_Param &sim, double a, Data_Vec< double, 2 > &corr_func_binned)
compute linear correlation function and store results
Definition: core_power.cpp:673
void print_vel_pwr(App_Var< T > &APP)
Definition: app_var.cpp:405
functions handling output of the program
FFTW_PLAN_TYPE p_F_pwr
Definition: app_var.hpp:69
void print_init(App_Var< T > &APP)
Definition: app_var.cpp:419
uint64_t memory_alloc
Definition: app_var.hpp:60
void print_mem(uint64_t memory_alloc)
Definition: app_var.cpp:35
App_Var(const Sim_Param &sim, const std::string &app_short, const std::string &app_long)
Definition: app_var.cpp:451
: linear interpolation (Steffen) of data [x, y]
Definition: core_power.h:96
Box_Opt box_opt
Definition: params.hpp:202
Tracking track
Definition: app_var.cpp:342
void set_pert_pos(const Sim_Param &sim, const double a, std::vector< Particle_x< double >> &particles, const std::vector< Mesh > &vel_field)
Definition: core_app.cpp:114
void print_power_spec(App_Var< T > &APP)
Definition: app_var.cpp:375
void gen_displ_k(std::vector< Mesh > &vel_field, const Mesh &pot_k)
Definition: core_app.cpp:623
: class storing simulation parameters
Definition: params.hpp:193
size_t size() const noexcept
void fftw_execute_dft_r2c(const FFTW_PLAN_TYPE &p_F, Mesh &rho)
compute forward (real to complex) FFT on mesh (inplace)
Definition: core_mesh.cpp:247
size_t mesh_num_pwr
Definition: params.hpp:58
uint64_t alloc_bin_spec(App_Var< T > &APP)
Definition: app_var.cpp:157
uint64_t alloc_particles(App_Var< T > &APP)
Definition: app_var.cpp:175
void gen_corr_func_binned_gsl_qawf(const Sim_Param &sim, const P &P_k, Data_Vec< double, 2 > &corr_func_binned)
compute correlation function and store results
Definition: core_power.cpp:665
Data_Vec< double, 2 > vel_pwr_spec_binned_0
Definition: app_var.hpp:68
size_t points_per_10_Mpc
Definition: params.hpp:85
void print_dens_bin(const std::vector< size_t > &dens_binned, std::string out_dir, std::string suffix)
Definition: core_out.cpp:402
: creates a mesh of N*N*(N+2) cells
Definition: class_mesh.hpp:95
void fftw_prep(App_Var< T > &APP)
Definition: app_var.cpp:181
std::string z_suffix() const
Definition: app_var.cpp:247
void fftw_execute_dft_c2r_triple(const FFTW_PLAN_TYPE &p_B, std::vector< Mesh > &rho)
compute three backward (complex to real) FFTs on vector of meshes (inplace)
Definition: core_mesh.cpp:263
std::vector< std::vector< Particle_x< double > > > par_pos
Definition: app_var.cpp:119
void print_pow_spec(const Data_Vec< double, 2 > &pwr_spec_binned, std::string out_dir, std::string suffix)
Definition: core_out.cpp:134
size_t nt_fftw
Definition: params.hpp:134
void print_info(const Sim_Param &sim) const
Definition: app_var.cpp:350
FFTW_PLAN_TYPE p_F
Definition: app_var.hpp:69
double dDda_init
Definition: app_var.cpp:428
bool get_pk_extrap
Definition: params.hpp:89
void print_vel_pow_spec(const Data_Vec< double, 2 > &pwr_spec_binned, std::string out_dir, std::string suffix)
Definition: core_out.cpp:154
std::vector< size_t > dens_binned
Definition: app_var.hpp:70
Impl(const Sim_Param &sim, const std::string &app_short, const std::string &app_long)
Definition: app_var.cpp:136
#define FFTW_PLAN_C2R
Definition: precision.hpp:30
void print_corr(App_Var< T > &APP, const Extrap_Pk< double, 2 > &P_k) const
Definition: app_var.cpp:397
void run_simulation()
Definition: app_var.cpp:478
bool printing() const
Definition: app_var.cpp:345
bool print_dens
Definition: params.hpp:87
void gen_pot_k(const Mesh &rho_k, Mesh &pot_k)
Definition: core_app.cpp:496
std::vector< Mesh > app_field
Definition: app_var.hpp:63
Data_Vec< double, 2 > pwr_spec_binned
Definition: app_var.hpp:68
void gen_pow_spec_binned(const Sim_Param &sim, const Mesh &power_aux, Data_Vec< double, 2 > &pwr_spec_binned)
Definition: core_app.cpp:460
cosmological & CCL parameters
Definition: params.hpp:22
Cosmo_Param cosmo
Definition: params.hpp:206
std::string get_z_suffix() const
Definition: app_var.cpp:547
double upper
Definition: params.hpp:163
void upd_time()
Definition: app_var.cpp:436
bool print_corr
Definition: params.hpp:87
bool get_pwr
Definition: params.hpp:89
#define FFTW_PLAN_OMP_CLEAN
Definition: precision.hpp:33
void create_dir(const std::string &out_dir)
Definition: core_out.cpp:74
interface for common functions for all types of approximations
void print_extrap_pwr(App_Var< T > &APP, const Extrap_Pk< double, 2 > &P_k) const
Definition: app_var.cpp:391
Data_Vec< double, 2 > corr_func_binned
Definition: app_var.hpp:68
static CCL_BEGIN_DECLS double x[111][8]
double a()
Definition: app_var.cpp:523
Integ_Opt integ_opt
Definition: params.hpp:203
void set_par_ids(size_t sqr_num_track_par, size_t par_num_per_dim)
Definition: app_var.cpp:98
std::string get_out_dir() const
Definition: app_var.cpp:541
Out_Opt out_opt
Definition: params.hpp:204
void print_pow_spec_diff(const Data_Vec< double, 2 > &pwr_spec_binned, const Data_Vec< double, 2 > &pwr_spec_binned_0, double growth, std::string out_dir, std::string suffix)
Definition: core_out.cpp:211
const char * humanSize(uint64_t bytes)
Definition: app_var.cpp:18
void gen_dens_binned(const Mesh &rho, std::vector< size_t > &dens_binned, const Sim_Param &sim)
Definition: core_app.cpp:627
Range x_corr
Definition: params.hpp:174
#define FFTW_PLAN_OMP
Definition: precision.hpp:31
classes handling approximations data
std::vector< T > particles
Definition: app_var.hpp:65
void get_binned_power_spec(App_Var< T > &APP) const
Definition: app_var.cpp:368
bool integrate() const
Definition: app_var.cpp:431
void print_end()
Definition: app_var.cpp:242
void print_track_par(const Sim_Param &sim, std::string out_dir, std::string suffix) const
Definition: app_var.cpp:75
virtual ~App_Var()
Definition: app_var.cpp:468
bool get_rho
Definition: params.hpp:89
void vel_pwr_spec_k(const std::vector< Mesh > &vel_field, Mesh &power_aux)
Definition: core_app.cpp:366
double lower
Definition: params.hpp:163
FFTW_PLAN_TYPE p_B
Definition: app_var.hpp:69
void pwr_spec_k(const Mesh &rho_k, Mesh &power_aux)
Definition: core_app.cpp:324
void print_corr_func(const Data_Vec< double, 2 > &pwr_spec_binned, std::string out_dir, std::string suffix)
Definition: core_out.cpp:174
Tracking(size_t sqr_num_track_par, size_t par_num_per_dim)
Definition: app_var.cpp:49
void gen_pow_spec_binned_init(const Sim_Param &sim, const Mesh &power_aux, const size_t half_length, Data_Vec< double, 2 > &pwr_spec_binned)
Definition: core_app.cpp:468
void update_track_par(const std::vector< T > &particles)
Definition: app_var.cpp:65
static double z[8]
void set_init_cond(App_Var< T > &APP)
Definition: app_var.cpp:210
virtual void upd_pos()=0
unsigned int step
Definition: app_var.cpp:341
const std::unique_ptr< Impl > m_impl
Definition: app_var.hpp:87
void create_work_dir(const Out_Opt &out_opt)
Definition: app_var.cpp:296
: linear interpolation of data [k, P(k)] within &#39;useful&#39; range fit to primordial P_i(k) below the &#39;us...
Definition: core_power.h:122
void reserve(size_t n)
void set_init_pos(App_Var< T > &APP)
Definition: app_var.cpp:205
Run_Opt run_opt
Definition: params.hpp:208
void print_par_pos_cut_small(const std::vector< T > &particles, const Sim_Param &sim, std::string out_dir, std::string suffix)
Definition: core_out.cpp:109
void print_sim_name() const
Definition: app_var.cpp:235
basic functions to work with mesh
size_t bins_per_decade
Definition: params.hpp:85
bool truncated_pk
Definition: params.hpp:41
void pwr_spec_k_init(const Mesh &rho_k, Mesh &power_aux)
Definition: core_app.cpp:349
bool print_vel_pwr
Definition: params.hpp:87
#define FFTW_PLAN_OMP_INIT
Definition: precision.hpp:32
double a_half()
Definition: app_var.cpp:529
Data_Vec< double, 2 > pwr_spec_binned_0
Definition: app_var.hpp:68
double x_0() const
Definition: params.hpp:216
virtual void print_output()
Definition: app_var.cpp:517
double da()
Definition: app_var.cpp:535
size_t mesh_num
Definition: params.hpp:58
void print_input_realisation(App_Var< T > &APP)
Definition: app_var.cpp:254
void print_info(std::string out, std::string app) const
Definition: params.cpp:497
FFTW_PLAN_TYPE p_B_pwr
Definition: app_var.hpp:69
: class storing info about tracked particles
Definition: app_var.cpp:45
void fftw_execute_dft_r2c_triple(const FFTW_PLAN_TYPE &p_F, std::vector< Mesh > &rho)
compute three forward (real to complex) FFTs on vector of meshes (inplace)
Definition: core_mesh.cpp:258
void gen_displ_k_cic(std::vector< Mesh > &vel_field, const Mesh &pot_k)
Definition: core_app.cpp:625
bool print_extrap_pwr
Definition: params.hpp:87
output options
Definition: params.hpp:82
const std::string z_suffix_const
Definition: app_var.cpp:233
std::vector< Mesh > power_aux
Definition: app_var.hpp:64
void integration(App_Var< T > &APP)
Definition: app_var.cpp:325
#define FFTW_DEST_PLAN
Definition: precision.hpp:27
Other_par other_par
Definition: params.hpp:209
void print_density(App_Var< T > &APP) const
Definition: app_var.cpp:361
const Sim_Param & sim
Definition: app_var.hpp:59
uint64_t alloc_mesh_vec(App_Var< T > &APP)
Definition: app_var.cpp:145
virtual void update_cosmo(Cosmo_Param &cosmo)
no truncation by default
Definition: app_var.cpp:500
double z() const
Definition: app_var.cpp:444
size_t dim() const noexcept
bool print_par_pos
Definition: params.hpp:87
double growth_change(double a, const Cosmo_Param &cosmo)
Definition: core_power.cpp:447
#define FFTW_PLAN_R2C
Definition: precision.hpp:29
uint64_t alloc_bin_corr(App_Var< T > &APP)
Definition: app_var.cpp:167