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

definitions of cosmological functions like power spectrum, growth, etc. More...

#include "core_power.h"
#include "class_data_vec.hpp"
#include "params.hpp"
#include <ccl_background.h>
#include <ccl_power.h>
#include <gsl/gsl_deriv.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_fit.h>
#include <gsl/gsl_integration.h>
#include <gsl/gsl_odeiv2.h>
#include <gsl/gsl_spline.h>
Include dependency graph for core_power.cpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

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

Namespaces

 anonymous_namespace{core_power.cpp}
 

Functions

template<typename T >
anonymous_namespace{core_power.cpp}::hubble_param (T a, const Cosmo_Param &cosmo)
 
double anonymous_namespace{core_power.cpp}::growth_factor_integrand (double a, void *params)
 
double anonymous_namespace{core_power.cpp}::growth_factor (double a, void *params)
 
double anonymous_namespace{core_power.cpp}::ln_growth_factor (double log_a, void *parameters)
 
template<typename T >
size_t anonymous_namespace{core_power.cpp}::get_nearest (const T val, const std::vector< T > &vec)
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
void norm_pwr (Cosmo_Param &cosmo)
 < end of anonymous namespace (private definitions) More...
 
double norm_growth_factor (const Cosmo_Param &cosmo)
 when computing growth factor outside CCL range we need to normalize the growth factor; $D(a=1)\equiv1$ More...
 
double growth_factor (double a, const Cosmo_Param &cosmo)
 
double growth_rate (double a, const Cosmo_Param &cosmo)
 
double growth_change (double a, const Cosmo_Param &cosmo)
 
double Omega_lambda (double a, const Cosmo_Param &cosmo)
 
double lin_pow_spec (double a, double k, const Cosmo_Param &cosmo)
 
double non_lin_pow_spec (double a, double k, const Cosmo_Param &cosmo)
 
static double truncation_fce (double k, double k2_G)
 
template<class P >
static double get_gsl_error (const Cosmo_Param &cosmo, const P &P_k)
 
template<class P >
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 More...
 
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 More...
 
void gen_corr_func_binned_gsl_qawf_nl (const Sim_Param &sim, double a, Data_Vec< double, 2 > &corr_func_binned)
 compute non-linear correlation function and store results More...
 
template<class P >
void gen_sigma_binned_gsl_qawf (const Sim_Param &sim, const P &P_k, Data_Vec< double, 2 > &sigma_binned)
 compute amplitude of density fluctuation and store results More...
 
void gen_sigma_func_binned_gsl_qawf_lin (const Sim_Param &sim, double a, Data_Vec< double, 2 > &sigma_binned)
 compute linear amplitude of density fluctuation and store results More...
 
void gen_sigma_func_binned_gsl_qawf_nl (const Sim_Param &sim, double a, Data_Vec< double, 2 > &sigma_binned)
 compute non-linear amplitude of density fluctuation and store results More...
 
template void gen_corr_func_binned_gsl_qawf (const Sim_Param &, const Extrap_Pk< double, 2 > &, Data_Vec< double, 2 > &)
 
template void gen_corr_func_binned_gsl_qawf (const Sim_Param &, const Extrap_Pk< double, 3 > &, Data_Vec< double, 2 > &)
 
template void gen_corr_func_binned_gsl_qawf (const Sim_Param &, const Extrap_Pk_Nl< double, 2 > &, Data_Vec< double, 2 > &)
 
template void gen_corr_func_binned_gsl_qawf (const Sim_Param &, const Extrap_Pk_Nl< double, 3 > &, Data_Vec< double, 2 > &)
 
template void gen_sigma_binned_gsl_qawf (const Sim_Param &, const Extrap_Pk< double, 2 > &, Data_Vec< double, 2 > &)
 
template void gen_sigma_binned_gsl_qawf (const Sim_Param &, const Extrap_Pk< double, 3 > &, Data_Vec< double, 2 > &)
 
template void gen_sigma_binned_gsl_qawf (const Sim_Param &, const Extrap_Pk_Nl< double, 2 > &, Data_Vec< double, 2 > &)
 
