CLASSpp Manual
Cosmology reference and developer manual
Loading...
Searching...
No Matches
ScalarTensorSpecies Class Reference

#include <scalar_tensor_species.h>

+ Inheritance diagram for ScalarTensorSpecies:

Public Member Functions

double F (double phi) const
 
double GetOmega0 () const override
 
double BackgroundDensityOverH0Sq (double a, double H0) const override
 
std::optional< double > GetParam (const std::string &name) 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
 
void ProcessBackgroundTable (const double *background_table, int n_rows, int row_stride, const double *z_table) override
 
double SourceSamplingRate (const double *pvecback) const override
 
void CloseFriedmann (double a, double K, const double *pvecback_B, double *pvecback, double &rho_tot, double &p_tot, double &rho_r, double &rho_m) const override
 
double HPrime (double k, const double *y, const perturb_workspace *ppw) const override
 
double EtaPrime (double k, const double *y, const perturb_workspace *ppw) const override
 
double HPrimePrime (double k, const double *y, const perturb_workspace *ppw) const override
 
double AlphaPrime (double k, const double *y, const perturb_workspace *ppw) const override
 
std::unique_ptr< BaseSpecies::PerturbLayout > CreatePerturbLayout () const override
 
void PerturbDerivs (const BaseSpecies::PerturbLayout &base, double tau, const double *y, double *dy, const perturb_parameters_and_workspace &ppaw) 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 ApplyInitialConditions (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 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 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 RegisterTransferSourceIndices (int &, const SourceRequestContext &)
 
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 void WriteOutputColumns (PerturbColumnWriter &, const PerturbationsModule &, file_format, TransferColumnSection=TransferColumnSection::all) const
 
virtual void FillSources (const PerturbLayout &, const double *, const double *, PerturbSourceContext &) 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 PerturbSynchronousToNewtonian (const PerturbLayout &, double *, const PerturbIcContext &)
 
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 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 int MaxMultipole (const precision *, bool) const
 
virtual bool SupportsExplicitPerturbationEvolver () 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
 

Detailed Description

A scalar field non-minimally coupled to gravity, in the Jordan frame:

S = ∫ d^4x √-g [ f(φ) R/2 − (∂φ)²/2 − V(φ) ] + S_m , M_pl = 1, f(φ) = N_st + ξ_st φ² , V(φ) = 3 H0² Omega_Lambda_st + λ_st M_pl² φ⁴ / 4 ,

with matter minimally coupled. That covers Early Modified Gravity (H0 Olympics, arXiv:2107.10291 sec. 2.4.6; Braglia et al. 2011.12934) at N = 1; the massless non-minimally coupled scalar at λ = 0; induced gravity, i.e. Brans–Dicke with ω = 1/(4ξ), at N = 0; and Rock 'n' Roll early dark energy at ξ = 0. φ is in units of the reduced Planck mass, and λ_st is the dimensionless coupling of the action.

The coupling modifies gravity, so besides being a species this implements ModifiedGravity:

  • Background: CloseFriedmann solves the Jordan-frame Friedmann equations for H and H', then reports an effective density and pressure, (.)rho_st and (.)p_st, that make GR's expressions exact. It is dark energy for the module's energy buckets; instead it scales the radiation and matter buckets by 1/f, so N_eff at BBN and z_eq see G/f. The potential's constant, Omega_Lambda_st, is shot for so that the effective density vanishes today, i.e. H(z = 0) = H0, with Lambda closing the GR budget as usual.
  • Perturbations: the scalar Einstein equations in synchronous gauge, and δφ with the Klein–Gordon equation in trace form. The species' stress-energy is the canonical scalar's; the coupling enters only through the Einstein equations.

Synchronous gauge, scalar modes, adiabatic initial conditions and a flat universe only; the factory refuses anything else.

Design: docs/superpowers/specs/2026-09-24-scalar-tensor-gravity-design.md

Member Function Documentation

◆ F()

double ScalarTensorSpecies::F ( double  phi) const
inline

The coupling f(φ) = F/M_pl² and the potential V(φ), in CLASS units (1/Mpc²).

◆ GetOmega0()

double ScalarTensorSpecies::GetOmega0 ( ) const
inlineoverridevirtual

The effective density today is shot to zero; see the class comment.

Implements BaseSpecies.

◆ BackgroundDensityOverH0Sq()

double ScalarTensorSpecies::BackgroundDensityOverH0Sq ( double  a,
double  H0 
) const
overridevirtual

Refused: there is no density before the background is solved, because this species changes H itself.

Reimplemented from BaseSpecies.

◆ GetParam()

std::optional< double > ScalarTensorSpecies::GetParam ( const std::string &  ) const
overridevirtual

Generic species-param accessor for the Python wrapper layer and cross-module readers that don't want to downcast. Each species may opt in by overriding this and returning the named param; default is std::nullopt.

Reimplemented from BaseSpecies.

◆ SetBackgroundModule()

void ScalarTensorSpecies::SetBackgroundModule ( const BackgroundModule *  )
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.

◆ RegisterBackgroundIndices()

void ScalarTensorSpecies::RegisterBackgroundIndices ( int &  index_bg)
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.

◆ RegisterIntegrationIndices()

void ScalarTensorSpecies::RegisterIntegrationIndices ( int &  index_bi)
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.

◆ SetBackgroundInitialConditions()

void ScalarTensorSpecies::SetBackgroundInitialConditions ( const BackgroundICContext &  ctx)
overridevirtual

Set initial conditions for ODE-integrated background variables.

Parameters
ctxBackground initial-condition context (a_ini, rho_rad, and the integration vector to fill).

Reimplemented from BaseSpecies.

◆ ComputeBackground()

void ScalarTensorSpecies::ComputeBackground ( double  a,
const double *  pvecback_B,
double *  pvecback 
)
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.

◆ BackgroundDerivs()

void ScalarTensorSpecies::BackgroundDerivs ( double  tau,
const double *  y,
double *  dy,
const double *  pvecback 
)
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.

◆ Rho()

double ScalarTensorSpecies::Rho ( const double *  pvecback) const
inlineoverridevirtual

Energy density at current background state.

Implements BaseSpecies.

◆ P()

double ScalarTensorSpecies::P ( const double *  pvecback) const
inlineoverridevirtual

Pressure at current background state.

Implements BaseSpecies.

◆ PPrime()

double ScalarTensorSpecies::PPrime ( double  a,
double  H,
const double *  pvecback_B,
const double *  pvecback 
) const
overridevirtual

The canonical scalar's p' only: the effective pressure's derivative would need H'', and the two consumers of p_tot' (N-body gauge, PPF) are refused.

Reimplemented from BaseSpecies.

◆ WriteBackgroundColumnTitles()

void ScalarTensorSpecies::WriteBackgroundColumnTitles ( BackgroundColumnWriter &  ) const
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.

◆ WriteBackgroundData()

void ScalarTensorSpecies::WriteBackgroundData ( const double *  ,
BackgroundColumnWriter &   
) const
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.

◆ ProcessBackgroundTable()

void ScalarTensorSpecies::ProcessBackgroundTable ( const double *  ,
int  ,
int  ,
const double *   
)
overridevirtual

Called once after the full background table is built. Lets a species run table-scope analysis over its own columns. Default no-op.

Reimplemented from BaseSpecies.

◆ SourceSamplingRate()

double ScalarTensorSpecies::SourceSamplingRate ( const double *  pvecback) const
overridevirtual

omega / pi for the field's oscillation in conformal time, from the period of the quartic oscillator at the amplitude its energy implies; 0 for lambda = 0. See BaseSpecies::SourceSamplingRate.

Reimplemented from BaseSpecies.

◆ CloseFriedmann()

void ScalarTensorSpecies::CloseFriedmann ( double  a,
double  K,
const double *  pvecback_B,
double *  pvecback,
double &  rho_tot,
double &  p_tot,
double &  rho_r,
double &  rho_m 
) const
overridevirtual

Close the Friedmann equations. Called in background_functions after every species has computed its background, with the running totals of all of them; the modified-gravity species itself has contributed nothing yet.

On return the species' own density and pressure are the effective ones that make GR's expressions exact, H = sqrt(rho_tot - K/a^2) and H' = -3/2 (rho_tot + p_tot) a + K/a, and they have been added to rho_tot and p_tot. rho_r and rho_m, the radiation- and matter-like parts of rho_tot, are updated to match.

Implements ModifiedGravity.

◆ HPrime()

double ScalarTensorSpecies::HPrime ( double  k,
const double *  y,
const perturb_workspace *  ppw 
) const
overridevirtual

h' from the 00 (energy) constraint.

Implements ModifiedGravity.

◆ EtaPrime()

double ScalarTensorSpecies::EtaPrime ( double  k,
const double *  y,
const perturb_workspace *  ppw 
) const
overridevirtual

eta' from the 0i (momentum) constraint.

Implements ModifiedGravity.

◆ HPrimePrime()

double ScalarTensorSpecies::HPrimePrime ( double  k,
const double *  y,
const perturb_workspace *  ppw 
) const
overridevirtual

h'' from the trace of the ij equation.

Implements ModifiedGravity.

◆ AlphaPrime()

double ScalarTensorSpecies::AlphaPrime ( double  k,
const double *  y,
const perturb_workspace *  ppw 
) const
overridevirtual

alpha' from the traceless part of the ij equation.

Implements ModifiedGravity.

◆ CreatePerturbLayout()

std::unique_ptr< BaseSpecies::PerturbLayout > ScalarTensorSpecies::CreatePerturbLayout ( ) const
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.

◆ PerturbDerivs()

void ScalarTensorSpecies::PerturbDerivs ( const BaseSpecies::PerturbLayout &  layout,
double  tau,
const double *  y,
double *  dy,
const perturb_parameters_and_workspace &  ppaw 
) const
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.

◆ StressEnergy()

BaseSpecies::StressEnergyContribution ScalarTensorSpecies::StressEnergy ( const BaseSpecies::PerturbLayout &  layout,
const perturb_vector *  pv,
const double *  y,
const double *  pvecback,
const perturb_workspace *  ppw 
) const
overridevirtual

All scalar stress-energy perturbations in one call.

Implements BaseSpecies.

◆ ApplyInitialConditions()

void ScalarTensorSpecies::ApplyInitialConditions ( const BaseSpecies::PerturbLayout &  ,
double *  ,
const PerturbIcContext &   
)
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.

◆ CopyPerturbationsAcrossSwitch()

void ScalarTensorSpecies::CopyPerturbationsAcrossSwitch ( const BaseSpecies::PerturbLayout &  ,
const BaseSpecies::PerturbLayout &  ,
const double *  ,
double *  ,
const PerturbSwitchContext &   
) const
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.

◆ PrintVariables()

void ScalarTensorSpecies::PrintVariables ( PerturbColumnWriter &  ,
const BaseSpecies::PerturbLayout *  ,
double  ,
const double *  ,
const PerturbationsModule &  ,
const perturb_workspace *   
) const
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.


The documentation for this class was generated from the following files: