Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
anonymous_namespace{core_power.cpp} Namespace Reference

Classes

class  Integr_obj
 basic integration object, wrapper for GSL integration functions More...
 
class  Integr_obj_qag
 QAG adaptive integration. More...
 
class  Integr_obj_qagiu
 QAGI adaptive integration on infinite intervals. More...
 
class  Integr_obj_qawf
 QAWF adaptive integration for Fourier integrals. More...
 
class  Integr_obj_qawo
 QAWO adaptive integration for oscillatory functions. More...
 
struct  integrand_param
 general integrand with callable function and one parameter More...
 
class  ODE_Solver
 : Explicit embedded Runge-Kutta Prince-Dormand (8, 9) method. More...
 

Functions

template<typename T >
hubble_param (T a, const Cosmo_Param &cosmo)
 
double growth_factor_integrand (double a, void *params)
 
double growth_factor (double a, void *params)
 
double ln_growth_factor (double log_a, void *parameters)
 
template<typename T >
size_t get_nearest (const T val, const std::vector< T > &vec)
 
template<class P >
double xi_integrand_W (double k, void *params)
 integrand for correlation function when weight-function 'sin(kr)' is used in integration More...
 
template<class P >
double xi_integrand_G (double k, void *params)
 integrand for correlation function when non-weighted integration is used More...
 
template<class P >
double sigma_integrand_G (double k, void *params)
 integrand for amplitude of mass fluctuaton when non-weighted integration is used More...
 
template<class P , class T >
void gen_fce_r_binned_gsl (const double x_min, const double x_max, const double lin_bin, const P &P_k, Data_Vec< double, 2 > &fce_binned, T &fce_r)
 compute given function in linear range and store results More...
 
template<class P , class T >
void gen_corr_func_binned_gsl (const Sim_Param &sim, const P &P_k, Data_Vec< double, 2 > &corr_func_binned, T &xi_r)
 compute correlation function and store results More...
 
template<class P , class T >
void gen_sigma_func_binned_gsl (const Sim_Param &sim, const P &P_k, Data_Vec< double, 2 > &sigma_binned, T &sigma_r)
 compute amplitude of density fluctuation and store results More...
 

Variables

constexpr double GSL_EPSABS = 1e-7
 absolute error at z = 0, scales for higher redshifts More...
 
constexpr size_t GSL_LIMIT = 1000
 max. number of subintervals for adaptive integration More...
 
constexpr size_t GSL_N = 100
 max. number of bisections of integration interval (QAWO / QAWF) More...
 

Detailed Description

PRIVATE FUNCTIONS DEFINITIONS *

Function Documentation

template<class P , class T >
void anonymous_namespace{core_power.cpp}::gen_corr_func_binned_gsl ( const Sim_Param sim,
const P &  P_k,
Data_Vec< double, 2 > &  corr_func_binned,
T &  xi_r 
)

compute correlation function and store results

Template Parameters
Pcallable object with 'operator()(double)'
Tcallable object with 'operator()(double)'
Parameters
simsimulation parameters
P_kpower spectrum (callable)
corr_func_binnedobject to store binned correlation function
xi_rcorrelation function at given r (callable)

Definition at line 362 of file core_power.cpp.

References gen_fce_r_binned_gsl(), Range::lower, Sim_Param::other_par, Sim_Param::out_opt, Out_Opt::points_per_10_Mpc, Range::upper, and Other_par::x_corr.

Referenced by gen_corr_func_binned_gsl_qawf().

363 {
364  const double x_min = sim.other_par.x_corr.lower;
365  const double x_max = sim.other_par.x_corr.upper;
366  const double lin_bin = 10./sim.out_opt.points_per_10_Mpc;
367  gen_fce_r_binned_gsl(x_min, x_max, lin_bin, P_k, corr_func_binned, xi_r);
368 }
void gen_fce_r_binned_gsl(const double x_min, const double x_max, const double lin_bin, const P &P_k, Data_Vec< double, 2 > &fce_binned, T &fce_r)
compute given function in linear range and store results
Definition: core_power.cpp:335
size_t points_per_10_Mpc
Definition: params.hpp:85
double upper
Definition: params.hpp:163
Out_Opt out_opt
Definition: params.hpp:204
Range x_corr
Definition: params.hpp:174
double lower
Definition: params.hpp:163
Other_par other_par
Definition: params.hpp:209
template<class P , class T >
void anonymous_namespace{core_power.cpp}::gen_fce_r_binned_gsl ( const double  x_min,
const double  x_max,
const double  lin_bin,
const P &  P_k,
Data_Vec< double, 2 > &  fce_binned,
T &  fce_r 
)

compute given function in linear range and store results