template void gen_sigma_binned_gsl_qawf (const Sim_Param &, const Extrap_Pk_Nl< double, 3 > &, Data_Vec< double, 2 > &)
 

Variables

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

Detailed Description

definitions of cosmological functions like power spectrum, growth, etc.

Author
Michal Vrastil
Date
2018-06-23

Definition in file core_power.cpp.

Function Documentation

template<class P >
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

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

Definition at line 665 of file core_power.cpp.

References Sim_Param::cosmo, anonymous_namespace{core_power.cpp}::gen_corr_func_binned_gsl(), get_gsl_error(), anonymous_namespace{core_power.cpp}::GSL_LIMIT, and anonymous_namespace{core_power.cpp}::GSL_N.

Referenced by gen_corr_func_binned_gsl_qawf_lin(), gen_corr_func_binned_gsl_qawf_nl(), gen_sigma_func_binned_gsl_qawf_nl(), and App_Var< T >::Impl< T >::print_corr().

666 {
667  BOOST_LOG_TRIVIAL(debug) << "Computing correlation function via GSL integration QAWF...";
668  const double gsp_epsabs = get_gsl_error(sim.cosmo, P_k);
669  Integr_obj_qawf xi_r(&xi_integrand_W<P>, 0, gsp_epsabs, GSL_LIMIT, GSL_N);
670  gen_corr_func_binned_gsl(sim, P_k, corr_func_binned, xi_r);
671 }
constexpr size_t GSL_LIMIT
max. number of subintervals for adaptive integration
Definition: core_power.cpp:391
Cosmo_Param cosmo
Definition: params.hpp:206
static double get_gsl_error(const Cosmo_Param &cosmo, const P &P_k)
Definition: core_power.cpp:656
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
Definition: core_power.cpp:362
constexpr size_t GSL_N
max. number of bisections of integration interval (QAWO / QAWF)
Definition: core_power.cpp:392
template void gen_corr_func_binned_gsl_qawf ( const Sim_Param ,
const Extrap_Pk< double, 2 > &  ,
Data_Vec< double, 2 > &   
)
template void gen_corr_func_binned_gsl_qawf ( const Sim_Param ,
const Extrap_Pk< double, 3 > &  ,
Data_Vec< double, 2 > &   
)
template void gen_corr_func_binned_gsl_qawf ( const Sim_Param ,
const Extrap_Pk_Nl< double, 2 > &  ,
Data_Vec< double, 2 > &   
)
template void gen_corr_func_binned_gsl_qawf ( const Sim_Param ,
const Extrap_Pk_Nl< double, 3 > &  ,
Data_Vec< double, 2 > &   
)
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

Parameters
simsimulation parameters
ascale factor
corr_func_binnedobject to store binned correlation function

Definition at line 673 of file core_power.cpp.

References Sim_Param::cosmo, gen_corr_func_binned_gsl_qawf(), and lin_pow_spec().

Referenced by App_Var< T >::Impl< T >::print_corr().

674 {
675  auto P_k = [&](FTYPE_t k){ return lin_pow_spec(a, k, sim.cosmo); };
676  gen_corr_func_binned_gsl_qawf(sim, P_k, corr_func_binned);
677 }
double lin_pow_spec(double a, double k, const Cosmo_Param &cosmo)
Definition: core_power.cpp:474
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
Cosmo_Param cosmo
Definition: params.hpp:206
void gen_corr_func_binned_gsl_qawf_nl ( const Sim_Param sim,
double  a,
Data_Vec< double, 2 > &  corr_func_binned 
)

compute non-linear correlation function and store results

Parameters
simsimulation parameters
ascale factor
corr_func_binnedobject to store binned correlation function

Definition at line 679 of file core_power.cpp.

References Sim_Param::cosmo, gen_corr_func_binned_gsl_qawf(), and non_lin_pow_spec().

