Finite Volume Solver  prototype
A framework to build finite volume solvers for the AG Klein at the Freie Universität Berlin.
Public Member Functions | Private Attributes | List of all members
fub::FlameMasterReactor Class Reference

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)
 
FlameMasterReactoroperator= (const FlameMasterReactor &other)
 
 FlameMasterReactor (FlameMasterReactor &&other) noexcept
 
FlameMasterReactoroperator= (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 FlameMasterMechanismgetMechanism () 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 ArrayXdGetMassFractionsArray () const
 
const ArrayXdGetMoleFractionsArray ()
 
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 ArrayXdGetReactionRatesArray () const
 
span< const double > GetProductionRates ()
 
const ArrayXdGetProductionRatesArray () 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 ArrayXdGetCpsArray () 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 FlameMasterMechanismmechanism_
 
FlameMasterState state_
 
FlameMasterArrayState array_state_
 
std::unique_ptr< OdeSolver > ode_solver_
 

Detailed Description

A class mimicking the IdealGasMix / Reactor / ReactorNet interface of Cantera, but with FlameMaster chemistry.

Constructor & Destructor Documentation

◆ FlameMasterReactor() [1/3]

fub::FlameMasterReactor::FlameMasterReactor ( const FlameMasterMechanism mechanism)

◆ ~FlameMasterReactor()

fub::FlameMasterReactor::~FlameMasterReactor ( )
default

◆ FlameMasterReactor() [2/3]

fub::FlameMasterReactor::FlameMasterReactor ( const FlameMasterReactor other)

◆ FlameMasterReactor() [3/3]

fub::FlameMasterReactor::FlameMasterReactor ( FlameMasterReactor &&  other)
noexcept

Member Function Documentation

◆ Advance() [1/2]

void fub::FlameMasterReactor::Advance ( double  dt)

Advance the reactor in time by dt.

Parameters
[in]dtThe time step size.
Exceptions
FlameMasterReactorExceptionThis exception may be thrown if the ode solver could not converge to a solution.

◆ Advance() [2/2]

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.

◆ AdvanceAndFindMaxdT()

double fub::FlameMasterReactor::AdvanceAndFindMaxdT ( double  dt)

Advance the reactor in time by dt and return the time where \(dT/dt\) peaked.

◆ GetCp()

double fub::FlameMasterReactor::GetCp ( ) const

Return the specific heat capacity cp.

◆ GetCpArray()

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.

◆ GetCps()

span<const double> fub::FlameMasterReactor::GetCps ( ) const

Return the specific heat capacities cp for all species.

◆ GetCpsArray()

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.

◆ GetCv()

double fub::FlameMasterReactor::GetCv ( ) const

Return the specific heat capacity cv.

◆ GetCvArray()

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.

◆ GetDensity()

double fub::FlameMasterReactor::GetDensity ( ) const
inline

Returns the density of the current mixture.

The units are \(kg/m^3\)

◆ GetDensityArray()

Array1d fub::FlameMasterReactor::GetDensityArray ( ) const
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.

◆ GetEnthalpies()

span<const double> fub::FlameMasterReactor::GetEnthalpies ( )

get the species' enthalpies

◆ GetEnthalpy()

double fub::FlameMasterReactor::GetEnthalpy ( ) const

Return the mix'es specific enthalpy.

The unit is \(J/kg\)

◆ GetEnthalpyArray()

Array1d fub::FlameMasterReactor::GetEnthalpyArray ( ) const

◆ GetEntropy()

double fub::FlameMasterReactor::GetEntropy ( ) const

Return the specific entropy.

◆ GetInternalEnergy()

double fub::FlameMasterReactor::GetInternalEnergy ( ) const

Return the mix'es specific internal energy.

The unit is \(J/kg\)

◆ GetInternalEnergyArray()

Array1d fub::FlameMasterReactor::GetInternalEnergyArray ( ) const

◆ GetMassFractions()

span<const double> fub::FlameMasterReactor::GetMassFractions ( ) const
inline

Return the mass fractions of the species as a double* array.

◆ GetMassFractionsArray()

const ArrayXd& fub::FlameMasterReactor::GetMassFractionsArray ( ) const
inline

◆ GetMeanMolarMass()

double fub::FlameMasterReactor::GetMeanMolarMass ( ) const

get the overall molar mass

Units are \(kg/kmol\)

◆ GetMeanMolarMassArray()

Array1d fub::FlameMasterReactor::GetMeanMolarMassArray ( ) const

◆ getMechanism()

const FlameMasterMechanism& fub::FlameMasterReactor::getMechanism ( ) const
inline

Set tolerances for the integration.

Defaults are 1e-9 for reltol and 1e-15 for abstol.

◆ GetMolarMasses()

span<const double> fub::FlameMasterReactor::GetMolarMasses ( ) const
inline

get the molar masses for all species

◆ GetMoleFractions()

span<const double> fub::FlameMasterReactor::GetMoleFractions ( )

◆ GetMoleFractionsArray()

const ArrayXd& fub::FlameMasterReactor::GetMoleFractionsArray ( )

◆ GetNReactions()

int fub::FlameMasterReactor::GetNReactions ( ) const
inline

Return the name of the ith species.

◆ GetNSpecies()

int fub::FlameMasterReactor::GetNSpecies ( ) const
inline

Return the number of species in the mechanism.

◆ GetOdeSolver()

const OdeSolver& fub::FlameMasterReactor::GetOdeSolver ( ) const
inlinenoexcept

◆ GetPressure()

double fub::FlameMasterReactor::GetPressure ( ) const
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.

◆ GetPressureArray()

Array1d fub::FlameMasterReactor::GetPressureArray ( ) const
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.

◆ GetProductionRates()

span<const double> fub::FlameMasterReactor::GetProductionRates ( )

◆ GetProductionRatesArray()

const ArrayXd& fub::FlameMasterReactor::GetProductionRatesArray ( ) const

◆ GetReactionRates()

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

◆ GetReactionRatesArray()

const ArrayXd& fub::FlameMasterReactor::GetReactionRatesArray ( ) const

◆ GetSpeciesMolarMass()

double fub::FlameMasterReactor::GetSpeciesMolarMass ( size_t  i) const
inline

get the molar mass of a single species

Units are \(kg/kmol\)

◆ GetSpeciesName()

const std::string& fub::FlameMasterReactor::GetSpeciesName ( int  i) const
inline

Return the name of the ith species.

◆ GetSpeciesNames()

span<const std::string> fub::FlameMasterReactor::GetSpeciesNames ( ) const
inline

Return the name of the ith species.

◆ GetTemperature()

double fub::FlameMasterReactor::GetTemperature ( ) const
inlinenoexcept

Returns the temperature of the current mixture.

In Kelvin

◆ GetTemperatureArray()

Array1d fub::FlameMasterReactor::GetTemperatureArray ( ) const
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.

◆ GetUniversalGasConstant()

double fub::FlameMasterReactor::GetUniversalGasConstant ( ) const
inline

Retrieve the universal gas constant.

Note that some mechanisms can override this, to use normalized quantities!

◆ MeanX() [1/2]

Array1d fub::FlameMasterReactor::MeanX ( const ArrayXd quantity) const

Return the name of the ith species.

◆ MeanX() [2/2]

double fub::FlameMasterReactor::MeanX ( span< const double >  quantity) const

Average a quantity over the mole fractions.

◆ MeanY() [1/2]

Array1d fub::FlameMasterReactor::MeanY ( const ArrayXd quantity) const

Return the name of the ith species.

◆ MeanY() [2/2]

double fub::FlameMasterReactor::MeanY ( span< const double >  quantity) const

Average a quantity over the mass fractions.

◆ operator=() [1/2]

FlameMasterReactor& fub::FlameMasterReactor::operator= ( const FlameMasterReactor other)

◆ operator=() [2/2]

FlameMasterReactor& fub::FlameMasterReactor::operator= ( FlameMasterReactor &&  other)
noexcept

◆ SetDensity()

void fub::FlameMasterReactor::SetDensity ( double  density)
inline

Sets the density of the current mixture.

The units are \(kg/m^3\)

◆ SetDensityArray()

void fub::FlameMasterReactor::SetDensityArray ( Array1d  density)
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.

◆ SetEnthalpy()

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.

◆ SetInternalEnergy()

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.

◆ SetInternalEnergyArray() [1/2]

void fub::FlameMasterReactor::SetInternalEnergyArray ( Array1d  energy,
double  dTtol = 1E-6 
)

◆ SetInternalEnergyArray() [2/2]

void fub::FlameMasterReactor::SetInternalEnergyArray ( Array1d  energy,
MaskArray  mask,
double  dTtol = 1E-6 
)

◆ SetMassFractions() [1/2]

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, ..

◆ SetMassFractions() [2/2]

void fub::FlameMasterReactor::SetMassFractions ( std::string  massFractions)

Return the name of the ith species.

◆ SetMassFractionsArray() [1/2]

void fub::FlameMasterReactor::SetMassFractionsArray ( const ArrayXd newMassFractions)

Return the name of the ith species.

◆ SetMassFractionsArray() [2/2]

void fub::FlameMasterReactor::SetMassFractionsArray ( const ArrayXd newMassFractions,
MaskArray  mask 
)

Return the name of the ith species.

◆ SetMoleFractions() [1/2]

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, ..

◆ SetMoleFractions() [2/2]

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, ..

◆ SetMoleFractionsArray()

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, ..

◆ SetOdeSolver()

void fub::FlameMasterReactor::SetOdeSolver ( std::unique_ptr< OdeSolver >  solver)
inline

◆ SetPressure()

void fub::FlameMasterReactor::SetPressure ( double  pressure)
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.

◆ SetPressureArray()

void fub::FlameMasterReactor::SetPressureArray ( Array1d  pressure)
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.

◆ SetPressureIsentropic()

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.

◆ SetTemperature()

void fub::FlameMasterReactor::SetTemperature ( double  temperature)

Set the temperature of the current mixture.

In Kelvin

◆ SetTemperatureArray()

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.

◆ Step()

double fub::FlameMasterReactor::Step ( )

Advance the reactor by one internal time step and return the time step size.

Member Data Documentation

◆ array_state_

FlameMasterArrayState fub::FlameMasterReactor::array_state_
private

◆ mechanism_

const FlameMasterMechanism* fub::FlameMasterReactor::mechanism_
private

◆ ode_solver_

std::unique_ptr<OdeSolver> fub::FlameMasterReactor::ode_solver_
private

◆ state_

FlameMasterState fub::FlameMasterReactor::state_
private

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