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

Go to the source code of this file.

Macros

#define CCL_CORR_LGNDRE   1001
 
#define CCL_CORR_FFTLOG   1002
 
#define CCL_CORR_BESSEL   1003
 
#define CCL_CORR_GG   2001
 
#define CCL_CORR_GL   2002
 
#define CCL_CORR_LP   2003
 
#define CCL_CORR_LM   2004
 

Functions

CCL_BEGIN_DECLS void ccl_correlation (ccl_cosmology *cosmo, int n_ell, double *ell, double *cls, int n_theta, double *theta, double *wtheta, int corr_type, int do_taper_cl, double *taper_cl_limits, int flag_method, int *status)
 
void ccl_correlation_3d (ccl_cosmology *cosmo, double a, int n_r, double *r, double *xi, int do_taper_pk, double *taper_pk_limits, int *status)
 

Macro Definition Documentation

#define CCL_CORR_BESSEL   1003
#define CCL_CORR_FFTLOG   1002

Definition at line 7 of file ccl_correlation.h.

Referenced by __ctest_corrs_histo_fftlog_run(), ccl_correlation(), and main().

#define CCL_CORR_GG   2001
#define CCL_CORR_GL   2002
#define CCL_CORR_LGNDRE   1001

Definition at line 6 of file ccl_correlation.h.

Referenced by ccl_correlation().

#define CCL_CORR_LM   2004
#define CCL_CORR_LP   2003

Function Documentation

CCL_BEGIN_DECLS void ccl_correlation ( ccl_cosmology cosmo,
int  n_ell,
double ell,
double cls,
int  n_theta,
double theta,
double wtheta,
int  corr_type,
int  do_taper_cl,
double taper_cl_limits,
int  flag_method,
int *  status 
)

Computes the correlation function (wrapper)

Parameters
cosmo:Cosmological parameters
n_ell: number of multipoles in the input power spectrum
ell: multipoles at which the power spectrum is evaluated
cls: input power spectrum
n_theta: number of output values of the separation angle (theta)
theta: values of the separation angle in degrees.
wtheta: the values of the correlation function at the angles above will be returned in this array, which should be pre-allocated
do_taper_cl:
taper_cl_limits
flag_method: method to compute the correlation function. Choose between:
  • CCL_CORR_FFTLOG : fast integration with FFTLog
  • CCL_CORR_BESSEL : direct integration over the Bessel function
  • CCL_CORR_LGNDRE : brute-force sum over legendre polynomials
corr_type: type of correlation function. Choose between:
  • CCL_CORR_GG : spin0-spin0
  • CCL_CORR_GL : spin0-spin2
  • CCL_CORR_LP : spin2-spin2 (xi+)
  • CCL_CORR_LM : spin2-spin2 (xi-) Currently supported spin-0 fields are number counts and CMB lensing. The only spin-2 is currently shear.

Definition at line 391 of file ccl_correlation.c.

References ccl_check_status(), CCL_CORR_BESSEL, CCL_CORR_FFTLOG, CCL_CORR_LGNDRE, ccl_cosmology_set_status_message(), CCL_ERROR_INCONSISTENT, ccl_tracer_corr_bessel(), ccl_tracer_corr_fftlog(), and ccl_tracer_corr_legendre().

Referenced by compare_corr(), and main().

396 {
397  switch(flag_method) {
398  case CCL_CORR_FFTLOG :
399  ccl_tracer_corr_fftlog(cosmo,n_ell,ell,cls,n_theta,theta,wtheta,corr_type,
400  do_taper_cl,taper_cl_limits,status);
401  break;
402  case CCL_CORR_LGNDRE :
403  ccl_tracer_corr_legendre(cosmo,n_ell,ell,cls,n_theta,theta,wtheta,corr_type,
404  do_taper_cl,taper_cl_limits,status);
405  break;
406  case CCL_CORR_BESSEL :
407  ccl_tracer_corr_bessel(cosmo,n_ell,ell,cls,n_theta,theta,wtheta,corr_type,status);
408  break;
409  default :
410  *status=CCL_ERROR_INCONSISTENT;
411  ccl_cosmology_set_status_message(cosmo, "ccl_correlation.c: ccl_correlation. Unknown algorithm\n");
412  }
413 
414  ccl_check_status(cosmo,status);
415 }
static void ccl_tracer_corr_bessel(ccl_cosmology *cosmo, int n_ell, double *ell, double *cls, int n_theta, double *theta, double *wtheta, int corr_type, int *status)
void ccl_check_status(ccl_cosmology *cosmo, int *status)
Definition: ccl_error.c:88
static void ccl_tracer_corr_legendre(ccl_cosmology *cosmo, int n_ell, double *ell, double *cls, int n_theta, double *theta, double *wtheta, int corr_type, int do_taper_cl, double *taper_cl_limits, int *status)
void ccl_cosmology_set_status_message(ccl_cosmology *cosmo, const char *status_message,...)
Definition: ccl_core.c:792
#define CCL_CORR_BESSEL
static void ccl_tracer_corr_fftlog(ccl_cosmology *cosmo, int n_ell, double *ell, double *cls, int n_theta, double *theta, double *wtheta, int corr_type, int do_taper_cl, double *taper_cl_limits, int *status)
#define CCL_CORR_FFTLOG
#define CCL_ERROR_INCONSISTENT
Definition: ccl_error.h:12
#define CCL_CORR_LGNDRE
void ccl_correlation_3d ( ccl_cosmology cosmo,
double  a,
int  n_r,
double r,
double xi,
int  do_taper_pk,
double taper_pk_limits,
int *  status 
)