680 {
681  auto P_k = [&](FTYPE_t k){ return non_lin_pow_spec(a, k, sim.cosmo); };
682  gen_corr_func_binned_gsl_qawf(sim, P_k, corr_func_binned);
683 }
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
double non_lin_pow_spec(double a, double k, const Cosmo_Param &cosmo)
Definition: core_power.cpp:486
Cosmo_Param cosmo
Definition: params.hpp:206
template<class P >
void gen_sigma_binned_gsl_qawf ( const Sim_Param sim,
const P &  P_k,
Data_Vec< double, 2 > &  sigma_binned 
)

compute amplitude of density fluctuation and store results

Template Parameters
Pcallable object with 'operator()(double)'
Parameters
simsimulation parameters
P_kpower spectrum (callable)
sigma_binnedobject to store binned correlation function

Definition at line 686 of file core_power.cpp.

References Sim_Param::cosmo, anonymous_namespace{core_power.cpp}::gen_sigma_func_binned_gsl(), get_gsl_error(), anonymous_namespace{core_power.cpp}::GSL_LIMIT, and anonymous_namespace{core_power.cpp}::GSL_N.

Referenced by gen_sigma_func_binned_gsl_qawf_lin(), and gen_sigma_func_binned_gsl_qawf_nl().

687 {
688  BOOST_LOG_TRIVIAL(debug) << "Computing mass fluctuations via GSL integration QAWF...";
689  const double gsp_epsabs = get_gsl_error(sim.cosmo, P_k);
690  Integr_obj_qagiu sigma_r(&sigma_integrand_G<P>, 0, gsp_epsabs, GSL_LIMIT, GSL_N);
691  gen_sigma_func_binned_gsl(sim, P_k, sigma_binned, sigma_r);
692 }
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
Definition: core_power.cpp:382
constexpr size_t GSL_LIMIT
max. number of subintervals for adaptive integration
Definition: core_power.cpp:391
Cosmo_Param cosmo
Definition: params.hpp:206
static double get_gsl_error(const Cosmo_Param &cosmo, const P &P_k)
Definition: core_power.cpp:656
constexpr size_t GSL_N
max. number of bisections of integration interval (QAWO / QAWF)
Definition: core_power.cpp:392
template void gen_sigma_binned_gsl_qawf ( const Sim_Param ,
const Extrap_Pk< double, 2 > &  ,
Data_Vec< double, 2 > &   
)
template void gen_sigma_binned_gsl_qawf ( const Sim_Param ,
const Extrap_Pk< double, 3 > &  ,
Data_Vec< double, 2 > &   
)
template void gen_sigma_binned_gsl_qawf ( const Sim_Param ,
const Extrap_Pk_Nl< double, 2 > &  ,
Data_Vec< double, 2 > &   
)
template void gen_sigma_binned_gsl_qawf ( const Sim_Param ,
const Extrap_Pk_Nl< double, 3 > &  ,
Data_Vec< double, 2 > &   
)
void gen_sigma_func_binned_gsl_qawf_lin ( const Sim_Param sim,
double  a,
Data_Vec< double, 2 > &  sigma_binned 
)

compute linear amplitude of density fluctuation and store results

Parameters
simsimulation parameters
ascale factor
sigma_binnedobject to store binned correlation function

Definition at line 694 of file core_power.cpp.

References Sim_Param::cosmo, gen_sigma_binned_gsl_qawf(), and lin_pow_spec().

695 {
696  auto P_k = [&](FTYPE_t k){ return lin_pow_spec(a, k, sim.cosmo); };
697  gen_sigma_binned_gsl_qawf(sim, P_k, sigma_binned);
698 }
double lin_pow_spec(double a, double k, const Cosmo_Param &cosmo)
Definition: core_power.cpp:474
Cosmo_Param cosmo
Definition: params.hpp:206
void gen_sigma_binned_gsl_qawf(const Sim_Param &sim, const P &P_k, Data_Vec< double, 2 > &sigma_binned)
compute amplitude of density fluctuation and store results
Definition: core_power.cpp:686
void gen_sigma_func_binned_gsl_qawf_nl ( const Sim_Param sim,
double  a,
Data_Vec< double, 2 > &  sigma_binned 
)

compute non-linear amplitude of density fluctuation and store results

Parameters
simsimulation parameters
ascale factor
sigma_binnedobject to store binned correlation function

