Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
ccl_power.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

CCL_BEGIN_DECLS void ccl_cosmology_write_power_class_z (char *filename, ccl_cosmology *cosmo, double z, int *status)
 
double ccl_bcm_model_fka (ccl_cosmology *cosmo, double k, double a, 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)
 
void ccl_cosmology_compute_power (ccl_cosmology *cosmo, int *status)
 
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)
 

Function Documentation

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.

Parameters
cosmoCosmology parameters and configurations, including baryonic parameters.
kFourier mode, in [1/Mpc] units
ascale factor, normalized to 1 for today
statusStatus flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c
Returns
f(k,a).

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().

574  {
575 
576  double fka;
577  double b0;
578  double bfunc, bfunc4;
579  double kg;
580  double gf,scomp;
581  double kh;
582  double z;
583 
584  z=1./a-1.;
585  kh = k/cosmo->params.h; //convert to h/Mpc
586  b0 = 0.105*cosmo->params.bcm_log10Mc-1.27; //Eq. 4.4
587  bfunc = b0/(1.+pow(z/2.3,2.5)); //Eq. 4.3
588  bfunc4 = (1-bfunc)*(1-bfunc)*(1-bfunc)*(1-bfunc); //B^4(z)
589  kg = 0.7*bfunc4*pow(cosmo->params.bcm_etab,-1.6); //Eq. 4.3
590  gf = bfunc/(1+pow(kh/kg,3.))+1.-bfunc; //Eq. 4.2, k in h/Mpc
591  scomp = 1+(kh/cosmo->params.bcm_ks)*(kh/cosmo->params.bcm_ks); //Eq 4.5, k in h/Mpc
592  fka = gf*scomp;
593  return fka;
594 }
ccl_parameters params
Definition: ccl_core.h:124
double h
Definition: ccl_core.h:33
double bcm_ks
Definition: ccl_core.h:59
static double z[8]
double bcm_etab
Definition: ccl_core.h:58
float pow(float base, unsigned long int exp)
Definition: precision.hpp:39
double bcm_log10Mc
Definition: ccl_core.h:57
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.

Parameters
cosmoCosmological parameters
statusStatus flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c
Returns
void

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().

1404 {
1405 
1406  if (cosmo->computed_power) return;
1407  switch(cosmo->config.transfer_function_method){
1408  case ccl_bbks:
1409  ccl_cosmology_compute_power_bbks(cosmo,status);
1410  break;
1411  case ccl_eisenstein_hu:
1412  ccl_cosmology_compute_power_eh(cosmo,status);
1413  break;
1414  case ccl_boltzmann_class:
1415  ccl_cosmology_compute_power_class(cosmo,status);
1416  break;
1417  case ccl_emulator:
1418  ccl_cosmology_compute_power_emu(cosmo,status);
1419  break;
1420  default:
1421  *status = CCL_ERROR_INCONSISTENT;
1422  ccl_cosmology_set_status_message(cosmo, "ccl_power.c: ccl_cosmology_compute_power(): Unknown or non-implemented transfer function method: %d \n", cosmo->config.transfer_function_method);
1423  }
1424 
1425  ccl_check_status(cosmo,status);
1426  if (*status==0){
1427  cosmo->computed_power = true;
1428  }
1429  return;
1430 }
bool computed_power
Definition: ccl_core.h:130
static void ccl_cosmology_compute_power_eh(ccl_cosmology *cosmo, int *status)
Definition: ccl_power.c:842
void ccl_check_status(ccl_cosmology *cosmo, int *status)
Definition: ccl_error.c:88
transfer_function_t transfer_function_method
Definition: ccl_config.h:111
static void ccl_cosmology_compute_power_emu(ccl_cosmology *cosmo, int *status)
Definition: ccl_power.c:1158
void ccl_cosmology_set_status_message(ccl_cosmology *cosmo, const char *status_message,...)
Definition: ccl_core.c:792
#define CCL_ERROR_INCONSISTENT
Definition: ccl_error.h:12
ccl_configuration config
Definition: ccl_core.h:125
static void ccl_cosmology_compute_power_class(ccl_cosmology *cosmo, int *status)
Definition: ccl_power.c:378
static void ccl_cosmology_compute_power_bbks(ccl_cosmology *cosmo, int *status)
Definition: ccl_power.c:1017
CCL_BEGIN_DECLS 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.

