Cantera
3.1.0a1
|
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. More...
#include <StoichManager.h>
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 588 of file 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 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 vector< size_t > &k, const vector< double > &order) |
void | add (size_t rxn, const vector< size_t > &k, const vector< double > &order, const vector< double > &stoich) |
Add a single reaction to the list of reactions that this stoichiometric manager object handles. More... | |
void | multiply (const double *input, double *output) const |
void | incrementSpecies (const double *input, double *output) const |
void | decrementSpecies (const double *input, double *output) const |
void | incrementReactions (const double *input, double *output) const |
void | decrementReactions (const double *input, double *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... | |
vector< C1 > | m_c1_list |
vector< C2 > | m_c2_list |
vector< C3 > | m_c3_list |
vector< C_AnyN > | m_cn_list |
SparseTriplets | m_coeffList |
Sparse matrices for stoichiometric coefficients. More... | |
Eigen::SparseMatrix< double > | m_stoichCoeffs |
vector< int > | m_outerIndices |
Storage indicies used to build derivatives. More... | |
vector< int > | m_innerIndices |
vector< double > | m_values |
|
inline |
Constructor for the StoichManagerN class.
Definition at line 594 of file StoichManager.h.
|
inline |
Resize the sparse coefficient matrix.
Definition at line 600 of file StoichManager.h.
|
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 646 of file StoichManager.h.
|
inline |
Add a single reaction to the list of reactions that this stoichiometric manager object handles.
rxn | Reaction index of the current reaction. This is used as an index into vectors which have length n_total_rxn. |
k | This 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. |
order | This 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. |
stoich | This is used to handle fractional stoichiometric coefficients on the product side of irreversible reactions. |
Definition at line 673 of file StoichManager.h.
|
inline |
Return matrix containing stoichiometric coefficients.
Definition at line 758 of file StoichManager.h.
|
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.
conc | Species concentration. |
rates | Rates-of-progress. |
Definition at line 780 of file StoichManager.h.
|
inline |
Scale input by reaction order and factor.
Definition at line 795 of file StoichManager.h.
|
private |
Boolean flag indicating whether object is fully configured.
Definition at line 804 of file StoichManager.h.
|
private |
Sparse matrices for stoichiometric coefficients.
Definition at line 812 of file StoichManager.h.
|
private |
Storage indicies used to build derivatives.
Definition at line 816 of file StoichManager.h.