Definition at line 700 of file core_power.cpp.

References Sim_Param::cosmo, gen_corr_func_binned_gsl_qawf(), gen_sigma_binned_gsl_qawf(), Interp_obj::init(), and non_lin_pow_spec().

701 {
702  auto P_k = [&](FTYPE_t k){ return non_lin_pow_spec(a, k, sim.cosmo); };
703  gen_sigma_binned_gsl_qawf(sim, P_k, sigma_binned);
704 }
double non_lin_pow_spec(double a, double k, const Cosmo_Param &cosmo)
Definition: core_power.cpp:486
Cosmo_Param cosmo
Definition: params.hpp:206
void gen_sigma_binned_gsl_qawf(const Sim_Param &sim, const P &P_k, Data_Vec< double, 2 > &sigma_binned)
compute amplitude of density fluctuation and store results
Definition: core_power.cpp:686
template<class P >
static double get_gsl_error ( const Cosmo_Param cosmo,
const P &  P_k 
)
static

Definition at line 656 of file core_power.cpp.

References anonymous_namespace{core_power.cpp}::GSL_EPSABS, and lin_pow_spec().

Referenced by gen_corr_func_binned_gsl_qawf(), and gen_sigma_binned_gsl_qawf().

657 {
658  const FTYPE_t k_ref = 0.1;
659  double ratio = P_k(k_ref) / lin_pow_spec(1, k_ref, cosmo);
660  BOOST_LOG_TRIVIAL(debug) << "\tSet absolute error to " << GSL_EPSABS*ratio;
661  return GSL_EPSABS*ratio;
662 }
double lin_pow_spec(double a, double k, const Cosmo_Param &cosmo)
Definition: core_power.cpp:474
constexpr double GSL_EPSABS
absolute error at z = 0, scales for higher redshifts
Definition: core_power.cpp:390
double growth_change ( double  a,
const Cosmo_Param cosmo 
)
Parameters
a
cosmocosmological parameters
Returns
FTYPE_t

Definition at line 447 of file core_power.cpp.

References cl_cmbl_bm::cosmo, growth_factor(), and growth_rate().

Referenced by kick_step_no_momentum(), App_Var_Chi::ChiImpl::kick_step_w_chi_no_momentum(), App_Var< T >::Impl< T >::print_vel_pwr(), set_pert_pos(), and TEST_CASE().

448 {
449  if (a){
450  // compute with growth rate
451  return growth_rate(a, cosmo)*growth_factor(a, cosmo)/a;
452  }
453  else{
454  gsl_function F = {&growth_factor, static_cast<void*>(cosmo)};
455  double dDda, error;
456  int status = gsl_deriv_forward(&F, a, 1e-12, &dDda, &error);
457  if (!status) return dDda;
458  else throw std::runtime_error("GSL ODE error: " + std::string(gsl_strerror(status)));
459  }
460 }
double growth_factor(double a, const Cosmo_Param &cosmo)
Definition: core_power.cpp:414
double growth_rate(double a, const Cosmo_Param &cosmo)
Definition: core_power.cpp:429
double growth_factor ( double  a,
const Cosmo_Param cosmo 
)
Parameters
a
cosmocosmological parameters
Returns
FTYPE_t

Definition at line 414 of file core_power.cpp.

References ccl_growth_factor(), Cosmo_Param::cosmo, Cosmo_Param::D_norm, anonymous_namespace{core_power.cpp}::growth_factor_integrand(), and anonymous_namespace{core_power.cpp}::hubble_param().

Referenced by growth_change(), anonymous_namespace{core_power.cpp}::growth_factor(), lin_pow_spec(), and anonymous_namespace{core_power.cpp}::ln_growth_factor().

