|
CLASSpp Manual
Cosmology reference and developer manual
|
#include <composite_species.h>
Inheritance diagram for CompositeSpecies:Data Structures | |
| struct | PerturbLayout |
Public Member Functions | |
| std::unique_ptr< BaseSpecies::PerturbLayout > | CreatePerturbLayout () const override |
| void | ApplyInitialConditions (const BaseSpecies::PerturbLayout &layout, double *y, const PerturbIcContext &ctx) override |
| StressEnergyContribution | StressEnergy (const BaseSpecies::PerturbLayout &layout, const perturb_vector *pv, const double *y, const double *pvecback, const perturb_workspace *ppw) const 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 | 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 |
| void | RegisterBackgroundIndices (int &index_bg) override |
| void | RegisterIntegrationIndices (int &index_bi) override |
| void | RegisterTransferSourceIndices (int &index_tp, const SourceRequestContext &ctx) override |
| double | GetOmega0 () const override |
| void | AppendBudgetLines (const double *pvecback_today, double rho_crit, std::vector< BudgetLine > &out) const |
| double | GetRadiationOmega0 () const override |
| double | DarkRadiationRhoToday (const double *pvecback_integration) const override |
| double | NeutrinoOmega0 () const override |
| double | NeffContribution (double z) const override |
| void | PrintNeffInfo () const override |
| void | PrintMassInfo () const override |
| double | TensorMasslessRelativisticRho (const double *pvecback) const override |
| void | CheckUltraRelativisticAtIc (const double *pvecback, double tol) const override |
| bool | IsUltraRelativisticAtIc (const double *pvecback, double tol) const override |
| void | WarnIfTooHeavyForHalofit (double m_ev_threshold) const override |
| double | BackgroundAIni (double a_proposed, double tol) const override |
| void | SetBackgroundModule (const BackgroundModule *bgm) override |
| void | SetThermodynamicsModule (const ThermodynamicsModule *thm) override |
| void | SetPerturbs (const perturbs *ppt) 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 |
| void | FinalizeBackground (double a, double H, 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 |
| double | FreestreamingRho (const double *pvecback) const override |
| bool | ClustersAsMatter () const override |
| bool | IsColdMatterSpecies () const override |
| bool | HasWarmMatter () const override |
| void | FinalizeMatterClassification () override |
Public Member Functions inherited from BaseSpecies | |
| virtual std::optional< double > | GetParam (const std::string &) const |
| virtual bool | IsFreestreaming () const |
| bool | IsPresent () const |
| virtual void | WriteBackgroundColumnTitles (BackgroundColumnWriter &) const |
| virtual void | WriteBackgroundData (const double *, BackgroundColumnWriter &) 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 void | WriteOutputColumns (PerturbColumnWriter &, const PerturbationsModule &, file_format, TransferColumnSection=TransferColumnSection::all) const |
| virtual void | PrintVariables (PerturbColumnWriter &, double, const double *, const PerturbationsModule &, const 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 |
| bool | ClustersAsMatterCached () const |
Protected Member Functions | |
| virtual void | AddCouplingDerivs (double tau, const double *y, double *dy, const perturb_parameters_and_workspace &ppaw) const |
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 |
CompositeSpecies: a BaseSpecies that owns N child species and acts as a single all_species_ entry for a physically coupled sector.
Background methods sum over children. The perturbation interface (layout signatures) is implemented by each concrete composite: its PerturbLayout nests one sub-layout per child, and every method forwards the matching sub-layout to the child, e.g. child->Delta(my.child_layout, ...).
Conventions concrete composites must follow so the Einstein equations get the right totals: Delta = rho-weighted average: Rho() * Delta() == sum_i(rho_i * delta_i) Theta = (rho+p)-weighted average: (Rho()+P()) * Theta() == sum_i((rho_i+p_i) * theta_i) delta_p / rho_plus_p_shear = summed inside StressEnergy. PerturbDerivs runs a two-phase dispatch:
|
overridevirtual |
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.
|
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.
Reimplemented in IDM_DR_IDR_Species.
|
overridevirtual |
All scalar stress-energy perturbations in one call.
Implements BaseSpecies.
Reimplemented in Type3Species.
|
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 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 DCDM_DR_Species, DCDM_WDM_Species, DNCDM_DR_Species, and IDM_DR_IDR_Species.
|
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 DCDM_DR_Species, and DNCDM_DR_Species.
|
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.
|
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 |
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.
Reimplemented in IDM_DR_IDR_Species.
|
inlineoverridevirtual |
Sums GetOmega0() over all children.
Implements BaseSpecies.
Reimplemented in DCDM_WDM_Species, and DNCDM_DR_Species.
|
inline |
Append one budget line per child (label = child name(), omega = today Rho/rho_crit, bucket = BudgetBucketOf(child)) for background_output_budget(). The composite owns its sector breakdown; children_ is never exposed.
|
inlineoverridevirtual |
Sums GetRadiationOmega0() over all children (dark-radiation children contribute their Omega0; matter children contribute 0).
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
Sums DarkRadiationRhoToday() over all children.
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
Sums NeutrinoOmega0() over children (matter NCDM children contribute).
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
Sums NeffContribution() over children.
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
Verbose N_eff line (background_verbose). Default no-op; NCDM prints; composites forward to children.
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
Verbose mass/omega line (background_verbose). Default no-op; NCDM prints; composites forward to children.
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
Contribution to the tensor-mode "relativistic" density in the massless approximation. Default 0; NCDM returns 3*P; composites sum.
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
Initial-time ultra-relativistic check (throws via class_test on failure). Default no-op; NCDM checks |w-1/3|; composites forward to children.
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
Initial-time ultra-relativistic predicate. Default true; NCDM checks |w-1/3| <= tol; composites AND over children.
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
Warn (stdout) if this species is too heavy for Halofit/HMcode. The policy threshold is passed by the nonlinear module. Default no-op; NCDM compares its mass; composites forward.
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
Threads a_proposed through all children (e.g. a wrapped DNCDM child may pull the earliest integration start earlier).
Reimplemented from BaseSpecies.
|
overridevirtual |
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.
Reimplemented in DCDM_DR_Species, DCDM_WDM_Species, and DNCDM_DR_Species.
|
overridevirtual |
Called by PerturbationsModule during construction to provide access to the thermodynamics module (pvecthermo indices, etc.). Default: no-op.
Reimplemented from BaseSpecies.
|
overridevirtual |
Called by PerturbationsModule during construction to provide access to the perturbs struct (alpha_idm_dr, gauge, etc.). Default: no-op.
Reimplemented from BaseSpecies.
Reimplemented in IDM_DR_IDR_Species.
|
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.
Reimplemented in DCDM_DR_Species, and DNCDM_DR_Species.
|
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.
Reimplemented in DCDM_WDM_Species.
|
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).
Reimplemented from BaseSpecies.
Reimplemented in DCDM_DR_Species, DCDM_WDM_Species, and DNCDM_DR_Species.
|
overridevirtual |
Post-Friedmann. Write this species' H-dependent owned output slots. H passed explicitly so the hook need not re-read it. Default no-op.
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 |
Free-streaming radiation density contributed by this species at the current background state. Plain species derive this from IsFreestreaming(); composites override it to sum over their children.
Reimplemented from BaseSpecies.
|
overridevirtual |
True iff this species' clustering participates in the total matter tally (delta_m / theta_m and the P_m(k) source). This is the axis-2 (perturbation) counterpart to EnergyType, which only drives the axis-1 background rho_r/rho_m split: a quintessence scalar field is EnergyType::Other (radiation-like early, so the background needs its rho-3P split) yet does NOT cluster as matter, so it must stay out of P_m(k). A member's contribution is computed generically (its matter density is rho-3P and its density perturbation is delta_rho-3*delta_p), so this predicate only governs membership, not the value. Default: cold matter (energy_type==Matter). Overrides: NCDM/DNCDM (warm matter) return true; composites scan children; a clustering scalar-field dark-matter model would override to true.
Reimplemented from BaseSpecies.
|
overridevirtual |
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.
|
overridevirtual |
True iff this species contributes WARM matter: it clusters in the total matter tally (delta_m / P_m) but stays out of the cold tally (delta_cb / P_cb). This is exactly the condition under which P_cb differs from P_m, so it gates the cb sources and spectra (has_source_delta_cb, has_pk_cb_). Default: derived from the two predicates above. Override: composites scan children (their own two predicates OR over children, so e.g. a cold parent + warm daughter composite would wrongly read as cold).
Reimplemented from BaseSpecies.
|
overridevirtual |
Stamp the cached classification from the (virtual) predicates. Called once by SpeciesCollection::freeze() after every species and its children are built. CompositeSpecies overrides to also recurse into children.
Reimplemented from BaseSpecies.
|
protectedvirtual |
Override in concrete subclasses to add coupling terms to dy after all children have written their free-streaming contributions. Default: no-op.
Reimplemented in DCDM_DR_Species, DCDM_WDM_Species, DNCDM_DR_Species, IDM_DR_IDR_Species, and Type3Species.