Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
ccl_massfunc.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_compute_sigma (ccl_cosmology *cosmo, int *status)
 
double ccl_massfunc (ccl_cosmology *cosmo, double smooth_mass, double a, double odelta, int *status)
 
double ccl_halo_bias (ccl_cosmology *cosmo, double smooth_mass, double a, double odelta, int *status)
 
double ccl_massfunc_m2r (ccl_cosmology *cosmo, double smooth_mass, int *status)
 
double ccl_sigmaM (ccl_cosmology *cosmo, double smooth_mass, double a, int *status)
 
double dc_NakamuraSuto (ccl_cosmology *cosmo, double a, int *status)
 
double Dv_BryanNorman (ccl_cosmology *cosmo, double a, int *status)
 
double r_delta (ccl_cosmology *cosmo, double halomass, double a, double odelta, int *status)
 

Function Documentation

CCL_BEGIN_DECLS void ccl_cosmology_compute_sigma ( ccl_cosmology cosmo,
int *  status 
)

Definition at line 431 of file ccl_massfunc.c.

References ccl_data::accelerator_m, ccl_cosmology_set_status_message(), CCL_ERROR_LINSPACE, CCL_ERROR_SPLINE, ccl_linear_spacing(), ccl_massfunc_m2r(), ccl_raise_gsl_warning(), ccl_sigmaR(), ccl_splines, ccl_cosmology::computed_sigma, ccl_cosmology::data, ccl_data::dlnsigma_dlogm, ccl_spline_params::LOGM_SPLINE_DELTA, ccl_spline_params::LOGM_SPLINE_MAX, ccl_spline_params::LOGM_SPLINE_MIN, ccl_spline_params::LOGM_SPLINE_NM, ccl_data::logsigma, m, M_SPLINE_TYPE, and pow().

Referenced by ccl_dlninvsig_dlogm(), ccl_halo_bias(), and ccl_sigmaM().

432 {
433  if(cosmo->computed_sigma)
434  return;
435 
436  // create linearly-spaced values of the mass.
437  int nm=ccl_splines->LOGM_SPLINE_NM;
439 
440  // create space for y, to be filled with sigma and dlnsigma_dlogm
441  double * y = malloc(sizeof(double)*nm);
442  double smooth_radius;
443  double na, nb;
444 
445  // start up of GSL pointers
446  int gslstatus = 0;
447  gsl_spline *logsigma;
448  gsl_spline *dlnsigma_dlogm;
449 
450  if (m==NULL ||
451  (fabs(m[0]-ccl_splines->LOGM_SPLINE_MIN)>1e-5) ||
452  (fabs(m[nm-1]-ccl_splines->LOGM_SPLINE_MAX)>1e-5) ||
453  (m[nm-1]>10E17)
454  ) {
455  *status = CCL_ERROR_LINSPACE;
456  ccl_cosmology_set_status_message(cosmo,"ccl_cosmology_compute_sigmas(): Error creating linear spacing in m\n");
457  }
458 
459  // fill in sigma, if no errors have been triggered at this time.
460  if (*status == 0) {
461  for (int i=0; i<nm; i++) {
462  smooth_radius = ccl_massfunc_m2r(cosmo, pow(10,m[i]), status);
463  y[i] = log10(ccl_sigmaR(cosmo, smooth_radius, 1., status));
464  }
465  logsigma = gsl_spline_alloc(M_SPLINE_TYPE, nm);
466  *status = gsl_spline_init(logsigma, m, y, nm);
467  }
468 
469  if (*status !=0 ) {
470  *status = CCL_ERROR_SPLINE ;
471  ccl_cosmology_set_status_message(cosmo, "ccl_massfunc.c: ccl_cosmology_compute_sigma(): Error creating sigma(M) spline\n");
472  }
473 
474  // again, making splines assuming nothing bad has happened to this point
475 
476  if (*status == 0 ) {
477  for (int i=0; i<nm; i++) {
478  if(i==0) {
479  gslstatus |= gsl_spline_eval_e(logsigma, m[i], NULL,&na);
480  gslstatus |= gsl_spline_eval_e(logsigma, m[i]+ccl_splines->LOGM_SPLINE_DELTA/2., NULL,&nb);
481  y[i] = (na-nb)*log(10.);
482  y[i] = 2.*y[i] / ccl_splines->LOGM_SPLINE_DELTA;
483  }
484  else if (i==nm-1) {
485  gslstatus |= gsl_spline_eval_e(logsigma, m[i]-ccl_splines->LOGM_SPLINE_DELTA/2., NULL,&na);
486  gslstatus |= gsl_spline_eval_e(logsigma, m[i], NULL,&nb);
487  y[i] = (na-nb)*log(10.);
488  y[i] = 2.*y[i] / ccl_splines->LOGM_SPLINE_DELTA;
489  }
490  else {
491  gslstatus |= gsl_spline_eval_e(logsigma, m[i]-ccl_splines->LOGM_SPLINE_DELTA/2., NULL,&na);
492  gslstatus |= gsl_spline_eval_e(logsigma, m[i]+ccl_splines->LOGM_SPLINE_DELTA/2., NULL,&nb);
493  y[i] = (na-nb)*log(10.);
494  y[i] = y[i] / ccl_splines->LOGM_SPLINE_DELTA;
495  }
496  }
497  }
498 
499  if(gslstatus != GSL_SUCCESS) {
500  ccl_raise_gsl_warning(gslstatus, "ccl_massfunc.c: ccl_cosmology_compute_sigma():");
501  *status |= gslstatus;
502  *status = CCL_ERROR_SPLINE ;
503  ccl_cosmology_set_status_message(cosmo, "ccl_massfunc.c: ccl_cosmology_compute_sigma(): Error evaluating grid points for dlnsigma/dlogM spline\n");
504  }
505 
506  if(*status==0) {
507  dlnsigma_dlogm = gsl_spline_alloc(M_SPLINE_TYPE, nm);
508  *status = gsl_spline_init(dlnsigma_dlogm, m, y, nm);
509  if(cosmo->data.accelerator_m==NULL)
510  cosmo->data.accelerator_m=gsl_interp_accel_alloc();
511  }
512 
513  if(*status!=0) {
514  *status = CCL_ERROR_SPLINE ;
515  ccl_cosmology_set_status_message(cosmo, "ccl_massfunc.c: ccl_cosmology_compute_sigma(): Error creating dlnsigma/dlogM spline\n");
516  }
517 
518 
519  cosmo->data.logsigma = logsigma;
520  cosmo->data.dlnsigma_dlogm = dlnsigma_dlogm;
521  cosmo->computed_sigma = true;
522 
523  free(m);
524  free(y);
525  if(*status != 0) {
526  gsl_spline_free(logsigma);
527  gsl_spline_free(dlnsigma_dlogm);
528  }
529  return;
530 }
gsl_interp_accel * accelerator_m
Definition: ccl_core.h:93
void ccl_raise_gsl_warning(int gslstatus, const char *msg,...)
Definition: ccl_error.c:75
double ccl_massfunc_m2r(ccl_cosmology *cosmo, double halomass, int *status)
Definition: ccl_massfunc.c:606
double LOGM_SPLINE_MAX
Definition: ccl_params.h:26
#define M_SPLINE_TYPE
Definition: ccl_constants.h:10
ccl_spline_params * ccl_splines
Definition: ccl_core.c:47
CCL_BEGIN_DECLS double * ccl_linear_spacing(double xmin, double xmax, int N)
Definition: ccl_utils.c:14
#define CCL_ERROR_SPLINE
Definition: ccl_error.h:13
#define CCL_ERROR_LINSPACE
Definition: ccl_error.h:11
void ccl_cosmology_set_status_message(ccl_cosmology *cosmo, const char *status_message,...)
Definition: ccl_core.c:792
double LOGM_SPLINE_DELTA
Definition: ccl_params.h:23
gsl_spline * logsigma
Definition: ccl_core.h:100
float pow(float base, unsigned long int exp)
Definition: precision.hpp:39
gsl_spline * dlnsigma_dlogm
Definition: ccl_core.h:101
static int m[2]
Definition: ccl_emu17.c:25
double LOGM_SPLINE_MIN
Definition: ccl_params.h:25
double ccl_sigmaR(ccl_cosmology *cosmo, double R, double a, int *status)
Definition: ccl_power.c:1715
ccl_data data
Definition: ccl_core.h:126
bool computed_sigma
Definition: ccl_core.h:131
double ccl_halo_bias ( ccl_cosmology cosmo,
double  smooth_mass,
double  a,
double  odelta,
int *  status 
)

Definition at line 582 of file ccl_massfunc.c.

References ccl_check_status(), ccl_cosmology_compute_sigma(), ccl_cosmology_set_status_message(), CCL_ERROR_NOT_IMPLEMENTED, ccl_halo_b1(), ccl_cosmology::computed_sigma, ccl_parameters::N_nu_mass, and ccl_cosmology::params.

Referenced by main(), and two_halo_integrand().