Computes the 3dcorrelation function (wrapper)

Parameters
cosmo:Cosmological parameters
a: scale factor
n_r: number of output values of distance r
r: values of the distance in Mpc
xi: the values of the correlation function at the distances above will be returned in this array, which should be pre-allocated
do_taper_pk: key for tapering (using cosine tapering by default)
taper_pk_limitslimits of tapering

Definition at line 427 of file ccl_correlation.c.

References ccl_check_status(), ccl_cosmology_set_status_message(), CCL_ERROR_MEMORY, ccl_log_spacing(), ccl_nonlin_matter_power(), ccl_spline_eval(), ccl_spline_free(), ccl_spline_init(), ccl_splines, ccl_spline_params::K_MAX, ccl_spline_params::K_MIN, ccl_spline_params::N_K_3DCOR, pk2xi(), and taper_cl().

Referenced by compare_correlation_3d(), and main().

431 {
432  int i,N_ARR;
433  double *k_arr,*pk_arr,*r_arr,*xi_arr;
434 
435  //number of data points for k and pk array
436  N_ARR=(int)(ccl_splines->N_K_3DCOR*log10(ccl_splines->K_MAX/ccl_splines->K_MIN));
437 
439  if(k_arr==NULL) {
440  *status=CCL_ERROR_MEMORY;
441  ccl_cosmology_set_status_message(cosmo, "ccl_correlation.c: ccl_correlation_3d ran out of memory\n");
442  return;
443  }
444 
445  pk_arr=malloc(N_ARR*sizeof(double));
446  if(pk_arr==NULL) {
447  free(k_arr);
448  *status=CCL_ERROR_MEMORY;
449  ccl_cosmology_set_status_message(cosmo, "ccl_correlation.c: ccl_correlation_3d ran out of memory\n");
450  return;
451  }
452 
453  for (i=0; i<N_ARR; i++)
454  pk_arr[i] = ccl_nonlin_matter_power(cosmo, k_arr[i], a, status);
455 
456  if (do_taper_pk)
457  taper_cl(N_ARR,k_arr,pk_arr,taper_pk_limits);
458 
459  r_arr=malloc(sizeof(double)*N_ARR);
460  if(r_arr==NULL) {
461  free(k_arr);
462  free(pk_arr);
463  *status=CCL_ERROR_MEMORY;
464  ccl_cosmology_set_status_message(cosmo, "ccl_correlation.c: ccl_correlation_3d ran out of memory\n");
465  return;
466  }
467  xi_arr=malloc(sizeof(double)*N_ARR);
468  if(xi_arr==NULL) {
469  free(k_arr); free(pk_arr); free(r_arr);
470  *status=CCL_ERROR_MEMORY;
471  ccl_cosmology_set_status_message(cosmo, "ccl_correlation.c: ccl_correlation_3d ran out of memory\n");
472  return;
473  }
474 
475  for(i=0;i<N_ARR;i++)
476  r_arr[i]=0;
477 
478  pk2xi(N_ARR,k_arr,pk_arr,r_arr,xi_arr);
479 
480  // Interpolate to output values of r
481  SplPar *xi_spl=ccl_spline_init(N_ARR,r_arr,xi_arr,xi_arr[0],0);
482  for(i=0;i<n_r;i++)
483  xi[i]=ccl_spline_eval(r[i],xi_spl);
484  ccl_spline_free(xi_spl);
485 
486  free(k_arr); free(pk_arr);
487  free(r_arr); free(xi_arr);
488 
489  ccl_check_status(cosmo,status);
490 
491  return;
492 }
double ccl_nonlin_matter_power(ccl_cosmology *cosmo, double k, double a, int *status)
Definition: ccl_power.c:1562
double * ccl_log_spacing(double xmin, double xmax, int N)
Definition: ccl_utils.c:102
void ccl_check_status(ccl_cosmology *cosmo, int *status)
Definition: ccl_error.c:88
ccl_spline_params * ccl_splines
Definition: ccl_core.c:47
void ccl_cosmology_set_status_message(ccl_cosmology *cosmo, const char *status_message,...)
Definition: ccl_core.c:792
double ccl_spline_eval(double x, SplPar *spl)
Definition: ccl_utils.c:170
void ccl_spline_free(SplPar *spl)
Definition: ccl_utils.c:316
#define CCL_ERROR_MEMORY
Definition: ccl_error.h:10
void pk2xi(int N, const double k[], const double pk[], double r[], double xi[])
Definition: fftlog.c:176
static int taper_cl(int n_ell, double *ell, double *cl, double *ell_limits)
SplPar * ccl_spline_init(int n, double *x, double *y, double y0, double yf)
Definition: ccl_utils.c:146