Eliminated some unnecessary memory management in stoichiometry managers
This commit is contained in:
parent
938d767fde
commit
52cf8cecae
9 changed files with 81 additions and 109 deletions
|
|
@ -220,7 +220,7 @@ public:
|
|||
//#ifdef HWMECH
|
||||
//get_wdot(&m_kdata->m_ropnet[0], net);
|
||||
//#else
|
||||
m_rxnstoich->getNetProductionRates(m_kk, &m_ropnet[0], net);
|
||||
m_rxnstoich.getNetProductionRates(m_kk, &m_ropnet[0], net);
|
||||
//#endif
|
||||
}
|
||||
|
||||
|
|
@ -233,7 +233,7 @@ public:
|
|||
*/
|
||||
virtual void getCreationRates(doublereal* cdot) {
|
||||
updateROP();
|
||||
m_rxnstoich->getCreationRates(m_kk, &m_ropf[0], &m_ropr[0], cdot);
|
||||
m_rxnstoich.getCreationRates(m_kk, &m_ropf[0], &m_ropr[0], cdot);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -245,7 +245,7 @@ public:
|
|||
*/
|
||||
virtual void getDestructionRates(doublereal* ddot) {
|
||||
updateROP();
|
||||
m_rxnstoich->getDestructionRates(m_kk, &m_ropf[0], &m_ropr[0], ddot);
|
||||
m_rxnstoich.getDestructionRates(m_kk, &m_ropf[0], &m_ropr[0], ddot);
|
||||
}
|
||||
|
||||
//@}
|
||||
|
|
@ -343,7 +343,7 @@ protected:
|
|||
|
||||
std::vector<size_t> m_irrev;
|
||||
|
||||
ReactionStoichMgr* m_rxnstoich;
|
||||
ReactionStoichMgr m_rxnstoich;
|
||||
|
||||
std::vector<size_t> m_fwdOrder;
|
||||
|
||||
|
|
|
|||
|
|
@ -380,7 +380,7 @@ protected:
|
|||
Rate1<Plog> m_plog_rates;
|
||||
Rate1<ChebyshevRate> m_cheb_rates;
|
||||
|
||||
ReactionStoichMgr* m_rxnstoich;
|
||||
ReactionStoichMgr m_rxnstoich;
|
||||
|
||||
std::vector<size_t> m_fwdOrder;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,11 +7,10 @@
|
|||
#define CT_RXN_STOICH
|
||||
|
||||
#include "cantera/base/ct_defs.h"
|
||||
|
||||
#include "cantera/kinetics/StoichManager.h"
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
class StoichManagerN;
|
||||
class ReactionData;
|
||||
|
||||
/**
|
||||
|
|
@ -235,9 +234,9 @@ protected:
|
|||
void writeNetProductionRates(std::ostream& f);
|
||||
void writeMultiplyReactants(std::ostream& f);
|
||||
void writeMultiplyRevProducts(std::ostream& f);
|
||||
StoichManagerN* m_reactants;
|
||||
StoichManagerN* m_revproducts;
|
||||
StoichManagerN* m_irrevproducts;
|
||||
StoichManagerN m_reactants;
|
||||
StoichManagerN m_revproducts;
|
||||
StoichManagerN m_irrevproducts;
|
||||
vector_fp m_dummy;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ AqueousKinetics::AqueousKinetics(thermo_t* thermo) :
|
|||
if (thermo != 0) {
|
||||
addPhase(*thermo);
|
||||
}
|
||||
m_rxnstoich = new ReactionStoichMgr;
|
||||
}
|
||||
//====================================================================================================================
|
||||
AqueousKinetics::AqueousKinetics(const AqueousKinetics& right) :
|
||||
|
|
@ -54,7 +53,6 @@ AqueousKinetics::AqueousKinetics(const AqueousKinetics& right) :
|
|||
//====================================================================================================================
|
||||
AqueousKinetics::~AqueousKinetics()
|
||||
{
|
||||
delete m_rxnstoich;
|
||||
}
|
||||
//====================================================================================================================
|
||||
AqueousKinetics& AqueousKinetics::operator=(const AqueousKinetics& right)
|
||||
|
|
@ -70,7 +68,7 @@ AqueousKinetics& AqueousKinetics::operator=(const AqueousKinetics& right)
|
|||
m_index = right.m_index;
|
||||
m_irrev = right.m_irrev;
|
||||
|
||||
*m_rxnstoich = *(right.m_rxnstoich);
|
||||
m_rxnstoich = right.m_rxnstoich;
|
||||
|
||||
m_fwdOrder = right.m_fwdOrder;
|
||||
m_nirrev = right.m_nirrev;
|
||||
|
|
@ -160,7 +158,7 @@ void AqueousKinetics::updateKc()
|
|||
}
|
||||
|
||||
// compute Delta G^0 for all reversible reactions
|
||||
m_rxnstoich->getRevReactionDelta(m_ii, &m_grt[0], &m_rkcn[0]);
|
||||
m_rxnstoich.getRevReactionDelta(m_ii, &m_grt[0], &m_rkcn[0]);
|
||||
|
||||
//doublereal logStandConc = m_kdata->m_logStandConc;
|
||||
doublereal rrt = 1.0/(GasConstant * thermo().temperature());
|
||||
|
|
@ -191,7 +189,7 @@ void AqueousKinetics::getEquilibriumConstants(doublereal* kc)
|
|||
}
|
||||
|
||||
// compute Delta G^0 for all reactions
|
||||
m_rxnstoich->getReactionDelta(m_ii, &m_grt[0], &m_rkcn[0]);
|
||||
m_rxnstoich.getReactionDelta(m_ii, &m_grt[0], &m_rkcn[0]);
|
||||
|
||||
doublereal rrt = 1.0/(GasConstant * thermo().temperature());
|
||||
for (size_t i = 0; i < m_ii; i++) {
|
||||
|
|
@ -225,7 +223,7 @@ void AqueousKinetics::getDeltaGibbs(doublereal* deltaG)
|
|||
* Use the stoichiometric manager to find deltaG for each
|
||||
* reaction.
|
||||
*/
|
||||
m_rxnstoich->getReactionDelta(m_ii, &m_grt[0], deltaG);
|
||||
m_rxnstoich.getReactionDelta(m_ii, &m_grt[0], deltaG);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -250,7 +248,7 @@ void AqueousKinetics::getDeltaEnthalpy(doublereal* deltaH)
|
|||
* Use the stoichiometric manager to find deltaG for each
|
||||
* reaction.
|
||||
*/
|
||||
m_rxnstoich->getReactionDelta(m_ii, &m_grt[0], deltaH);
|
||||
m_rxnstoich.getReactionDelta(m_ii, &m_grt[0], deltaH);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -275,7 +273,7 @@ void AqueousKinetics::getDeltaEntropy(doublereal* deltaS)
|
|||
* Use the stoichiometric manager to find deltaS for each
|
||||
* reaction.
|
||||
*/
|
||||
m_rxnstoich->getReactionDelta(m_ii, &m_grt[0], deltaS);
|
||||
m_rxnstoich.getReactionDelta(m_ii, &m_grt[0], deltaS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -302,7 +300,7 @@ void AqueousKinetics::getDeltaSSGibbs(doublereal* deltaG)
|
|||
* Use the stoichiometric manager to find deltaG for each
|
||||
* reaction.
|
||||
*/
|
||||
m_rxnstoich->getReactionDelta(m_ii, &m_grt[0], deltaG);
|
||||
m_rxnstoich.getReactionDelta(m_ii, &m_grt[0], deltaG);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -333,7 +331,7 @@ void AqueousKinetics::getDeltaSSEnthalpy(doublereal* deltaH)
|
|||
* Use the stoichiometric manager to find deltaG for each
|
||||
* reaction.
|
||||
*/
|
||||
m_rxnstoich->getReactionDelta(m_ii, &m_grt[0], deltaH);
|
||||
m_rxnstoich.getReactionDelta(m_ii, &m_grt[0], deltaH);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -363,7 +361,7 @@ void AqueousKinetics::getDeltaSSEntropy(doublereal* deltaS)
|
|||
* Use the stoichiometric manager to find deltaS for each
|
||||
* reaction.
|
||||
*/
|
||||
m_rxnstoich->getReactionDelta(m_ii, &m_grt[0], deltaS);
|
||||
m_rxnstoich.getReactionDelta(m_ii, &m_grt[0], deltaS);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -392,12 +390,12 @@ void AqueousKinetics::updateROP()
|
|||
multiply_each(m_ropr.begin(), m_ropr.end(), m_rkcn.begin());
|
||||
|
||||
// multiply ropf by concentration products
|
||||
m_rxnstoich->multiplyReactants(&m_conc[0], &m_ropf[0]);
|
||||
m_rxnstoich.multiplyReactants(&m_conc[0], &m_ropf[0]);
|
||||
//m_reactantStoich.multiply(m_conc.begin(), ropf.begin());
|
||||
|
||||
// for reversible reactions, multiply ropr by concentration
|
||||
// products
|
||||
m_rxnstoich->multiplyRevProducts(&m_conc[0], &m_ropr[0]);
|
||||
m_rxnstoich.multiplyRevProducts(&m_conc[0], &m_ropr[0]);
|
||||
//m_revProductStoich.multiply(m_conc.begin(), ropr.begin());
|
||||
|
||||
for (size_t j = 0; j != m_ii; ++j) {
|
||||
|
|
@ -557,7 +555,7 @@ void AqueousKinetics::installReagents(const ReactionData& r)
|
|||
|
||||
m_rkcn.push_back(0.0);
|
||||
|
||||
m_rxnstoich->add(reactionNumber(), r);
|
||||
m_rxnstoich.add(reactionNumber(), r);
|
||||
|
||||
if (r.reversible) {
|
||||
m_dn.push_back(productGlobalOrder - reactantGlobalOrder);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
#include "cantera/kinetics/GRI_30_Kinetics.h"
|
||||
|
||||
#include "cantera/kinetics/ReactionData.h"
|
||||
//#include "StoichManager.h"
|
||||
#include "cantera/kinetics/Enhanced3BConc.h"
|
||||
#include "cantera/kinetics/ThirdBodyMgr.h"
|
||||
#include "cantera/kinetics/RateCoeffMgr.h"
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ GasKinetics(thermo_t* thermo) :
|
|||
addPhase(*thermo);
|
||||
}
|
||||
m_temp = 0.0;
|
||||
m_rxnstoich = new ReactionStoichMgr();
|
||||
}
|
||||
|
||||
//====================================================================================================================
|
||||
|
|
@ -58,13 +57,11 @@ GasKinetics::GasKinetics(const GasKinetics& right) :
|
|||
m_finalized(false)
|
||||
{
|
||||
m_temp = 0.0;
|
||||
m_rxnstoich = new ReactionStoichMgr();
|
||||
*this = right;
|
||||
}
|
||||
//====================================================================================================================
|
||||
GasKinetics::~GasKinetics()
|
||||
{
|
||||
delete m_rxnstoich;
|
||||
}
|
||||
//====================================================================================================================
|
||||
GasKinetics& GasKinetics::operator=(const GasKinetics& right)
|
||||
|
|
@ -88,7 +85,7 @@ GasKinetics& GasKinetics::operator=(const GasKinetics& right)
|
|||
m_plog_rates = right.m_plog_rates;
|
||||
m_cheb_rates = right.m_cheb_rates;
|
||||
|
||||
*m_rxnstoich = *(right.m_rxnstoich);
|
||||
m_rxnstoich = right.m_rxnstoich;
|
||||
|
||||
m_fwdOrder = right.m_fwdOrder;
|
||||
m_nirrev = right.m_nirrev;
|
||||
|
|
@ -230,7 +227,7 @@ void GasKinetics::updateKc()
|
|||
fill(m_rkcn.begin(), m_rkcn.end(), 0.0);
|
||||
|
||||
// compute Delta G^0 for all reversible reactions
|
||||
m_rxnstoich->getRevReactionDelta(m_ii, &m_grt[0], &m_rkcn[0]);
|
||||
m_rxnstoich.getRevReactionDelta(m_ii, &m_grt[0], &m_rkcn[0]);
|
||||
|
||||
doublereal rrt = 1.0/(GasConstant * thermo().temperature());
|
||||
for (size_t i = 0; i < m_nrev; i++) {
|
||||
|
|
@ -254,7 +251,7 @@ void GasKinetics::getEquilibriumConstants(doublereal* kc)
|
|||
fill(m_rkcn.begin(), m_rkcn.end(), 0.0);
|
||||
|
||||
// compute Delta G^0 for all reactions
|
||||
m_rxnstoich->getReactionDelta(m_ii, &m_grt[0], &m_rkcn[0]);
|
||||
m_rxnstoich.getReactionDelta(m_ii, &m_grt[0], &m_rkcn[0]);
|
||||
|
||||
doublereal rrt = 1.0/(GasConstant * thermo().temperature());
|
||||
for (size_t i = 0; i < m_ii; i++) {
|
||||
|
|
@ -288,7 +285,7 @@ void GasKinetics::getDeltaGibbs(doublereal* deltaG)
|
|||
* Use the stoichiometric manager to find deltaG for each
|
||||
* reaction.
|
||||
*/
|
||||
m_rxnstoich->getReactionDelta(m_ii, &m_grt[0], deltaG);
|
||||
m_rxnstoich.getReactionDelta(m_ii, &m_grt[0], deltaG);
|
||||
}
|
||||
//====================================================================================================================
|
||||
/**
|
||||
|
|
@ -313,7 +310,7 @@ void GasKinetics::getDeltaEnthalpy(doublereal* deltaH)
|
|||
* Use the stoichiometric manager to find deltaG for each
|
||||
* reaction.
|
||||
*/
|
||||
m_rxnstoich->getReactionDelta(m_ii, &m_grt[0], deltaH);
|
||||
m_rxnstoich.getReactionDelta(m_ii, &m_grt[0], deltaH);
|
||||
}
|
||||
//====================================================================================================================
|
||||
/*
|
||||
|
|
@ -338,7 +335,7 @@ void GasKinetics::getDeltaEntropy(doublereal* deltaS)
|
|||
* Use the stoichiometric manager to find deltaS for each
|
||||
* reaction.
|
||||
*/
|
||||
m_rxnstoich->getReactionDelta(m_ii, &m_grt[0], deltaS);
|
||||
m_rxnstoich.getReactionDelta(m_ii, &m_grt[0], deltaS);
|
||||
}
|
||||
//====================================================================================================================
|
||||
/**
|
||||
|
|
@ -365,7 +362,7 @@ void GasKinetics::getDeltaSSGibbs(doublereal* deltaG)
|
|||
* Use the stoichiometric manager to find deltaG for each
|
||||
* reaction.
|
||||
*/
|
||||
m_rxnstoich->getReactionDelta(m_ii, &m_grt[0], deltaG);
|
||||
m_rxnstoich.getReactionDelta(m_ii, &m_grt[0], deltaG);
|
||||
}
|
||||
//====================================================================================================================
|
||||
/**
|
||||
|
|
@ -396,7 +393,7 @@ void GasKinetics::getDeltaSSEnthalpy(doublereal* deltaH)
|
|||
* Use the stoichiometric manager to find deltaG for each
|
||||
* reaction.
|
||||
*/
|
||||
m_rxnstoich->getReactionDelta(m_ii, &m_grt[0], deltaH);
|
||||
m_rxnstoich.getReactionDelta(m_ii, &m_grt[0], deltaH);
|
||||
}
|
||||
//====================================================================================================================
|
||||
/*********************************************************************
|
||||
|
|
@ -426,7 +423,7 @@ void GasKinetics::getDeltaSSEntropy(doublereal* deltaS)
|
|||
* Use the stoichiometric manager to find deltaS for each
|
||||
* reaction.
|
||||
*/
|
||||
m_rxnstoich->getReactionDelta(m_ii, &m_grt[0], deltaS);
|
||||
m_rxnstoich.getReactionDelta(m_ii, &m_grt[0], deltaS);
|
||||
}
|
||||
|
||||
//====================================================================================================================
|
||||
|
|
@ -443,7 +440,7 @@ void GasKinetics::getDeltaSSEntropy(doublereal* deltaS)
|
|||
void GasKinetics::getNetProductionRates(doublereal* net)
|
||||
{
|
||||
updateROP();
|
||||
m_rxnstoich->getNetProductionRates(m_kk, &m_ropnet[0], net);
|
||||
m_rxnstoich.getNetProductionRates(m_kk, &m_ropnet[0], net);
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Return the species creation rates
|
||||
|
|
@ -459,7 +456,7 @@ void GasKinetics::getNetProductionRates(doublereal* net)
|
|||
void GasKinetics::getCreationRates(doublereal* cdot)
|
||||
{
|
||||
updateROP();
|
||||
m_rxnstoich->getCreationRates(m_kk, &m_ropf[0], &m_ropr[0], cdot);
|
||||
m_rxnstoich.getCreationRates(m_kk, &m_ropf[0], &m_ropr[0], cdot);
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Return a vector of the species destruction rates
|
||||
|
|
@ -477,7 +474,7 @@ void GasKinetics::getCreationRates(doublereal* cdot)
|
|||
void GasKinetics::getDestructionRates(doublereal* ddot)
|
||||
{
|
||||
updateROP();
|
||||
m_rxnstoich->getDestructionRates(m_kk, &m_ropf[0], &m_ropr[0], ddot);
|
||||
m_rxnstoich.getDestructionRates(m_kk, &m_ropf[0], &m_ropr[0], ddot);
|
||||
}
|
||||
//====================================================================================================================
|
||||
void GasKinetics::processFalloffReactions()
|
||||
|
|
@ -534,12 +531,12 @@ void GasKinetics::updateROP()
|
|||
multiply_each(m_ropr.begin(), m_ropr.end(), m_rkcn.begin());
|
||||
|
||||
// multiply ropf by concentration products
|
||||
m_rxnstoich->multiplyReactants(&m_conc[0], &m_ropf[0]);
|
||||
m_rxnstoich.multiplyReactants(&m_conc[0], &m_ropf[0]);
|
||||
//m_reactantStoich.multiply(m_conc.begin(), ropf.begin());
|
||||
|
||||
// for reversible reactions, multiply ropr by concentration
|
||||
// products
|
||||
m_rxnstoich->multiplyRevProducts(&m_conc[0], &m_ropr[0]);
|
||||
m_rxnstoich.multiplyRevProducts(&m_conc[0], &m_ropr[0]);
|
||||
//m_revProductStoich.multiply(m_conc.begin(), ropr.begin());
|
||||
|
||||
for (size_t j = 0; j != m_ii; ++j) {
|
||||
|
|
@ -798,7 +795,7 @@ void GasKinetics::installReagents(const ReactionData& r)
|
|||
}
|
||||
m_products.push_back(pk);
|
||||
m_rkcn.push_back(0.0);
|
||||
m_rxnstoich->add(reactionNumber(), r);
|
||||
m_rxnstoich.add(reactionNumber(), r);
|
||||
|
||||
if (r.reversible) {
|
||||
m_dn.push_back(productGlobalOrder - reactantGlobalOrder);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include "cantera/kinetics/InterfaceKinetics.h"
|
||||
#include "cantera/thermo/SurfPhase.h"
|
||||
#include "StoichManager.h"
|
||||
#include "cantera/kinetics/StoichManager.h"
|
||||
#include "cantera/kinetics/RateCoeffMgr.h"
|
||||
|
||||
#include "ImplicitSurfChem.h"
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
//------------------------------------------------
|
||||
|
||||
#include "cantera/kinetics/ReactionStoichMgr.h"
|
||||
#include "StoichManager.h"
|
||||
#include "cantera/base/ctexceptions.h"
|
||||
#include "cantera/kinetics/ReactionData.h"
|
||||
|
||||
|
|
@ -20,52 +19,32 @@ namespace Cantera
|
|||
// create stoichiometry managers for the reactants of all reactions,
|
||||
// for the products of the reversible reactions, and for the
|
||||
// products of the irreversible reactions.
|
||||
ReactionStoichMgr::ReactionStoichMgr() :
|
||||
m_reactants(0),
|
||||
m_revproducts(0),
|
||||
m_irrevproducts(0)
|
||||
ReactionStoichMgr::ReactionStoichMgr()
|
||||
{
|
||||
m_reactants = new StoichManagerN;
|
||||
m_revproducts = new StoichManagerN;
|
||||
m_irrevproducts = new StoichManagerN;
|
||||
m_dummy.resize(10,1.0);
|
||||
}
|
||||
//====================================================================================================================
|
||||
// delete the three stoichiometry managers
|
||||
ReactionStoichMgr::~ReactionStoichMgr()
|
||||
{
|
||||
delete m_reactants;
|
||||
delete m_revproducts;
|
||||
delete m_irrevproducts;
|
||||
}
|
||||
|
||||
//====================================================================================================================
|
||||
ReactionStoichMgr::ReactionStoichMgr(const ReactionStoichMgr& right) :
|
||||
m_reactants(0),
|
||||
m_revproducts(0),
|
||||
m_irrevproducts(0)
|
||||
m_reactants(right.m_reactants),
|
||||
m_revproducts(right.m_revproducts),
|
||||
m_irrevproducts(right.m_irrevproducts),
|
||||
m_dummy(right.m_dummy)
|
||||
{
|
||||
m_reactants = new StoichManagerN(*right.m_reactants);
|
||||
m_revproducts = new StoichManagerN(*right.m_revproducts);
|
||||
m_irrevproducts = new StoichManagerN(*right.m_irrevproducts);
|
||||
m_dummy = right.m_dummy;
|
||||
}
|
||||
|
||||
//====================================================================================================================
|
||||
ReactionStoichMgr& ReactionStoichMgr::operator=(const ReactionStoichMgr& right)
|
||||
{
|
||||
if (this != &right) {
|
||||
if (m_reactants) {
|
||||
delete(m_reactants);
|
||||
}
|
||||
if (m_revproducts) {
|
||||
delete(m_revproducts);
|
||||
}
|
||||
if (m_irrevproducts) {
|
||||
delete(m_irrevproducts);
|
||||
}
|
||||
|
||||
m_reactants = new StoichManagerN(*right.m_reactants);
|
||||
m_revproducts = new StoichManagerN(*right.m_revproducts);
|
||||
m_irrevproducts = new StoichManagerN(*right.m_irrevproducts);
|
||||
m_reactants = right.m_reactants;
|
||||
m_revproducts = right.m_revproducts;
|
||||
m_irrevproducts = right.m_irrevproducts;
|
||||
m_dummy = right.m_dummy;
|
||||
}
|
||||
return *this;
|
||||
|
|
@ -77,12 +56,12 @@ add(size_t rxn, const std::vector<size_t>& reactants,
|
|||
bool reversible)
|
||||
{
|
||||
|
||||
m_reactants->add(rxn, reactants);
|
||||
m_reactants.add(rxn, reactants);
|
||||
|
||||
if (reversible) {
|
||||
m_revproducts->add(rxn, products);
|
||||
m_revproducts.add(rxn, products);
|
||||
} else {
|
||||
m_irrevproducts->add(rxn, products);
|
||||
m_irrevproducts.add(rxn, products);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -108,9 +87,9 @@ add(size_t rxn, const ReactionData& r)
|
|||
// if the reaction has fractional stoichiometric coefficients
|
||||
// or specified reaction orders, then add it in a general reaction
|
||||
if (isfrac || r.global || rk.size() > 3) {
|
||||
m_reactants->add(rxn, r.reactants, r.rorder, r.rstoich);
|
||||
m_reactants.add(rxn, r.reactants, r.rorder, r.rstoich);
|
||||
} else {
|
||||
m_reactants->add(rxn, rk);
|
||||
m_reactants.add(rxn, rk);
|
||||
}
|
||||
|
||||
std::vector<size_t> pk;
|
||||
|
|
@ -133,14 +112,14 @@ add(size_t rxn, const ReactionData& r)
|
|||
"\nfor irreversible reactions and most reversible reactions");
|
||||
}
|
||||
if (pk.size() > 3 || r.isReversibleWithFrac) {
|
||||
m_revproducts->add(rxn, r.products, r.porder, r.pstoich);
|
||||
m_revproducts.add(rxn, r.products, r.porder, r.pstoich);
|
||||
} else {
|
||||
m_revproducts->add(rxn, pk);
|
||||
m_revproducts.add(rxn, pk);
|
||||
}
|
||||
} else if (isfrac || pk.size() > 3) {
|
||||
m_irrevproducts->add(rxn, r.products, r.porder, r.pstoich);
|
||||
m_irrevproducts.add(rxn, r.products, r.porder, r.pstoich);
|
||||
} else {
|
||||
m_irrevproducts->add(rxn, pk);
|
||||
m_irrevproducts.add(rxn, pk);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -152,11 +131,11 @@ getCreationRates(size_t nsp, const doublereal* ropf,
|
|||
fill(c, c + nsp, 0.0);
|
||||
|
||||
// the forward direction creates product species
|
||||
m_revproducts->incrementSpecies(ropf, c);
|
||||
m_irrevproducts->incrementSpecies(ropf, c);
|
||||
m_revproducts.incrementSpecies(ropf, c);
|
||||
m_irrevproducts.incrementSpecies(ropf, c);
|
||||
|
||||
// the reverse direction creates reactant species
|
||||
m_reactants->incrementSpecies(ropr, c);
|
||||
m_reactants.incrementSpecies(ropr, c);
|
||||
}
|
||||
|
||||
void ReactionStoichMgr::
|
||||
|
|
@ -165,9 +144,9 @@ getDestructionRates(size_t nsp, const doublereal* ropf,
|
|||
{
|
||||
fill(d, d + nsp, 0.0);
|
||||
// the reverse direction destroys products in reversible reactions
|
||||
m_revproducts->incrementSpecies(ropr, d);
|
||||
m_revproducts.incrementSpecies(ropr, d);
|
||||
// the forward direction destroys reactants
|
||||
m_reactants->incrementSpecies(ropf, d);
|
||||
m_reactants.incrementSpecies(ropf, d);
|
||||
}
|
||||
|
||||
void ReactionStoichMgr::
|
||||
|
|
@ -175,10 +154,10 @@ getNetProductionRates(size_t nsp, const doublereal* ropnet, doublereal* w)
|
|||
{
|
||||
fill(w, w + nsp, 0.0);
|
||||
// products are created for positive net rate of progress
|
||||
m_revproducts->incrementSpecies(ropnet, w);
|
||||
m_irrevproducts->incrementSpecies(ropnet, w);
|
||||
m_revproducts.incrementSpecies(ropnet, w);
|
||||
m_irrevproducts.incrementSpecies(ropnet, w);
|
||||
// reactants are destroyed for positive net rate of progress
|
||||
m_reactants->decrementSpecies(ropnet, w);
|
||||
m_reactants.decrementSpecies(ropnet, w);
|
||||
}
|
||||
|
||||
void ReactionStoichMgr::
|
||||
|
|
@ -186,30 +165,30 @@ getReactionDelta(size_t nr, const doublereal* g, doublereal* dg)
|
|||
{
|
||||
fill(dg, dg + nr, 0.0);
|
||||
// products add
|
||||
m_revproducts->incrementReactions(g, dg);
|
||||
m_irrevproducts->incrementReactions(g, dg);
|
||||
m_revproducts.incrementReactions(g, dg);
|
||||
m_irrevproducts.incrementReactions(g, dg);
|
||||
// reactants subtract
|
||||
m_reactants->decrementReactions(g, dg);
|
||||
m_reactants.decrementReactions(g, dg);
|
||||
}
|
||||
|
||||
void ReactionStoichMgr::
|
||||
getRevReactionDelta(size_t nr, const doublereal* g, doublereal* dg)
|
||||
{
|
||||
fill(dg, dg + nr, 0.0);
|
||||
m_revproducts->incrementReactions(g, dg);
|
||||
m_reactants->decrementReactions(g, dg);
|
||||
m_revproducts.incrementReactions(g, dg);
|
||||
m_reactants.decrementReactions(g, dg);
|
||||
}
|
||||
|
||||
void ReactionStoichMgr::
|
||||
multiplyReactants(const doublereal* c, doublereal* r)
|
||||
{
|
||||
m_reactants->multiply(c, r);
|
||||
m_reactants.multiply(c, r);
|
||||
}
|
||||
|
||||
void ReactionStoichMgr::
|
||||
multiplyRevProducts(const doublereal* c, doublereal* r)
|
||||
{
|
||||
m_revproducts->multiply(c, r);
|
||||
m_revproducts.multiply(c, r);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -233,9 +212,9 @@ writeCreationRates(ostream& f)
|
|||
f << " void getCreationRates(const doublereal* rf, const doublereal* rb," << endl;
|
||||
f << " doublereal* c) {" << endl;
|
||||
map<size_t, string> out;
|
||||
m_revproducts->writeIncrementSpecies("rf",out);
|
||||
m_irrevproducts->writeIncrementSpecies("rf",out);
|
||||
m_reactants->writeIncrementSpecies("rb",out);
|
||||
m_revproducts.writeIncrementSpecies("rf",out);
|
||||
m_irrevproducts.writeIncrementSpecies("rf",out);
|
||||
m_reactants.writeIncrementSpecies("rb",out);
|
||||
map<size_t, string>::iterator b;
|
||||
for (b = out.begin(); b != out.end(); ++b) {
|
||||
string rhs = wrapString(b->second);
|
||||
|
|
@ -251,8 +230,8 @@ writeDestructionRates(ostream& f)
|
|||
f << " void getDestructionRates(const doublereal* rf, const doublereal* rb," << endl;
|
||||
f << " doublereal* d) {" << endl;
|
||||
map<size_t, string> out;
|
||||
m_revproducts->writeIncrementSpecies("rb",out);
|
||||
m_reactants->writeIncrementSpecies("rf",out);
|
||||
m_revproducts.writeIncrementSpecies("rb",out);
|
||||
m_reactants.writeIncrementSpecies("rf",out);
|
||||
map<size_t, string>::iterator b;
|
||||
for (b = out.begin(); b != out.end(); ++b) {
|
||||
string rhs = wrapString(b->second);
|
||||
|
|
@ -267,9 +246,9 @@ writeNetProductionRates(ostream& f)
|
|||
{
|
||||
f << " void getNetProductionRates(const doublereal* r, doublereal* w) {" << endl;
|
||||
map<size_t, string> out;
|
||||
m_revproducts->writeIncrementSpecies("r",out);
|
||||
m_irrevproducts->writeIncrementSpecies("r",out);
|
||||
m_reactants->writeDecrementSpecies("r",out);
|
||||
m_revproducts.writeIncrementSpecies("r",out);
|
||||
m_irrevproducts.writeIncrementSpecies("r",out);
|
||||
m_reactants.writeDecrementSpecies("r",out);
|
||||
map<size_t, string>::iterator b;
|
||||
for (b = out.begin(); b != out.end(); ++b) {
|
||||
string rhs = wrapString(b->second);
|
||||
|
|
@ -284,7 +263,7 @@ writeMultiplyReactants(ostream& f)
|
|||
{
|
||||
f << " void multiplyReactants(const doublereal* c, doublereal* r) {" << endl;
|
||||
map<size_t, string> out;
|
||||
m_reactants->writeMultiply("c",out);
|
||||
m_reactants.writeMultiply("c",out);
|
||||
map<size_t, string>::iterator b;
|
||||
for (b = out.begin(); b != out.end(); ++b) {
|
||||
string rhs = b->second;
|
||||
|
|
@ -298,7 +277,7 @@ writeMultiplyRevProducts(ostream& f)
|
|||
{
|
||||
f << " void multiplyRevProducts(const doublereal* c, doublereal* r) {" << endl;
|
||||
map<size_t, string> out;
|
||||
m_revproducts->writeMultiply("c",out);
|
||||
m_revproducts.writeMultiply("c",out);
|
||||
map<size_t, string>::iterator b;
|
||||
for (b = out.begin(); b != out.end(); ++b) {
|
||||
string rhs = b->second;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue