Sources#

discocmb.sources implements the line-of-sight sources that are passed to DISCO-EB for computation on-the-fly alongside the E-B integration.

Line-of-sight integration (Seljak & Zaldarriaga 1996, discocmb.transfer) builds today’s anisotropy from a few local sources. They combine the perturbation state with the visibility g = kappa' exp(-kappa):

  • S: the monopole (Sachs-Wolfe) and polarization correction times g, plus the integrated Sachs-Wolfe term 2 Phi' exp(-kappa).

  • S_j1: the Doppler term g (k alpha + theta_b / k).

  • S_j2: the quadrupole and polarization term.

They multiply j_l(x), j_l'(x) and j_l''(x) with x = k (tau_0 - tau). The E-mode transfer function reuses S_j2 against j_l(x) / x^2 (CAMB’s sources(2)).

The solve. LineOfSightSources is a DISCO-EB component, which discoeb.solve_eb() compiles into its kernel when passed as extra. With keep=[LineOfSightSources.keep] the kernel returns seven numbers per save and trajectory instead of the full state, so a batch fits in one launch:

values = discoeb.solve_eb(
    cosmologies, grid.k_values, grid.a_save,
    extra=[LineOfSightSources],
    keep=[LineOfSightSources.keep],
    error_weights=error_weights(type(cosmologies[0])),
)

error_weights() resolves the small polarization sources at low k. Without it the low multipoles of EE and TE come out 10 to 40 percent low.

The weighting. weighted_channels() multiplies the kept sources by the visibility, and cmb_sources() adds the ISW term as a centered difference of the saved potential. visibility() splines a tabulated opacity for the grid’s summary of the fiducial. A trapezoid on the save grid overshot kappa' by 0.2 percent through recombination and lowered C_l by 0.5 percent.

class discocmb.LineOfSightSources(**overrides)[source]#

Bases: Component

CAMB-form temperature and polarization sources as a model component.

It provides the Weyl potential k^2 phi = -4 pi G a^2 (delta_rho + 3 aH (rho + p) theta / k^2 + 3/2 (rho + p) sigma) and the unweighted parts of the three sources, without the ISW term: monopole + 5/8 Pi, k alpha + theta_b / k and 15/8 Pi, with Pi the scattering source. Every species the model includes contributes through the sums delta_rho, momentum and stress.

Pass it to discoeb.solve_eb() as extra=[LineOfSightSources] with keep=[LineOfSightSources.keep]. DISCO-EB compiles it into the kernel, which evaluates the sources at every save.

LineOfSightSources.keep = ('m0', 'm1', 'm2', 'phi', 'opacity', 'kappa', 'tau')#

What discoeb.solve_eb() keeps at every save, in the channel order the transfer functions read.

The three unweighted sources and the Weyl potential, which this component provides, and the opacity kappa', the optical depth kappa and the conformal time tau, which the model’s recombination history has: the solve integrates in the scale factor, and tau is a state whose value today is the conformal age. The list leaves out phi' on purpose. Late-time phi' is a small residual of large terms that cancel, so the analytic derivative amplifies the solver’s state error tenfold at l = 2. Differencing saved potentials cancels that error, which cmb_sources() does.

discocmb.error_weights(model, overrides: dict | None = None) → dict[source]#

Return {state name: weight} for discoeb.solve_eb()’s error_weights.

Polarization. The E-mode source is g Pi with Pi = sigma_g / 5 + 3/5 E_2. Well below the acoustic scale both moments stay near the solve’s atol = 1e-4 through recombination, so step-size control ignores them and the low multipoles of EE and TE come out 10 to 40 percent low. The weight clip(POLARIZATION_WEIGHT_K / k, 1, POLARIZATION_WEIGHT_MAX) divides the tolerance of the photon quadrupole F_2 and E_2 (E_0). It slows only the low-k trajectories, which take the fewest steps: a batch of 128 costs 10 percent more, and EE matches CLASS to 0.35 percent from l = 2. A scalar tolerance of 1e-5 reaches the same accuracy at 1.8 times the cost.

Massive neutrinos. The bins psi get weight zero, which takes them out of step-size control. They stream freely to today, and resolving them cost a massive-neutrino batch most of its steps. With the photon quadrupole and E_2 weighted, the spectra stay as close to CLASS without them.

Lensing modes. Above K_MAX_CMB every photon and neutrino state takes LENSING_RADIATION_WEIGHT.

overrides, {state name: weight}, go over the first two and the lensing modes’ weight over all. A weight is a number or a function of the wave numbers, as DISCO-EB takes it.