Bicameral Engine
GPU-resident engine for a magic-research open-world game
Loading...
Searching...
No Matches
bicameral::sim::anonymous_namespace{reaction_table.cpp} Namespace Reference

Classes

struct  TermsResult

Typedefs

using NameIndex = std::map<std::string, uint32_t, std::less<>>

Functions

uint64_t HashName (std::string_view name)
ReactionTableDefinition CanonicalOrder (const ReactionTableDefinition &definition)
std::expected< NameIndex, std::string > IndexElements (const ReactionTableDefinition &definition, BakedReactionTable &baked)
int64_t ZeroKelvinEnthalpy (const SpeciesDefinition &species)
std::expected< void, std::string > BakeSpecies (const SpeciesDefinition &definition, const NameIndex &elements, const ReactionTableDefinition &table, BakedReactionTable &baked)
std::expected< NameIndex, std::string > BakeAllSpecies (const ReactionTableDefinition &definition, const NameIndex &elements, BakedReactionTable &baked)
std::expected< TermsResult, std::string > CopyTerms (const RuleDefinition &rule, std::span< const RuleTerm > terms, const NameIndex &species, std::span< uint32_t > ids, std::span< uint32_t > coefficients)
std::expected< void, std::string > CheckElementBalance (const RuleDefinition &definition, const RxRule &rule, const BakedReactionTable &baked)
int64_t ReactionEnthalpy (const RxRule &rule, const BakedReactionTable &baked)
std::expected< RxRule, std::string > BakeRule (const RuleDefinition &definition, const NameIndex &species, const BakedReactionTable &baked)
std::optional< std::string > CheckDeclaredEnthalpy (const RuleDefinition &rule, const ReactionTableDefinition &definition, const NameIndex &species)
std::expected< uint64_t, std::string > BakeRate (const RuleDefinition &definition, int64_t lnConstantPart, uint32_t kelvin)
std::expected< void, std::string > BakeRates (const RuleDefinition &definition, const RxRule &rule, BakedReactionTable &baked)
void BuildRuleIndex (BakedReactionTable &baked)
template<typename Cell>
Cell FillReactionCell (const BakedReactionTable &table, Cell cell, std::span< const SpeciesAmount > amounts, int32_t temperatureMilliKelvin)
template<typename Cell>
std::vector< uint64_t > CountCellElements (const BakedReactionTable &table, const Cell &cell)
template<typename Cell>
uint64_t HashCell (const Cell &cell)

Variables

constexpr uint64_t GAS_CONSTANT_NANOJOULES = 8314462618
constexpr uint64_t NANOJOULES_PER_JOULE = 1000000000
constexpr uint64_t MICROJOULES_PER_JOULE = 1000000
constexpr int64_t STANDARD_TEMPERATURE_MILLIKELVIN = 298150
constexpr int32_t RATE_EXPONENT_MIN = -4096
constexpr int32_t RATE_EXPONENT_MAX = 4096
constexpr int64_t CELL_VOLUME_LOG2 = -3
constexpr uint64_t FNV_OFFSET = 0xcbf29ce484222325ULL
constexpr uint64_t FNV_PRIME = 0x100000001b3ULL
constexpr int64_t DECLARED_ENTHALPY_TOLERANCE_JOULES = 1000

Typedef Documentation

◆ NameIndex

using bicameral::sim::anonymous_namespace{reaction_table.cpp}::NameIndex = std::map<std::string, uint32_t, std::less<>>

Definition at line 36 of file reaction_table.cpp.

Function Documentation

◆ BakeAllSpecies()

std::expected< NameIndex, std::string > bicameral::sim::anonymous_namespace{reaction_table.cpp}::BakeAllSpecies ( const ReactionTableDefinition & definition,
const NameIndex & elements,
BakedReactionTable & baked )

Definition at line 122 of file reaction_table.cpp.