Template Parameters
Pcallable object with 'operator()(double)'
Tcallable object with 'operator()(double)'
Parameters
x_minstarting radius of function evaluation
x_maxlast radius of function evaluation
lin_binlinear step between function evaluations
P_kpower spectrum (callable)
fce_binnedobject to store binned function
fce_rcallable function

Definition at line 335 of file core_power.cpp.

References anonymous_namespace{core_power.cpp}::integrand_param< P >::r, and Data_Vec< T, N >::resize().

Referenced by gen_corr_func_binned_gsl(), and gen_sigma_func_binned_gsl().

336 {
337  const size_t req_size = (size_t)ceil((x_max - x_min)/lin_bin);
338 
339  fce_binned.resize(req_size);
340  integrand_param<P> my_param(0, P_k);
341 
342  for(size_t i = 0; i < req_size; i++){
343  double r = x_min + i*lin_bin;
344  my_param.r = r;
345  fce_binned[0][i] = r;
346  fce_binned[1][i] = fce_r(r, &my_param);
347  }
348 }
void resize(size_t n)
template<class P , class T >
void anonymous_namespace{core_power.cpp}::gen_sigma_func_binned_gsl ( const Sim_Param sim,
const P &  P_k,
Data_Vec< double, 2 > &  sigma_binned,
T &  sigma_r 
)

compute amplitude of density fluctuation and store results

Template Parameters
Pcallable object with 'operator()(double)'
Tcallable object with 'operator()(double)'
Parameters
simsimulation parameters
P_kpower spectrum (callable)
sigma_binnedobject to store binned amplitude of density fluctuation
sigma_ramplitude of density fluctuation at given r (callable)

Definition at line 382 of file core_power.cpp.

References gen_fce_r_binned_gsl(), Range::lower, Sim_Param::other_par, Sim_Param::out_opt, Out_Opt::points_per_10_Mpc, Range::upper, and Other_par::x_corr.

Referenced by gen_sigma_binned_gsl_qawf().

383 {
384  const double x_min = sim.other_par.x_corr.lower;
385  const double x_max = sim.other_par.x_corr.upper;
386  const double lin_bin = 10./sim.out_opt.points_per_10_Mpc;
387  gen_fce_r_binned_gsl(x_min, x_max, lin_bin, P_k, sigma_binned, sigma_r);
388 }
void gen_fce_r_binned_gsl(const double x_min, const double x_max, const double lin_bin, const P &P_k, Data_Vec< double, 2 > &fce_binned, T &fce_r)
compute given function in linear range and store results
Definition: core_power.cpp:335
size_t points_per_10_Mpc
Definition: params.hpp:85
double upper
Definition: params.hpp:163
Out_Opt out_opt
Definition: params.hpp:204
Range x_corr
Definition: params.hpp:174
double lower
Definition: params.hpp:163
Other_par other_par
Definition: params.hpp:209
template<typename T >
size_t anonymous_namespace{core_power.cpp}::get_nearest ( const T  val,
const std::vector< T > &  vec 
)

Definition at line 260 of file core_power.cpp.

261 { // assume data in 'vec' are ordered, vec[0] < vec[1] < ...
262  return lower_bound(vec.begin(), vec.end(), val) - vec.begin();
263 }
double anonymous_namespace{core_power.cpp}::growth_factor ( double  a,
void *  params 
)

Definition at line 249 of file core_power.cpp.

References growth_factor().

250 {
251  return growth_factor(a, *static_cast<const Cosmo_Param*>(params));
252 }
double growth_factor(double a, const Cosmo_Param &cosmo)
Definition: core_power.cpp:414
dictionary params
Definition: halomod_bm.py:27
double anonymous_namespace{core_power.cpp}::growth_factor_integrand ( double  a,
void *  params 
)

Definition at line 244 of file core_power.cpp.

References hubble_param(), and pow().

Referenced by growth_factor(), and norm_growth_factor().

245 {
246  return pow(a*hubble_param(a, *static_cast<const Cosmo_Param*>(params)), -3);
247 }
T hubble_param(T a, const Cosmo_Param &cosmo)
Definition: core_power.cpp:239
dictionary params
Definition: halomod_bm.py:27
float pow(float base, unsigned long int exp)
Definition: precision.hpp:39
template<typename T >
T anonymous_namespace{core_power.cpp}::hubble_param ( a,
const Cosmo_Param cosmo 
)

Definition at line 239 of file core_power.cpp.

References Cosmo_Param::Omega_L(), Cosmo_Param::Omega_m, pow(), and sqrt().

Referenced by growth_factor(), and growth_factor_integrand().

