hmf.core.mass_variance

The MassVariance stage: sigma(m) and dln(sigma)/dln(m) on a deterministic mass lattice.

The mass variance of the unnormalised linear power at z = 0,

\[\sigma^2(M) = \frac{1}{2\pi^2} \int k^3 P(k)\, W^2(kR)\, d\ln k,\]

and its logarithmic slope \(d\ln\sigma/d\ln M\), as functions of mass. sigma8 normalisation and redshift enter in the stages built on this one (LinearPower and MassFunction).

The mass lattice

Both are computed at the nodes of a lattice in mass, and interpolated between them:

  • Nodes sit at \(\log_{10}(m / (M_\odot/h)) = j\,\Delta\) for integer \(j\), with \(\Delta\) = MassAccuracy.dlog10_m. Positions are computed as j * Δ, so two lattices with the same spacing share their nodes exactly.

  • One fused integral per node gives \(\ln\sigma\), \(d = d\ln\sigma/d\ln M\) and (if MassAccuracy.second_derivative) \(d_2 = d^2\ln\sigma/d(\ln M)^2\), from one evaluation of the window. The quadrature is Simpson’s rule along the k axis, so a node’s values do not depend on which other nodes are computed with it.

  • sigma is interpolated in \(\ln\sigma\) against \(\ln M\), by a quintic Hermite interpolant using \(d\) and \(d_2\) (a cubic Hermite without \(d_2\)).

  • dln(sigma)/dln(m) is interpolated separately, in \(\ln|d|\): a cubic Hermite interpolant with slope \(d_2/d\), or, without \(d_2\), the local 4-point Lagrange interpolant through the nodes \(j-1 \ldots j+2\). (Where \(d\) changes sign across the nodes used, the same schemes are applied to \(d\) itself.) The sigma interpolant is never differentiated: that amplifies quadrature noise by \(1/\Delta\), and fails where \(d \to 0\).

  • Lazy extension. Nodes are computed when a mass first needs them and memoised. The memo is not part of the stage’s value or hash, and computing a node is idempotent, so results are bit-for-bit independent of the order of requests: a lattice built for [10⁸, 10¹⁶] and extended to [10⁰, 10¹⁸] gives the same values as one built in the opposite order.

At the default settings, the interpolants agree with a direct evaluation on the same k grid to INTERPOLATION_RTOL in sigma, and to about 1e-4 in dln(sigma)/dln(m). MassVariance.ln_sigma_at_radius_kernel() is that direct evaluation, at any filter radius, without the lattice (e.g. sigma_8, at R = 8 Mpc/h).

Mass and radius

A mass and its filter radius are related by \(M = \tfrac{4\pi}{3}\bar\rho_{\rm cb}(cR)^3\), with \(\bar\rho_{\rm cb}\) the mean density of CDM + baryons (the power source’s rho_mean0, whatever the species of its power) and \(c\) the filter’s mass_assignment.

Domains

MassVariance.valid_domain bounds the masses at which sigma is evaluated (\(m > 0\), or the default lattice range with MassAccuracy.extension="raise"), the filter radii (\(R > 0\)) and the values of sigma (\(\sigma > 0\)). The public methods check their input with Domain.check, the kernel-level entry points from its extent (check_extent()); both raise a DomainError. A mass, radius or sigma inside it can still raise, as below, when the k grid can’t resolve it: that depends on the power, and is known only once computed.

The k grid

The k grid is a lattice too: \(\ln k = i\,\delta\) for integer \(i\), with \(\delta\) = KAccuracy.dln_k, from KAccuracy.ln_k_min up to \(k_{\max} \ge\) k_max_r_min \(/R(M_{\min})\). \(M_{\min}\) is MassAccuracy.log10_m_min, not the smallest mass requested: the k grid is fixed by the settings, so it does not change when the mass lattice extends, which keeps extension bit-for-bit deterministic.

If the power source extrapolates a table the user supplied (its table_range, see hmf.core.power_source), and that table does not cover the grid’s range from ln_k_min to \(k_{\max}\), the stage warns once per power source and end of the table. The ends of the grid are rounded outwards onto lattice nodes, by less than one step: a table that reaches the unrounded ends (to LATTICE_RTOL steps) covers the grid.

Masses the grid can’t resolve

Every node carries a bound on the error that the truncation of the k integrals at both ends of the grid causes, in sigma and in dln(sigma)/dln(m) (which enters dn/dm, and is typically kR times more sensitive). A request that needs a node whose bound exceeds truncation_rtol, or where sigma or its derivatives are not finite, raises a DomainError.

Every node also carries a Richardson estimate of the error from the resolution of the k grid (Simpson’s rule on the grid against every other grid point). A request that needs a node where it exceeds RESOLUTION_RTOL raises too. This catches gross failures only: with the top-hat, the grid aliases the window’s oscillations at \(kR \gtrsim \pi / (2\,\delta)\), which is harmless for physical spectra (\(P \propto k^{-3}\) at high k) but not for ones that fall more slowly than about \(k^{-2}\) (e.g. a power law with \(n \ge -1\), for which dln(sigma)/dln(m) only converges conditionally).

Classes

MassVariance(*, power[, filter, ...])

The mass variance sigma(m) of the unnormalised linear power at z = 0, and its slope.

Functions

n_eff_kernel(dlnsigma_dlnm)

The effective spectral index at a mass, from the slope of sigma(m).