References BakeAllSpecies(), BakeSpecies(), bicameral::sim::BakedReactionTable::molarMasses, bicameral::sim::SpeciesDefinition::name, bicameral::sim::BakedReactionTable::species, bicameral::sim::ReactionTableDefinition::species, bicameral::sim::BakedReactionTable::speciesElements, and bicameral::sim::BakedReactionTable::speciesNames.

Referenced by BakeAllSpecies().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BakeRate()

std::expected< uint64_t, std::string > bicameral::sim::anonymous_namespace{reaction_table.cpp}::BakeRate ( const RuleDefinition & definition,
int64_t lnConstantPart,
uint32_t kelvin )

Definition at line 282 of file reaction_table.cpp.

References bicameral::sim::ArrheniusRate::activationEnergy, BakeRate(), GAS_CONSTANT_NANOJOULES, bicameral::sim::RuleDefinition::name, NANOJOULES_PER_JOULE, bicameral::sim::RuleDefinition::rate, RATE_EXPONENT_MAX, and RATE_EXPONENT_MIN.

Referenced by BakeRate(), and BakeRates().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BakeRates()

std::expected< void, std::string > bicameral::sim::anonymous_namespace{reaction_table.cpp}::BakeRates ( const RuleDefinition & definition,
const RxRule & rule,
BakedReactionTable & baked )

Definition at line 309 of file reaction_table.cpp.

References bicameral::sim::ArrheniusRate::activationEnergy, BakeRate(), BakeRates(), CELL_VOLUME_LOG2, bicameral::sim::RuleDefinition::name, bicameral::sim::ArrheniusRate::preExponentialExponent10, bicameral::sim::ArrheniusRate::preExponentialMantissa, bicameral::sim::RuleDefinition::rate, and bicameral::sim::BakedReactionTable::rates.

Referenced by BakeRates().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BakeRule()

std::expected< RxRule, std::string > bicameral::sim::anonymous_namespace{reaction_table.cpp}::BakeRule ( const RuleDefinition & definition,
const NameIndex & species,
const BakedReactionTable & baked )

Definition at line 217 of file reaction_table.cpp.

References BakeRule(), CheckElementBalance(), CopyTerms(), HashName(), bicameral::sim::RuleDefinition::name, bicameral::sim::RuleDefinition::products, bicameral::sim::RuleDefinition::reactants, and ReactionEnthalpy().

Referenced by BakeRule().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BakeSpecies()

std::expected< void, std::string > bicameral::sim::anonymous_namespace{reaction_table.cpp}::BakeSpecies ( const SpeciesDefinition & definition,
const NameIndex & elements,
const ReactionTableDefinition & table,
BakedReactionTable & baked )

◆ BuildRuleIndex()

void bicameral::sim::anonymous_namespace{reaction_table.cpp}::BuildRuleIndex ( BakedReactionTable & baked)

Definition at line 345 of file reaction_table.cpp.

References BuildRuleIndex(), bicameral::sim::BakedReactionTable::ruleIndex, bicameral::sim::BakedReactionTable::rules, and bicameral::sim::BakedReactionTable::species.

Referenced by BuildRuleIndex().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CanonicalOrder()

ReactionTableDefinition bicameral::sim::anonymous_namespace{reaction_table.cpp}::CanonicalOrder ( const ReactionTableDefinition & definition)

Definition at line 52 of file reaction_table.cpp.

References CanonicalOrder(), bicameral::sim::ReactionTableDefinition::elements, bicameral::sim::RuleDefinition::products, bicameral::sim::RuleDefinition::reactants, bicameral::sim::ReactionTableDefinition::rules, bicameral::sim::ReactionTableDefinition::species, and bicameral::sim::RuleTerm::species.

Referenced by CanonicalOrder().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckDeclaredEnthalpy()

std::optional< std::string > bicameral::sim::anonymous_namespace{reaction_table.cpp}::CheckDeclaredEnthalpy ( const RuleDefinition & rule,
const ReactionTableDefinition & definition,
const NameIndex & species )

