CLASS MANUAL
transfer.c File Reference
#include "transfer.h"
+ Include dependency graph for transfer.c:

Functions

int transfer_functions_at_q (struct transfer *ptr, int index_md, int index_ic, int index_tt, int index_l, double q, double *transfer_function)
 
int transfer_init (struct precision *ppr, struct background *pba, struct thermodynamics *pth, struct perturbations *ppt, struct fourier *pfo, struct transfer *ptr)
 
int transfer_free (struct transfer *ptr)
 
int transfer_indices (struct precision *ppr, struct perturbations *ppt, struct transfer *ptr, double q_period, double K, int sgnK)
 
int transfer_get_l_list (struct precision *ppr, struct perturbations *ppt, struct transfer *ptr)
 
int transfer_get_q_list (struct precision *ppr, struct perturbations *ppt, struct transfer *ptr, double q_period, double K, int sgnK)
 
int transfer_get_k_list (struct perturbations *ppt, struct transfer *ptr, double K)
 
int transfer_get_source_correspondence (struct perturbations *ppt, struct transfer *ptr, int **tp_of_tt)
 
int transfer_source_tau_size (struct precision *ppr, struct background *pba, struct perturbations *ppt, struct transfer *ptr, double tau_rec, double tau0, int index_md, int index_tt, int *tau_size)
 
int transfer_compute_for_each_q (struct precision *ppr, struct background *pba, struct perturbations *ppt, struct transfer *ptr, int **tp_of_tt, int index_q, int tau_size_max, double tau_rec, double ***pert_sources, double ***pert_sources_spline, double *window, struct transfer_workspace *ptw)
 
int transfer_interpolate_sources (struct perturbations *ppt, struct transfer *ptr, int index_q, int index_md, int index_ic, int index_type, double *pert_source, double *pert_source_spline, double *interpolated_sources)
 
int transfer_sources (struct precision *ppr, struct background *pba, struct perturbations *ppt, struct transfer *ptr, double *interpolated_sources, double tau_rec, int index_q, int index_md, int index_tt, double *sources, double *window, int tau_size_max, double *tau0_minus_tau, double *w_trapz, int *tau_size_out)
 
int transfer_selection_function (struct precision *ppr, struct perturbations *ppt, struct transfer *ptr, int bin, double z, double *selection)
 
int transfer_dNdz_analytic (struct transfer *ptr, double z, double *dNdz, double *dln_dNdz_dz)
 
int transfer_selection_sampling (struct precision *ppr, struct background *pba, struct perturbations *ppt, struct transfer *ptr, int bin, double *tau0_minus_tau, int tau_size)
 
int transfer_lensing_sampling (struct precision *ppr, struct background *pba, struct perturbations *ppt, struct transfer *ptr, int bin, double tau0, double *tau0_minus_tau, int tau_size)
 
int transfer_source_resample (struct precision *ppr, struct background *pba, struct perturbations *ppt, struct transfer *ptr, int bin, double *tau0_minus_tau, int tau_size, int index_md, double tau0, double *interpolated_sources, double *sources)
 
int transfer_selection_times (struct precision *ppr, struct background *pba, struct perturbations *ppt, struct transfer *ptr, int bin, double *tau_min, double *tau_mean, double *tau_max)
 
int transfer_selection_compute (struct precision *ppr, struct background *pba, struct perturbations *ppt, struct transfer *ptr, double *selection, double *tau0_minus_tau, double *w_trapz, int tau_size, double *pvecback, double tau0, int bin)
 
int transfer_compute_for_each_l (struct transfer_workspace *ptw, struct precision *ppr, struct perturbations *ppt, struct transfer *ptr, int index_q, int index_md, int index_ic, int index_tt, int index_l, double l, double q_max_bessel, radial_function_type radial_type)
 
int transfer_integrate (struct perturbations *ppt, struct transfer *ptr, struct transfer_workspace *ptw, int index_q, int index_md, int index_tt, double l, int index_l, double k, radial_function_type radial_type, double *trsf)
 
int transfer_limber (struct transfer *ptr, struct transfer_workspace *ptw, int index_md, int index_q, double l, double q, radial_function_type radial_type, double *trsf)
 
int transfer_limber_interpolate (struct transfer *ptr, double *tau0_minus_tau, double *sources, int tau_size, double tau0_minus_tau_limber, double *S)
 