240 { // hubble normalize to H(a = 1) == 1
241  return sqrt(cosmo.Omega_m/pow(a, 3) + cosmo.Omega_L());
242 }
double Omega_L() const
Definition: params.hpp:38
Grid< NDIM, T > sqrt(Grid< NDIM, T > lhs)
Definition: grid.h:231
double Omega_m
Definition: params.hpp:36
float pow(float base, unsigned long int exp)
Definition: precision.hpp:39
double anonymous_namespace{core_power.cpp}::ln_growth_factor ( double  log_a,
void *  parameters 
)

Definition at line 254 of file core_power.cpp.

References growth_factor().

Referenced by growth_rate().

255 {
256  return log(growth_factor(exp(log_a), parameters));
257 }
double growth_factor(double a, const Cosmo_Param &cosmo)
Definition: core_power.cpp:414
template<class P >
double anonymous_namespace{core_power.cpp}::sigma_integrand_G ( double  k,
void *  params 
)

integrand for amplitude of mass fluctuaton when non-weighted integration is used

Template Parameters
P
Parameters
k
params
Returns
double

Definition at line 307 of file core_power.cpp.

References anonymous_namespace{core_power.cpp}::integrand_param< P >::P_k, PI, anonymous_namespace{core_power.cpp}::integrand_param< P >::r, and w.

307  {
308  integrand_param<P>* my_par = (integrand_param<P>*) params;
309  const double kr = k*my_par->r;
310  const double w = kr < 0.1 ?
311  1.-0.1*kr*kr+0.003571429*kr*kr*kr*kr
312  -6.61376E-5*kr*kr*kr*kr*kr*kr
313  +7.51563E-7*kr*kr*kr*kr*kr*kr*kr*kr
314  :
315  3.*(sin(kr) - kr*cos(kr))/(kr*kr*kr);
316 
317  const P& P_k = my_par->P_k;
318  return 1/(2*PI*PI)*k*k*w*w*P_k(k);
319 };
dictionary params
Definition: halomod_bm.py:27
constexpr double PI
Definition: precision.hpp:37
static double w[2][28][111]
Definition: ccl_emu17.c:33
template<class P >
double anonymous_namespace{core_power.cpp}::xi_integrand_G ( double  k,
void *  params 
)

integrand for correlation function when non-weighted integration is used

Template Parameters
Pcallable object with 'operator()(double)'
Parameters
k
params
Returns
double

Definition at line 290 of file core_power.cpp.

References anonymous_namespace{core_power.cpp}::integrand_param< P >::P_k, PI, and anonymous_namespace{core_power.cpp}::integrand_param< P >::r.

290  {
291  integrand_param<P>* my_par = (integrand_param<P>*) params;
292  const double kr = k*my_par->r;
293  double j0 = kr < 1e-6 ? 1 - kr*kr/6. : sin(kr) / (kr);
294  const P& P_k = my_par->P_k;
295  return 1/(2*PI*PI)*k*k*j0*P_k(k);
296 };
dictionary params
Definition: halomod_bm.py:27
constexpr double PI
Definition: precision.hpp:37
template<class P >
double anonymous_namespace{core_power.cpp}::xi_integrand_W ( double  k,
void *  params 
)

integrand for correlation function when weight-function 'sin(kr)' is used in integration

Template Parameters
Pcallable object with 'operator()(double)'
Parameters
k
params
Returns
double

Definition at line 274 of file core_power.cpp.

References anonymous_namespace{core_power.cpp}::integrand_param< P >::P_k, PI, and anonymous_namespace{core_power.cpp}::integrand_param< P >::r.

274  {
275  integrand_param<P>* my_par = (integrand_param<P>*) params;
276  const double r = my_par->r;
277  const P& P_k = my_par->P_k;
278  return 1/(2*PI*PI)*k/r*P_k(k);
279 };
dictionary params
Definition: halomod_bm.py:27
constexpr double PI
Definition: precision.hpp:37

Variable Documentation

constexpr double anonymous_namespace{core_power.cpp}::GSL_EPSABS = 1e-7

absolute error at z = 0, scales for higher redshifts

Definition at line 390 of file core_power.cpp.

Referenced by get_gsl_error().

constexpr size_t anonymous_namespace{core_power.cpp}::GSL_LIMIT = 1000

max. number of subintervals for adaptive integration

Definition at line 391 of file core_power.cpp.

Referenced by gen_corr_func_binned_gsl_qawf(), and gen_sigma_binned_gsl_qawf().

constexpr size_t anonymous_namespace{core_power.cpp}::GSL_N = 100

max. number of bisections of integration interval (QAWO / QAWF)

Definition at line 392 of file core_power.cpp.

Referenced by gen_corr_func_binned_gsl_qawf(), and gen_sigma_binned_gsl_qawf().