Definition at line 248 of file reaction_table.cpp.

References CheckDeclaredEnthalpy(), DECLARED_ENTHALPY_TOLERANCE_JOULES, bicameral::sim::RuleDefinition::declaredReactionEnthalpy, bicameral::sim::SpeciesDefinition::formationEnthalpy, bicameral::sim::RuleDefinition::name, bicameral::sim::RuleDefinition::products, bicameral::sim::RuleDefinition::reactants, and bicameral::sim::ReactionTableDefinition::species.

Referenced by CheckDeclaredEnthalpy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckElementBalance()

std::expected< void, std::string > bicameral::sim::anonymous_namespace{reaction_table.cpp}::CheckElementBalance ( const RuleDefinition & definition,
const RxRule & rule,
const BakedReactionTable & baked )

Definition at line 181 of file reaction_table.cpp.

References CheckElementBalance(), bicameral::sim::BakedReactionTable::elementNames, bicameral::sim::RuleDefinition::name, and bicameral::sim::BakedReactionTable::speciesElements.

Referenced by BakeRule(), and CheckElementBalance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CopyTerms()

std::expected< TermsResult, std::string > bicameral::sim::anonymous_namespace{reaction_table.cpp}::CopyTerms ( const RuleDefinition & rule,
std::span< const RuleTerm > terms,
const NameIndex & species,
std::span< uint32_t > ids,
std::span< uint32_t > coefficients )

Definition at line 151 of file reaction_table.cpp.

References CopyTerms(), bicameral::sim::anonymous_namespace{reaction_table.cpp}::TermsResult::count, bicameral::sim::anonymous_namespace{reaction_table.cpp}::TermsResult::firstOrderMask, and bicameral::sim::RuleDefinition::name.

Referenced by BakeRule(), and CopyTerms().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CountCellElements()

template<typename Cell>
std::vector< uint64_t > bicameral::sim::anonymous_namespace{reaction_table.cpp}::CountCellElements ( const BakedReactionTable & table,
const Cell & cell )

Definition at line 434 of file reaction_table.cpp.

References CountCellElements(), bicameral::sim::BakedReactionTable::elementNames, and bicameral::sim::BakedReactionTable::speciesElements.

Referenced by CountCellElements().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FillReactionCell()

template<typename Cell>
Cell bicameral::sim::anonymous_namespace{reaction_table.cpp}::FillReactionCell ( const BakedReactionTable & table,
Cell cell,
std::span< const SpeciesAmount > amounts,
int32_t temperatureMilliKelvin )

Definition at line 414 of file reaction_table.cpp.

References FillReactionCell(), and bicameral::sim::BakedReactionTable::View().

Referenced by FillReactionCell().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HashCell()

template<typename Cell>
uint64_t bicameral::sim::anonymous_namespace{reaction_table.cpp}::HashCell ( const Cell & cell)

Definition at line 448 of file reaction_table.cpp.

References HashCell().

Referenced by HashCell().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HashName()

uint64_t bicameral::sim::anonymous_namespace{reaction_table.cpp}::HashName ( std::string_view name)

Definition at line 38 of file reaction_table.cpp.

References FNV_OFFSET, FNV_PRIME, and HashName().

Referenced by BakeRule(), and HashName().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IndexElements()

std::expected< NameIndex, std::string > bicameral::sim::anonymous_namespace{reaction_table.cpp}::IndexElements ( const ReactionTableDefinition & definition,
BakedReactionTable & baked )

Definition at line 71 of file reaction_table.cpp.

References bicameral::sim::BakedReactionTable::elementNames, bicameral::sim::ReactionTableDefinition::elements, IndexElements(), and bicameral::sim::ElementDefinition::name.

Referenced by IndexElements().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReactionEnthalpy()