415 {
416  // D(0) == 0; D(1) == 1, do not check (not often, better performance)
417  if (!a) return 0;
418 
419  // try ccl range
420  int status = 0;
421  FTYPE_t D_ccl = ccl_growth_factor(cosmo.cosmo, a, &status);
422  if (!status) return D_ccl;
423 
424  // integrate outside range
425  Integr_obj_qag D(&growth_factor_integrand, 0, a, 0, 1e-12, 1000, GSL_INTEG_GAUSS61);
426  return hubble_param(a, cosmo)*D(static_cast<void*>(cosmo))/cosmo.D_norm;
427 }
ccl_cosmology * cosmo
Definition: params.hpp:32
double D_norm
Definition: params.hpp:44
double ccl_growth_factor(ccl_cosmology *cosmo, double a, int *status)
T hubble_param(T a, const Cosmo_Param &cosmo)
Definition: core_power.cpp:239
double growth_factor_integrand(double a, void *params)
Definition: core_power.cpp:244
double growth_rate ( double  a,
const Cosmo_Param cosmo 
)
Parameters
a
cosmocosmological parameters
Returns
FTYPE_t

Definition at line 429 of file core_power.cpp.

References ccl_growth_rate(), cl_cmbl_bm::cosmo, Cosmo_Param::cosmo, and anonymous_namespace{core_power.cpp}::ln_growth_factor().

Referenced by growth_change(), and TEST_CASE().

430 {
431  // f(0) == 1
432  if (!a) return 1;
433 
434  // try ccl range
435  int status = 0;
436  double f = ccl_growth_rate(cosmo.cosmo, a, &status);
437  if (!status) return f;
438 
439  // logarithmic derivative outside range
440  gsl_function F = {&ln_growth_factor, static_cast<void*>(cosmo)};
441  double error;
442  status = gsl_deriv_central(&F, log(a), 1e-12, &f, &error);
443  if (!status) return f;
444  else throw std::runtime_error("GSL ODE error: " + std::string(gsl_strerror(status)));
445 }
ccl_cosmology * cosmo
Definition: params.hpp:32
double ccl_growth_rate(ccl_cosmology *cosmo, double a, int *status)
double ln_growth_factor(double log_a, void *parameters)
Definition: core_power.cpp:254
double lin_pow_spec ( double  a,
double  k,
const Cosmo_Param cosmo 
)
Parameters
a
k
cosmocosmological parameters
Returns
FTYPE_t

Definition at line 474 of file core_power.cpp.

References ccl_linear_matter_power(), Cosmo_Param::cosmo, growth_factor(), Cosmo_Param::h, pow(), and ccl_cosmology::status_message.

Referenced by Extrap_Pk< T, N >::fit_lin(), gen_corr_func_binned_gsl_qawf_lin(), gen_rho_w_pow_k(), gen_sigma_func_binned_gsl_qawf_lin(), get_gsl_error(), non_lin_pow_spec(), Extrap_Pk< T, N >::operator()(), and Extrap_Pk_Nl< T, N >::operator()().

475 {
476  int status = 0;
477  FTYPE_t pk = ccl_linear_matter_power(cosmo.cosmo, k*cosmo.h, a, &status)*pow(cosmo.h, 3);
478  if (!status) return pk;
479  status = 0;
480  pk = ccl_linear_matter_power(cosmo.cosmo, k*cosmo.h, 1, &status)*pow(cosmo.h, 3);
481  FTYPE_t D = growth_factor(a, cosmo);
482  if (!status) return D*D*pk;
483  else throw std::runtime_error(cosmo.cosmo->status_message);
484 }
ccl_cosmology * cosmo
Definition: params.hpp:32
double growth_factor(double a, const Cosmo_Param &cosmo)
Definition: core_power.cpp:414
double h
Definition: params.hpp:36
double ccl_linear_matter_power(ccl_cosmology *cosmo, double k, double a, int *status)
Definition: ccl_power.c:1506
float pow(float base, unsigned long int exp)
Definition: precision.hpp:39
char status_message[500]
Definition: ccl_core.h:136
double non_lin_pow_spec ( double  a,
double  k,
const Cosmo_Param cosmo 
)
Parameters
a
k
cosmocosmological parameters
Returns
FTYPE_t

Definition at line 486 of file core_power.cpp.

References ccl_nonlin_matter_power(), Cosmo_Param::cosmo, Cosmo_Param::h, lin_pow_spec(), pow(), and ccl_cosmology::status_message.