int transfer_limber2 (int tau_size, struct transfer *ptr, int index_md, int index_k, double l, double k, double *tau0_minus_tau, double *sources, radial_function_type radial_type, double *trsf)
 
int transfer_precompute_selection (struct precision *ppr, struct background *pba, struct perturbations *ppt, struct transfer *ptr, double tau_rec, int tau_size_max, double **window)
 

Detailed Description

Documented transfer module.

Julien Lesgourgues, 28.07.2013

This module has two purposes:

  • at the beginning, to compute the transfer functions $ \Delta_l^{X} (q) $, and store them in tables used for interpolation in other modules.
  • at any time in the code, to evaluate the transfer functions (for a given mode, initial condition, type and multipole l) at any wavenumber q (by interpolating within the interpolation table).

Hence the following functions can be called from other modules:

  1. transfer_init() at the beginning (but after perturbations_init() and bessel_init())
  2. transfer_functions_at_q() at any later time
  3. transfer_free() at the end, when no more calls to transfer_functions_at_q() are needed

Note that in the standard implementation of CLASS, only the pre-computed values of the transfer functions are used, no interpolation is necessary; hence the routine transfer_functions_at_q() is actually never called.

Function Documentation

◆ transfer_functions_at_q()

int transfer_functions_at_q ( struct transfer ptr,
int  index_md,
int  index_ic,
int  index_tt,
int  index_l,
double  q,
double *  transfer_function 
)

Transfer function $ \Delta_l^{X} (q) $ at a given wavenumber q.

For a given mode (scalar, vector, tensor), initial condition, type (temperature, polarization, lensing, etc) and multipole, computes the transfer function for an arbitrary value of q by interpolating between pre-computed values of q. This function can be called from whatever module at whatever time, provided that transfer_init() has been called before, and transfer_free() has not been called yet.

Wavenumbers are called q in this module and k in the perturbation module. In flat universes k=q. In non-flat universes q and k differ through $ q2 = k2 + K(1+m)$, where m=0,1,2 for scalar, vector, tensor. q should be used throughout the transfer module, excepted when interpolating or manipulating the source functions S(k,tau) calculated in the perturbation module: for a given value of q, this should be done at the corresponding k(q).

Parameters
ptrInput: pointer to transfer structure
index_mdInput: index of requested mode
index_icInput: index of requested initial condition
index_ttInput: index of requested type
index_lInput: index of requested multipole
qInput: any wavenumber
transfer_functionOutput: transfer function
Returns
the error status

Summary:

  • interpolate in pre-computed table using array_interpolate_two()

◆ transfer_init()

int transfer_init ( struct precision ppr,
struct background pba,
struct thermodynamics pth,
struct perturbations ppt,
struct fourier pfo,
struct transfer ptr 
)

This routine initializes the transfer structure, (in particular, computes table of transfer functions $ \Delta_l^{X} (q) $)

Main steps:

  • initialize all indices in the transfer structure and allocate all its arrays using transfer_indices().
  • for each thread (in case of parallel run), initialize the fields of a memory zone called the transfer_workspace with transfer_workspace_init()
  • loop over q values. For each q, compute the Bessel functions if needed with transfer_update_HIS(), and defer the calculation of all transfer functions to transfer_compute_for_each_q()
  • for each thread, free the the workspace with transfer_workspace_free()
Parameters
pprInput: pointer to precision structure
pbaInput: pointer to background structure
pthInput: pointer to thermodynamics structure
pptInput: pointer to perturbation structure
pfoInput: pointer to fourier structure
ptrOutput: pointer to initialized transfer structure
Returns
the error status