int64_t bicameral::sim::anonymous_namespace{reaction_table.cpp}::ReactionEnthalpy ( const RxRule & rule,
const BakedReactionTable & baked )

Definition at line 206 of file reaction_table.cpp.

References ReactionEnthalpy(), and bicameral::sim::BakedReactionTable::species.

Referenced by BakeRule(), and ReactionEnthalpy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ZeroKelvinEnthalpy()

int64_t bicameral::sim::anonymous_namespace{reaction_table.cpp}::ZeroKelvinEnthalpy ( const SpeciesDefinition & species)

Definition at line 85 of file reaction_table.cpp.

References bicameral::sim::SpeciesDefinition::formationEnthalpy, bicameral::sim::SpeciesDefinition::heatCapacity, MICROJOULES_PER_JOULE, STANDARD_TEMPERATURE_MILLIKELVIN, and ZeroKelvinEnthalpy().

Referenced by BakeSpecies(), and ZeroKelvinEnthalpy().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ CELL_VOLUME_LOG2

int64_t bicameral::sim::anonymous_namespace{reaction_table.cpp}::CELL_VOLUME_LOG2 = -3
constexpr

Definition at line 30 of file reaction_table.cpp.

Referenced by BakeRates().

◆ DECLARED_ENTHALPY_TOLERANCE_JOULES

int64_t bicameral::sim::anonymous_namespace{reaction_table.cpp}::DECLARED_ENTHALPY_TOLERANCE_JOULES = 1000
constexpr

Definition at line 34 of file reaction_table.cpp.

Referenced by CheckDeclaredEnthalpy().

◆ FNV_OFFSET

uint64_t bicameral::sim::anonymous_namespace{reaction_table.cpp}::FNV_OFFSET = 0xcbf29ce484222325ULL
constexpr

Definition at line 31 of file reaction_table.cpp.

Referenced by HashName().

◆ FNV_PRIME

uint64_t bicameral::sim::anonymous_namespace{reaction_table.cpp}::FNV_PRIME = 0x100000001b3ULL
constexpr

Definition at line 32 of file reaction_table.cpp.

Referenced by HashName().

◆ GAS_CONSTANT_NANOJOULES

uint64_t bicameral::sim::anonymous_namespace{reaction_table.cpp}::GAS_CONSTANT_NANOJOULES = 8314462618
constexpr

Definition at line 21 of file reaction_table.cpp.

Referenced by BakeRate().

◆ MICROJOULES_PER_JOULE

uint64_t bicameral::sim::anonymous_namespace{reaction_table.cpp}::MICROJOULES_PER_JOULE = 1000000
constexpr

Definition at line 23 of file reaction_table.cpp.

Referenced by ZeroKelvinEnthalpy().

◆ NANOJOULES_PER_JOULE

uint64_t bicameral::sim::anonymous_namespace{reaction_table.cpp}::NANOJOULES_PER_JOULE = 1000000000
constexpr

Definition at line 22 of file reaction_table.cpp.

Referenced by BakeRate().

◆ RATE_EXPONENT_MAX

int32_t bicameral::sim::anonymous_namespace{reaction_table.cpp}::RATE_EXPONENT_MAX = 4096
constexpr

Definition at line 28 of file reaction_table.cpp.

Referenced by BakeRate().

◆ RATE_EXPONENT_MIN

int32_t bicameral::sim::anonymous_namespace{reaction_table.cpp}::RATE_EXPONENT_MIN = -4096
constexpr

Definition at line 27 of file reaction_table.cpp.

Referenced by BakeRate().

◆ STANDARD_TEMPERATURE_MILLIKELVIN

int64_t bicameral::sim::anonymous_namespace{reaction_table.cpp}::STANDARD_TEMPERATURE_MILLIKELVIN = 298150
constexpr

Definition at line 25 of file reaction_table.cpp.

Referenced by ZeroKelvinEnthalpy().