Cantera 2.6.0
Public Member Functions | Private Attributes | List of all members
StoichManagerN Class Reference

#include <StoichManager.h>

Public Member Functions

 StoichManagerN ()
 Constructor for the StoichManagerN class. More...
 
void resizeCoeffs (size_t nSpc, size_t nRxn)
 Resize the sparse coefficient matrix. More...
 
void add (size_t rxn, const std::vector< size_t > &k)
 Add a single reaction to the list of reactions that this stoichiometric manager object handles. More...
 
void add (size_t rxn, const std::vector< size_t > &k, const vector_fp &order)
 
void add (size_t rxn, const std::vector< size_t > &k, const vector_fp &order, const vector_fp &stoich)
 Add a single reaction to the list of reactions that this stoichiometric manager object handles. More...
 
void multiply (const doublereal *input, doublereal *output) const
 
void incrementSpecies (const doublereal *input, doublereal *output) const
 
void decrementSpecies (const doublereal *input, doublereal *output) const
 
void incrementReactions (const doublereal *input, doublereal *output) const
 
void decrementReactions (const doublereal *input, doublereal *output) const
 
const Eigen::SparseMatrix< double > & stoichCoeffs () const
 Return matrix containing stoichiometric coefficients. More...
 
Eigen::SparseMatrix< double > derivatives (const double *conc, const double *rates)
 Calculate derivatives with respect to species concentrations. More...
 
void scale (const double *in, double *out, double factor) const
 Scale input by reaction order and factor. More...
 

Private Attributes

bool m_ready
 Boolean flag indicating whether object is fully configured. More...
 
std::vector< C1m_c1_list
 
std::vector< C2m_c2_list
 
std::vector< C3m_c3_list
 
std::vector< C_AnyNm_cn_list
 
SparseTriplets m_coeffList
 Sparse matrices for stoichiometric coefficients. More...
 
Eigen::SparseMatrix< double > m_stoichCoeffs
 
std::vector< int > m_outerIndices
 Storage indicies used to build derivatives. More...
 
std::vector< int > m_innerIndices
 
vector_fp m_values
 

Detailed Description

This class handles operations involving the stoichiometric coefficients on one side of a reaction (reactant or product) for a set of reactions comprising a reaction mechanism. This class is used by class Kinetics, which contains three instances of this class (one to handle operations on the reactions, one for the products of reversible reactions, and one for the products of irreversible reactions).

This class is designed for use with elementary reactions, or at least ones with integral stoichiometric coefficients. Let \( M(i) \) be the number of molecules on the product or reactant side of reaction number i.

\[ r_i = \sum_m^{M_i} s_{k_{m,i}} \]

To understand the operations performed by this class, let \( N_{k,i}\) denote the stoichiometric coefficient of species k on one side (reactant or product) in reaction i. Then N is a sparse K by I matrix of stoichiometric coefficients.

The following matrix operations may be carried out with a vector S of length K, and a vector R of length I:

The actual implementation, however, does not compute these quantities by matrix multiplication. A faster algorithm is used that makes use of the fact that the integer-valued N matrix is very sparse, and the non-zero terms are small positive integers.

\[ S_k = R_{i1} + \dots + R_{iM} \]

where M is the number of molecules, and \( i(m) \) is the See Stoichiometry

Definition at line 594 of file StoichManager.h.

Constructor & Destructor Documentation

◆ StoichManagerN()

StoichManagerN ( )
inline

Constructor for the StoichManagerN class.

Consider adding defaulted entries here that supply the total number of reactions in the mechanism and the total number of species in the species list. Then, we could use those numbers to provide error checks during the construction of the object. Those numbers would also provide some clarity to the purpose and utility of this class.

DGG - the problem is that the number of reactions and species are not known initially.

Definition at line 610 of file StoichManager.h.

Member Function Documentation

◆ resizeCoeffs()

void resizeCoeffs ( size_t  nSpc,
size_t  nRxn 
)
inline

Resize the sparse coefficient matrix.

Definition at line 616 of file StoichManager.h.

References StoichManagerN::m_coeffList, StoichManagerN::m_outerIndices, and StoichManagerN::m_ready.

Referenced by Kinetics::resizeReactions().

◆ add() [1/3]

void add ( size_t  rxn,
const std::vector< size_t > &  k 
)
inline

Add a single reaction to the list of reactions that this stoichiometric manager object handles.

This function is the same as the add() function below. However, the order of each species in the power list expression is set to one automatically.

Definition at line 662 of file StoichManager.h.