Summary:

  • define local variables
  • array with the correspondence between the index of sources in the perturbation module and in the transfer module, tp_of_tt[index_md][index_tt]
  • check whether any spectrum in harmonic space (i.e., any $C_l$'s) is actually requested
  • get number of modes (scalars, tensors...)
  • get conformal age / recombination time from background / thermodynamics structures (only place where these structures are used in this module)
  • correspondence between k and l depend on angular diameter distance, i.e. on curvature.
  • order of magnitude of the oscillation period of transfer functions
  • initialize all indices in the transfer structure and allocate all its arrays using transfer_indices()
  • copy sources to a local array sources (in fact, only the pointers are copied, not the data), and eventually apply non-linear corrections to the sources
  • spline all the sources passed by the perturbation module with respect to k (in order to interpolate later at a given value of k)
  • allocate and fill array describing the correspondence between perturbation types and transfer types
  • evaluate maximum number of sampled times in the transfer sources: needs to be known here, in order to allocate a large enough workspace
  • compute flat spherical bessel functions
  • eventually read the selection and evolution functions
  • precompute window function for integrated nCl/sCl quantities
  • loop over all wavenumbers (parallelized).
  • finally, free arrays allocated outside parallel zone

◆ transfer_free()

int transfer_free ( struct transfer ptr)

This routine frees all the memory space allocated by transfer_init().

To be called at the end of each run, only when no further calls to transfer_functions_at_k() are needed.

Parameters
ptrInput: pointer to transfer structure (which fields must be freed)
Returns
the error status
+ Here is the call graph for this function:

◆ transfer_indices()

int transfer_indices ( struct precision ppr,
struct perturbations ppt,
struct transfer ptr,
double  q_period,
double  K,
int  sgnK 
)

This routine defines all indices and allocates all tables in the transfer structure

Compute list of (k, l) values, allocate and fill corresponding arrays in the transfer structure. Allocate the array of transfer function tables.

Parameters
pprInput: pointer to precision structure
pptInput: pointer to perturbation structure
ptrInput/Output: pointer to transfer structure
q_periodInput: order of magnitude of the oscillation period of transfer functions
KInput: spatial curvature (in absolute value)
sgnKInput: spatial curvature sign (open/closed/flat)
Returns
the error status

Summary:

  • define local variables
  • define indices for transfer types
  • type indices common to scalars and tensors
  • type indices for scalars
  • type indices for vectors
  • type indices for tensors
  • allocate arrays of (k, l) values and transfer functions
  • get q values using transfer_get_q_list()
  • get k values using transfer_get_k_list()
  • get l values using transfer_get_l_list()
  • loop over modes (scalar, etc). For each mode:
  • allocate arrays of transfer functions, (ptr->transfer[index_md])[index_ic][index_tt][index_l][index_k]

◆ transfer_get_l_list()

int transfer_get_l_list ( struct precision ppr,
struct perturbations ppt,
struct transfer ptr 
)

This routine defines the number and values of multipoles l for all modes.

Parameters
pprInput: pointer to precision structure
pptInput: pointer to perturbation structure
ptrInput/Output: pointer to transfer structure containing l's
Returns
the error status

Summary:

  • allocate and fill l array
  • start from l = 2 and increase with logarithmic step
  • when the logarithmic step becomes larger than some linear step, stick to this linear step till l_max
  • last value set to exactly l_max
  • so far we just counted the number of values. Now repeat the whole thing but fill array with values.

◆ transfer_get_q_list()

int transfer_get_q_list ( struct precision ppr,
struct perturbations ppt,
struct transfer ptr,
double  q_period,
double  K,
int  sgnK 
)

This routine defines the number and values of wavenumbers q for each mode (goes smoothly from logarithmic step for small q's to linear step for large q's).

Parameters
pprInput: pointer to precision structure
pptInput: pointer to perturbation structure
ptrInput/Output: pointer to transfer structure containing q's
q_periodInput: order of magnitude of the oscillation period of transfer functions
KInput: spatial curvature (in absolute value)
sgnKInput: spatial curvature sign (open/closed/flat)
Returns
the error status

◆ transfer_get_k_list()

int transfer_get_k_list ( struct perturbations ppt,
struct transfer ptr,
double  K 
)

This routine infers from the q values a list of corresponding k values for each mode.

Parameters
pptInput: pointer to perturbation structure
ptrInput/Output: pointer to transfer structure containing q's
KInput: spatial curvature
Returns
the error status

◆ transfer_get_source_correspondence()

int transfer_get_source_correspondence ( struct perturbations ppt,
struct transfer ptr,
int **  tp_of_tt 
)

This routine defines the correspondence between the sources in the perturbation and transfer module.

Parameters
pptInput: pointer to perturbation structure
ptrInput: pointer to transfer structure containing l's
tp_of_ttInput/Output: array with the correspondence (allocated before, filled here)
Returns
the error status

Summary:

  • running index on modes
  • running index on transfer types
  • which source are we considering? Define correspondence between transfer types and source types

◆ transfer_source_tau_size()

int transfer_source_tau_size ( struct precision ppr,
struct background pba,
struct perturbations ppt,
struct transfer ptr,
double  tau_rec,
double  tau0,
int  index_md,
int  index_tt,
int *  tau_size 
)

the code makes a distinction between "perturbation sources" (e.g. gravitational potential) and "transfer sources" (e.g. total density fluctuations, obtained through the Poisson equation, and observed with a given selection function).

This routine computes the number of sampled time values for each type of transfer sources.

Parameters
pprInput: pointer to precision structure
pbaInput: pointer to background structure
pptInput: pointer to perturbation structure
ptrInput: pointer to transfer structure
tau_recInput: recombination time
tau0Input: time today
index_mdInput: index of the mode (scalar, tensor)
index_ttInput: index of transfer type
tau_sizeOutput: pointer to number of sampled times
Returns
the error status

◆ transfer_compute_for_each_q()

int transfer_compute_for_each_q ( struct precision ppr,
struct background pba,
struct perturbations ppt,
struct transfer ptr,
int **  tp_of_tt,
int  index_q,
int  tau_size_max,
double  tau_rec,
double ***  pert_sources,
double ***  pert_sources_spline,
double *  window,
struct transfer_workspace ptw 
)

Summary:

  • define local variables
  • we deal with workspaces, i.e. with contiguous memory zones (one per thread) containing various fields used by the integration routine
  • for a given l, maximum value of k such that we can convolve the source with Bessel functions j_l(x) without reaching x_max
  • store the sources in the workspace and define all fields in this workspace
  • loop over all modes. For each mode
  • loop over initial conditions.
  • check if we must now deal with a new source with a new index ppt->index_type. If yes, interpolate it at the right values of k.
  • Select radial function type

◆ transfer_interpolate_sources()

int transfer_interpolate_sources ( struct perturbations ppt,
struct transfer ptr,
int  index_q,
int  index_md,
int  index_ic,
int  index_type,
double *  pert_source,
double *  pert_source_spline,
double *  interpolated_sources 
)

This routine interpolates sources $ S(k, \tau) $ for each mode, initial condition and type (of perturbation module), to get them at the right values of k, using the spline interpolation method.

Parameters
pptInput: pointer to perturbation structure
ptrInput: pointer to transfer structure
index_qInput: index of wavenumber
index_mdInput: index of mode
index_icInput: index of initial condition
index_typeInput: index of type of source (in perturbation module)
pert_sourceInput: array of sources
pert_source_splineInput: array of second derivative of sources
interpolated_sourcesOutput: array of interpolated sources (filled here but allocated in transfer_init() to avoid numerous reallocation)
Returns
the error status

Summary:

  • define local variables
  • interpolate at each k value using the usual spline interpolation algorithm.

◆ transfer_sources()

int transfer_sources ( struct precision ppr,
struct background pba,
struct perturbations ppt,
struct transfer ptr,
double *  interpolated_sources,
double  tau_rec,
int  index_q,
int  index_md,
int  index_tt,
double *  sources,
double *  window,
int  tau_size_max,
double *  tau0_minus_tau,
double *  w_trapz,
int *  tau_size_out 
)

The code makes a distinction between "perturbation sources" (e.g. gravitational potential) and "transfer sources" (e.g. total density fluctuations, obtained through the Poisson equation, and observed with a given selection function).

This routine computes the transfer source given the interpolated perturbation source, and copies it in the workspace.

Parameters
pprInput: pointer to precision structure
pbaInput: pointer to background structure
pptInput: pointer to perturbation structure
ptrInput: pointer to transfer structure
interpolated_sourcesInput: interpolated perturbation source
tau_recInput: recombination time
index_qInput: index of wavenumber
index_mdInput: index of mode
index_ttInput: index of type of (transfer) source
sourcesOutput: transfer source
windowInput: window functions for each type and time
tau_size_maxInput: number of times at wich window fucntions are sampled
tau0_minus_tauOutput: values of (tau0-tau) at which source are sample
w_trapzOutput: trapezoidal weights for integration over tau
tau_size_outOutput: pointer to size of previous two arrays, converted to double
Returns
the error status

Summary:

  • define local variables
  • in which cases are perturbation and transfer sources are different? I.e., in which case do we need to multiply the sources by some background and/or window function, and eventually to resample it, or redefine its time limits?
  • case where we need to redefine by a window function (or any function of the background and of k)
  • case where we do not need to redefine
  • return tau_size value that will be stored in the workspace (the workspace wants a double)

◆ transfer_selection_function()

int transfer_selection_function ( struct precision ppr,
struct perturbations ppt,
struct transfer ptr,
int  bin,
double  z,
double *  selection 
)

Arbitrarily normalized selection function dN/dz(z,bin)

Parameters
pprInput: pointer to precision structure
pptInput: pointer to perturbation structure
ptrInput: pointer to transfer structure
binInput: redshift bin number
zInput: one value of redshift
selectionOutput: pointer to selection function
Returns
the error status

◆ transfer_dNdz_analytic()

int transfer_dNdz_analytic ( struct transfer ptr,
double  z,
double *  dNdz,
double *  dln_dNdz_dz 
)

Analytic form for dNdz distribution, from arXiv:1004.4640

Parameters
ptrInput: pointer to transfer structure
zInput: redshift
dNdzOutput: density per redshift, dN/dZ
dln_dNdz_dzOutput: dln(dN/dz)/dz, used optionally for the source evolution
Returns
the error status

◆ transfer_selection_sampling()

int transfer_selection_sampling ( struct precision ppr,
struct background pba,
struct perturbations ppt,
struct transfer ptr,
int  bin,
double *  tau0_minus_tau,
int  tau_size 
)

For sources that need to be multiplied by a selection function, redefine a finer time sampling in a small range

Parameters
pprInput: pointer to precision structure
pbaInput: pointer to background structure
pptInput: pointer to perturbation structure
ptrInput: pointer to transfer structure
binInput: redshift bin number
tau0_minus_tauOutput: values of (tau0-tau) at which source are sample
tau_sizeOutput: pointer to size of previous array
Returns
the error status

◆ transfer_lensing_sampling()

int transfer_lensing_sampling ( struct precision ppr,
struct background pba,
struct perturbations ppt,
struct transfer ptr,
int  bin,
double  tau0,
double *  tau0_minus_tau,
int  tau_size 
)

For lensing sources that need to be convolved with a selection function, redefine the sampling within the range extending from the tau_min of the selection function up to tau0

Parameters
pprInput: pointer to precision structure
pbaInput: pointer to background structure
pptInput: pointer to perturbation structure
ptrInput: pointer to transfer structure
binInput: redshift bin number
tau0Input: time today
tau0_minus_tauOutput: values of (tau0-tau) at which source are sample
tau_sizeOutput: pointer to size of previous array
Returns
the error status

◆ transfer_source_resample()

int transfer_source_resample ( struct precision ppr,
struct background pba,
struct perturbations ppt,
struct transfer ptr,
int  bin,
double *  tau0_minus_tau,
int  tau_size,
int  index_md,
double  tau0,
double *  interpolated_sources,
double *  sources 
)

For sources that need to be multiplied by a selection function, redefine a finer time sampling in a small range, and resample the perturbation sources at the new value by linear interpolation

Parameters
pprInput: pointer to precision structure
pbaInput: pointer to background structure
pptInput: pointer to perturbation structure
ptrInput: pointer to transfer structure
binInput: redshift bin number
tau0_minus_tauOutput: values of (tau0-tau) at which source are sample
tau_sizeOutput: pointer to size of previous array
index_mdInput: index of mode
tau0Input: time today
interpolated_sourcesInput: interpolated perturbation source
sourcesOutput: resampled transfer source
Returns
the error status

◆ transfer_selection_times()

int transfer_selection_times ( struct precision ppr,
struct background pba,
struct perturbations ppt,
struct transfer ptr,
int  bin,
double *  tau_min,
double *  tau_mean,
double *  tau_max 
)

For each selection function, compute the min, mean and max values of conformal time (associated to the min, mean and max values of redshift specified by the user)

Parameters
pprInput: pointer to precision structure
pbaInput: pointer to background structure
pptInput: pointer to perturbation structure
ptrInput: pointer to transfer structure
binInput: redshift bin number
tau_minOutput: smallest time in the selection interval
tau_meanOutput: time corresponding to z_mean
tau_maxOutput: largest time in the selection interval
Returns
the error status

◆ transfer_selection_compute()

int transfer_selection_compute ( struct precision ppr,
struct background pba,
struct perturbations ppt,
struct transfer ptr,
double *  selection,
double *  tau0_minus_tau,
double *  w_trapz,
int  tau_size,
double *  pvecback,
double  tau0,
int  bin 
)

Compute and normalize selection function for a set of time values

Parameters
pprInput: pointer to precision structure
pbaInput: pointer to background structure
pptInput: pointer to perturbation structure
ptrInput: pointer to transfer structure
selectionOutput: normalized selection function
tau0_minus_tauInput: values of (tau0-tau) at which source are sample
w_trapzInput: trapezoidal weights for integration over tau
tau_sizeInput: size of previous two arrays
pvecbackInput: allocated array of background values
tau0Input: time today
binInput: redshift bin number
Returns
the error status

◆ transfer_compute_for_each_l()

int transfer_compute_for_each_l ( struct transfer_workspace ptw,
struct precision ppr,
struct perturbations ppt,
struct transfer ptr,
int  index_q,
int  index_md,
int  index_ic,
int  index_tt,
int  index_l,
double  l,
double  q_max_bessel,
radial_function_type  radial_type 
)

This routine computes the transfer functions $ \Delta_l^{X} (k) $) as a function of wavenumber k for a given mode, initial condition, type and multipole l passed in input.

For a given value of k, the transfer function is inferred from the source function (passed in input in the array interpolated_sources) and from Bessel functions (passed in input in the bessels structure), either by convolving them along tau, or by a Limber approximation. This elementary task is distributed either to transfer_integrate() or to transfer_limber(). The task of this routine is mainly to loop over k values, and to decide at which k_max the calculation can be stopped, according to some approximation scheme designed to find a compromise between execution time and precision. The approximation scheme is defined by parameters in the precision structure.

Parameters
ptwInput: pointer to transfer_workspace structure (allocated in transfer_init() to avoid numerous reallocation)
pprInput: pointer to precision structure
pptInput: pointer to perturbation structure
ptrInput/output: pointer to transfer structure (result stored there)
index_qInput: index of wavenumber
index_mdInput: index of mode
index_icInput: index of initial condition
index_ttInput: index of type of transfer
index_lInput: index of multipole
lInput: multipole
q_max_besselInput: maximum value of argument q at which Bessel functions are computed
radial_typeInput: type of radial (Bessel) functions to convolve with
Returns
the error status

Summary:

  • define local variables
  • return zero transfer function if l is above l_max
  • store transfer function in transfer structure
+ Here is the call graph for this function:

◆ transfer_integrate()

int transfer_integrate ( struct perturbations ppt,
struct transfer ptr,
struct transfer_workspace ptw,
int  index_q,
int  index_md,
int  index_tt,
double  l,
int  index_l,
double  k,
radial_function_type  radial_type,
double *  trsf 
)

