22 #ifndef FUB_FLAME_MASTER_REACTOR_HPP
23 #define FUB_FLAME_MASTER_REACTOR_HPP
28 #include "fub/ode_solver/OdeSolver.hpp"
43 : std::runtime_error(message) {}
46 : std::runtime_error(std::move(message)) {}
55 virtual std::unique_ptr<FlameMasterMechanism>
Clone()
const = 0;
60 double pressure)
const = 0;
248 const Array1d temperature_s = (temperature > 0.0).select(temperature, 1.0);
460 double dTtol = 1E-6);
#define FUB_ASSERT(x)
Definition: assert.hpp:39
This class encapsulates all exceptions which can occur in the FlameMasterReactor class.
Definition: FlameMasterReactor.hpp:40
FlameMasterReactorException(const char *message)
Definition: FlameMasterReactor.hpp:42
FlameMasterReactorException(std::string message)
Definition: FlameMasterReactor.hpp:45
A class mimicking the IdealGasMix / Reactor / ReactorNet interface of Cantera, but with FlameMaster c...
Definition: FlameMasterReactor.hpp:159
void SetPressureArray(Array1d pressure)
Returns the pressure of the mixture.
Definition: FlameMasterReactor.hpp:245
const OdeSolver & GetOdeSolver() const noexcept
Definition: FlameMasterReactor.hpp:208
void SetInternalEnergyArray(Array1d energy, double dTtol=1E-6)
std::unique_ptr< OdeSolver > ode_solver_
Definition: FlameMasterReactor.hpp:481
const ArrayXd & GetMoleFractionsArray()
span< const double > GetMolarMasses() const
get the molar masses for all species
Definition: FlameMasterReactor.hpp:409
int GetNReactions() const
Return the name of the ith species.
Definition: FlameMasterReactor.hpp:347
Array1d GetCvArray() const
Returns the pressure of the mixture.
Array1d GetTemperatureArray() const noexcept
Returns the pressure of the mixture.
Definition: FlameMasterReactor.hpp:291
const ArrayXd & GetProductionRatesArray() const
double MeanY(span< const double > quantity) const
Average a quantity over the mass fractions.
FlameMasterArrayState array_state_
Definition: FlameMasterReactor.hpp:480
void SetTemperatureArray(Array1d temperature)
Returns the pressure of the mixture.
void SetMassFractionsArray(const ArrayXd &newMassFractions)
Return the name of the ith species.
Array1d GetDensityArray() const
Returns the pressure of the mixture.
Definition: FlameMasterReactor.hpp:273
void SetDensityArray(Array1d density)
Returns the pressure of the mixture.
Definition: FlameMasterReactor.hpp:281
double GetDensity() const
Returns the density of the current mixture.
Definition: FlameMasterReactor.hpp:272
Array1d MeanX(const ArrayXd &quantity) const
Return the name of the ith species.
Array1d GetPressureArray() const
Returns the pressure of the mixture.
Definition: FlameMasterReactor.hpp:227
void SetInternalEnergyArray(Array1d energy, MaskArray mask, double dTtol=1E-6)
void SetMoleFractions(std::string newMoleFractions)
Set the dimensionless mole fractions of the mixture.
void SetDensity(double density)
Sets the density of the current mixture.
Definition: FlameMasterReactor.hpp:280
void SetMassFractionsArray(const ArrayXd &newMassFractions, MaskArray mask)
Return the name of the ith species.
void Advance(double dt)
Advance the reactor in time by dt.
double GetEnthalpy() const
Return the mix'es specific enthalpy.
const FlameMasterMechanism * mechanism_
Definition: FlameMasterReactor.hpp:478
const FlameMasterMechanism & getMechanism() const
Set tolerances for the integration.
Definition: FlameMasterReactor.hpp:197
void SetMassFractions(std::string massFractions)
Return the name of the ith species.
double Step()
Advance the reactor by one internal time step and return the time step size.
span< const double > GetMoleFractions()
FlameMasterReactor & operator=(FlameMasterReactor &&other) noexcept
span< const double > GetMassFractions() const
Return the mass fractions of the species as a double* array.
Definition: FlameMasterReactor.hpp:392
FlameMasterReactor & operator=(const FlameMasterReactor &other)
span< const double > GetEnthalpies()
get the species' enthalpies
FlameMasterReactor(const FlameMasterReactor &other)
double GetTemperature() const noexcept
Returns the temperature of the current mixture.
Definition: FlameMasterReactor.hpp:288
double GetEntropy() const
Return the specific entropy.
const ArrayXd & GetReactionRatesArray() const
void Advance(double dt, function_ref< void(fub::span< const double >, double, FlameMasterReactor *)> feedbackFun)
Advance the reactor in time by dt and call a function for each internal timestep.
span< const std::string > GetSpeciesNames() const
Return the name of the ith species.
Definition: FlameMasterReactor.hpp:338
Array1d MeanY(const ArrayXd &quantity) const
Return the name of the ith species.
double GetPressure() const
Returns the pressure of the mixture.
Definition: FlameMasterReactor.hpp:222
double GetCp() const
Return the specific heat capacity cp.
double GetSpeciesMolarMass(size_t i) const
get the molar mass of a single species
Definition: FlameMasterReactor.hpp:404
void SetInternalEnergy(double energy, double dTtol=1E-6)
Set the mix'es specific internal energy.
void SetPressure(double pressure)
Set the pressure of the mixture.
Definition: FlameMasterReactor.hpp:240
const ArrayXd & GetCpsArray() const
Returns the pressure of the mixture.
void SetMoleFractions(span< const double > newMoleFractions)
Set the dimensionless mole fractions of the mixture.
FlameMasterState state_
Definition: FlameMasterReactor.hpp:479
void SetTemperature(double temperature)
Set the temperature of the current mixture.
void SetOdeSolver(std::unique_ptr< OdeSolver > solver)
Definition: FlameMasterReactor.hpp:202
void SetMassFractions(span< const double > newMassFractions)
Set the dimensionless mass fractions of the mixture.
double GetInternalEnergy() const
Return the mix'es specific internal energy.
void SetEnthalpy(double enthalpy, double dTtol)
Set the mix'es specific enthalpy.
span< const double > GetCps() const
Return the specific heat capacities cp for all species.
Array1d GetMeanMolarMassArray() const
const ArrayXd & GetMassFractionsArray() const
Definition: FlameMasterReactor.hpp:394
FlameMasterReactor(FlameMasterReactor &&other) noexcept
double AdvanceAndFindMaxdT(double dt)
Advance the reactor in time by dt and return the time where peaked.
double MeanX(span< const double > quantity) const
Average a quantity over the mole fractions.
const std::string & GetSpeciesName(int i) const
Return the name of the ith species.
Definition: FlameMasterReactor.hpp:334
~FlameMasterReactor()=default
double SetPressureIsentropic(double pressure)
Adjust the pressure of the mixture isentropically.
void SetMoleFractionsArray(const ArrayXd &newMoleFractions)
Set the dimensionless mole fractions of the mixture.
double GetUniversalGasConstant() const
Retrieve the universal gas constant.
Definition: FlameMasterReactor.hpp:475
double GetCv() const
Return the specific heat capacity cv.
Array1d GetEnthalpyArray() const
double GetMeanMolarMass() const
get the overall molar mass
Array1d GetInternalEnergyArray() const
int GetNSpecies() const
Return the number of species in the mechanism.
Definition: FlameMasterReactor.hpp:345
span< const double > GetProductionRates()
span< const double > GetReactionRates() const
get the current reaction rates d/dt m, where m denotes the actual mole counts: Y = m * molarMasses / ...
Array1d GetCpArray() const
Returns the pressure of the mixture.
FlameMasterReactor(const FlameMasterMechanism &mechanism)
An efficient, type-erasing, non-owning reference to a callable.
Definition: function_ref.hpp:37
The fub namespace.
Definition: AnyBoundaryCondition.hpp:31
Array< double, Eigen::Dynamic > ArrayXd
Definition: Eigen.hpp:57
Array< double, 1 > Array1d
Definition: Eigen.hpp:53
Array< bool, 1 > MaskArray
Definition: Eigen.hpp:59
Definition: FlameMasterReactor.hpp:134
ArrayXd moles
Definition: FlameMasterReactor.hpp:136
ArrayXd entropies
Definition: FlameMasterReactor.hpp:153
ArrayXd heat_capacities_at_constant_pressure
Definition: FlameMasterReactor.hpp:152
Array1d density
Definition: FlameMasterReactor.hpp:144
Array1d thermoTemp
Temperature at which the thermodynamic state was last evaluated.
Definition: FlameMasterReactor.hpp:143
ArrayXd production_rates
Computational space for the reaction mechanism.
Definition: FlameMasterReactor.hpp:147
Array1d temperature
We make this a pointer because we want to make sure it is stored at the beginning of moles (for CVode...
Definition: FlameMasterReactor.hpp:141
ArrayXd reaction_rates
Definition: FlameMasterReactor.hpp:148
ArrayXd rate_coefficients
Definition: FlameMasterReactor.hpp:149
ArrayXd molesStorage
Definition: FlameMasterReactor.hpp:137
ArrayXd massFractions
Definition: FlameMasterReactor.hpp:135
ArrayXd enthalpies
Definition: FlameMasterReactor.hpp:151
ArrayXd third_body_concentrations
Definition: FlameMasterReactor.hpp:150
This abstract base class encapsulates the underlying chemistry for the FlameMasterReactor.
Definition: FlameMasterReactor.hpp:52
virtual void getMolarMass(span< double >) const =0
virtual double getUniversalGasConstant() const
Definition: FlameMasterReactor.hpp:77
virtual void ComputeProductionRates(span< double > cdot, span< double > w, span< double > k, span< double > c, span< double > M, double temp, double pressure) const =0
virtual int getNThirdBodyReactions() const =0
virtual std::unique_ptr< FlameMasterMechanism > Clone() const =0
virtual void ComputeThermoData(span< double > h, span< double > cp, double t, span< double > s) const =0
virtual int getNSpecies() const =0
virtual int getNReactions() const =0
virtual std::vector< std::string > getSpeciesNames() const =0
virtual int getNSpecs() const
Definition: FlameMasterReactor.hpp:79
virtual ~FlameMasterMechanism()=default
virtual void ComputeThermoData(ArrayXd &h, ArrayXd &cp, Array1d t) const =0
Definition: FlameMasterReactor.hpp:82
double density
Definition: FlameMasterReactor.hpp:105
std::vector< double > enthalpies
Definition: FlameMasterReactor.hpp:112
double thermoTemp
Temperature at which the thermodynamic state was last evaluated.
Definition: FlameMasterReactor.hpp:131
std::vector< std::string > speciesNames
We store the names of the species here.
Definition: FlameMasterReactor.hpp:117
std::vector< double > third_body_concentrations
Definition: FlameMasterReactor.hpp:111
std::vector< double > massFractions
Definition: FlameMasterReactor.hpp:94
std::array< double, 2 > setPVector
A vector containing temperature for setPressureIsentropic()
Definition: FlameMasterReactor.hpp:128
int nSpeciesEffective
Effective number of species for mechanisms with steady state species.
Definition: FlameMasterReactor.hpp:86
std::vector< double > heat_capacities_at_constant_pressure
Definition: FlameMasterReactor.hpp:113
double reltol
Relative integration tolerance.
Definition: FlameMasterReactor.hpp:125
double abstol
Absolute integration tolerance.
Definition: FlameMasterReactor.hpp:123
span< double > moles
Derived from massFractions, stores the actual mole counts during time Advancement.
Definition: FlameMasterReactor.hpp:99
std::vector< double > production_rates
Computational space for the reaction mechanism.
Definition: FlameMasterReactor.hpp:108
std::vector< double > rate_coefficients
Definition: FlameMasterReactor.hpp:110
int nThirdBodyReactions
The number of third body reactions in the mechanism.
Definition: FlameMasterReactor.hpp:90
std::vector< double > molarMasses
We store the molar masses of the species here.
Definition: FlameMasterReactor.hpp:120
std::vector< double > reaction_rates
Definition: FlameMasterReactor.hpp:109
int nSpecies
The number of species in the mechanism.
Definition: FlameMasterReactor.hpp:84
double gasConstant
Universal Gas Constant for this mechanism.
Definition: FlameMasterReactor.hpp:92
double * temperature
We make this a pointer because we want to make sure it is stored at the beginning of moles (for CVode...
Definition: FlameMasterReactor.hpp:103
int nReactions
The number of reactions in the mechanism.
Definition: FlameMasterReactor.hpp:88
std::vector< double > entropies
Definition: FlameMasterReactor.hpp:114
std::vector< double > molesStorage
Definition: FlameMasterReactor.hpp:95