|
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 &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 | PerturbDerivs (const BaseSpecies::PerturbLayout &base, double tau, const double *y, double *dy, const perturb_parameters_and_workspace &ppaw) const override |
| void | PerturbDerivsDiagonal (const BaseSpecies::PerturbLayout &base, double tau, const double *y, double *diag, 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 | 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 |
| 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 |
| 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 |
| bool | SupportsExplicitPerturbationEvolver () const override |
| int | MaxMultipole (const precision *ppr, bool tensors) const override |
| bool | PrefersExponentialPerturbationEvolver () const override |
| bool | SupportsExponentialPerturbationEvolver () const override |
| 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 |
| void | PrintBackgroundDetails (const double *pvecback_today, double rho_crit_today) 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 |
| std::optional< double > | ChildOmega0 (const std::string &name) 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 | BackgroundDerivsDiagonal (double tau, const double *y, double *diag, 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 |
| double | NonClusteringOmega0 () const override |
| double | ColdMatterRho (const double *pvecback) const override |
| double | ColdMatterOmega0 () 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 |
| 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 | 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 |
| bool | ClustersAsMatterCached () const |
| virtual bool | HasNcdm () const |
| virtual double | SourceSamplingRate (const double *) 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 |
The same for the scalar perturbation ODE; see BackgroundDerivsDiagonal for the accumulate contract, the zero default and the wrong-sign warning, which apply verbatim here.
Reimplemented from BaseSpecies.
Reimplemented in DNCDMProxySpecies, and DNCDMInvSpecies.
|
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 IDM_DR_IDR_Species.
|
overridevirtual |
Names every child's transfer columns, in children_ order. Chained like every other per-species hook so that a composite which allocates a child's source slot (RegisterTransferSourceIndices) and fills it (FillSources) also names it — without this the columns are computed every step and thrown away, and d_tot is not reconstructible from the d_i (issue #391). Composites that own slots at composite level override and chain to this first.
Reimplemented from BaseSpecies.
Reimplemented in IDM_DR_IDR_Species.
|
overridevirtual |
Chains each child's k_output_values columns, in children_ order. Composites that publish sector-level aggregates their children cannot form (the DNCDM a4Pi decomposition) override and add those on top.
Reimplemented from BaseSpecies.
Reimplemented in DNCDMInvSpecies, DNCDMProxySpecies, 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.
Reimplemented in DNCDMProxySpecies.
|
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.
Reimplemented in DNCDMProxySpecies.
|
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 DNCDMSector.
|
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 |
A composite is explicit-evolver safe only if every child is. Unlike HasNcdm() this DOES scan children: the question is about the stiffness of the merged system, to which each child contributes its own equations.
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
s_l must cover the deepest hierarchy anywhere in the subtree, so this DOES scan children – a composite owns no multipoles of its own, and the whole point of #421 is that the daughter's requirement must reach the module.
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
A composite benefits from etd if ANY child does – the exponential step is chosen for the whole system, so one stiff diagonal in the subtree is enough to make it worth taking.
Reimplemented from BaseSpecies.
|
inlineoverridevirtual |
...but it is only SAFE under etd if EVERY child is, which is why this scans rather than combining the two answers above; see BaseSpecies::SupportsExponentialPerturbationEvolver().
Reimplemented from BaseSpecies.
|
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 |
Details printed once the background table is built (background_verbose > 2). pvecback_today is today's row of the table, rho_crit_today the critical density in it. Default no-op; the scalar field prints its Omega and potential parameters; 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 |
|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.
|
inlineoverridevirtual |
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.
Reimplemented in IDM_DR_IDR_Species.
|
inlineoverridevirtual |
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 |
Looks the name up among the children only.
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, DNCDM_DR_Species, DNCDMInvSpecies, and DNCDMProxySpecies.
|
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, DNCDM_DR_Species, and DNCDMProxySpecies.
|
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, and DNCDMProxySpecies.
|
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, DNCDM_DR_Species, DNCDMInvSpecies, and DNCDMProxySpecies.
|
overridevirtual |
Contribute d(dy_i)/d(y_i) — the DIAGONAL of this species' background Jacobian — for the slots it owns, in the same units and layout as BackgroundDerivs.
For the exponential evolver, which integrates the diagonal exactly and carries the remainder explicitly. ACCUMULATE (+=): the caller zeroes the buffer once, and a composite's rungs each add their own slots.
Default: nothing. That is the correct answer for a species without a stiff self-coupling, not a fallback — at diag = 0 the exponential step degenerates smoothly to its explicit counterpart.
A diagonal that is not the true one costs efficiency and conditioning, never correctness (the evolver forms N = f - Ly, so the fixed point is exact for any L). A wrong SIGN is the dangerous case; pin any implementation against finite differences of BackgroundDerivs.
Reimplemented from BaseSpecies.
Reimplemented in DNCDMInvSpecies, and DNCDMProxySpecies.
|
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; dark energy once its pressure is negative) 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 |
Today's density fraction in components that neither cluster as matter nor are radiation or dark energy: a quintessence-like field. HMcode 2020 integrates its growth in a cosmology of matter, Lambda and a w0-wa fluid, and refuses these. Default: GetOmega0() for an EnergyType::Other species that does not cluster as matter, else 0. Override: composites sum over children.
Reimplemented from BaseSpecies.
|
overridevirtual |
This species' density in cold matter: Rho for a cold species, else 0. Summed over the species it is the rho_M of the growth factor, and without the baryons the dark matter that annihilates or decays into the plasma. Override: composites sum over children, so IDM_DR_IDR gives its dark matter and not its dark radiation.
Reimplemented from BaseSpecies.
|
overridevirtual |
The same today, as a density fraction known before the background is integrated (where the EDE fluid places matter-radiation equality). Default: GetOmega0() for a cold species, else 0. Overrides: composites sum over children; DCDM refuses, its density today being an output of the background.
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, DNCDMInvSpecies, DNCDMProxySpecies, IDM_DR_IDR_Species, and Type3Species.