This routine computes the transfer functions $ \Delta_l^{X} (k) $) for each mode, initial condition, type, multipole l and wavenumber k, by convolving the source function (passed in input in the array interpolated_sources) with Bessel functions (passed in input in the bessels structure).

Parameters
pptInput: pointer to perturbation structure
ptrInput: pointer to transfer structure
ptwInput: pointer to transfer_workspace structure (allocated in transfer_init() to avoid numerous reallocation)
index_qInput: index of wavenumber
index_mdInput: index of mode
index_ttInput: index of type
lInput: multipole
index_lInput: index of multipole
kInput: wavenumber
radial_typeInput: type of radial (Bessel) functions to convolve with
trsfOutput: transfer function $ \Delta_l(k) $
Returns
the error status

Summary:

  • define local variables
  • find minimum value of (tau0-tau) at which $ j_l(k[\tau_0-\tau]) $ is known, given that $ j_l(x) $ is sampled above some finite value $ x_{\min} $ (below which it can be approximated by zero)
  • if there is no overlap between the region in which bessels and sources are non-zero, return zero
  • if there is an overlap:
  • --> trivial case: the source is a Dirac function and is sampled in only one point
  • --> other cases
  • —> (a) find index in the source's tau list corresponding to the last point in the overlapping region. After this step, index_tau_max can be as small as zero, but not negative.
  • —> (b) the source function can vanish at large $ \tau $. Check if further points can be eliminated. After this step and if we did not return a null transfer function, index_tau_max can be as small as zero, but not negative.
  • Compute the radial function:
  • Now we do most of the convolution integral:
  • This integral is correct for the case where no truncation has occurred. If it has been truncated at some index_tau_max because f[index_tau_max+1]==0, it is still correct. The 'mistake' in using the wrong weight w_trapz[index_tau_max] is exactly compensated by the triangle we miss. However, for the Bessel cut off, we must subtract the wrong triangle and add the correct triangle.