583 {
584  if (cosmo->params.N_nu_mass>0){
585  *status = CCL_ERROR_NOT_IMPLEMENTED;
586  ccl_cosmology_set_status_message(cosmo, "ccl_background.c: ccl_cosmology_compute_growth(): Support for the halo bias in cosmologies with massive neutrinos is not yet implemented.\n");
587  return NAN;
588  }
589 
590 
591  if (!cosmo->computed_sigma) {
592  ccl_cosmology_compute_sigma(cosmo, status);
593  ccl_check_status(cosmo, status);
594  }
595 
596  double f;
597  f = ccl_halo_b1(cosmo,halomass,a,odelta, status);
598  ccl_check_status(cosmo, status);
599  return f;
600 }
#define CCL_ERROR_NOT_IMPLEMENTED
Definition: ccl_error.h:25
ccl_parameters params
Definition: ccl_core.h:124
static double ccl_halo_b1(ccl_cosmology *cosmo, double halomass, double a, double odelta, int *status)
Definition: ccl_massfunc.c:374
void ccl_check_status(ccl_cosmology *cosmo, int *status)
Definition: ccl_error.c:88
void ccl_cosmology_compute_sigma(ccl_cosmology *cosmo, int *status)
Definition: ccl_massfunc.c:431
void ccl_cosmology_set_status_message(ccl_cosmology *cosmo, const char *status_message,...)
Definition: ccl_core.c:792
bool computed_sigma
Definition: ccl_core.h:131
double ccl_massfunc ( ccl_cosmology cosmo,
double  smooth_mass,
double  a,
double  odelta,
int *  status 
)

Definition at line 562 of file ccl_massfunc.c.

References ccl_cosmology_set_status_message(), ccl_dlninvsig_dlogm(), CCL_ERROR_NOT_IMPLEMENTED, ccl_parameters::h, massfunc_f(), ccl_parameters::N_nu_mass, ccl_parameters::Omega_m, ccl_cosmology::params, and RHO_CRITICAL.

Referenced by compare_massfunc(), main(), one_halo_integrand(), and two_halo_integrand().

563 {
564  if (cosmo->params.N_nu_mass>0){
565  *status = CCL_ERROR_NOT_IMPLEMENTED;
566  ccl_cosmology_set_status_message(cosmo, "ccl_background.c: ccl_cosmology_compute_growth(): Support for the halo mass function in cosmologies with massive neutrinos is not yet implemented.\n");
567  return NAN;
568  }
569 
570  double f, rho_m;
571 
572  rho_m = RHO_CRITICAL*cosmo->params.Omega_m*cosmo->params.h*cosmo->params.h;
573  f=massfunc_f(cosmo,halomass,a,odelta,status);
574 
575  return f*rho_m*ccl_dlninvsig_dlogm(cosmo,halomass,status)/halomass;
576 }
#define CCL_ERROR_NOT_IMPLEMENTED
Definition: ccl_error.h:25
ccl_parameters params
Definition: ccl_core.h:124
double h
Definition: ccl_core.h:33
static double massfunc_f(ccl_cosmology *cosmo, double halomass, double a, double odelta, int *status)
Definition: ccl_massfunc.c:234
void ccl_cosmology_set_status_message(ccl_cosmology *cosmo, const char *status_message,...)
Definition: ccl_core.c:792
static double ccl_dlninvsig_dlogm(ccl_cosmology *cosmo, double halomass, int *status)
Definition: ccl_massfunc.c:537
double Omega_m
Definition: ccl_core.h:21
#define RHO_CRITICAL
Definition: ccl_constants.h:61
double ccl_massfunc_m2r ( ccl_cosmology cosmo,
double  smooth_mass,
int *  status 
)

Definition at line 606 of file ccl_massfunc.c.

References ccl_rho_x(), ccl_species_m_label, M_PI, and pow().

Referenced by ccl_cosmology_compute_sigma().

607 {
608  double rho_m, smooth_radius;
609 
610  // Comoving matter density
611  //rho_m = RHO_CRITICAL*cosmo->params.Omega_m*cosmo->params.h*cosmo->params.h;
612  rho_m = ccl_rho_x(cosmo, 1., ccl_species_m_label, 1, status);
613 
614  smooth_radius = pow((3.0*halomass) / (4*M_PI*rho_m), (1.0/3.0));
615 
616  return smooth_radius;
617 }
#define M_PI
Definition: ccl_constants.h:22
double ccl_rho_x(ccl_cosmology *cosmo, double a, ccl_species_x_label label, int is_comoving, int *status)
float pow(float base, unsigned long int exp)
Definition: precision.hpp:39
double ccl_sigmaM ( ccl_cosmology cosmo,
double  smooth_mass,
double  a,
int *  status 
)

Definition at line 624 of file ccl_massfunc.c.

References ccl_data::accelerator_m, ccl_check_status(), ccl_cosmology_compute_sigma(), ccl_cosmology_set_status_message(), CCL_ERROR_NOT_IMPLEMENTED, ccl_growth_factor(), ccl_raise_gsl_warning(), ccl_cosmology::computed_sigma, ccl_cosmology::data, ccl_data::logsigma, ccl_parameters::N_nu_mass, ccl_cosmology::params, and pow().

Referenced by ccl_halo_b1(), ccl_halo_concentration(), compare_massfunc(), compare_sigmam(), and massfunc_f().

625 {
626  if (cosmo->params.N_nu_mass>0){
627  *status = CCL_ERROR_NOT_IMPLEMENTED;
628  ccl_cosmology_set_status_message(cosmo, "ccl_background.c: ccl_cosmology_compute_growth(): Support for the sigma(M) function in cosmologies with massive neutrinos is not yet implemented.\n");
629  return NAN;
630  }
631 
632  double sigmaM;
633  // Check if sigma has already been calculated
634  if (!cosmo->computed_sigma) {
635  ccl_cosmology_compute_sigma(cosmo, status);
636  ccl_check_status(cosmo, status);
637  }
638 
639  double lgsigmaM;
640 
641  int gslstatus = gsl_spline_eval_e(cosmo->data.logsigma,
642  log10(halomass),
643  cosmo->data.accelerator_m,&lgsigmaM);
644 
645  if(gslstatus != GSL_SUCCESS) {
646  ccl_raise_gsl_warning(gslstatus, "ccl_massfunc.c: ccl_sigmaM():");
647  *status |= gslstatus;
648  }
649 
650  // Interpolate to get sigma
651  sigmaM = pow(10,lgsigmaM)*ccl_growth_factor(cosmo, a, status);
652  ccl_check_status(cosmo, status);
653  return sigmaM;
654 }
gsl_interp_accel * accelerator_m
Definition: ccl_core.h:93
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
ccl_parameters params
Definition: ccl_core.h:124
double ccl_growth_factor(ccl_cosmology *cosmo, double a, int *status)
void ccl_check_status(ccl_cosmology *cosmo, int *status)
Definition: ccl_error.c:88
void ccl_cosmology_compute_sigma(ccl_cosmology *cosmo, int *status)
Definition: ccl_massfunc.c:431
void ccl_cosmology_set_status_message(ccl_cosmology *cosmo, const char *status_message,...)
Definition: ccl_core.c:792
gsl_spline * logsigma
Definition: ccl_core.h:100
float pow(float base, unsigned long int exp)
Definition: precision.hpp:39
ccl_data data
Definition: ccl_core.h:126
bool computed_sigma
Definition: ccl_core.h:131
double dc_NakamuraSuto ( ccl_cosmology cosmo,
double  a,
int *  status 
)

Definition at line 21 of file ccl_massfunc.c.

References ccl_omega_x(), ccl_species_m_label, M_PI, and pow().

Referenced by ccl_halo_b1(), and massfunc_f().

21  {
22 
23  double Om_mz = ccl_omega_x(cosmo, a, ccl_species_m_label, status);
24  double dc0 = (3./20.)*pow(12.*M_PI,2./3.);
25  double dc = dc0*(1.+0.012299*log10(Om_mz));
26 
27  return dc;
28 
29 }
double ccl_omega_x(ccl_cosmology *cosmo, double a, ccl_species_x_label label, int *status)
#define M_PI
Definition: ccl_constants.h:22
float pow(float base, unsigned long int exp)
Definition: precision.hpp:39
double Dv_BryanNorman ( ccl_cosmology cosmo,
double  a,
int *  status 
)

Definition at line 37 of file ccl_massfunc.c.

References ccl_omega_x(), ccl_species_m_label, M_PI, pow(), and x.

Referenced by ccl_halo_b1(), ccl_halo_concentration(), ccl_twohalo_matter_power(), massfunc_f(), one_halo_integrand(), and two_halo_integrand().

37  {
38 
39  double Om_mz = ccl_omega_x(cosmo, a, ccl_species_m_label, status);
40  double x = Om_mz-1.;
41  double Dv0 = 18.*pow(M_PI,2);
42  double Dv = (Dv0+82.*x-39.*pow(x,2))/Om_mz;
43 
44  return Dv;
45 
46 }
double ccl_omega_x(ccl_cosmology *cosmo, double a, ccl_species_x_label label, int *status)
#define M_PI
Definition: ccl_constants.h:22
static CCL_BEGIN_DECLS double x[111][8]
float pow(float base, unsigned long int exp)
Definition: precision.hpp:39
double r_delta ( ccl_cosmology cosmo,
double  halomass,
double  a,
double  odelta,
int *  status 
)

Definition at line 52 of file ccl_massfunc.c.

References ccl_rho_x(), M_PI, and pow().

Referenced by window_function().

52  {
53 
54  double rho_matter = ccl_rho_x(cosmo, 1., 1, 1, status);
55 
56  return pow(halomass*3.0/(4.0*M_PI*rho_matter*odelta),1.0/3.0);
57 
58 }
#define M_PI
Definition: ccl_constants.h:22
double ccl_rho_x(ccl_cosmology *cosmo, double a, ccl_species_x_label label, int is_comoving, int *status)
float pow(float base, unsigned long int exp)
Definition: precision.hpp:39