|
CLASSpp Manual
Cosmology reference and developer manual
|
#include <fluid.h>
Inheritance diagram for FluidSpecies:Public Member Functions | |
| 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 | RegisterIntegrationIndices (int &index_bi) override |
| void | SetBackgroundInitialConditions (const BackgroundICContext &ctx) override |
| void | ComputeBackground (double a, const double *pvecback_B, double *pvecback) override |
| void | BackgroundDerivs (double tau, const double *y, double *dy, const 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 |
| virtual bool | HyrecCplApproximation (double *w0, double *wa) const |
| void | RegisterTransferSourceIndices (int &index_tp, const SourceRequestContext &ctx) override |
| void | PerturbDerivs (const BaseSpecies::PerturbLayout &layout, double tau, const double *y, double *dy, const perturb_parameters_and_workspace &ppaw) const override |
| void | FillSources (const BaseSpecies::PerturbLayout &layout, const double *y, const double *dy, PerturbSourceContext &ctx) const override |
| void | ApplyInitialConditions (const BaseSpecies::PerturbLayout &layout, double *y, const PerturbIcContext &ctx) override |
| void | PerturbSynchronousToNewtonian (const BaseSpecies::PerturbLayout &layout, double *y, const PerturbIcContext &ctx) override |
| void | CopyPerturbationsAcrossSwitch (const BaseSpecies::PerturbLayout &old_layout, const BaseSpecies::PerturbLayout &new_layout, const double *old_y, double *new_y, const PerturbSwitchContext &ctx) const override |
| StressEnergyContribution | StressEnergy (const BaseSpecies::PerturbLayout &layout, 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, 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 | 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 |
| virtual void | ProcessBackgroundTable (const double *, int, int, const double *) |
| 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 | WriteTensorOutputColumnTitles (std::string &) const |
| virtual void | ContributeTensorGwSource (const PerturbLayout &, double, const double *, perturb_workspace *) const |
| virtual double | RhoDotOverRho (const double *pvecback, double a_prime_over_a) const |
| virtual void | MarkUsedInSources (const PerturbLayout &, const perturb_workspace *, int *) 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 double | TensorMasslessRelativisticRho (const double *) const |
| virtual void | CheckUltraRelativisticAtIc (const double *, double) const |
| virtual bool | IsUltraRelativisticAtIc (const double *, double) const |
| virtual void | WarnIfTooHeavyForHalofit (double) 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 |
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 ODE-integrated via BackgroundDerivs called from background_derivs_member(). ComputeBackground reads rho_fld from pvecback_B.
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 |
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 |
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.
|
overridevirtual |
Contribute to dy/dtau for species with ODE-integrated background variables. pvecback already contains all evaluated background quantities. Default: nothing (species with analytic rho(a) don't override this).
rho' = -3*a*H*(1+w)*rho
Reimplemented from 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. Just remember that so far, HyRec explicitely assumes that w(a)= w0 + wa (1-a/a0); but Recfast does not assume anything
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.
|
virtual |
HyRec reconstructs its internal dark-energy density from a CPL (w0, wa) pair (hyrec/history.c:83). Fill (w0, wa) with this fluid's best CPL representation and return true, or return false when no CPL pair can represent the density history (the caller must then refuse to run HyRec). Base fluid: tangent at a = 1, w0 = w(1), wa = -dw/da(1) — exactly the historical behavior.
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_member() 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_member (data mode). Guard computation behind: if (!writer.IsTitleMode()) { ... compute ... } Use writer.Add(title, computed_value, active).
Reimplemented from BaseSpecies.
Reimplemented in PpfFluid.