◆ transfer_limber()

int transfer_limber ( struct transfer ptr,
struct transfer_workspace ptw,
int  index_md,
int  index_q,
double  l,
double  q,
radial_function_type  radial_type,
double *  trsf 
)

This routine computes the transfer functions $ \Delta_l^{X} (k) $) for each mode, initial condition, type, multipole l and wavenumber k, by using the Limber approximation, i.e by evaluating the source function (passed in input in the array interpolated_sources) at a single value of tau (the Bessel function being approximated as a Dirac distribution).

Parameters
ptrInput: pointer to transfer structure
ptwInput: pointer to transfer workspace structure
index_mdInput: index of mode
index_qInput: index of wavenumber
lInput: multipole
qInput: wavenumber
radial_typeInput: type of radial (Bessel) functions to convolve with
trsfOutput: transfer function $ \Delta_l(k) $
Returns
the error status

Summary:

  • define local variables
  • get k, l and infer tau such that k(tau0-tau)=l+1/2; check that tau is in appropriate range
  • get transfer = source * $ \sqrt{\pi/(2l+1)}/q $ = source*[tau0-tau] * $ \sqrt{\pi/(2l+1)}/(l+1/2)$

◆ transfer_limber_interpolate()

int transfer_limber_interpolate ( struct transfer ptr,
double *  tau0_minus_tau,
double *  sources,
int  tau_size,
double  tau0_minus_tau_limber,
double *  S 
)
  • find bracketing indices. index_tau must be at least 1 (so that index_tau-1 is at least 0) and at most tau_size-2 (so that index_tau+1 is at most tau_size-1).
  • interpolate by fitting a polynomial of order two; get source and its first two derivatives. Note that we are not interpolating S, but the product S*(tau0-tau). Indeed this product is regular in tau=tau0, while S alone diverges for lensing.

