Finite Volume Solver
prototype
A framework to build finite volume solvers for the AG Klein at the Freie Universität Berlin.
|
A class mimicking the IdealGasMix / Reactor / ReactorNet interface of Cantera, but with FlameMaster chemistry. More...
#include <FlameMasterReactor.hpp>
Public Member Functions | |
FlameMasterReactor (const FlameMasterMechanism &mechanism) | |
~FlameMasterReactor ()=default | |
FlameMasterReactor (const FlameMasterReactor &other) | |
FlameMasterReactor & | operator= (const FlameMasterReactor &other) |
FlameMasterReactor (FlameMasterReactor &&other) noexcept | |
FlameMasterReactor & | operator= (FlameMasterReactor &&other) noexcept |
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. More... | |
void | Advance (double dt) |
Advance the reactor in time by dt. More... | |
double | Step () |
Advance the reactor by one internal time step and return the time step size. More... | |
double | AdvanceAndFindMaxdT (double dt) |
Advance the reactor in time by dt and return the time where \(dT/dt\) peaked. More... | |
const FlameMasterMechanism & | getMechanism () const |
Set tolerances for the integration. More... | |
void | SetOdeSolver (std::unique_ptr< OdeSolver > solver) |
const OdeSolver & | GetOdeSolver () const noexcept |
span< const double > | GetMassFractions () const |
Return the mass fractions of the species as a double* array. More... | |
span< const double > | GetMoleFractions () |
const ArrayXd & | GetMassFractionsArray () const |
const ArrayXd & | GetMoleFractionsArray () |
double | GetSpeciesMolarMass (size_t i) const |
get the molar mass of a single species More... | |
span< const double > | GetMolarMasses () const |
get the molar masses for all species More... | |
double | GetMeanMolarMass () const |
get the overall molar mass More... | |
Array1d | GetMeanMolarMassArray () const |
span< const double > | GetEnthalpies () |
get the species' enthalpies More... | |
double | GetEnthalpy () const |
Return the mix'es specific enthalpy. More... | |
Array1d | GetEnthalpyArray () const |
void | SetEnthalpy (double enthalpy, double dTtol) |
Set the mix'es specific enthalpy. More... | |
double | GetInternalEnergy () const |
Return the mix'es specific internal energy. More... | |
Array1d | GetInternalEnergyArray () const |
void | SetInternalEnergy (double energy, double dTtol=1E-6) |
Set the mix'es specific internal energy. More... | |
void | SetInternalEnergyArray (Array1d energy, double dTtol=1E-6) |
void | SetInternalEnergyArray (Array1d energy, MaskArray mask, double dTtol=1E-6) |
span< const double > | GetReactionRates () const |
get the current reaction rates d/dt m, where m denotes the actual mole counts: Y = m * molarMasses / density More... | |
const ArrayXd & | GetReactionRatesArray () const |
span< const double > | GetProductionRates () |
const ArrayXd & | GetProductionRatesArray () const |
double | GetUniversalGasConstant () const |
Retrieve the universal gas constant. More... | |
Thermodynamic properties | |
double | GetPressure () const |
Returns the pressure of the mixture. More... | |
Array1d | GetPressureArray () const |
Returns the pressure of the mixture. More... | |
void | SetPressure (double pressure) |
Set the pressure of the mixture. More... | |
void | SetPressureArray (Array1d pressure) |
Returns the pressure of the mixture. More... | |
double | SetPressureIsentropic (double pressure) |
Adjust the pressure of the mixture isentropically. More... | |
double | GetDensity () const |
Returns the density of the current mixture. More... | |
Array1d | GetDensityArray () const |
Returns the pressure of the mixture. More... | |
void | SetDensity (double density) |
Sets the density of the current mixture. More... | |
void | SetDensityArray (Array1d density) |
Returns the pressure of the mixture. More... | |
double | GetTemperature () const noexcept |
Returns the temperature of the current mixture. More... | |
Array1d | GetTemperatureArray () const noexcept |
Returns the pressure of the mixture. More... | |
void | SetTemperature (double temperature) |
Set the temperature of the current mixture. More... | |
void | SetTemperatureArray (Array1d temperature) |
Returns the pressure of the mixture. More... | |
double | GetCv () const |
Return the specific heat capacity cv. More... | |
Array1d | GetCvArray () const |
Returns the pressure of the mixture. More... | |
double | GetCp () const |
Return the specific heat capacity cp. More... | |
Array1d | GetCpArray () const |
Returns the pressure of the mixture. More... | |
span< const double > | GetCps () const |
Return the specific heat capacities cp for all species. More... | |
const ArrayXd & | GetCpsArray () const |
Returns the pressure of the mixture. More... | |
double | GetEntropy () const |
Return the specific entropy. More... | |
Mass-/Mole fractions | |
const std::string & | GetSpeciesName (int i) const |
Return the name of the ith species. More... | |
span< const std::string > | GetSpeciesNames () const |
Return the name of the ith species. More... | |
int | GetNSpecies () const |
Return the number of species in the mechanism. More... | |
int | GetNReactions () const |
Return the name of the ith species. More... | |
double | MeanX (span< const double > quantity) const |
Average a quantity over the mole fractions. More... | |
Array1d | MeanX (const ArrayXd &quantity) const |
Return the name of the ith species. More... | |
double | MeanY (span< const double > quantity) const |
Average a quantity over the mass fractions. More... | |
Array1d | MeanY (const ArrayXd &quantity) const |
Return the name of the ith species. More... | |
void | SetMassFractions (span< const double > newMassFractions) |
Set the dimensionless mass fractions of the mixture. More... | |
void | SetMassFractionsArray (const ArrayXd &newMassFractions) |
Return the name of the ith species. More... | |
void | SetMassFractionsArray (const ArrayXd &newMassFractions, MaskArray mask) |
Return the name of the ith species. More... | |
void | SetMassFractions (std::string massFractions) |
Return the name of the ith species. More... | |
void | SetMoleFractions (span< const double > newMoleFractions) |
Set the dimensionless mole fractions of the mixture. More... | |
void | SetMoleFractionsArray (const ArrayXd &newMoleFractions) |
Set the dimensionless mole fractions of the mixture. More... | |
void | SetMoleFractions (std::string newMoleFractions) |
Set the dimensionless mole fractions of the mixture. More... | |
Private Attributes | |
const FlameMasterMechanism * | mechanism_ |
FlameMasterState | state_ |
FlameMasterArrayState | array_state_ |
std::unique_ptr< OdeSolver > | ode_solver_ |
A class mimicking the IdealGasMix / Reactor / ReactorNet interface of Cantera, but with FlameMaster chemistry.
fub::FlameMasterReactor::FlameMasterReactor | ( | const FlameMasterMechanism & | mechanism | ) |
|
default |
fub::FlameMasterReactor::FlameMasterReactor | ( | const FlameMasterReactor & | other | ) |
|
noexcept |
void fub::FlameMasterReactor::Advance | ( | double | dt | ) |
Advance the reactor in time by dt.
[in] | dt | The time step size. |
FlameMasterReactorException | This exception may be thrown if the ode solver could not converge to a solution. |
void fub::FlameMasterReactor::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.
double fub::FlameMasterReactor::AdvanceAndFindMaxdT | ( | double | dt | ) |
Advance the reactor in time by dt and return the time where \(dT/dt\) peaked.
double fub::FlameMasterReactor::GetCp | ( | ) | const |
Return the specific heat capacity cp.
Array1d fub::FlameMasterReactor::GetCpArray | ( | ) | const |
Returns the pressure of the mixture.
This used the ideal gas law to derive the pressure from temperature, the mass fractions and density.
The unit for pressure is Pascal.
span<const double> fub::FlameMasterReactor::GetCps | ( | ) | const |
Return the specific heat capacities cp for all species.
const ArrayXd& fub::FlameMasterReactor::GetCpsArray | ( | ) | const |
Returns the pressure of the mixture.
This used the ideal gas law to derive the pressure from temperature, the mass fractions and density.
The unit for pressure is Pascal.
double fub::FlameMasterReactor::GetCv | ( | ) | const |
Return the specific heat capacity cv.
Array1d fub::FlameMasterReactor::GetCvArray | ( | ) | const |
Returns the pressure of the mixture.
This used the ideal gas law to derive the pressure from temperature, the mass fractions and density.
The unit for pressure is Pascal.
|
inline |
Returns the density of the current mixture.
The units are \(kg/m^3\)
|
inline |
Returns the pressure of the mixture.
This used the ideal gas law to derive the pressure from temperature, the mass fractions and density.
The unit for pressure is Pascal.
span<const double> fub::FlameMasterReactor::GetEnthalpies | ( | ) |
get the species' enthalpies
double fub::FlameMasterReactor::GetEnthalpy | ( | ) | const |
Return the mix'es specific enthalpy.
The unit is \(J/kg\)
Array1d fub::FlameMasterReactor::GetEnthalpyArray | ( | ) | const |
double fub::FlameMasterReactor::GetEntropy | ( | ) | const |
Return the specific entropy.
double fub::FlameMasterReactor::GetInternalEnergy | ( | ) | const |
Return the mix'es specific internal energy.
The unit is \(J/kg\)
Array1d fub::FlameMasterReactor::GetInternalEnergyArray | ( | ) | const |
|
inline |
Return the mass fractions of the species as a double* array.
|
inline |
double fub::FlameMasterReactor::GetMeanMolarMass | ( | ) | const |
get the overall molar mass
Units are \(kg/kmol\)
Array1d fub::FlameMasterReactor::GetMeanMolarMassArray | ( | ) | const |
|
inline |
Set tolerances for the integration.
Defaults are 1e-9 for reltol and 1e-15 for abstol.
|
inline |
get the molar masses for all species
span<const double> fub::FlameMasterReactor::GetMoleFractions | ( | ) |
const ArrayXd& fub::FlameMasterReactor::GetMoleFractionsArray | ( | ) |
|
inline |
Return the name of the ith species.
|
inline |
Return the number of species in the mechanism.
|
inlinenoexcept |
|
inline |
Returns the pressure of the mixture.
This used the ideal gas law to derive the pressure from temperature, the mass fractions and density.
The unit for pressure is Pascal.
|
inline |
Returns the pressure of the mixture.
This used the ideal gas law to derive the pressure from temperature, the mass fractions and density.
The unit for pressure is Pascal.
span<const double> fub::FlameMasterReactor::GetProductionRates | ( | ) |
const ArrayXd& fub::FlameMasterReactor::GetProductionRatesArray | ( | ) | const |
span<const double> fub::FlameMasterReactor::GetReactionRates | ( | ) | const |
get the current reaction rates d/dt m, where m denotes the actual mole counts: Y = m * molarMasses / density
const ArrayXd& fub::FlameMasterReactor::GetReactionRatesArray | ( | ) | const |
|
inline |
get the molar mass of a single species
Units are \(kg/kmol\)
|
inline |
Return the name of the ith species.
|
inline |
Return the name of the ith species.
|
inlinenoexcept |
Returns the temperature of the current mixture.
In Kelvin
|
inlinenoexcept |
Returns the pressure of the mixture.
This used the ideal gas law to derive the pressure from temperature, the mass fractions and density.
The unit for pressure is Pascal.
|
inline |
Retrieve the universal gas constant.
Note that some mechanisms can override this, to use normalized quantities!
Return the name of the ith species.
double fub::FlameMasterReactor::MeanX | ( | span< const double > | quantity | ) | const |
Average a quantity over the mole fractions.
Return the name of the ith species.
double fub::FlameMasterReactor::MeanY | ( | span< const double > | quantity | ) | const |
Average a quantity over the mass fractions.
FlameMasterReactor& fub::FlameMasterReactor::operator= | ( | const FlameMasterReactor & | other | ) |
|
noexcept |
|
inline |
Sets the density of the current mixture.
The units are \(kg/m^3\)
|
inline |
Returns the pressure of the mixture.
This used the ideal gas law to derive the pressure from temperature, the mass fractions and density.
The unit for pressure is Pascal.
void fub::FlameMasterReactor::SetEnthalpy | ( | double | enthalpy, |
double | dTtol | ||
) |
Set the mix'es specific enthalpy.
The unit is \(J/kg\). This function actually tries to match the mixtures temperature such that the enthalpy is correct. It does so by using the same Newton algorithm which is also used by Cantera.
void fub::FlameMasterReactor::SetInternalEnergy | ( | double | energy, |
double | dTtol = 1E-6 |
||
) |
Set the mix'es specific internal energy.
The unit is \(J/kg\). This function actually tries to match the mixtures temperature such that the energy is correct. It does so by using the same Newton algorithm which is also used by Cantera.
void fub::FlameMasterReactor::SetInternalEnergyArray | ( | Array1d | energy, |
double | dTtol = 1E-6 |
||
) |
void fub::FlameMasterReactor::SetInternalEnergyArray | ( | Array1d | energy, |
MaskArray | mask, | ||
double | dTtol = 1E-6 |
||
) |
void fub::FlameMasterReactor::SetMassFractions | ( | span< const double > | newMassFractions | ) |
Set the dimensionless mass fractions of the mixture.
You can either supply them as a double* array, or as a string of the form species: fraction, species: fraction, ..
void fub::FlameMasterReactor::SetMassFractions | ( | std::string | massFractions | ) |
Return the name of the ith species.
void fub::FlameMasterReactor::SetMassFractionsArray | ( | const ArrayXd & | newMassFractions | ) |
Return the name of the ith species.
void fub::FlameMasterReactor::SetMassFractionsArray | ( | const ArrayXd & | newMassFractions, |
MaskArray | mask | ||
) |
Return the name of the ith species.
void fub::FlameMasterReactor::SetMoleFractions | ( | span< const double > | newMoleFractions | ) |
Set the dimensionless mole fractions of the mixture.
You can either supply them as a double* array, or as a string of the form species: fraction, species: fraction, ..
void fub::FlameMasterReactor::SetMoleFractions | ( | std::string | newMoleFractions | ) |
Set the dimensionless mole fractions of the mixture.
You can either supply them as a double* array, or as a string of the form species: fraction, species: fraction, ..
void fub::FlameMasterReactor::SetMoleFractionsArray | ( | const ArrayXd & | newMoleFractions | ) |
Set the dimensionless mole fractions of the mixture.
You can either supply them as a double* array, or as a string of the form species: fraction, species: fraction, ..
|
inline |
|
inline |
Set the pressure of the mixture.
This actually sets the density based on the current temperature and mass fractions, using the ideal gas law
The unit for pressure is Pascal.
|
inline |
Returns the pressure of the mixture.
This used the ideal gas law to derive the pressure from temperature, the mass fractions and density.
The unit for pressure is Pascal.
double fub::FlameMasterReactor::SetPressureIsentropic | ( | double | pressure | ) |
Adjust the pressure of the mixture isentropically.
Flamemaster does not offer entropy data. However, we still have the relation dH = V dp + T dS, which reduces to dH = V dp in the isentropic case. This function integrates H to the desired p and ensures fixed entropy this way.
The function simultaneously integrates velocity using the relation du = - 1/(c \rho) dp = - sqrt(1/(\gamma p \rho)) dp. This relation is fulfiled across rarefaction waves, and the call allows to use the function to calculate the state behind such a wave.
void fub::FlameMasterReactor::SetTemperature | ( | double | temperature | ) |
Set the temperature of the current mixture.
In Kelvin
void fub::FlameMasterReactor::SetTemperatureArray | ( | Array1d | temperature | ) |
Returns the pressure of the mixture.
This used the ideal gas law to derive the pressure from temperature, the mass fractions and density.
The unit for pressure is Pascal.
double fub::FlameMasterReactor::Step | ( | ) |
Advance the reactor by one internal time step and return the time step size.
|
private |
|
private |
|
private |
|
private |