Parameters
filenameFile into which k, P(k,a) will be written
cosmoCosmology parameters and configurations
zRedshift at which the power spectrum is evaluated
statusStatus 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().

597 {
598  struct precision pr; // for precision parameters
599  struct background ba; // for cosmological background
600  struct thermo th; // for thermodynamics
601  struct perturbs pt; // for source functions
602  struct transfers tr; // for transfer functions
603  struct primordial pm; // for primordial spectra
604  struct spectra sp; // for output spectra
605  struct nonlinear nl; // for non-linear spectra
606  struct lensing le;
607  struct output op;
608  struct file_content fc;
609 
610  ErrorMsg errmsg; // for error messages
611  // generate file_content structure
612  // CLASS configuration parameters will be passed through this structure,
613  // to avoid writing and reading .ini files for every call
614  int parser_length = 20;
615  int init_arr[7]={0,0,0,0,0,0,0};
616  if (parser_init(&fc,parser_length,"none",errmsg) == _FAILURE_) {
617  *status = CCL_ERROR_CLASS;
618  ccl_cosmology_set_status_message(cosmo, "ccl_power.c: write_power_class_z(): parser init error:%s\n", errmsg);
619  return;
620  }
621 
622  ccl_fill_class_parameters(cosmo,&fc,parser_length, status);
623 
624  if (*status != CCL_ERROR_CLASS)
625  ccl_run_class(cosmo, &fc,&pr,&ba,&th,&pt,&tr,&pm,&sp,&nl,&le,&op,init_arr,status);
626 
627  if (*status == CCL_ERROR_CLASS) {
628  //printed error message while running CLASS
629  ccl_free_class_structs(cosmo, &ba,&th,&pt,&tr,&pm,&sp,&nl,&le,init_arr,status);
630  return;
631  }
632  if (parser_free(&fc)== _FAILURE_) {
633  *status = CCL_ERROR_CLASS;
634  ccl_cosmology_set_status_message(cosmo, "ccl_power.c: write_power_class_z(): Error freeing CLASS parser\n");
635  ccl_free_class_structs(cosmo, &ba,&th,&pt,&tr,&pm,&sp,&nl,&le,init_arr,status);
636  return;
637  }
638  FILE *f;
639  f = fopen(filename,"w");
640  if (!f){
641  *status = CCL_ERROR_CLASS;
642  ccl_cosmology_set_status_message(cosmo, "ccl_power.c: write_power_class_z(): Error opening output file\n");
643  ccl_free_class_structs(cosmo, &ba,&th,&pt,&tr,&pm,&sp,&nl,&le,init_arr,status);
644  fclose(f);
645  return;
646  }
647  double psout_l,ic;
648  int s=0;
649  for (int i=0; i<sp.ln_k_size; i++) {
650  s |= spectra_pk_at_k_and_z(&ba, &pm, &sp,exp(sp.ln_k[i]),z, &psout_l,&ic);
651  fprintf(f,"%e %e\n",exp(sp.ln_k[i]),psout_l);
652  }
653  fclose(f);
654  if(s) {
655  *status = CCL_ERROR_CLASS;
656  ccl_cosmology_set_status_message(cosmo, "ccl_power.c: write_power_class_z(): Error writing CLASS power spectrum\n");
657  }
658 
659  ccl_free_class_structs(cosmo, &ba,&th,&pt,&tr,&pm,&sp,&nl,&le,init_arr,status);
660 }
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)
Definition: ccl_power.c:21
static double spectra(char *tr1, char *tr2, int l, RunParams *par)
Definition: spectra.c:22
#define CCL_ERROR_CLASS
Definition: ccl_error.h:17
void ccl_cosmology_set_status_message(ccl_cosmology *cosmo, const char *status_message,...)
Definition: ccl_core.c:792
static void ccl_fill_class_parameters(ccl_cosmology *cosmo, struct file_content *fc, int parser_length, int *status)
Definition: ccl_power.c:266
static double z[8]
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)
Definition: ccl_power.c:160
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.

Parameters
cosmoCosmology parameters and configurations
kFourier mode, in [1/Mpc] units
ascale factor, normalized to 1 for today
statusStatus flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c
Returns
P_lin(k,a).

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().

1508 {
1509  if ((cosmo->config.transfer_function_method == ccl_emulator) && (a<A_MIN_EMU)){
1510  *status = CCL_ERROR_INCONSISTENT;
1511  ccl_cosmology_set_status_message(cosmo, "ccl_power.c: the cosmic emulator cannot be used above a=%f\n",A_MIN_EMU);
1512  return NAN;
1513  }
1514 
1515  if (!cosmo->computed_power) ccl_cosmology_compute_power(cosmo, status);
1516  // Return if compilation failed
1517  //if (cosmo->data.p_lin == NULL) return NAN;
1518  if (!cosmo->computed_power) return NAN;
1519 
1520  double log_p_1;
1521  int gslstatus;
1522 
1523  if(a<ccl_splines->A_SPLINE_MINLOG_PK) { //Extrapolate linearly at high redshift
1524  double pk0=ccl_linear_matter_power(cosmo,k,ccl_splines->A_SPLINE_MINLOG_PK,status);
1525  double gf=ccl_growth_factor(cosmo,a,status)/ccl_growth_factor(cosmo,ccl_splines->A_SPLINE_MINLOG_PK,status);
1526 
1527  return pk0*gf*gf;
1528  }
1529  if (*status!=CCL_ERROR_INCONSISTENT){
1530  if(k<=cosmo->data.k_min_lin) {
1531  log_p_1=ccl_power_extrapol_lowk(cosmo,k,a,cosmo->data.p_lin,cosmo->data.k_min_lin,status);
1532 
1533  return exp(log_p_1);
1534  }
1535  else if(k<cosmo->data.k_max_lin){
1536  gslstatus = gsl_spline2d_eval_e(cosmo->data.p_lin, log(k), a,NULL,NULL,&log_p_1);
1537  if(gslstatus != GSL_SUCCESS) {
1538  ccl_raise_gsl_warning(gslstatus, "ccl_power.c: ccl_linear_matter_power():");
1539  *status = CCL_ERROR_SPLINE_EV;
1540  ccl_cosmology_set_status_message(cosmo, "ccl_power.c: ccl_linear_matter_power(): Spline evaluation error\n");
1541  return NAN;
1542  }
1543  else {
1544  return exp(log_p_1);
1545  }
1546  }
1547  else { //Extrapolate using log derivative
1548  log_p_1 = ccl_power_extrapol_highk(cosmo,k,a,cosmo->data.p_lin,cosmo->data.k_max_lin,status);
1549  return exp(log_p_1);
1550  }
1551  }
1552 
1553  return exp(log_p_1);
1554 }
bool computed_power
Definition: ccl_core.h:130
void ccl_raise_gsl_warning(int gslstatus, const char *msg,...)
Definition: ccl_error.c:75
double ccl_growth_factor(ccl_cosmology *cosmo, double a, int *status)
static double ccl_power_extrapol_lowk(ccl_cosmology *cosmo, double k, double a, gsl_spline2d *powerspl, double kmin_spline, int *status)
Definition: ccl_power.c:1480
#define A_MIN_EMU
Definition: ccl_emu17.h:4
static double ccl_power_extrapol_highk(ccl_cosmology *cosmo, double k, double a, gsl_spline2d *powerspl, double kmax_spline, int *status)
Definition: ccl_power.c:1437
#define CCL_ERROR_SPLINE_EV
Definition: ccl_error.h:14
ccl_spline_params * ccl_splines
Definition: ccl_core.c:47
void ccl_cosmology_compute_power(ccl_cosmology *cosmo, int *status)
Definition: ccl_power.c:1403
transfer_function_t transfer_function_method
Definition: ccl_config.h:111
gsl_spline2d * p_lin
Definition: ccl_core.h:111
void ccl_cosmology_set_status_message(ccl_cosmology *cosmo, const char *status_message,...)
Definition: ccl_core.c:792
double k_min_lin
Definition: ccl_core.h:113
#define CCL_ERROR_INCONSISTENT
Definition: ccl_error.h:12
double k_max_lin
Definition: ccl_core.h:115
ccl_configuration config
Definition: ccl_core.h:125
double ccl_linear_matter_power(ccl_cosmology *cosmo, double k, double a, int *status)
Definition: ccl_power.c:1506
double A_SPLINE_MINLOG_PK
Definition: ccl_params.h:16
ccl_data data
Definition: ccl_core.h:126
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.