Referenced by gen_corr_func_binned_gsl_qawf_nl(), gen_sigma_func_binned_gsl_qawf_nl(), and Extrap_Pk_Nl< T, N >::operator()().

487 {
488  if (a < 1e-3) return lin_pow_spec(a, k, cosmo);
489  int status = 0;
490  FTYPE_t pk = ccl_nonlin_matter_power(cosmo.cosmo, k*cosmo.h, a, &status)*pow(cosmo.h, 3);
491  if (!status) return pk;
492  else throw std::runtime_error(cosmo.cosmo->status_message);
493 }
ccl_cosmology * cosmo
Definition: params.hpp:32
double lin_pow_spec(double a, double k, const Cosmo_Param &cosmo)
Definition: core_power.cpp:474
double h
Definition: params.hpp:36
double ccl_nonlin_matter_power(ccl_cosmology *cosmo, double k, double a, int *status)
Definition: ccl_power.c:1562
float pow(float base, unsigned long int exp)
Definition: precision.hpp:39
char status_message[500]
Definition: ccl_core.h:136
double norm_growth_factor ( const Cosmo_Param cosmo)

when computing growth factor outside CCL range we need to normalize the growth factor; $D(a=1)\equiv1$

Parameters
cosmocosmological parameters
Returns
FTYPE_t unnormalized growth factor at 'a = 1'

Definition at line 408 of file core_power.cpp.

References anonymous_namespace{core_power.cpp}::growth_factor_integrand().

Referenced by Cosmo_Param::init().

409 {
410  Integr_obj_qag D(&growth_factor_integrand, 0, 1, 0, 1e-12, 1000, GSL_INTEG_GAUSS61);
411  return D(static_cast<void*>(cosmo));
412 }
double growth_factor_integrand(double a, void *params)
Definition: core_power.cpp:244
void norm_pwr ( Cosmo_Param cosmo)

< end of anonymous namespace (private definitions)

declaration in class_data_vec.hpp

PUBLIC FUNCTIONS DEFINITIONS *

Definition at line 400 of file core_power.cpp.

References ccl_sigma8(), Cosmo_Param::cosmo, and ccl_cosmology::status_message.

Referenced by Cosmo_Param::init().

401 {
402  BOOST_LOG_TRIVIAL(debug) << "Initializing CCL power spectrum...";
403  int status = 0;
404  ccl_sigma8(cosmo.cosmo, &status);
405  if (status) throw std::runtime_error(cosmo.cosmo->status_message);
406 }
ccl_cosmology * cosmo
Definition: params.hpp:32
double ccl_sigma8(ccl_cosmology *cosmo, int *status)
Definition: ccl_power.c:1777
char status_message[500]
Definition: ccl_core.h:136
double Omega_lambda ( double  a,
const Cosmo_Param cosmo 
)
Parameters
a
cosmocosmological parameters
Returns
FTYPE_t

Definition at line 462 of file core_power.cpp.

References ccl_omega_x(), ccl_species_l_label, Cosmo_Param::cosmo, Cosmo_Param::Omega_L(), Cosmo_Param::Omega_m, and pow().

463 {
464  // try ccl range
465  int status = 0;
466  FTYPE_t OL = ccl_omega_x(cosmo.cosmo, a, ccl_species_l_label, &status);
467  if(!status) return OL;
468 
469  // compute outside range
470  OL = cosmo.Omega_L();
471  return OL/(cosmo.Omega_m/pow(a, 3) + OL);
472 }
ccl_cosmology * cosmo
Definition: params.hpp:32
double ccl_omega_x(ccl_cosmology *cosmo, double a, ccl_species_x_label label, int *status)
double Omega_L() const
Definition: params.hpp:38
double Omega_m
Definition: params.hpp:36
float pow(float base, unsigned long int exp)
Definition: precision.hpp:39
static double truncation_fce ( double  k,
double  k2_G 
)
static

Definition at line 554 of file core_power.cpp.

Referenced by Extrap_Pk< T, N >::fit_lin().

555 {
556  return exp(-k*k/k2_G);
557 }