|
CLASSpp Manual
Cosmology reference and developer manual
|
#include <dr_psd_species.h>
Inheritance diagram for DrPsdSpecies:Public Member Functions | |
| DrPsdSpecies (FileContent *pfc, const std::string &instance_name, const NcdmSettings &settings, const background *pba, const BackgroundModule *bgm, Statistics stat, double kinematic_q_max=0.) | |
| int | bg_index (int iq) const |
| int | refine () const |
| void | PinTemperature (double T) |
| void | SetSpeciesMultiplicity (int n) |
| void | RegisterBackgroundIndices (int &index_bg) override |
| void | RegisterIntegrationIndices (int &index_bi) override |
| void | SetBackgroundInitialConditions (const BackgroundICContext &ctx) override |
| void | ComputeBackground (double a, const double *pvecback_B, double *pvecback) override |
| double | InitialRadiationOmega0 (double H0) const |
| double | Rho (const double *pvecback) const override |
| double | P (const double *pvecback) const override |
| double | Number (const double *pvecback) const |
| double | PPrime (double a, double H, const double *pvecback_B, const double *pvecback) const override |
| void | WriteBackgroundColumnTitles (BackgroundColumnWriter &w) const override |
| void | WriteBackgroundData (const double *pvecback, BackgroundColumnWriter &w) const override |
| double | GetOmega0 () const override |
| double | NeutrinoOmega0 () const override |
| double | NeffContribution (double) const override |
| bool | IsFreestreaming () const override |
| double | BackgroundAIni (double a_proposed, double) const override |
| double | DeviationFromRadiation (const double *) const override |
| void | SetReducedBasis (int n_moments, const std::vector< double > &psi, const std::vector< double > &gnorm, double q_ref, double alpha0) |
| double | ReducedEnergyAtL (const NCDMBaseSpecies::PerturbLayout &layout, const double *y, int l) const |
| void | ReducedProject (const double *fq, double *m) const |
| void | ReducedDriver (const double *pvecback, double *D) const |
| void | PerturbDerivs (const BaseSpecies::PerturbLayout &base, double tau, const double *y, double *dy, const perturb_parameters_and_workspace &ppaw) const override |
| void | ApplyInitialConditions (const BaseSpecies::PerturbLayout &base, double *y, const PerturbIcContext &ctx) override |
| StressEnergyContribution | StressEnergy (const BaseSpecies::PerturbLayout &base, const perturb_vector *pv, const double *y, const double *pvecback, const perturb_workspace *ppw) const override |
| void | FillSources (const BaseSpecies::PerturbLayout &base, const double *y, const double *dy, PerturbSourceContext &ctx) const override |
| void | WriteOutputColumns (PerturbColumnWriter &writer, const PerturbationsModule &mod, file_format fmt, TransferColumnSection section=TransferColumnSection::all) const override |
| void | RegisterTensorPerturbationIndices (BaseSpecies::PerturbLayout &, perturb_vector *, const precision *, int &, const perturb_workspace *, int) override |
| void | PerturbSynchronousToNewtonian (const BaseSpecies::PerturbLayout &, double *, const PerturbIcContext &) override |
| std::string | ColumnLabel () const |
Public Member Functions inherited from NCDMBaseSpecies | |
| int | MaxMultipole (const precision *ppr, bool) const override |
| int | LMax (const precision *ppr) const |
| void | SetLMaxInput (int l_max) |
| bool | HasNcdm () const override |
| std::unique_ptr< BaseSpecies::PerturbLayout > | CreatePerturbLayout () const override |
| double | GetOmega0 () const override |
| double | GetT () const |
| double | GetKsi () const |
| bool | UsesPsdFile () const |
| double | rho_nu_rel () const |
| bool | ClustersAsMatter () const override |
| bool | IsColdMatterSpecies () const override |
| double | BackgroundAIni (double a_proposed, double tol) const override |
| double | BackgroundDensityOverH0Sq (double a, double H0) const override |
| void | PrintNeffInfo () const override |
| void | PrintMassInfo () const override |
| double | NeutrinoOmega0 () const override |
| double | NeffContribution (double z) const override |
| double | TensorMasslessRelativisticRho (const double *pvecback) const override |
| double | DeviationFromRadiation (const double *pvecback) const override |
| void | WarnIfNonlinearUnreliable (double m_ev_threshold) const override |
| std::vector< double > | FreeStreamingWavenumbers () const override |
| void | SetBackgroundModule (const BackgroundModule *bgm) override |
| void | SetPerturbs (const perturbs *ppt) override |
| void | RegisterTransferSourceIndices (int &index_tp, const SourceRequestContext &ctx) override |
| void | PerturbTensorDerivs (const BaseSpecies::PerturbLayout &base, double tau, const double *y, double *dy, const perturb_parameters_and_workspace &ppaw) const override |
| void | ApplyTensorInitialConditions (const BaseSpecies::PerturbLayout &base, double *y, double f0, const double *pvecback) const override |
| void | ContributeTensorGwSource (const BaseSpecies::PerturbLayout &base, double a, const double *y, perturb_workspace *ppw) const override |
| void | MarkUsedInSources (const BaseSpecies::PerturbLayout &base, const perturb_workspace *ppw, int *used_in_sources) const override |
| void | PerturbSynchronousToNewtonian (const BaseSpecies::PerturbLayout &base, double *y, const PerturbIcContext &ctx) override |
| void | CopyPerturbationsAcrossSwitch (const BaseSpecies::PerturbLayout &old_base, const BaseSpecies::PerturbLayout &new_base, const double *old_y, double *new_y, const PerturbSwitchContext &ctx) const override |
Public Member Functions inherited from BaseSpecies | |
| virtual void | SetThermodynamicsModule (const ThermodynamicsModule *) |
| virtual std::optional< double > | GetParam (const std::string &) const |
| virtual void | BackgroundDerivs (double tau, const double *y, double *dy, const double *pvecback) |
| virtual void | BackgroundDerivsDiagonal (double tau, const double *y, double *diag, const double *pvecback) |
| virtual void | FinalizeBackground (double a, double H, const double *pvecback_B, double *pvecback) |
| virtual double | FreestreamingRho (const double *pvecback) const |
| bool | IsPresent () const |
| int | bg_rho_index () const |
| virtual void | ProcessBackgroundTable (const double *, int, int, const double *) |
| virtual void | PerturbDerivsDiagonal (const PerturbLayout &, double, const double *, double *, const perturb_parameters_and_workspace &) const |
| virtual void | PerturbVectorDerivs (const PerturbLayout &, double, const double *, double *, const perturb_parameters_and_workspace &) const |
| virtual void | WriteTensorOutputColumnTitles (std::string &) const |
| virtual void | PrintVariables (PerturbColumnWriter &, const PerturbLayout *, double, const double *, const PerturbationsModule &, const perturb_workspace *) const |
| virtual int | ApproximationCount () const |
| virtual int | ApproximationRegimeAt (int, double, const double *) const |
| int | ApproximationRegime (const perturb_workspace *ppw, int which=0) const |
| int | ApproximationRegimeBefore (const PerturbSwitchContext &ctx, int which=0) const |
| virtual bool | SupportsNewtonianGauge () const |
| virtual bool | SupportsIsocurvatureInitialConditions () const |
| virtual double | RhoPrimeOverRho (const double *pvecback, double a_prime_over_a) const |
| virtual double | GetRadiationOmega0 () const |
| virtual double | DarkRadiationRhoToday (const double *) const |
| virtual void | PrintBackgroundDetails (const double *, double) const |
| virtual std::optional< double > | ChildOmega0 (const std::string &) const |
| bool | ClustersAsMatterCached () const |
| virtual void | FinalizeMatterClassification () |
| virtual bool | HasWarmMatter () const |
| virtual double | NonClusteringOmega0 () const |
| virtual double | ColdMatterRho (const double *pvecback) const |
| virtual double | ColdMatterOmega0 () const |
| virtual double | SourceSamplingRate (const double *) const |
| virtual bool | SupportsExplicitPerturbationEvolver () const |
| virtual bool | PrefersExponentialPerturbationEvolver () const |
| virtual bool | SupportsExponentialPerturbationEvolver () const |
Static Public Attributes | |
| static constexpr double | kQMaxMargin = 1.05 |
| static constexpr int | kMaxReducedMoments = 12 |
Protected Member Functions | |
| double | GetDlnf0Dlnq (int iq, const double *pvecback) const override |
Protected Member Functions inherited from NCDMBaseSpecies | |
| virtual double | GetW0ForGwSource (int iq, const double *pvecback) const |
| virtual double | EvaluatePsdAnalytic (double q) const |
| virtual quadrature_method | DefaultQuadratureStrategy () const |
| virtual void | FillQuadratureParams (GBQuadParams &) const |
| void | BuildQuadratureAndMass (const NcdmSettings &settings) |
Protected Member Functions inherited from BaseSpecies | |
| void | ApplyFluidLikeNewtonianShift (double *y, int idx_delta, int idx_theta, const double *pvecback, const PerturbIcContext &ctx) const |
Additional Inherited Members | |
Public Types inherited from BaseSpecies | |
| enum class | EnergyType |
Protected Attributes inherited from NCDMBaseSpecies | |
| int | l_max_input_ = -1 |
| double | dlnf0_dlnq_cut_ = 0. |
| bool | normalise_drivers_ = true |
Massless momentum-resolved dark-radiation daughter of the ν_H ↔ ν_l + φ system (arXiv:2011.01502; design §5 "dr_psd_species"). ONE class plays both daughters — statistics = Fermion (Pauli) or Boson (Bose) is a construction parameter, so there is exactly one daughter equation to get right.
The comoving PSD f(q,τ) is integrated directly per momentum bin (positivity floor kFFloor, not ln f — gains dominate at low q). ∂f̄/∂lnq is splined live from f̄ vs ln q every ComputeBackground, from f̄ ITSELF and not ln f̄: a decay-filled PSD is a bump on the floor plateau, and the ln of that cliff rings.
Perturbations are the UNNORMALIZED F_ℓ(q) ≡ f̄·Ψ_ℓ = δf hierarchy — deliberately NOT the normalized Ψ = δf/f̄ that DNCDMSpecies and the rest of the NCDM family use. A daughter is sourced from EXACTLY zero abundance, where f̄̇/f̄ is smooth but enormous at early times; both the −(f̄̇/f̄)Ψ dilution and the collision operator's 1/f̄ divide by it, so the normalized form diverges. In F-space those terms cancel structurally (derivation in dr_psd_species.cpp's perturbation section). The free-streaming ℓ,ℓ±1 coefficients are unchanged (same form as DNCDMSpecies with M_ = 0, ε = q); the metric driver uses ∂f̄/∂lnq instead of ∂lnf̄/∂lnq and the moment weights drop their f̄. Synchronous gauge only; no fluid approximation.
Standalone it is a free-streaming massless PSD species ("all species are equal"): with no source (BackgroundDerivs is a no-op) comoving f is constant and ρ redshifts as radiation ∝ a⁻⁴. The composite DNCDMInvSpecies injects the kernel source into the f-slots; the sector's density is reserved by the composite, so a daughter's own GetOmega0() is 0 (decay-product neutrality, mirrors WdmDecayProductSpecies).
TWO momentum grids, coupled by EXACT INTEGER SUBSAMPLING (dr_bg_refine = m): the background grid must be fine to resolve the decay-injection band, but the Boltzmann hierarchy costs N_pt·(l_max+1) variables per k-mode, so the perturbation grid must be allowed to be coarser. q_[j] is read straight out of q_bg_[j·m] — never interpolated, never re-derived from a fresh log-spaced formula. Both reasons are load-bearing: (1) splining background quantities across the daughter's injection cliff rings, and exact subsampling removes that by construction, because a PT-grid point IS a BG-grid array entry; (2) every background column is readable at PT index j as BG column j·m with no reconstruction. Points span N−1 intervals, so N_bg−1 = m·(N_pt−1), NOT N_bg = m·N_pt. m = 1 (the default) reproduces the single-grid case bit-for-bit.
| DrPsdSpecies::DrPsdSpecies | ( | FileContent * | pfc, |
| const std::string & | instance_name, | ||
| const NcdmSettings & | settings, | ||
| const background * | pba, | ||
| const BackgroundModule * | bgm, | ||
| Statistics | stat, | ||
| double | kinematic_q_max = 0. |
||
| ) |
kinematic_q_max: the highest momentum this daughter will ever be FED, from the parent's decay kinematics (DecayTransitionKernel::MaxDaughterMomentum at a = 1). Used ONLY to choose the default dr_q_max, so a composite-built daughter is sized to cover its own emission band instead of inheriting a fixed 1e2 that silently clamps – and thereby leaks energy – as soon as a*m/2 outgrows it. 0 (the default) means "no parent, no bound known", which is the standalone dr_psd case: a daughter with no decay channel feeding it has no kinematic requirement, and the historical default stands. An explicit dr_q_max ALWAYS wins over this; the composite warns once if the user's choice sits below the band (see DNCDMInvSpecies::Create).
|
inline |
PT-grid index -> BG-grid index. The perturbation grid is always an exact integer SUBSAMPLE of the background grid (never a spline: background quantities ring across the daughter's ~87-decade injection cliff, and never an independently spaced grid: two exp() formulas agree only to rounding). Which subsample differs by sampling, and the difference is exactly one index:
log q_bg[i] = q_min*exp(i*h), so index 0 IS the endpoint q_min and q_bg[j*m] is uniform in ln q from that endpoint -> j*m linear q_bg[i] = (i+1)*h with q=0 an IMPLICIT zero-weight point, so index 0 sits at h, not at 0. q_bg[j*m] would leave a first cell of width h among cells of width m*h – not a trapezoid rule at all. Subsampling from the other end, q_bg[(j+1)*m - 1] = (j+1)*(m*h), is the canonical qm_trapz grid of step m*h -> (j+1)*m - 1
Hence the divisibility requirement also differs: N_bg-1 divisible by refine for log (N points span N-1 intervals from the endpoint), N_bg divisible by refine for linear (N cells of width h from the implicit zero). Both keep the last PT point ON the last BG point, so the exact q_max endpoint is inherited.
|
inline |
Background-to-perturbation grid refinement m: PT bin j is BG bin j·m. Any read of a per-bin BACKGROUND column at a PT loop index must be scaled by this.
| void DrPsdSpecies::PinTemperature | ( | double | T | ) |
Pin this daughter's T to the parent's (#385 kernel-unit consistency: the kernel boundary conversion assumes every species reports occupation at the SAME dimensionless q = p/T). Re-runs SetDegAndFactor(GetDeg()) so factor_ picks up the new T_. Called by the DNCDMInvSpecies constructor for both daughters, before anything reads factor_.
| void DrPsdSpecies::SetSpeciesMultiplicity | ( | int | n | ) |
Make this one object stand for n IDENTICAL daughter species (scenario B's dr_n_daughter). Multiplies the per-species dof count set at construction, so rho/n/Pi come out n times larger while the stored per-dof occupation – which is what the kernel's (1 -+ f) blocking terms read – is untouched. That separation is the whole point: folding the count into the occupation instead would push f > 1 into Pauli blocking, which is wrong in a way that still looks like physics.
Idempotent (it sets the degeneracy absolutely, not cumulatively), but intended to be called once, by DNCDMInvSpecies::Create, before anything reads factor_. The RATE half of the multiplicity lives in DecayTransitionKernel::Config.
|
overridevirtual |
Claim consecutive slots in pvecback. Called once during background_indices(). Implementation must assign index_bg_rho_ (and any other needed indices) and increment index_bg accordingly.
Implements BaseSpecies.
|
overridevirtual |
Claim slots in the ODE integration vector y. Called during background_indices(). Default: no integrated variables (analytic species do not need this).
Reimplemented from BaseSpecies.
|
overridevirtual |
Set initial conditions for ODE-integrated background variables.
| ctx | Background initial-condition context (a_ini, rho_rad, and the integration vector to fill). |
Reimplemented from BaseSpecies.
|
overridevirtual |
Compute species background quantities at scale factor a. pvecback_B is the current ODE integration vector. Write density (and any other owned quantities) into pvecback.
Implements BaseSpecies.
| double DrPsdSpecies::InitialRadiationOmega0 | ( | double | H0 | ) | const |
Its seeded population (f_ini, SetBackgroundInitialConditions) as free radiation today, a^4 rho / H0^2: the quadrature ComputeBackground integrates, before anything decays.
|
inlineoverridevirtual |
Energy density at current background state.
Implements BaseSpecies.
|
inlineoverridevirtual |
Pressure at current background state.
Implements BaseSpecies.
|
inline |
Comoving-number density n (already accumulated by ComputeMomenta in ComputeBackground). Published so the exact transition-network identity n_H + ½(n_φ + n_l) = const (arXiv:2011.01502 fig. 11) can be read straight off background.dat for all three species, as the reference implementation does — instead of being reconstructed from the per-bin f columns.
|
inlineoverridevirtual |
Post-Friedmann. This species' conformal-time pressure derivative p' (a' / a = a*H). pvecback_B is the ODE state (IN); pvecback is fully populated through H. Default 0 (matter / Lambda).
Reimplemented from BaseSpecies.
|
overridevirtual |
Write this species' background column titles into writer. Called by BackgroundModule::background_output_titles(). Default: no-op (species with no background output need not override).
Reimplemented from BaseSpecies.
|
overridevirtual |
Write this species' background data values into writer. pvecback is the full background vector at the current time step. Called by BackgroundModule::background_output_data(). Default: no-op.
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
Returns the species' contribution to Omega0 (used for budget closure during construction). For composites, this defaults to summing children. For decay-product species starting at zero, override returning 0.
Implements BaseSpecies.
|
inlineoverridevirtual |
This species' contribution to Omega0 of the neutrino/NCDM sector (fnu). Default 0; NCDM returns GetOmega0(); composites sum children.
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
Contribution to N_eff at redshift z. Default 0; NCDM returns GetNeff(z); composites sum children.
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
True for species that are free-streaming and massless at IC time (deep radiation domination). Used to accumulate rho_nu / fracnu in perturbation IC setup. Static at construction time. Default: false.
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
Earliest scale factor this species needs integration to start from. Default: returns a_proposed unchanged. NCDM species may pull it earlier.
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
|w - 1/3|: how far this species is from ultra-relativistic, for the perturbations' initial time, which must come while every non-cold relic is still relativistic. Default 0 (no such constraint); NCDM computes it; composites take the max over their children.
Reimplemented from BaseSpecies.
| void DrPsdSpecies::SetReducedBasis | ( | int | n_moments, |
| const std::vector< double > & | psi, | ||
| const std::vector< double > & | gnorm, | ||
| double | q_ref, | ||
| double | alpha0 | ||
| ) |
Carry n_moments q-MOMENTS of delta-f per multipole instead of the full q-grid.
WHY IT IS A DROP-IN. For a MASSLESS daughter eps = q, so the free-streaming coefficient qk/eps is exactly k – it carries no q at all. Every q-moment of the hierarchy therefore obeys the SAME hierarchy, with no closure error (design note M3, a theorem rather than a fit). And all four stress-energy sums carry the same weight q^3 once eps = q, so the metric only ever reads the ENERGY moment at l = 0, 1, 2. Replacing the q index by a moment index thus changes three things and nothing else: how many slots there are, what the metric driver is (the projected d f-bar / d ln q rather than its pointwise value), and how the moments are read back out.
THE BASIS IS FROZEN, and that is not an optimisation. psi_j is built from w = f-bar(1 -/+ f-bar), which evolves; a basis that tracked a would make the state variables mean something different at every step, and dm_j/dtau would acquire an integral of (dpsi_j/dtau) delta-f that this hierarchy does not have. Measured cost of freezing at Gamma=1e7 (l=2 collision rate, scale-relative p90): at n_moments = 2 it is a factor 2.5, at 4 it is 1.5, at 6-8 it is ~1.2 – which is why 6 is the recommended working point rather than the 2 the design proposed.
psi is n_moments * q_size, row-major in the moment index; gnorm is the (diagonal) Gram. Both come from ReducedCollisionOperator so there is exactly one Stieltjes recurrence in the build.
|
inline |
The energy moment at one multipole, read straight out of the state vector. Defined here because StressEnergy and FillSources both need it and a second spelling of the (m_1 + alpha0 m_0) combination is exactly the kind of thing that drifts.
| void DrPsdSpecies::ReducedProject | ( | const double * | fq, |
| double * | m | ||
| ) | const |
Projection of a q-resolved grid function onto the frozen moments.
| void DrPsdSpecies::ReducedDriver | ( | const double * | pvecback, |
| double * | D | ||
| ) | const |
The metric driver in reduced coordinates: D_j = Sum dq q^2 psi_j (df-bar/dlnq).
|
overridevirtual |
Contribute to dy for the scalar perturbation ODE at conformal time tau. The PerturbScalarContext inside ppaw->ppw has pre-computed metric terms, cross-species state (delta_g, theta_g, theta_b, ...), and approximation flags. The layout is this species' PerturbLayout slot (ppw->pv->species_layouts[i]); composites receive their own layout and pass nested sub-layouts to children.
Implements BaseSpecies.
|
overridevirtual |
Write synchronous-gauge initial conditions for this species into y[]. y[] == ppw->pv->y. The module pre-computes ctx.delta_g_ic, ctx.delta_ur, etc. Guard each IC type: if (ctx.index_ic == ctx.p_mod->index_ic_ad_) { ... } Newtonian gauge transformation is handled by the module after this loop. Default: no-op.
Reimplemented from BaseSpecies.
|
overridevirtual |
All scalar stress-energy perturbations in one call.
Implements BaseSpecies.
|
overridevirtual |
Write per-k, per-tau source values for this species into the source table. Called in perturb_sources() after metric/temperature sources are set. Use ctx.p_mod->SetSourceValue(ctx.index_md, ctx.index_ic, ctx.p_mod->index_tp_XXX_, ctx.index_tau, ctx.index_k, value). All addressing (index_md, index_ic, index_k, index_tau) is in ctx. Default: no-op.
Reimplemented from BaseSpecies.
|
overridevirtual |
Append this species' output columns (delta, theta) to writer. Called from perturb_output_titles (title mode) and perturb_output_data (data mode). In class_format, the module may call this separately for density and velocity sections to preserve the historical transfer-column ordering. Use writer.Add(title, mod.index_tp_XXX_, active) — writer looks up tk[tp_index].
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
Tensor modes: no slots (daughter tensor anisotropic stress neglected; documented scope limit, empty until late times — mirrors dcdm_wdm).
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
Synchronous gauge only (guarded by the composite / standalone factory).
Reimplemented from BaseSpecies.
|
inline |
name() suffixed by statistics ("_l"/"_phi", the paper's ν_l/φ notation). The composite constructs both daughters under the SAME instance name (they are not separately dot-addressable), so background/output COLUMN NAMES must disambiguate here or the fermion and boson columns collide. Public because DNCDMInvSpecies names its children's per-q diagnostic columns and must use this one definition rather than re-spelling the suffix.
|
inlineoverrideprotectedvirtual |
The DNCDM seam. dr_psd publishes ∂f̄/∂lnq (its F-hierarchy driver), so the base class's NORMALIZED contract is recovered by dividing by f̄. Reached only from NCDMBaseSpecies' tensor hierarchy, for which dr_psd registers no slots — the scalar path reads the ∂f̄/∂lnq column directly and never normalizes.
Implements NCDMBaseSpecies.
|
staticconstexpr |
Margin on the kinematic bound when defaulting dr_q_max. The Gauss-Legendre nodes approach the band edge without reaching it (measured: 0.966-1.000 of the bound across the relativistic and non-relativistic regimes), so a few percent is enough to guarantee the top node stays bracketed.
|
staticconstexpr |
Cap on n_moments, so the hot paths can use a stack array. The measured accuracy ceiling of the reduction is 9 (reduced_operator_test), so 12 is headroom, not a limit anyone will meet.