References StoichManagerN::add().

Referenced by StoichManagerN::add(), and Kinetics::addReaction().

◆ add() [2/3]

void add ( size_t  rxn,
const std::vector< size_t > &  k,
const vector_fp order 
)
inline

Definition at line 668 of file StoichManager.h.

◆ add() [3/3]

void add ( size_t  rxn,
const std::vector< size_t > &  k,
const vector_fp order,
const vector_fp stoich 
)
inline

Add a single reaction to the list of reactions that this stoichiometric manager object handles.

Parameters
rxnReaction index of the current reaction. This is used as an index into vectors which have length n_total_rxn.
kThis is a vector of integer values specifying the species indices. The length of this vector species the number of different species in the description. The value of the entries are the species indices. These are used as indexes into vectors which have length n_total_species.
orderThis is a vector of the same length as vector k. The order is used for the routine power(), which produces a power law expression involving the species vector.
stoichThis is used to handle fractional stoichiometric coefficients on the product side of irreversible reactions.

Definition at line 689 of file StoichManager.h.

References StoichManagerN::m_coeffList, and StoichManagerN::m_ready.

◆ multiply()

void multiply ( const doublereal *  input,
doublereal *  output 
) const
inline

Definition at line 736 of file StoichManager.h.

◆ incrementSpecies()

void incrementSpecies ( const doublereal *  input,
doublereal *  output 
) const
inline

Definition at line 743 of file StoichManager.h.

◆ decrementSpecies()

void decrementSpecies ( const doublereal *  input,
doublereal *  output 
) const
inline

Definition at line 750 of file StoichManager.h.

◆ incrementReactions()

void incrementReactions ( const doublereal *  input,
doublereal *  output 
) const
inline

Definition at line 757 of file StoichManager.h.

◆ decrementReactions()

void decrementReactions ( const doublereal *  input,
doublereal *  output 
) const
inline

Definition at line 764 of file StoichManager.h.

◆ stoichCoeffs()

const Eigen::SparseMatrix< double > & stoichCoeffs ( ) const
inline

◆ derivatives()

Eigen::SparseMatrix< double > derivatives ( const double *  conc,
const double *  rates 
)
inline

Calculate derivatives with respect to species concentrations.

The species derivative is the term of the Jacobian that accounts for species products in the law of mass action. As StoichManagerN does not account for third bodies or rate constants that depend on species concentrations, corresponding derivatives are not included.

Parameters
concSpecies concentration.
ratesRates-of-progress.

Definition at line 794 of file StoichManager.h.

References StoichManagerN::m_outerIndices.

Referenced by GasKinetics::process_ddX().

◆ scale()

void scale ( const double *  in,
double *  out,
double  factor 
) const
inline

Scale input by reaction order and factor.

Definition at line 809 of file StoichManager.h.

Referenced by GasKinetics::process_ddC().

Member Data Documentation

◆ m_ready

bool m_ready
private

Boolean flag indicating whether object is fully configured.

Definition at line 818 of file StoichManager.h.

Referenced by StoichManagerN::add(), StoichManagerN::resizeCoeffs(), and StoichManagerN::stoichCoeffs().

◆ m_c1_list

std::vector<C1> m_c1_list
private

Definition at line 820 of file StoichManager.h.

◆ m_c2_list

std::vector<C2> m_c2_list
private

Definition at line 821 of file StoichManager.h.

◆ m_c3_list

std::vector<C3> m_c3_list
private

Definition at line 822 of file StoichManager.h.

◆ m_cn_list

std::vector<C_AnyN> m_cn_list
private

Definition at line 823 of file StoichManager.h.

◆ m_coeffList

SparseTriplets m_coeffList
private

Sparse matrices for stoichiometric coefficients.

Definition at line 826 of file StoichManager.h.

Referenced by StoichManagerN::add(), and StoichManagerN::resizeCoeffs().

◆ m_stoichCoeffs

Eigen::SparseMatrix<double> m_stoichCoeffs
private

Definition at line 827 of file StoichManager.h.

◆ m_outerIndices

std::vector<int> m_outerIndices
private

Storage indicies used to build derivatives.

Definition at line 830 of file StoichManager.h.

Referenced by StoichManagerN::derivatives(), and StoichManagerN::resizeCoeffs().

◆ m_innerIndices

std::vector<int> m_innerIndices
private

Definition at line 831 of file StoichManager.h.

◆ m_values

vector_fp m_values
private

Definition at line 832 of file StoichManager.h.


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