Parameters
cosmoCosmology parameters and configurations
kFourier mode, in [1/Mpc] units
ascale factor, normalized to 1 for today
statusStatus flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c
Returns
P_NL(k,a).

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().

1563 {
1564  double log_p_1, pk;
1565 
1566  switch(cosmo->config.matter_power_spectrum_method) {
1567 
1568  //If the matter PS specified was linear, then do the linear compuation
1569  case ccl_linear:
1570  return ccl_linear_matter_power(cosmo,k,a,status);
1571 
1572  case ccl_halofit:
1573  if (!cosmo->computed_power)
1574  ccl_cosmology_compute_power(cosmo, status);
1575  if (cosmo->data.p_nl == NULL) return NAN; // Return if computation failed
1576 
1577  if(a<ccl_splines->A_SPLINE_MINLOG_PK) { //Extrapolate linearly at high redshift
1578  double pk0=ccl_nonlin_matter_power(cosmo,k,ccl_splines->A_SPLINE_MINLOG_PK,status);
1579  double gf=ccl_growth_factor(cosmo,a,status)/ccl_growth_factor(cosmo,ccl_splines->A_SPLINE_MINLOG_PK,status);
1580  return pk0*gf*gf;
1581  }
1582  break;
1583 
1584  case ccl_emu:
1585  if ((cosmo->config.transfer_function_method == ccl_emulator) && (a<A_MIN_EMU)){
1586  *status = CCL_ERROR_EMULATOR_BOUND;
1587  ccl_cosmology_set_status_message(cosmo, "ccl_power.c: the cosmic emulator cannot be used above z=2\n");
1588  return NAN;
1589  }
1590 
1591  // Compute power spectrum if needed; return if computation failed
1592  if (!cosmo->computed_power){
1593  ccl_cosmology_compute_power(cosmo,status);
1594  }
1595  if (cosmo->data.p_nl == NULL) return NAN;
1596  break;
1597 
1598  default:
1601  "config.matter_power_spectrum_method = %d not yet supported "
1602  "continuing with linear power spectrum\n", cosmo->config.matter_power_spectrum_method);
1604  return ccl_linear_matter_power(cosmo,k,a,status);
1605  } // end switch
1606 
1607  // if we get here, try to evaluate the power spectrum
1608  // we need to account for bounds below and above
1609  if (k <= cosmo->data.k_min_nl) {
1610  // we assume no baryonic effects below k_min_nl
1611  log_p_1 = ccl_power_extrapol_lowk(cosmo, k, a, cosmo->data.p_nl, cosmo->data.k_min_nl, status);
1612  return exp(log_p_1);
1613  }
1614 
1615  if (k < cosmo->data.k_max_nl) {
1616  int gslstatus = gsl_spline2d_eval_e(cosmo->data.p_nl, log(k), a, NULL ,NULL, &log_p_1);
1617  if (gslstatus != GSL_SUCCESS) {
1618  ccl_raise_gsl_warning(gslstatus, "ccl_power.c: ccl_nonlin_matter_power():");
1619  *status = CCL_ERROR_SPLINE_EV;
1620  ccl_cosmology_set_status_message(cosmo, "ccl_power.c: ccl_nonlin_matter_power(): Spline evaluation error\n");
1621  return NAN;
1622  } else {
1623  pk = exp(log_p_1);
1624  }
1625  } else {
1626  // Extrapolate NL regime using log derivative
1627  log_p_1 = ccl_power_extrapol_highk(cosmo, k, a, cosmo->data.p_nl, cosmo->data.k_max_nl, status);
1628  pk = exp(log_p_1);
1629  }
1630 
1631  // Add baryonic correction
1633  int pwstatus = 0;
1634  double fbcm = ccl_bcm_model_fka(cosmo, k, a, &pwstatus);
1635  pk *= fbcm;
1636  if (pwstatus) {
1637  *status = CCL_ERROR_SPLINE_EV;
1638  ccl_cosmology_set_status_message(cosmo, "ccl_power.c: ccl_nonlin_matter_power(): Error in BCM correction\n");
1639  return NAN;
1640  }
1641  }
1642 
1643  return pk;
1644 }
double k_min_nl
Definition: ccl_core.h:114
bool computed_power
Definition: ccl_core.h:130
double ccl_nonlin_matter_power(ccl_cosmology *cosmo, double k, double a, int *status)
Definition: ccl_power.c:1562
void ccl_raise_gsl_warning(int gslstatus, const char *msg,...)
Definition: ccl_error.c:75
#define CCL_ERROR_NOT_IMPLEMENTED
Definition: ccl_error.h:25
matter_power_spectrum_t matter_power_spectrum_method
Definition: ccl_config.h:112
double ccl_growth_factor(ccl_cosmology *cosmo, double a, int *status)
static double ccl_power_extrapol_lowk(ccl_cosmology *cosmo, double k, double a, gsl_spline2d *powerspl, double kmin_spline, int *status)
Definition: ccl_power.c:1480
#define A_MIN_EMU
Definition: ccl_emu17.h:4
static double ccl_power_extrapol_highk(ccl_cosmology *cosmo, double k, double a, gsl_spline2d *powerspl, double kmax_spline, int *status)
Definition: ccl_power.c:1437
#define CCL_ERROR_SPLINE_EV
Definition: ccl_error.h:14
ccl_spline_params * ccl_splines
Definition: ccl_core.c:47
void ccl_cosmology_compute_power(ccl_cosmology *cosmo, int *status)
Definition: ccl_power.c:1403
double ccl_bcm_model_fka(ccl_cosmology *cosmo, double k, double a, int *status)
Definition: ccl_power.c:574
transfer_function_t transfer_function_method
Definition: ccl_config.h:111
void ccl_cosmology_set_status_message(ccl_cosmology *cosmo, const char *status_message,...)
Definition: ccl_core.c:792
gsl_spline2d * p_nl
Definition: ccl_core.h:112
void ccl_raise_warning(int err, const char *msg,...)
Definition: ccl_error.c:56
#define CCL_ERROR_EMULATOR_BOUND
Definition: ccl_error.h:23
baryons_power_spectrum_t baryons_power_spectrum_method
Definition: ccl_config.h:113
double k_max_nl
Definition: ccl_core.h:116
ccl_configuration config
Definition: ccl_core.h:125
double ccl_linear_matter_power(ccl_cosmology *cosmo, double k, double a, int *status)
Definition: ccl_power.c:1506
double A_SPLINE_MINLOG_PK
Definition: ccl_params.h:16
ccl_data data
Definition: ccl_core.h:126
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.

