|
CLASSpp Manual
Cosmology reference and developer manual
|
#include <fluid.h>
Inheritance diagram for FluidSpecies:Public Member Functions | |
| bool | SupportsExplicitPerturbationEvolver () const override |
| std::unique_ptr< BaseSpecies::PerturbLayout > | CreatePerturbLayout () const override |
| double | GetOmega0 () const override |
| void | SetBackgroundModule (const BackgroundModule *bgm) override |
| void | RegisterBackgroundIndices (int &index_bg) override |
| void | ComputeBackground (double a, const double *pvecback_B, double *pvecback) override |
| double | Rho (const double *pvecback) const override |
| double | P (const double *pvecback) const override |
| 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 | W (const double *pvecback) const |
| virtual void | ComputeWFld (double a, double *w_fld, double *dw_over_da_fld, double *integral_fld) const |
| virtual double | Cs2 (double, double) const |
| virtual bool | ReachesPhantomDivide () const |
| void | RegisterTransferSourceIndices (int &index_tp, const SourceRequestContext &ctx) override |
| void | PerturbDerivs (const BaseSpecies::PerturbLayout &base, double tau, const double *y, double *dy, const perturb_parameters_and_workspace &ppaw) const override |
| void | FillSources (const BaseSpecies::PerturbLayout &base, const double *y, const double *dy, PerturbSourceContext &ctx) const override |
| void | ApplyInitialConditions (const BaseSpecies::PerturbLayout &base, double *y, const PerturbIcContext &ctx) 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 |
| StressEnergyContribution | StressEnergy (const BaseSpecies::PerturbLayout &base, const perturb_vector *pv, const double *y, const double *pvecback, const perturb_workspace *ppw) const override |
| void | WriteOutputColumns (PerturbColumnWriter &writer, const PerturbationsModule &mod, file_format fmt, TransferColumnSection section=TransferColumnSection::all) const override |
| void | PrintVariables (PerturbColumnWriter &writer, const BaseSpecies::PerturbLayout *base, double tau, const double *y, const PerturbationsModule &mod, const perturb_workspace *ppw) const override |
Public Member Functions inherited from BaseSpecies | |
| virtual void | SetThermodynamicsModule (const ThermodynamicsModule *) |
| virtual void | SetPerturbs (const perturbs *) |
| virtual std::optional< double > | GetParam (const std::string &) const |
| virtual void | RegisterIntegrationIndices (int &index_bi) |
| virtual void | SetBackgroundInitialConditions (const BackgroundICContext &ctx) |
| 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 bool | IsFreestreaming () const |
| 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 | PerturbTensorDerivs (const PerturbLayout &, double, const double *, double *, const perturb_parameters_and_workspace &) const |
| virtual void | ApplyTensorInitialConditions (const PerturbLayout &, double *, double, const double *) const |
| virtual void | WriteTensorOutputColumnTitles (std::string &) const |
| virtual void | ContributeTensorGwSource (const PerturbLayout &, double, const double *, 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 void | MarkUsedInSources (const PerturbLayout &, const perturb_workspace *, int *) const |
| virtual double | BackgroundDensityOverH0Sq (double a, double H0) const |
| virtual double | GetRadiationOmega0 () const |
| virtual double | DarkRadiationRhoToday (const double *) const |
| virtual double | NeutrinoOmega0 () const |
| virtual double | NeffContribution (double) const |
| virtual void | PrintNeffInfo () const |
| virtual void | PrintMassInfo () const |
| virtual void | PrintBackgroundDetails (const double *, double) const |
| virtual double | TensorMasslessRelativisticRho (const double *) const |
| virtual double | DeviationFromRadiation (const double *) const |
| virtual std::vector< double > | FreeStreamingWavenumbers () const |
| virtual void | WarnIfNonlinearUnreliable (double) const |
| virtual std::optional< double > | ChildOmega0 (const std::string &) const |
| virtual double | BackgroundAIni (double a_proposed, double) const |
| bool | ClustersAsMatterCached () const |
| virtual void | FinalizeMatterClassification () |
| virtual bool | ClustersAsMatter () const |
| virtual bool | IsColdMatterSpecies () const |
| virtual bool | HasWarmMatter () const |
| virtual double | NonClusteringOmega0 () const |
| virtual double | ColdMatterRho (const double *pvecback) const |
| virtual double | ColdMatterOmega0 () const |
| virtual bool | HasNcdm () const |
| virtual double | SourceSamplingRate (const double *) const |
| virtual int | MaxMultipole (const precision *, bool) const |
| virtual bool | PrefersExponentialPerturbationEvolver () const |
| virtual bool | SupportsExponentialPerturbationEvolver () const |
Additional Inherited Members | |
Public Types inherited from BaseSpecies | |
| enum class | EnergyType |
Protected Member Functions inherited from BaseSpecies | |
| void | ApplyFluidLikeNewtonianShift (double *y, int idx_delta, int idx_theta, const double *pvecback, const PerturbIcContext &ctx) const |
Dark energy fluid species with evolving equation of state w(a).
Background: rho_fld is not integrated: ComputeBackground evaluates rho_fld,0 exp(integral_fld) from the closed-form integral ComputeWFld returns, so the background closes exactly at a = 1.
Perturbations (true fluid): dy[delta_fld] = -(1+w)(theta_fld + metric_continuity) dy[theta_fld] = -(1-3*cs2)*H'*theta_fld + cs2*k^2/(1+w)*delta_fld + metric_euler
|
inlineoverridevirtual |
Benchmarked against ndf15 on 2026-10-22 and 2026-10-27: CPL w0wa with and without PPF, constant w with cs2 = 1, 0.01 and 1e-6, (G)PEDE, the pheno-axion fluid, and the newtonian gauge. At the default tolerance rkdp45 is as close to ndf15 at 1e-5 as ndf15 at the default tolerance (TT, EE, TE <= 1e-5 of their peak, P(k) <= 8e-5) and 35-60% faster. See BaseSpecies::SupportsExplicitPerturbationEvolver().
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 PpfFluid.
|
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 |
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.
|
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 |
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.
|
overridevirtual |
Energy density at current background state.
Implements BaseSpecies.
|
overridevirtual |
Pressure at current background state.
Implements BaseSpecies.
|
overridevirtual |
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.
|
inline |
Returns w_fld from pvecback. Used by perturbations to read the cached value.
|
virtual |
Fluid equation-of-state evaluation. Owns w_fld(a), dw_fld/da(a), and the analytic integral used by background initial conditions. Implementation moved here from BackgroundModule::background_w_fld because this is pure fluid physics.

note: of course you can generalise these formulas to anything, defining new parameters pba->w..._fld. Neither recombination code constrains the form: both read the true background.
Reimplemented in AxionEDEFluid.
|
inlinevirtual |
Effective sound speed in the fluid rest frame, cs2(k^2, a). The base fluid uses the constant input cs2_fld; AxionEDEFluid overrides with the k- and a-dependent GDM formula. Takes k^2 to avoid a sqrt in PerturbDerivs.
Reimplemented in AxionEDEFluid.
|
virtual |
True iff w(a) reaches or crosses -1 between the infinite past and today, which would make the true-fluid delta/theta equations divide by 1+w. The base fluid answers with the historical endpoint test (w at a=0 and a=1, product of (1+w) factors <= 0 — this includes exact contact at -1, which for CLP-style w(a) does reach the divide). AxionEDEFluid overrides: its sigmoid satisfies w > -1 strictly for every a > 0, so the a=0 asymptote at exactly -1 is not a crossing.
Reimplemented in AxionEDEFluid.
|
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 |
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.
Reimplemented in PpfFluid.
|
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.
Reimplemented in PpfFluid.
|
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 |
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.
|
overridevirtual |
Copy perturbation state from one layout to another across an approximation switch. Called when the perturbation vector is reallocated (e.g., NCDM FA collapse from full Boltzmann hierarchy to fluid variables delta/theta/shear). Default: no-op. Most species have no approximation switches.
Reimplemented from BaseSpecies.
Reimplemented in PpfFluid.
|
overridevirtual |
All scalar stress-energy perturbations in one call.
Implements 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.
|
overridevirtual |
Append this species' time-evolution variables to writer. Called from perturb_prepare_k_output (title mode, tau=0/y=nullptr/ppw=nullptr) and perturb_print_variables (data mode). Guard computation behind: if (!writer.IsTitleMode()) { ... compute ... } Use writer.Add(title, computed_value, active).
layout is NULL in title mode (there is no perturb_vector yet) and is the species' own sub-layout otherwise — passed in rather than resolved from collection_index_ so that CompositeSpecies can chain this to children, which are not registered in the collection and have no valid collection_index_.
Reimplemented from BaseSpecies.
Reimplemented in PpfFluid.