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

#include <photons.h>

+ Inheritance diagram for PhotonsSpecies:

Data Structures

struct  TensorTcaClosure
 

Public Member Functions

bool SupportsExplicitPerturbationEvolver () const override
 
int MaxMultipole (const precision *ppr, bool tensors) const override
 
std::unique_ptr< BaseSpecies::PerturbLayout > CreatePerturbLayout () const override
 
double GetOmega0 () const override
 
void RegisterBackgroundIndices (int &index_bg) override
 
void ComputeBackground (double a, const double *, 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 *, const double *pvecback) const override
 
void WriteBackgroundColumnTitles (BackgroundColumnWriter &w) const override
 
void WriteBackgroundData (const double *pvecback, BackgroundColumnWriter &w) const override
 
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 PerturbVectorDerivs (const BaseSpecies::PerturbLayout &base, double tau, const double *y, double *dy, const perturb_parameters_and_workspace &ppaw) const override
 
void PerturbTensorDerivs (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 MarkUsedInSources (const BaseSpecies::PerturbLayout &base, const perturb_workspace *ppw, int *used_in_sources) const override
 
void MarkTensorUsedInSources (const BaseSpecies::PerturbLayout &base, const perturb_workspace *ppw, int *used_in_sources) const 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 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
 
StressEnergyContribution StressEnergy (const BaseSpecies::PerturbLayout &base, const perturb_vector *pv, const double *y, const double *pvecback, const perturb_workspace *ppw) const override
 
void SetThermodynamicsModule (const ThermodynamicsModule *thm) override
 
void SetPerturbs (const perturbs *ppt) override
 
- Public Member Functions inherited from BaseSpecies
virtual void SetBackgroundModule (const BackgroundModule *)
 
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 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 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 bool PrefersExponentialPerturbationEvolver () const
 
virtual bool SupportsExponentialPerturbationEvolver () const
 

Static Public Member Functions

static double TensorP2 (double F0, double shear, double F4, double G0, double G2, double G4)
 
static double TensorTcaDrift (double gwdot, double dkappa, double gw_second, double ddkappa)
 
static TensorTcaClosure TensorTightCoupling (double gwdot, double dkappa, double drift=0.)
 

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

Photons: rho ~ a^{-4}. Boltzmann hierarchy with l_max_g multipoles.


Data Structure Documentation

◆ PhotonsSpecies::TensorTcaClosure

struct PhotonsSpecies::TensorTcaClosure

Leading-order tensor tight-coupling state, in the multipoles the hierarchy evolves. Everything above l = 0 is higher order in 1/kappa' and stays zero.

Data Fields
double F0

photon temperature monopole (delta_g)

double G0

photon polarisation monopole (pol0_g)

double P2

the combination above, evaluated on this state

Member Function Documentation

◆ SupportsExplicitPerturbationEvolver()

bool PhotonsSpecies::SupportsExplicitPerturbationEvolver ( ) const
inlineoverridevirtual

Benchmarked against ndf15 across the standard parameter range; see BaseSpecies::SupportsExplicitPerturbationEvolver().

Reimplemented from BaseSpecies.

◆ MaxMultipole()

int PhotonsSpecies::MaxMultipole ( const precision *  ,
bool   
) const
inlineoverridevirtual

Highest multipole index this species' hierarchy will address in this mode, or 0 if it carries none.

Consumed by PerturbationsModule::perturb_workspace_init to size ppw->s_l, which the free-streaming loops index up to s_l[l_max] (they read s_l[l+1] for l < l_max). That sizing used to be a hard-coded list of species KEYS, which silently missed the DarkRadiationSpecies daughter inside a DNCDM composite – keyed by its instance name, not "DCDM_DR" – so its hierarchy read past the end of s_l (#421). A species answers for its own storage; a module cannot know.

Over-reporting is safe (s_l is merely longer, and the unused entries are never read); under-reporting is a heap overflow. When in doubt, report more.

Reimplemented from BaseSpecies.

◆ CreatePerturbLayout()

std::unique_ptr< BaseSpecies::PerturbLayout > PhotonsSpecies::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.

◆ GetOmega0()

double PhotonsSpecies::GetOmega0 ( ) const
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.

◆ RegisterBackgroundIndices()

void PhotonsSpecies::RegisterBackgroundIndices ( int &  index_bg)
inlineoverridevirtual

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.

◆ ComputeBackground()

void PhotonsSpecies::ComputeBackground ( double  a,
const double *  pvecback_B,
double *  pvecback 
)
inlineoverridevirtual

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.

◆ Rho()

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

Energy density at current background state.

Implements BaseSpecies.

◆ P()

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

Pressure at current background state.

Implements BaseSpecies.

◆ PPrime()

double PhotonsSpecies::PPrime ( double  a,
double  H,
const double *  pvecback_B,
const double *  pvecback 
) const
inlineoverridevirtual

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.

◆ WriteBackgroundColumnTitles()

void PhotonsSpecies::WriteBackgroundColumnTitles ( BackgroundColumnWriter &  ) const
inlineoverridevirtual

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 PhotonsSpecies::WriteBackgroundData ( const double *  ,
BackgroundColumnWriter &   
) const
inlineoverridevirtual

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.

◆ RegisterTransferSourceIndices()

void PhotonsSpecies::RegisterTransferSourceIndices ( int &  ,
const SourceRequestContext &   
)
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.

◆ PerturbDerivs()

void PhotonsSpecies::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.

◆ PerturbVectorDerivs()

void PhotonsSpecies::PerturbVectorDerivs ( const BaseSpecies::PerturbLayout &  ,
double  ,
const double *  ,
double *  ,
const perturb_parameters_and_workspace &   
) const
overridevirtual

Contribute to dy for the vector perturbation ODE. Default: no-op.

Reimplemented from BaseSpecies.

◆ PerturbTensorDerivs()

void PhotonsSpecies::PerturbTensorDerivs ( const BaseSpecies::PerturbLayout &  ,
double  ,
const double *  ,
double *  ,
const perturb_parameters_and_workspace &   
) const
overridevirtual

Contribute to dy for the tensor perturbation ODE. Default: no-op.

Reimplemented from BaseSpecies.

◆ TensorP2()

static double PhotonsSpecies::TensorP2 ( double  F0,
double  shear,
double  F4,
double  G0,
double  G2,
double  G4 
)
inlinestatic

The polarisation combination $ P^{(2)} $ that couples the temperature and polarisation tensor hierarchies. Shared so that PerturbTensorDerivs, the source, and the tight-coupling closure cannot drift apart.

◆ TensorTcaDrift()

static double PhotonsSpecies::TensorTcaDrift ( double  gwdot,
double  dkappa,
double  gw_second,
double  ddkappa 
)
inlinestatic

$ D = d/d\tau (\dot h / \kappa') $, the drift the first-order closure needs, from the quantities a call site already has.

◆ TensorTightCoupling()

PhotonsSpecies::TensorTcaClosure PhotonsSpecies::TensorTightCoupling ( double  gwdot,
double  dkappa,
double  drift = 0. 
)
static

Solve the tensor hierarchy's stiff balance for (F_0, G_0, P^{(2)}).

Parameters
gwdot$ \dot h $, the gravitational-wave velocity.
dkappa$ \kappa' $, the Thomson scattering rate.
drift$ D $ from TensorTcaDrift(). Zero – the default – gives the leading-order closure, for call sites with no time derivative available.

◆ FillSources()

void PhotonsSpecies::FillSources ( const BaseSpecies::PerturbLayout &  ,
const double *  ,
const double *  ,
PerturbSourceContext &   
) const
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.

◆ ApplyInitialConditions()

void PhotonsSpecies::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.

◆ PerturbSynchronousToNewtonian()

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

◆ MarkUsedInSources()

void PhotonsSpecies::MarkUsedInSources ( const BaseSpecies::PerturbLayout &  base,
const perturb_workspace *  ppw,
int *  used_in_sources 
) const
overridevirtual

Photon temperature l>=3 and polarization l=1,3+ are not needed in source evaluation when both rsa and tca are off. Called only in scalar mode (the dispatch loop in the module is guarded by if (scalars)).

Reimplemented from BaseSpecies.

◆ MarkTensorUsedInSources()

void PhotonsSpecies::MarkTensorUsedInSources ( const BaseSpecies::PerturbLayout &  base,
const perturb_workspace *  ppw,
int *  used_in_sources 
) const
overridevirtual

In tensor mode, photon temperature l=0,2,4 and pol l=0,2,4 are needed; mark higher multipoles as unused when both rsa and tca are off.

Reimplemented from BaseSpecies.

◆ CopyPerturbationsAcrossSwitch()

void PhotonsSpecies::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.

◆ WriteOutputColumns()

void PhotonsSpecies::WriteOutputColumns ( PerturbColumnWriter &  ,
const PerturbationsModule &  ,
file_format  ,
BaseSpecies::TransferColumnSection  = TransferColumnSection::all 
) const
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.

◆ PrintVariables()

void PhotonsSpecies::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.

◆ StressEnergy()

BaseSpecies::StressEnergyContribution PhotonsSpecies::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.

◆ SetThermodynamicsModule()

void PhotonsSpecies::SetThermodynamicsModule ( const ThermodynamicsModule *  )
inlineoverridevirtual

Called by PerturbationsModule during construction to provide access to the thermodynamics module (pvecthermo indices, etc.). Default: no-op.

Reimplemented from BaseSpecies.

◆ SetPerturbs()

void PhotonsSpecies::SetPerturbs ( const perturbs *  )
inlineoverridevirtual

Called by PerturbationsModule during construction to provide access to the perturbs struct (alpha_idm_dr, gauge, etc.). Default: no-op.

Reimplemented from BaseSpecies.


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