Parameters
cosmoCosmology parameters and configurations
statusStatus flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c
Returns
sigma8.

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().

1778 {
1779  return ccl_sigmaR(cosmo,8/cosmo->params.h, 1.,status);
1780 }
ccl_parameters params
Definition: ccl_core.h:124
double h
Definition: ccl_core.h:33
double ccl_sigmaR(ccl_cosmology *cosmo, double R, double a, int *status)
Definition: ccl_power.c:1715
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.

Parameters
cosmoCosmology parameters and configurations
RSmoothing scale, in [Mpc] units
ascale factor
statusStatus flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c
Returns
sigma(R).

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().

1716 {
1717  SigmaR_pars par;
1718  par.status = status;
1719 
1720  par.cosmo=cosmo;
1721  par.R=R;
1722  gsl_integration_cquad_workspace *workspace=gsl_integration_cquad_workspace_alloc(ccl_gsl->N_ITERATION);
1723  gsl_function F;
1724  F.function=&sigmaR_integrand;
1725  F.params=&par;
1726  double sigma_R;
1727  int gslstatus = gsl_integration_cquad(&F, log10(ccl_splines->K_MIN), log10(ccl_splines->K_MAX),
1729  workspace,&sigma_R,NULL,NULL);
1730  if(gslstatus != GSL_SUCCESS) {
1731  ccl_raise_gsl_warning(gslstatus, "ccl_power.c: ccl_sigmaR():");
1732  *status |= gslstatus;
1733  }
1734 
1735  gsl_integration_cquad_workspace_free(workspace);
1736 
1737  return sqrt(sigma_R*M_LN10/(2*M_PI*M_PI))*ccl_growth_factor(cosmo, a, status);
1738 }
double INTEGRATION_SIGMAR_EPSREL
Definition: ccl_params.h:68
void ccl_raise_gsl_warning(int gslstatus, const char *msg,...)
Definition: ccl_error.c:75
static double sigmaR_integrand(double lk, void *params)
Definition: ccl_power.c:1685
double ccl_growth_factor(ccl_cosmology *cosmo, double a, int *status)
ccl_spline_params * ccl_splines
Definition: ccl_core.c:47
#define M_PI
Definition: ccl_constants.h:22
ccl_gsl_params * ccl_gsl
Definition: ccl_core.c:48
Grid< NDIM, T > sqrt(Grid< NDIM, T > lhs)
Definition: grid.h:231
size_t N_ITERATION
Definition: ccl_params.h:55
double R
Definition: ccl_power.c:1649
int * status
Definition: ccl_power.c:1650
ccl_cosmology * cosmo
Definition: ccl_power.c:1648
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.

Parameters
cosmoCosmology parameters and configurations
Rsmoothing scale, in [Mpc] units
ascale factor
statusStatus flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c
Returns
sigma(R).

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.

1747 {
1748  SigmaV_pars par;
1749  par.status = status;
1750 
1751  par.cosmo=cosmo;
1752  par.R=R;
1753  gsl_integration_cquad_workspace *workspace=gsl_integration_cquad_workspace_alloc(ccl_gsl->N_ITERATION);
1754  gsl_function F;
1755  F.function=&sigmaV_integrand;
1756  F.params=&par;
1757  double sigma_V;
1758  int gslstatus = gsl_integration_cquad(&F, log10(ccl_splines->K_MIN), log10(ccl_splines->K_MAX),
1760  workspace,&sigma_V,NULL,NULL);
1761 
1762  if(gslstatus != GSL_SUCCESS) {
1763  ccl_raise_gsl_warning(gslstatus, "ccl_power.c: ccl_sigmaV():");
1764  *status |= gslstatus;
1765  }
1766 
1767  gsl_integration_cquad_workspace_free(workspace);
1768 
1769  return sqrt(sigma_V*M_LN10/(2*M_PI*M_PI))*ccl_growth_factor(cosmo, a, status);
1770 }
double INTEGRATION_SIGMAR_EPSREL
Definition: ccl_params.h:68
ccl_cosmology * cosmo
Definition: ccl_power.c:1654
void ccl_raise_gsl_warning(int gslstatus, const char *msg,...)
Definition: ccl_error.c:75
double ccl_growth_factor(ccl_cosmology *cosmo, double a, int *status)
ccl_spline_params * ccl_splines
Definition: ccl_core.c:47
#define M_PI
Definition: ccl_constants.h:22
ccl_gsl_params * ccl_gsl
Definition: ccl_core.c:48
Grid< NDIM, T > sqrt(Grid< NDIM, T > lhs)
Definition: grid.h:231
static double sigmaV_integrand(double lk, void *params)
Definition: ccl_power.c:1698
size_t N_ITERATION
Definition: ccl_params.h:55
double R
Definition: ccl_power.c:1655
int * status
Definition: ccl_power.c:1656