◆ transfer_limber2()

int transfer_limber2 ( int  tau_size,
struct transfer ptr,
int  index_md,
int  index_k,
double  l,
double  k,
double *  tau0_minus_tau,
double *  sources,
radial_function_type  radial_type,
double *  trsf 
)

This routine computes the transfer functions $ \Delta_l^{X} (k) $) for each mode, initial condition, type, multipole l and wavenumber k, by using the Limber approximation at order two, i.e as a function of the source function and its first two derivatives at a single value of tau

Parameters
tau_sizeInput: size of conformal time array
ptrInput: pointer to transfer structure
index_mdInput: index of mode
index_kInput: index of wavenumber
lInput: multipole
kInput: wavenumber
tau0_minus_tauInput: array of values of (tau_today - tau)
sourcesInput: source functions
radial_typeInput: type of radial (Bessel) functions to convolve with
trsfOutput: transfer function $ \Delta_l(k) $
Returns
the error status

Summary:

  • define local variables
  • get k, l and infer tau such that k(tau0-tau)=l+1/2; check that tau is in appropriate range
  • find bracketing indices
  • interpolate by fitting a polynomial of order two; get source and its first two derivatives
  • get transfer from 2nd order Limber approx (inferred from 0809.5112 [astro-ph])

◆ transfer_precompute_selection()

int transfer_precompute_selection ( struct precision ppr,
struct background pba,
struct perturbations ppt,
struct transfer ptr,
double  tau_rec,
int  tau_size_max,
double **  window 
)

Here we can precompute the window functions for the final integration For each type of nCl/dCl/sCl we combine the selection function with the corresponding prefactor (e.g. 1/aH), and, if required, we also integrate for integrated (lensed) contributions (In the original ClassGAL paper these would be labeled g4,g5, and lens)

All factors of k have to be added later (at least in the current version)

Parameters
pprInput: pointer to precision structure
pbaInput: pointer to background structure
pptInput: pointer to perturbation structure
ptrInput: pointer to transfer structure
tau_recInput: recombination time
tau_size_maxInput: maximum size that tau array can have
windowOutput: pointer to array of selection functions
Returns
the error status

Summary:

  • define local variables