Cantera  3.1.0a1
Loading...
Searching...
No Matches
StoichManagerN Class Reference

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>

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:

  • \( S = S + N R \) (incrementSpecies)
  • \( S = S - N R \) (decrementSpecies)
  • \( R = R + N^T S \) (incrementReaction)
  • \( R = R - N^T S \) (decrementReaction)

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.
 
void resizeCoeffs (size_t nSpc, size_t nRxn)
 Resize the sparse coefficient matrix.
 
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.
 
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.
 
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.
 
Eigen::SparseMatrix< double > derivatives (const double *conc, const double *rates)
 Calculate derivatives with respect to species concentrations.
 
void scale (const double *in, double *out, double factor) const
 Scale input by reaction order and factor.
 

Private Attributes

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

Constructor & Destructor Documentation

◆ StoichManagerN()

StoichManagerN ( )
inline

Constructor for the StoichManagerN class.

Definition at line 594 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 600 of file StoichManager.h.

◆ add() [1/3]

void add ( size_t  rxn,
const 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 646 of file StoichManager.h.

◆ add() [2/3]

void add ( size_t  rxn,
const vector< size_t > &  k,
const vector< double > &  order 
)
inline

Definition at line 652 of file StoichManager.h.

◆ add() [3/3]

void add ( size_t  rxn,
const vector< size_t > &  k,
const vector< double > &  order,
const vector< double > &  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 673 of file StoichManager.h.

◆ multiply()

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

Definition at line 722 of file StoichManager.h.

◆ incrementSpecies()

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

Definition at line 729 of file StoichManager.h.

◆ decrementSpecies()

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

Definition at line 736 of file StoichManager.h.

◆ incrementReactions()

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

Definition at line 743 of file StoichManager.h.

◆ decrementReactions()

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

Definition at line 750 of file StoichManager.h.

◆ stoichCoeffs()

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

Return matrix containing stoichiometric coefficients.

Definition at line 758 of file StoichManager.h.

◆ 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 780 of file StoichManager.h.

◆ scale()

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

Scale input by reaction order and factor.

Definition at line 795 of file StoichManager.h.

Member Data Documentation

◆ m_ready

bool m_ready
private

Boolean flag indicating whether object is fully configured.

Definition at line 804 of file StoichManager.h.

◆ m_c1_list

vector<C1> m_c1_list
private

Definition at line 806 of file StoichManager.h.

◆ m_c2_list

vector<C2> m_c2_list
private

Definition at line 807 of file StoichManager.h.

◆ m_c3_list

vector<C3> m_c3_list
private

Definition at line 808 of file StoichManager.h.

◆ m_cn_list

vector<C_AnyN> m_cn_list
private

Definition at line 809 of file StoichManager.h.

◆ m_coeffList

SparseTriplets m_coeffList
private

Sparse matrices for stoichiometric coefficients.

Definition at line 812 of file StoichManager.h.

◆ m_stoichCoeffs

Eigen::SparseMatrix<double> m_stoichCoeffs
private

Definition at line 813 of file StoichManager.h.

◆ m_outerIndices

vector<int> m_outerIndices
private

Storage indicies used to build derivatives.

Definition at line 816 of file StoichManager.h.

◆ m_innerIndices

vector<int> m_innerIndices
private

Definition at line 817 of file StoichManager.h.

◆ m_values

vector<double> m_values
private

Definition at line 818 of file StoichManager.h.


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