|
CLASSpp Manual
Cosmology reference and developer manual
|
#include <ncdm_base_species.h>
Inheritance diagram for NCDMBaseSpecies:Data Structures | |
| struct | DeferInit |
| struct | PerturbLayout |
Public Member Functions | |
| 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 | RegisterBackgroundIndices (int &index_bg)=0 |
| virtual void | RegisterIntegrationIndices (int &index_bi) |
| virtual void | SetBackgroundInitialConditions (const BackgroundICContext &ctx) |
| virtual void | ComputeBackground (double a, const double *pvecback_B, double *pvecback)=0 |
| 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 double | Rho (const double *pvecback) const =0 |
| virtual double | P (const double *pvecback) const =0 |
| virtual double | PPrime (double a, double H, const double *pvecback_B, const double *pvecback) const |
| virtual void | FinalizeBackground (double a, double H, const double *pvecback_B, double *pvecback) |
| virtual bool | IsFreestreaming () const |
| virtual double | FreestreamingRho (const double *pvecback) const |
| bool | IsPresent () const |
| int | bg_rho_index () const |
| virtual void | WriteBackgroundColumnTitles (BackgroundColumnWriter &) const |
| virtual void | WriteBackgroundData (const double *, BackgroundColumnWriter &) const |
| virtual void | ProcessBackgroundTable (const double *, int, int, const double *) |
| virtual void | PerturbDerivs (const PerturbLayout &layout, double tau, const double *y, double *dy, const perturb_parameters_and_workspace &ppaw) const =0 |
| 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 StressEnergyContribution | StressEnergy (const PerturbLayout &layout, const perturb_vector *pv, const double *y, const double *pvecback, const perturb_workspace *ppw) const =0 |
| virtual void | WriteOutputColumns (PerturbColumnWriter &, const PerturbationsModule &, file_format, TransferColumnSection=TransferColumnSection::all) const |
| virtual void | PrintVariables (PerturbColumnWriter &, const PerturbLayout *, double, const double *, const PerturbationsModule &, const perturb_workspace *) const |
| virtual void | FillSources (const PerturbLayout &, const double *, const double *, PerturbSourceContext &) const |
| virtual void | ApplyInitialConditions (const PerturbLayout &, double *, const PerturbIcContext &) |
| 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 |
Protected Member Functions | |
| virtual double | GetDlnf0Dlnq (int iq, const double *pvecback) const =0 |
| 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 |
Protected Attributes | |
| int | l_max_input_ = -1 |
| double | dlnf0_dlnq_cut_ = 0. |
| bool | normalise_drivers_ = true |
Additional Inherited Members | |
Public Types inherited from BaseSpecies | |
| enum class | EnergyType |
Abstract base for all NCDM flavors. Owns per-species quadrature, distribution function, and thermodynamic parameters. Subclasses implement the perturbation interface.
| struct NCDMBaseSpecies::DeferInit |
Tag type selecting the deferred-init constructor: reads parameters but does NOT build quadrature or mass, so a subclass can set up an overridden PSD first and then call BuildQuadratureAndMass itself.
|
inlineoverridevirtual |
Every NCDM-family hierarchy (ncdm, dncdm, dr_psd, wdm daughters) runs to its own LMax, in both modes.
Reimplemented from BaseSpecies.
|
inline |
This species' hierarchy l_max (#137): its instance key (<name>.l_max, or <parent>.l_max_dr for a decay daughter), else the precision default l_max_ncdm.
|
inline |
For a composite that builds this species as a daughter: -1 restores l_max_ncdm.
|
inlineoverridevirtual |
Every NCDM species is, by definition, a momentum-resolved hierarchy.
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
Produce a fresh layout for this species. Called once per pv during perturb_vector_init, before Register*PerturbationIndices. Default: empty base PerturbLayout (suitable for species with no perturbation slots, or as a placeholder during migration).
Reimplemented from BaseSpecies.
Reimplemented in WdmDecayProductSpecies.
|
overridevirtual |
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.
Reimplemented in WdmDecayProductSpecies.
|
inline |
T_ncdm / T_cmb (#385: the kernel boundary pins the daughters' T to this).
|
inline |
mu / T_ncdm (#385: nonzero on the parent has no single bare-occupation reading at the kernel boundary — guarded at DNCDMInvSpecies::Create).
|
inline |
True iff use_psd_file=1 (#385: a file-based parent PSD has no single bare- occupation reading at the kernel boundary — guarded at DNCDMInvSpecies::Create).
|
inline |
One-standard-massless-neutrino reference density (#385 test anchor): GetNeff()/PrintNeffInfo() normalize against this. Stefan-Boltzmann-type closed form for g=2, T_nu = (4/11)^(1/3) T_cmb, a pure function of T_cmb_ alone — assigned ONCE in the NCDMBaseSpecies constructor (both overloads, see RhoNuRelFromTcmb in the .cpp), before ReadParametersByInstance / BuildQuadratureAndMass run, so it is valid even for DeferInit subclasses that build their own grid and never call InitQuadrature (DrPsdSpecies, WdmDecayProductSpecies) — those used to read this back as the 0. default, which made GetNeff() divide by zero.
|
inlineoverridevirtual |
NCDM (and DNCDM) are "warm" matter — they participate in delta_m but NOT in the delta_cb cold-matter tally. EnergyType::Other → both base defaults would return false, so both explicit overrides are needed.
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
True iff this sector participates in the cold-matter tally (delta_cb, theta_cb). Cold matter excludes NCDM/DNCDM (which are "warm" matter). Default: energy_type_ == EnergyType::Matter. Overrides: NCDMBaseSpecies returns false; composites scan children.
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
NCDM may need to start integration earlier so it is relativistic at a_ini.
Reimplemented from BaseSpecies.
Reimplemented in WdmDecayProductSpecies.
|
overridevirtual |
From the momentum quadrature: a relic still relativistic at a is not matter.
Reimplemented from BaseSpecies.
|
overridevirtual |
Verbose N_eff line (background_verbose). Default no-op; NCDM prints; composites forward to children.
Reimplemented from BaseSpecies.
Reimplemented in WdmDecayProductSpecies.
|
overridevirtual |
Verbose mass/omega line (background_verbose). Default no-op; NCDM prints; composites forward to children.
Reimplemented from BaseSpecies.
Reimplemented in WdmDecayProductSpecies.
|
inlineoverridevirtual |
This species' contribution to Omega0 of the neutrino/NCDM sector (fnu). Default 0; NCDM returns GetOmega0(); composites sum children.
Reimplemented from BaseSpecies.
Reimplemented in WdmDecayProductSpecies.
|
inlineoverridevirtual |
Contribution to N_eff at redshift z. Default 0; NCDM returns GetNeff(z); composites sum children.
Reimplemented from BaseSpecies.
Reimplemented in WdmDecayProductSpecies.
|
inlineoverridevirtual |
Contribution to the tensor-mode "relativistic" density in the massless approximation. Default 0; NCDM returns 3*P; composites sum.
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.
Reimplemented in WdmDecayProductSpecies.
|
overridevirtual |
Warn (stdout) if Halofit/HMcode are unreliable with this species. The mass threshold for NCDM is passed by the nonlinear module. Default no-op; NCDM compares its mass; IDM_DR_IDR warns about interacting dark matter; composites forward.
Reimplemented from BaseSpecies.
|
overridevirtual |
The free-streaming wavenumbers of this species, 1/lambda_fs in 1/Mpc, with lambda_fs the comoving distance its particles have travelled since the big bang at their rms velocity: one for a massive species that free-streams, none for the others. Below that k it clusters like cold matter; above, its free streaming cuts off the matter source, which the continuation past the last perturbation mode (AsymptoticExtrapolation) does not know about. Read after the background is computed. Default: none. NCDM integrates sqrt(3 P/rho); composites gather their children's.
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
Called by BackgroundModule after construction to provide access to its indices (index_bg_a_, index_bg_H_, etc.) and background state. Species that need it override this; default is no-op.
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
Called by PerturbationsModule during construction to provide access to the perturbs struct (alpha_idm_dr, gauge, etc.). Default: no-op.
Reimplemented from BaseSpecies.
|
overridevirtual |
Register this species' transfer-source (index_tp) slots. Set once in perturb_indices_of_perturbs() before the k-loop; mirrors RegisterBackgroundIndices (k-independent, cached in a plain species member). Takes no PerturbLayout — that absence marks it as non-per-k state. Default: no-op (species that emit no transfer functions).
Reimplemented from BaseSpecies.
|
overridevirtual |
Tensor-mode Boltzmann hierarchy for NCDM species. Subclasses must provide GetDlnf0Dlnq to specialise the driving term (static table for NCDMSpecies; pvecback array for DNCDMSpecies).
Reimplemented from BaseSpecies.
|
overridevirtual |
Psi_0(q) = -1/4 dlnf0/dlnq F_0 in each momentum bin, when the tensor hierarchy is evolved (tensor_method = exact).
Reimplemented from BaseSpecies.
|
overridevirtual |
Contributes this species' anisotropic-stress integral to ppw->gw_source. Uses the species's per-pv NCDMBaseSpecies::PerturbLayout slot.
Reimplemented from BaseSpecies.
|
overridevirtual |
NCDM multipoles l > 2 do not enter source functions.
Reimplemented from BaseSpecies.
|
overridevirtual |
Transform this species' own perturbation variables from synchronous to Newtonian gauge, in place in y[]. Called by the module after alpha is known (ctx.alpha / ctx.alpha_prime filled). The synchronous IC is already in y[] (ApplyInitialConditions runs in both gauges), so this is a pure shift/re-seed. Default: no-op (species with no perturbed variables, e.g. cosmological constant).
Reimplemented from BaseSpecies.
Reimplemented in WdmDecayProductSpecies.
|
overridevirtual |
Layout-shape-preserving slot-by-slot copy across a vector reallocation. Default for NCDM-family species with no approximation switches of their own: the vector is still reallocated (zero-initialized) whenever any OTHER species' approximation flips (TCA/RSA/...), so every species must migrate its slots or lose its hierarchy mid-integration (#372). Subclasses whose layout shape can change across a switch must override (NCDMSpecies' fluid-approximation collapse).
Reimplemented from BaseSpecies.
|
protectedpure virtual |
Return d ln f_0 / d ln q for momentum bin iq. NCDMSpecies reads a static table; DNCDMSpecies reads pvecback. Used by PerturbTensorDerivs.
Implemented in DNCDMSpecies, DrPsdSpecies, and WdmDecayProductSpecies.
|
protectedvirtual |
Return the quadrature weight w_0[iq] for the GW source integral. NCDMBaseSpecies returns the static w_[iq]; DNCDMSpecies overrides.
Reimplemented in DNCDMSpecies.
|
protectedvirtual |
Analytic PSD f0(q) for the non-file case. Base: Fermi-Dirac with chemical potential ksi_. GreyBodyNCDMSpecies overrides this.
Reimplemented in AxionNCDMSpecies, and GreyBodyNCDMSpecies.
|
inlineprotectedvirtual |
Default quadrature strategy when the user leaves quadrature_strategy_ at qm_auto. Base: qm_auto (unchanged). GreyBodyNCDMSpecies returns a GB-specific method. Wired into InitQuadrature in Task 5.1; not consulted yet.
Reimplemented in GreyBodyNCDMSpecies.
|
inlineprotectedvirtual |
Populate grey-body quadrature parameters. Base: leaves p.active == false.
Reimplemented in GreyBodyNCDMSpecies.
|
protected |
Build perturbation/background quadrature and the dimensionless mass M_. Calls InitQuadrature (which dispatches the virtual PSD) then computes M_ from m_in_eV_. Call once, after the object is fully constructed.
|
protected |
<name>.l_max, or what a composite set; -1 runs the hierarchy to l_max_ncdm (see LMax).
|
protected |
The extra d ln f / d ln q of the last node of a grid that stops at a finite q_max (qm_trapz), -q_max/dq_last; zero for the grids that run to infinity. Such a grid integrates f0(q) Theta(q_max - q), whose derivative carries -f0(q_max) delta(q - q_max). Without that term, the q-sums of the metric sources lose the boundary term q_max^3 eps f0(q_max) of the integration by parts that makes them -3(rho+p): at q_max = 15 the species does not conserve energy and momentum to 7e-4, which the cancellation in the comoving density of Newtonian gauge turns into percent errors (#496). Already included in dlnf0_dlnq_; species that compute d ln f / d ln q themselves (DNCDMSpecies) add it to their last node.
|
protected |
precision::ncdm_driver_normalisation: scale the metric drivers of the hierarchy so that their q-sum is the rho+p of the background grid (NCDMSpecies::PerturbDerivs, DNCDMSpecies::PerturbDerivs).