|
Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
|
#include <stdio.h>#include <stdlib.h>#include <math.h>#include <gsl/gsl_integration.h>#include <gsl/gsl_interp.h>#include <gsl/gsl_spline.h>#include <gsl/gsl_errno.h>#include <class.h>#include "ccl.h"#include "ccl_params.h"#include "ccl_emu17.h"#include "ccl_emu17_params.h"
Go to the source code of this file.
Classes | |
| struct | eh_struct |
| struct | SigmaR_pars |
| struct | SigmaV_pars |
Functions | |
| static void | ccl_free_class_structs (ccl_cosmology *cosmo, struct background *ba, struct thermo *th, struct perturbs *pt, struct transfers *tr, struct primordial *pm, struct spectra *sp, struct nonlinear *nl, struct lensing *le, int *init_arr, int *status) |
| static void | ccl_class_preinit (struct background *ba, struct thermo *th, struct perturbs *pt, struct transfers *tr, struct primordial *pm, struct spectra *sp, struct nonlinear *nl, struct lensing *le) |
| static void | ccl_run_class (ccl_cosmology *cosmo, struct file_content *fc, struct precision *pr, struct background *ba, struct thermo *th, struct perturbs *pt, struct transfers *tr, struct primordial *pm, struct spectra *sp, struct nonlinear *nl, struct lensing *le, struct output *op, int *init_arr, int *status) |
| static double | ccl_get_class_As (ccl_cosmology *cosmo, struct file_content *fc, int position_As, double sigma8, int *status) |
| static void | ccl_fill_class_parameters (ccl_cosmology *cosmo, struct file_content *fc, int parser_length, int *status) |
| static void | ccl_cosmology_compute_power_class (ccl_cosmology *cosmo, int *status) |
| double | ccl_bcm_model_fka (ccl_cosmology *cosmo, double k, double a, int *status) |
| void | ccl_cosmology_write_power_class_z (char *filename, ccl_cosmology *cosmo, double z, int *status) |
| static eh_struct * | eh_struct_new (ccl_parameters *params) |
| static double | tkEH_0 (double keq, double k, double a, double b) |
| static double | tkEH_c (eh_struct *eh, double k) |
| static double | jbes0 (double x) |
| static double | tkEH_b (eh_struct *eh, double k) |
| static double | tsqr_EH (ccl_parameters *params, eh_struct *eh, double k, int wiggled) |
| static double | eh_power (ccl_parameters *params, eh_struct *eh, double k, int wiggled) |
| static void | ccl_cosmology_compute_power_eh (ccl_cosmology *cosmo, int *status) |
| static double | tsqr_BBKS (ccl_parameters *params, double k) |
| static double | bbks_power (ccl_parameters *params, double k) |
| static void | ccl_cosmology_compute_power_bbks (ccl_cosmology *cosmo, int *status) |
| static void | ccl_cosmology_compute_power_emu (ccl_cosmology *cosmo, int *status) |
| void | ccl_cosmology_compute_power (ccl_cosmology *cosmo, int *status) |
| static double | ccl_power_extrapol_highk (ccl_cosmology *cosmo, double k, double a, gsl_spline2d *powerspl, double kmax_spline, int *status) |
| static double | ccl_power_extrapol_lowk (ccl_cosmology *cosmo, double k, double a, gsl_spline2d *powerspl, double kmin_spline, int *status) |
| double | ccl_linear_matter_power (ccl_cosmology *cosmo, double k, double a, int *status) |
| double | ccl_nonlin_matter_power (ccl_cosmology *cosmo, double k, double a, int *status) |
| static double | w_tophat (double kR) |
| static double | sigmaR_integrand (double lk, void *params) |
| static double | sigmaV_integrand (double lk, void *params) |
| double | ccl_sigmaR (ccl_cosmology *cosmo, double R, double a, int *status) |
| double | ccl_sigmaV (ccl_cosmology *cosmo, double R, double a, int *status) |
| double | ccl_sigma8 (ccl_cosmology *cosmo, int *status) |
|
static |
Definition at line 1007 of file ccl_power.c.
References ccl_parameters::n_s, pow(), and tsqr_BBKS().
Referenced by ccl_cosmology_compute_power_bbks().
| double ccl_bcm_model_fka | ( | ccl_cosmology * | cosmo, |
| double | k, | ||
| double | a, | ||
| int * | status | ||
| ) |
Correction for the impact of baryonic physics on the matter power spectrum. Returns f(k,a) [dimensionless] for given cosmology, using the method specified for the baryonic transfer function. f(k,a) is the fractional change in the nonlinear matter power spectrum from the Baryon Correction Model (BCM) of Schenider & Teyssier (2015). The parameters of the model are passed as part of the cosmology class.
| cosmo | Cosmology parameters and configurations, including baryonic parameters. |
| k | Fourier mode, in [1/Mpc] units |
| a | scale factor, normalized to 1 for today |
| status | Status flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c |
Definition at line 574 of file ccl_power.c.
References ccl_parameters::bcm_etab, ccl_parameters::bcm_ks, ccl_parameters::bcm_log10Mc, ccl_parameters::h, ccl_cosmology::params, pow(), and z.
Referenced by ccl_nonlin_matter_power(), and compare_bcm().
|
static |
| void ccl_cosmology_compute_power | ( | ccl_cosmology * | cosmo, |
| int * | status | ||
| ) |
Compute the power spectrum and create a 2d spline P(k,z) to be stored in the cosmology structure.
| cosmo | Cosmological parameters |
| status | Status flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c |
Definition at line 1403 of file ccl_power.c.
References ccl_bbks, ccl_boltzmann_class, ccl_check_status(), ccl_cosmology_compute_power_bbks(), ccl_cosmology_compute_power_class(), ccl_cosmology_compute_power_eh(), ccl_cosmology_compute_power_emu(), ccl_cosmology_set_status_message(), ccl_eisenstein_hu, ccl_emulator, CCL_ERROR_INCONSISTENT, ccl_cosmology::computed_power, ccl_cosmology::config, and ccl_configuration::transfer_function_method.
Referenced by ccl_linear_matter_power(), and ccl_nonlin_matter_power().
|
static |
Definition at line 1017 of file ccl_power.c.
References ccl_spline_params::A_SPLINE_MAX, ccl_spline_params::A_SPLINE_MIN_PK, ccl_spline_params::A_SPLINE_MINLOG_PK, ccl_spline_params::A_SPLINE_NA_PK, ccl_spline_params::A_SPLINE_NLOG_PK, bbks_power(), ccl_cosmology_set_status_message(), CCL_ERROR_INCONSISTENT, CCL_ERROR_MEMORY, CCL_ERROR_SPLINE, ccl_growth_factor(), ccl_linlog_spacing(), ccl_log_spacing(), ccl_sigma8(), ccl_splines, ccl_cosmology::computed_power, ccl_cosmology::data, ccl_spline_params::K_MAX, ccl_data::k_max_lin, ccl_data::k_max_nl, ccl_spline_params::K_MIN, ccl_data::k_min_lin, ccl_data::k_min_nl, ccl_spline_params::N_K, ccl_data::p_lin, ccl_data::p_nl, ccl_cosmology::params, PLIN_SPLINE_TYPE, PNL_SPLINE_TYPE, ccl_test_power::sigma8, ccl_parameters::sigma8, and x.
Referenced by ccl_cosmology_compute_power().
|
static |
Definition at line 378 of file ccl_power.c.
References ccl_spline_params::A_SPLINE_MAX, ccl_spline_params::A_SPLINE_MIN_PK, ccl_spline_params::A_SPLINE_MINLOG_PK, ccl_spline_params::A_SPLINE_NA_PK, ccl_spline_params::A_SPLINE_NLOG_PK, ccl_cosmology_set_status_message(), CCL_ERROR_CLASS, CCL_ERROR_SPLINE, ccl_fill_class_parameters(), ccl_free_class_structs(), ccl_halofit, ccl_linlog_spacing(), ccl_log_spacing(), ccl_run_class(), ccl_splines, ccl_cosmology::config, ccl_cosmology::data, ccl_data::k_max_lin, ccl_data::k_max_nl, ccl_spline_params::K_MAX_SPLINE, ccl_data::k_min_lin, ccl_data::k_min_nl, ccl_configuration::matter_power_spectrum_method, ccl_spline_params::N_K, run_pk_param_space::nonlinear, ccl_data::p_lin, ccl_data::p_nl, PLIN_SPLINE_TYPE, PNL_SPLINE_TYPE, run_pk_param_space::precision, spectra(), and x.
Referenced by ccl_cosmology_compute_power().
|
static |
Definition at line 842 of file ccl_power.c.
References ccl_spline_params::A_SPLINE_MAX, ccl_spline_params::A_SPLINE_MIN_PK, ccl_spline_params::A_SPLINE_MINLOG_PK, ccl_spline_params::A_SPLINE_NA_PK, ccl_spline_params::A_SPLINE_NLOG_PK, ccl_cosmology_set_status_message(), CCL_ERROR_INCONSISTENT, CCL_ERROR_MEMORY, CCL_ERROR_SPLINE, ccl_growth_factor(), ccl_linlog_spacing(), ccl_log_spacing(), ccl_sigma8(), ccl_splines, ccl_cosmology::computed_power, ccl_cosmology::data, eh_power(), eh_struct_new(), ccl_spline_params::K_MAX, ccl_data::k_max_lin, ccl_data::k_max_nl, ccl_spline_params::K_MIN, ccl_data::k_min_lin, ccl_data::k_min_nl, ccl_spline_params::N_K, ccl_data::p_lin, ccl_data::p_nl, ccl_cosmology::params, PLIN_SPLINE_TYPE, PNL_SPLINE_TYPE, ccl_test_power::sigma8, ccl_parameters::sigma8, and x.
Referenced by ccl_cosmology_compute_power().
|
static |
Definition at line 1158 of file ccl_power.c.
References A_MIN_EMU, ccl_spline_params::A_SPLINE_MAX, ccl_spline_params::A_SPLINE_MIN_PK, ccl_spline_params::A_SPLINE_MINLOG_PK, ccl_spline_params::A_SPLINE_NA_PK, ccl_spline_params::A_SPLINE_NLOG_PK, ccl_data::accelerator, ccl_cosmology_set_status_message(), ccl_emu_equalize, ccl_emu_strict, CCL_ERROR_CLASS, CCL_ERROR_INCONSISTENT, CCL_ERROR_MEMORY, CCL_ERROR_SPLINE, ccl_fill_class_parameters(), ccl_free_class_structs(), ccl_linear_spacing(), ccl_linlog_spacing(), ccl_log_spacing(), ccl_Omeganuh2(), ccl_pkemu(), ccl_run_class(), ccl_splines, ccl_cosmology::config, ccl_cosmology::data, ccl_configuration::emulator_neutrinos_method, ccl_parameters::h, if(), K_MAX_EMU, ccl_data::k_max_lin, ccl_data::k_max_nl, ccl_spline_params::K_MAX_SPLINE, K_MIN_EMU, ccl_data::k_min_lin, ccl_data::k_min_nl, ccl_parameters::mnu, mode, ccl_spline_params::N_K, ccl_parameters::N_nu_mass, ccl_parameters::N_nu_rel, ccl_parameters::n_s, NK_EMU, run_pk_param_space::nonlinear, ccl_parameters::Omega_b, ccl_parameters::Omega_c, ccl_parameters::Omega_n_mass, ccl_data::p_lin, ccl_data::p_nl, ccl_cosmology::params, PLIN_SPLINE_TYPE, run_pk_param_space::precision, ccl_parameters::sigma8, spectra(), ccl_parameters::sum_nu_masses, ccl_parameters::T_CMB, ccl_parameters::w0, ccl_parameters::wa, and x.
Referenced by ccl_cosmology_compute_power().
| void ccl_cosmology_write_power_class_z | ( | char * | filename, |
| ccl_cosmology * | cosmo, | ||
| double | z, | ||
| int * | status | ||
| ) |
CLASS power spectrum without splines. Write k, P(k,z) [1/Mpc, Mpc^3] for given cosmology at the k values used within CLASS (spectra.ln_k[]), using the method specified in config.matter_power_spectrum_method.
| filename | File into which k, P(k,a) will be written |
| cosmo | Cosmology parameters and configurations |
| z | Redshift at which the power spectrum is evaluated |
| status | Status flag. 0 if there are no errors, nonzero otherwise. |
Definition at line 596 of file ccl_power.c.
References ccl_cosmology_set_status_message(), CCL_ERROR_CLASS, ccl_fill_class_parameters(), ccl_free_class_structs(), ccl_run_class(), run_pk_param_space::nonlinear, run_pk_param_space::precision, and spectra().
Referenced by write_Pk_CLASS().
|
static |
Definition at line 266 of file ccl_power.c.
References ccl_parameters::A_s, ccl_spline_params::A_SPLINE_MINLOG_PK, ccl_cosmology_set_status_message(), CCL_ERROR_INCONSISTENT, ccl_get_class_As(), ccl_halofit, ccl_splines, ccl_cosmology::config, ccl_parameters::h, ccl_spline_params::K_MAX_SPLINE, ccl_configuration::matter_power_spectrum_method, ccl_parameters::mnu, ccl_parameters::N_nu_mass, ccl_parameters::N_nu_rel, ccl_parameters::n_s, ccl_parameters::Omega_b, ccl_parameters::Omega_c, ccl_parameters::Omega_k, ccl_cosmology::params, ccl_parameters::sigma8, ccl_parameters::T_CMB, ccl_parameters::w0, and ccl_parameters::wa.
Referenced by ccl_cosmology_compute_power_class(), ccl_cosmology_compute_power_emu(), and ccl_cosmology_write_power_class_z().
|
static |
Definition at line 21 of file ccl_power.c.
References ccl_cosmology_set_status_message(), and CCL_ERROR_CLASS.
Referenced by ccl_cosmology_compute_power_class(), ccl_cosmology_compute_power_emu(), ccl_cosmology_write_power_class_z(), and ccl_get_class_As().
|
static |
Definition at line 228 of file ccl_power.c.
References CCL_ERROR_CLASS, ccl_free_class_structs(), ccl_run_class(), run_pk_param_space::nonlinear, pow(), run_pk_param_space::precision, ccl_test_power::sigma8, spectra(), and ccl_cosmology::status.
Referenced by ccl_fill_class_parameters().
| double ccl_linear_matter_power | ( | ccl_cosmology * | cosmo, |
| double | k, | ||
| double | a, | ||
| int * | status | ||
| ) |
Linear matter power spectrum. Returns P_lin(k,a) [Mpc^3] for given cosmology, using the method specified in cosmo->config.transfer_function_method.
| cosmo | Cosmology parameters and configurations |
| k | Fourier mode, in [1/Mpc] units |
| a | scale factor, normalized to 1 for today |
| status | Status flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c |
Definition at line 1506 of file ccl_power.c.
References A_MIN_EMU, ccl_spline_params::A_SPLINE_MINLOG_PK, ccl_cosmology_compute_power(), ccl_cosmology_set_status_message(), ccl_emulator, CCL_ERROR_INCONSISTENT, CCL_ERROR_SPLINE_EV, ccl_growth_factor(), ccl_power_extrapol_highk(), ccl_power_extrapol_lowk(), ccl_raise_gsl_warning(), ccl_splines, ccl_cosmology::computed_power, ccl_cosmology::config, ccl_cosmology::data, ccl_data::k_max_lin, ccl_data::k_min_lin, ccl_data::p_lin, and ccl_configuration::transfer_function_method.
Referenced by ccl_nonlin_matter_power(), ccl_twohalo_matter_power(), compare_bbks(), compare_eh(), compare_power_nu(), lin_pow_spec(), main(), sigmaR_integrand(), and sigmaV_integrand().
| double ccl_nonlin_matter_power | ( | ccl_cosmology * | cosmo, |
| double | k, | ||
| double | a, | ||
| int * | status | ||
| ) |
Non-linear matter power spectrum. Returns P_NL(k,a) [Mpc^3] for given cosmology, using the method specified in cosmo->config.transfer_function_method and cosmo->config.matter_power_spectrum_method.
| cosmo | Cosmology parameters and configurations |
| k | Fourier mode, in [1/Mpc] units |
| a | scale factor, normalized to 1 for today |
| status | Status flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c |
Definition at line 1562 of file ccl_power.c.
References A_MIN_EMU, ccl_spline_params::A_SPLINE_MINLOG_PK, ccl_configuration::baryons_power_spectrum_method, ccl_bcm, ccl_bcm_model_fka(), ccl_cosmology_compute_power(), ccl_cosmology_set_status_message(), ccl_emu, ccl_emulator, CCL_ERROR_EMULATOR_BOUND, CCL_ERROR_NOT_IMPLEMENTED, CCL_ERROR_SPLINE_EV, ccl_growth_factor(), ccl_halofit, ccl_linear, ccl_linear_matter_power(), ccl_power_extrapol_highk(), ccl_power_extrapol_lowk(), ccl_raise_gsl_warning(), ccl_raise_warning(), ccl_splines, ccl_cosmology::computed_power, ccl_cosmology::config, ccl_cosmology::data, ccl_data::k_max_nl, ccl_data::k_min_nl, ccl_configuration::matter_power_spectrum_method, ccl_data::p_nl, and ccl_configuration::transfer_function_method.
Referenced by ccl_correlation_3d(), cl_integrand(), compare_bcm(), compare_emu(), compare_emu_nu(), compare_power_nu_nl(), main(), non_lin_pow_spec(), and transfer_nc().
|
static |
Definition at line 1437 of file ccl_power.c.
References ccl_cosmology_set_status_message(), CCL_ERROR_SPLINE_EV, and ccl_raise_gsl_warning().
Referenced by ccl_linear_matter_power(), and ccl_nonlin_matter_power().
|
static |
Definition at line 1480 of file ccl_power.c.
References ccl_cosmology_set_status_message(), CCL_ERROR_SPLINE_EV, ccl_raise_gsl_warning(), ccl_parameters::n_s, and ccl_cosmology::params.
Referenced by ccl_linear_matter_power(), and ccl_nonlin_matter_power().
|
static |
Definition at line 160 of file ccl_power.c.
References ccl_class_preinit(), ccl_cosmology_set_status_message(), and CCL_ERROR_CLASS.
Referenced by ccl_cosmology_compute_power_class(), ccl_cosmology_compute_power_emu(), ccl_cosmology_write_power_class_z(), and ccl_get_class_As().
| double ccl_sigma8 | ( | ccl_cosmology * | cosmo, |
| int * | status | ||
| ) |
Computes sigma8, variance of the matter density field with (top-hat) smoothing scale R = 8 Mpc/h, from linear power spectrum. Returns sigma8 for specified cosmology.
| cosmo | Cosmology parameters and configurations |
| status | Status flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c |
Definition at line 1777 of file ccl_power.c.
References ccl_sigmaR(), ccl_parameters::h, and ccl_cosmology::params.
Referenced by ccl_cosmology_compute_power_bbks(), ccl_cosmology_compute_power_eh(), main(), and norm_pwr().
| double ccl_sigmaR | ( | ccl_cosmology * | cosmo, |
| double | R, | ||
| double | a, | ||
| int * | status | ||
| ) |
Variance of the matter density field with (top-hat) smoothing scale R [Mpc]. Returns sigma(R) for specified cosmology at a = 1.
| cosmo | Cosmology parameters and configurations |
| R | Smoothing scale, in [Mpc] units |
| a | scale factor |
| status | Status flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c |
Definition at line 1715 of file ccl_power.c.
References ccl_growth_factor(), ccl_gsl, ccl_raise_gsl_warning(), ccl_splines, cl_cmbl_bm::cosmo, SigmaR_pars::cosmo, ccl_gsl_params::INTEGRATION_SIGMAR_EPSREL, ccl_spline_params::K_MAX, ccl_spline_params::K_MIN, M_PI, ccl_gsl_params::N_ITERATION, SigmaR_pars::R, sigmaR_integrand(), sqrt(), and SigmaR_pars::status.
Referenced by ccl_cosmology_compute_sigma(), ccl_sigma8(), and main().
| double ccl_sigmaV | ( | ccl_cosmology * | cosmo, |
| double | R, | ||
| double | a, | ||
| int * | status | ||
| ) |
Variance of the displacement field with (top-hat) smoothing scale R [Mpc] Returns sigma(V(R)) for specified cosmology at a = 1.
| cosmo | Cosmology parameters and configurations |
| R | smoothing scale, in [Mpc] units |
| a | scale factor |
| status | Status flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c |
Definition at line 1746 of file ccl_power.c.
References ccl_growth_factor(), ccl_gsl, ccl_raise_gsl_warning(), ccl_splines, cl_cmbl_bm::cosmo, SigmaV_pars::cosmo, ccl_gsl_params::INTEGRATION_SIGMAR_EPSREL, ccl_spline_params::K_MAX, ccl_spline_params::K_MIN, M_PI, ccl_gsl_params::N_ITERATION, SigmaV_pars::R, sigmaV_integrand(), sqrt(), and SigmaV_pars::status.
|
static |
Definition at line 836 of file ccl_power.c.
References ccl_parameters::h, ccl_parameters::n_s, pow(), and tsqr_EH().
Referenced by ccl_cosmology_compute_power_eh().
|
static |
Definition at line 678 of file ccl_power.c.
References eh_struct::alphab, eh_struct::alphac, eh_struct::betab, eh_struct::betac, eh_struct::bnode, ccl_parameters::h, eh_struct::keq, eh_struct::kSilk, ccl_parameters::Omega_b, ccl_parameters::Omega_m, pow(), eh_struct::rsound, eh_struct::rsound_approx, sqrt(), ccl_parameters::T_CMB, eh_struct::th2p7, eh_struct::zdrag, and eh_struct::zeq.
Referenced by ccl_cosmology_compute_power_eh().
Definition at line 1685 of file ccl_power.c.
References ccl_linear_matter_power(), SigmaR_pars::cosmo, pow(), SigmaR_pars::R, SigmaR_pars::status, w, and w_tophat().
Referenced by ccl_sigmaR().
Definition at line 1698 of file ccl_power.c.
References ccl_linear_matter_power(), SigmaV_pars::cosmo, pow(), SigmaV_pars::R, SigmaV_pars::status, w, and w_tophat().
Referenced by ccl_sigmaV().
Definition at line 747 of file ccl_power.c.
References cl_cmbl_bm::c, cl_cmbl_bm::l, and pow().
Referenced by tkEH_b(), and tkEH_c().
Definition at line 779 of file ccl_power.c.
References eh_struct::alphab, eh_struct::betab, eh_struct::bnode, jbes0(), eh_struct::keq, eh_struct::kSilk, pow(), eh_struct::rsound, tkEH_0(), and x.
Referenced by tsqr_EH().
Definition at line 758 of file ccl_power.c.
References eh_struct::alphac, eh_struct::betac, eh_struct::keq, pow(), eh_struct::rsound, and tkEH_0().
Referenced by tsqr_EH().
|
static |
Definition at line 995 of file ccl_power.c.
References ccl_parameters::h, ccl_parameters::Omega_b, ccl_parameters::Omega_m, and pow().
Referenced by bbks_power().
|
static |
Definition at line 804 of file ccl_power.c.
References ccl_parameters::h, ccl_parameters::Omega_b, ccl_parameters::Omega_m, pow(), eh_struct::rsound_approx, eh_struct::th2p7, tkEH_b(), and tkEH_c().
Referenced by eh_power().
Definition at line 1663 of file ccl_power.c.
References w.
Referenced by sigmaR_integrand(), and sigmaV_integrand().