Make use of the ReactionData struct when installing reactions
This commit is contained in:
parent
b4c07978e6
commit
234439d10f
13 changed files with 80 additions and 101 deletions
|
|
@ -346,7 +346,7 @@ public:
|
|||
virtual void init();
|
||||
|
||||
/// Add a reaction to the mechanism.
|
||||
virtual void addReaction(const ReactionData& r);
|
||||
virtual void addReaction(ReactionData& r);
|
||||
|
||||
virtual void finalize();
|
||||
virtual bool ready() const;
|
||||
|
|
@ -419,7 +419,7 @@ private:
|
|||
}
|
||||
std::vector<std::map<int, doublereal> > m_stoich;
|
||||
|
||||
void addElementaryReaction(const ReactionData& r);
|
||||
void addElementaryReaction(ReactionData& r);
|
||||
|
||||
|
||||
void installReagents(const ReactionData& r);
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ public:
|
|||
virtual void init();
|
||||
|
||||
/// Add a reaction to the mechanism.
|
||||
virtual void addReaction(const ReactionData& r);
|
||||
virtual void addReaction(ReactionData& r);
|
||||
|
||||
virtual void finalize();
|
||||
virtual bool ready() const;
|
||||
|
|
@ -449,11 +449,11 @@ private:
|
|||
}
|
||||
std::vector<std::map<int, doublereal> > m_stoich;
|
||||
|
||||
void addElementaryReaction(const ReactionData& r);
|
||||
void addThreeBodyReaction(const ReactionData& r);
|
||||
void addFalloffReaction(const ReactionData& r);
|
||||
void addPlogReaction(const ReactionData& r);
|
||||
void addChebyshevReaction(const ReactionData& r);
|
||||
void addElementaryReaction(ReactionData& r);
|
||||
void addThreeBodyReaction(ReactionData& r);
|
||||
void addFalloffReaction(ReactionData& r);
|
||||
void addPlogReaction(ReactionData& r);
|
||||
void addChebyshevReaction(ReactionData& r);
|
||||
|
||||
void installReagents(const ReactionData& r);
|
||||
|
||||
|
|
|
|||
|
|
@ -460,7 +460,7 @@ public:
|
|||
* @param r Reference to a ReactionData object containing all of
|
||||
* the info needed to describe the reaction.
|
||||
*/
|
||||
virtual void addReaction(const ReactionData& r);
|
||||
virtual void addReaction(ReactionData& r);
|
||||
|
||||
|
||||
//! Finish adding reactions and prepare for use.
|
||||
|
|
@ -557,7 +557,7 @@ public:
|
|||
return m_ii;
|
||||
}
|
||||
|
||||
void addElementaryReaction(const ReactionData& r);
|
||||
void addElementaryReaction(ReactionData& r);
|
||||
void addGlobalReaction(const ReactionData& r);
|
||||
void installReagents(const ReactionData& r);
|
||||
|
||||
|
|
|
|||
|
|
@ -917,7 +917,7 @@ public:
|
|||
* @param r Reference to the ReactionData object for the reaction
|
||||
* to be added.
|
||||
*/
|
||||
virtual void addReaction(const ReactionData& r) {
|
||||
virtual void addReaction(ReactionData& r) {
|
||||
err("addReaction");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,32 +33,23 @@ public:
|
|||
/**
|
||||
* Install a rate coefficient calculator.
|
||||
* @param rxnNumber the reaction number
|
||||
* @param rateType the rate type
|
||||
* @param m length of coefficient array
|
||||
* @param coefficients
|
||||
* @param rdata rate coefficient specification for the reaction
|
||||
* @param useAux flag to indicate that auxiliary rate information from
|
||||
* rdata should be used.
|
||||
*/
|
||||
size_t install(size_t rxnNumber, int rateType, size_t m,
|
||||
const doublereal* c) {
|
||||
size_t install(size_t rxnNumber, const ReactionData& rdata) {
|
||||
/*
|
||||
* Check to see if the current reaction rate type
|
||||
* is the same as the type of this class. If not,
|
||||
* throw an error condition.
|
||||
* Check to see if the current reaction rate type is the same as the
|
||||
* type of this class. If not, throw an error condition.
|
||||
*/
|
||||
if (rateType != R::type())
|
||||
if (rdata.rateCoeffType != R::type())
|
||||
throw CanteraError("Rate1::install",
|
||||
"incorrect rate coefficient type: "+int2str(rateType));
|
||||
"incorrect rate coefficient type: "+int2str(rdata.rateCoeffType));
|
||||
|
||||
// if any coefficient other than the first is non-zero, or
|
||||
// if alwaysComputeRate() is true, install a rate
|
||||
// calculator and return the index of the calculator.
|
||||
for (size_t i = 1; i < m; i++) {
|
||||
if (c[i] != 0.0 || R::alwaysComputeRate()) {
|
||||
m_rxn.push_back(rxnNumber);
|
||||
m_rates.push_back(R(m, c));
|
||||
return m_rates.size() - 1;
|
||||
}
|
||||
}
|
||||
return npos;
|
||||
// Install a rate calculator and return the index of the calculator.
|
||||
m_rxn.push_back(rxnNumber);
|
||||
m_rates.push_back(R(rdata));
|
||||
return m_rates.size() - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
#define CT_REACTION_DATA_H
|
||||
|
||||
#include "cantera/kinetics/reaction_defs.h"
|
||||
#include "cantera/kinetics/RxnRates.h"
|
||||
|
||||
namespace Cantera
|
||||
{
|
||||
|
|
@ -75,7 +74,7 @@ public:
|
|||
|
||||
//! Arrhenius parameters for P-log reactions.
|
||||
//! The keys are the pressures corresponding to each Arrhenius expression.
|
||||
std::map<double, Arrhenius> plogParameters;
|
||||
std::map<double, vector_fp> plogParameters;
|
||||
|
||||
double chebTmin; //!< Minimum temperature for Chebyshev fit
|
||||
double chebTmax; //!< Maximum temperature for Chebyshev fit
|
||||
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "reaction_defs.h"
|
||||
#include "cantera/base/ctexceptions.h"
|
||||
#include "ReactionData.h"
|
||||
|
||||
namespace Cantera
|
||||
{
|
||||
|
|
@ -26,7 +27,6 @@ namespace Cantera
|
|||
class Arrhenius
|
||||
{
|
||||
public:
|
||||
|
||||
//! return the rate coefficient type.
|
||||
static int type() {
|
||||
return ARRHENIUS_REACTION_RATECOEFF_TYPE;
|
||||
|
|
@ -39,11 +39,11 @@ public:
|
|||
m_E(0.0),
|
||||
m_A(0.0) {}
|
||||
|
||||
//! Constructor with Arrhenius parameters specified with an array.
|
||||
Arrhenius(size_t csize, const doublereal* c) :
|
||||
m_b(c[1]),
|
||||
m_E(c[2]),
|
||||
m_A(c[0]) {
|
||||
//! Constructor from ReactionData.
|
||||
explicit Arrhenius(const ReactionData& rdata) :
|
||||
m_b(rdata.rateCoeffParameters[1]),
|
||||
m_E(rdata.rateCoeffParameters[2]),
|
||||
m_A(rdata.rateCoeffParameters[0]) {
|
||||
if (m_A <= 0.0) {
|
||||
m_logA = -1.0E300;
|
||||
} else {
|
||||
|
|
@ -123,7 +123,7 @@ protected:
|
|||
doublereal m_logA, m_b, m_E, m_A;
|
||||
};
|
||||
|
||||
|
||||
//! @deprecated This class is not used.
|
||||
class ArrheniusSum
|
||||
{
|
||||
|
||||
|
|
@ -216,24 +216,27 @@ public:
|
|||
m_nmcov(0) {
|
||||
}
|
||||
|
||||
SurfaceArrhenius(size_t csize, const doublereal* c) :
|
||||
m_b(c[1]),
|
||||
m_E(c[2]),
|
||||
m_A(c[0]),
|
||||
explicit SurfaceArrhenius(const ReactionData& rdata) :
|
||||
m_b(rdata.rateCoeffParameters[1]),
|
||||
m_E(rdata.rateCoeffParameters[2]),
|
||||
m_A(rdata.rateCoeffParameters[0]),
|
||||
m_acov(0.0),
|
||||
m_ecov(0.0),
|
||||
m_mcov(0.0),
|
||||
m_ncov(0),
|
||||
m_nmcov(0) {
|
||||
m_nmcov(0)
|
||||
{
|
||||
if (m_A <= 0.0) {
|
||||
m_logA = -1.0E300;
|
||||
} else {
|
||||
m_logA = log(c[0]);
|
||||
m_logA = log(m_A);
|
||||
}
|
||||
if (csize >= 7) {
|
||||
for (size_t n = 3; n < csize-3; n += 4) {
|
||||
addCoverageDependence(size_t(c[n]),
|
||||
c[n+1], c[n+2], c[n+3]);
|
||||
|
||||
const vector_fp& data = rdata.auxRateCoeffParameters;
|
||||
if (data.size() >= 7) {
|
||||
for (size_t n = 3; n < data.size()-3; n += 4) {
|
||||
addCoverageDependence(size_t(data[n]), data[n+1],
|
||||
data[n+2], data[n+3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -381,11 +384,11 @@ public:
|
|||
m_E(0.0),
|
||||
m_A(0.0) {}
|
||||
|
||||
//! Constructor with Arrhenius parameters specified with an array.
|
||||
ExchangeCurrent(size_t csize, const doublereal* c) :
|
||||
m_b(c[1]),
|
||||
m_E(c[2]),
|
||||
m_A(c[0]) {
|
||||
//! Constructor with Arrhenius parameters from a ReactionData struct.
|
||||
explicit ExchangeCurrent(const ReactionData& rdata) :
|
||||
m_b(rdata.rateCoeffParameters[1]),
|
||||
m_E(rdata.rateCoeffParameters[2]),
|
||||
m_A(rdata.rateCoeffParameters[0]) {
|
||||
if (m_A <= 0.0) {
|
||||
m_logA = -1.0E300;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
*/
|
||||
|
||||
#include "cantera/kinetics/AqueousKinetics.h"
|
||||
#include "ReactionData.h"
|
||||
#include "cantera/kinetics/ReactionData.h"
|
||||
#include "cantera/kinetics/RateCoeffMgr.h"
|
||||
#include "cantera/base/stringUtils.h"
|
||||
|
||||
|
|
@ -523,7 +523,7 @@ getRevRateConstants(doublereal* krev, bool doIrreversible)
|
|||
}
|
||||
}
|
||||
|
||||
void AqueousKinetics::addReaction(const ReactionData& r)
|
||||
void AqueousKinetics::addReaction(ReactionData& r)
|
||||
{
|
||||
|
||||
if (r.reactionType == ELEMENTARY_RXN) {
|
||||
|
|
@ -540,14 +540,12 @@ void AqueousKinetics::addReaction(const ReactionData& r)
|
|||
|
||||
|
||||
|
||||
void AqueousKinetics::addElementaryReaction(const ReactionData& r)
|
||||
void AqueousKinetics::addElementaryReaction(ReactionData& r)
|
||||
{
|
||||
size_t iloc;
|
||||
|
||||
// install rate coeff calculator
|
||||
iloc = m_rates.install(reactionNumber(),
|
||||
r.rateCoeffType, r.rateCoeffParameters.size(),
|
||||
DATA_PTR(r.rateCoeffParameters));
|
||||
iloc = m_rates.install(reactionNumber(), r);
|
||||
|
||||
// add constant term to rate coeff value vector
|
||||
m_kdata->m_rfn.push_back(r.rateCoeffParameters[0]);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "cantera/kinetics/GRI_30_Kinetics.h"
|
||||
|
||||
#include "ReactionData.h"
|
||||
#include "cantera/kinetics/ReactionData.h"
|
||||
//#include "StoichManager.h"
|
||||
#include "cantera/kinetics/Enhanced3BConc.h"
|
||||
#include "cantera/kinetics/ThirdBodyMgr.h"
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "cantera/kinetics/GasKinetics.h"
|
||||
|
||||
#include "ReactionData.h"
|
||||
#include "cantera/kinetics/ReactionData.h"
|
||||
#include "cantera/kinetics/Enhanced3BConc.h"
|
||||
#include "cantera/kinetics/ThirdBodyMgr.h"
|
||||
#include "cantera/kinetics/RateCoeffMgr.h"
|
||||
|
|
@ -655,7 +655,7 @@ getRevRateConstants(doublereal* krev, bool doIrreversible)
|
|||
}
|
||||
//====================================================================================================================
|
||||
void GasKinetics::
|
||||
addReaction(const ReactionData& r)
|
||||
addReaction(ReactionData& r)
|
||||
{
|
||||
switch (r.reactionType) {
|
||||
case ELEMENTARY_RXN:
|
||||
|
|
@ -686,24 +686,15 @@ addReaction(const ReactionData& r)
|
|||
|
||||
//====================================================================================================================
|
||||
void GasKinetics::
|
||||
addFalloffReaction(const ReactionData& r)
|
||||
addFalloffReaction(ReactionData& r)
|
||||
{
|
||||
|
||||
// install high and low rate coeff calculators
|
||||
|
||||
size_t iloc = m_falloff_high_rates.install(m_nfall,
|
||||
r.rateCoeffType,
|
||||
r.rateCoeffParameters.size(),
|
||||
&r.rateCoeffParameters[0]);
|
||||
|
||||
m_falloff_low_rates.install(m_nfall,
|
||||
r.rateCoeffType, r.auxRateCoeffParameters.size(),
|
||||
DATA_PTR(r.auxRateCoeffParameters));
|
||||
|
||||
// add constant terms to high and low rate
|
||||
// coeff value vectors
|
||||
// and add constant terms to high and low rate coeff value vectors
|
||||
size_t iloc = m_falloff_high_rates.install(m_nfall, r);
|
||||
m_kdata->m_rfn_high.push_back(r.rateCoeffParameters[0]);
|
||||
m_kdata->m_rfn_low.push_back(r.auxRateCoeffParameters[0]);
|
||||
std::swap(r.rateCoeffParameters, r.auxRateCoeffParameters);
|
||||
m_falloff_low_rates.install(m_nfall, r);
|
||||
m_kdata->m_rfn_low.push_back(r.rateCoeffParameters[0]);
|
||||
|
||||
// add a dummy entry in m_rf, where computed falloff
|
||||
// rate coeff will be put
|
||||
|
|
@ -733,14 +724,12 @@ addFalloffReaction(const ReactionData& r)
|
|||
//====================================================================================================================
|
||||
|
||||
void GasKinetics::
|
||||
addElementaryReaction(const ReactionData& r)
|
||||
addElementaryReaction(ReactionData& r)
|
||||
{
|
||||
size_t iloc;
|
||||
|
||||
// install rate coeff calculator
|
||||
iloc = m_rates.install(reactionNumber(),
|
||||
r.rateCoeffType, r.rateCoeffParameters.size(),
|
||||
DATA_PTR(r.rateCoeffParameters));
|
||||
iloc = m_rates.install(reactionNumber(), r);
|
||||
|
||||
// add constant term to rate coeff value vector
|
||||
m_kdata->m_rfn.push_back(r.rateCoeffParameters[0]);
|
||||
|
|
@ -752,13 +741,11 @@ addElementaryReaction(const ReactionData& r)
|
|||
|
||||
//====================================================================================================================
|
||||
void GasKinetics::
|
||||
addThreeBodyReaction(const ReactionData& r)
|
||||
addThreeBodyReaction(ReactionData& r)
|
||||
{
|
||||
size_t iloc;
|
||||
// install rate coeff calculator
|
||||
iloc = m_rates.install(reactionNumber(),
|
||||
r.rateCoeffType, r.rateCoeffParameters.size(),
|
||||
DATA_PTR(r.rateCoeffParameters));
|
||||
iloc = m_rates.install(reactionNumber(), r);
|
||||
|
||||
// add constant term to rate coeff value vector
|
||||
m_kdata->m_rfn.push_back(r.rateCoeffParameters[0]);
|
||||
|
|
@ -772,12 +759,12 @@ addThreeBodyReaction(const ReactionData& r)
|
|||
}
|
||||
//====================================================================================================================
|
||||
|
||||
void GasKinetics::addPlogReaction(const ReactionData& r)
|
||||
void GasKinetics::addPlogReaction(ReactionData& r)
|
||||
{
|
||||
// @todo: Not yet implemented
|
||||
}
|
||||
|
||||
void GasKinetics::addChebyshevReaction(const ReactionData& r)
|
||||
void GasKinetics::addChebyshevReaction(ReactionData& r)
|
||||
{
|
||||
// @todo: Not yet implemented
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include "cantera/kinetics/EdgeKinetics.h"
|
||||
#include "cantera/thermo/SurfPhase.h"
|
||||
|
||||
#include "ReactionData.h"
|
||||
#include "cantera/kinetics/ReactionData.h"
|
||||
#include "cantera/kinetics/RateCoeffMgr.h"
|
||||
|
||||
#include "ImplicitSurfChem.h"
|
||||
|
|
@ -1049,7 +1049,7 @@ void InterfaceKinetics::getDeltaSSEntropy(doublereal* deltaS)
|
|||
* There is no difference between elementary and surface
|
||||
* reactions.
|
||||
*/
|
||||
void InterfaceKinetics::addReaction(const ReactionData& r)
|
||||
void InterfaceKinetics::addReaction(ReactionData& r)
|
||||
{
|
||||
|
||||
/*
|
||||
|
|
@ -1103,10 +1103,10 @@ void InterfaceKinetics::addReaction(const ReactionData& r)
|
|||
}
|
||||
}
|
||||
//====================================================================================================================
|
||||
void InterfaceKinetics::addElementaryReaction(const ReactionData& r)
|
||||
void InterfaceKinetics::addElementaryReaction(ReactionData& r)
|
||||
{
|
||||
// install rate coeff calculator
|
||||
vector_fp rp = r.rateCoeffParameters;
|
||||
vector_fp& rp = r.rateCoeffParameters;
|
||||
size_t ncov = r.cov.size();
|
||||
if (ncov > 3) {
|
||||
m_has_coverage_dependence = true;
|
||||
|
|
@ -1114,7 +1114,7 @@ void InterfaceKinetics::addElementaryReaction(const ReactionData& r)
|
|||
for (size_t m = 0; m < ncov; m++) {
|
||||
rp.push_back(r.cov[m]);
|
||||
}
|
||||
size_t iloc = m_rates.install(reactionNumber(), ARRHENIUS_REACTION_RATECOEFF_TYPE, rp.size(), DATA_PTR(rp));
|
||||
size_t iloc = m_rates.install(reactionNumber(), r);
|
||||
// store activation energy
|
||||
m_E.push_back(r.rateCoeffParameters[2]);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include "cantera/kinetics/ReactionStoichMgr.h"
|
||||
#include "StoichManager.h"
|
||||
#include "cantera/base/ctexceptions.h"
|
||||
#include "ReactionData.h"
|
||||
#include "cantera/kinetics/ReactionData.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
#include "cantera/thermo/SpeciesThermoFactory.h"
|
||||
#include "cantera/kinetics/KineticsFactory.h"
|
||||
#include "cantera/kinetics/reaction_defs.h"
|
||||
#include "ReactionData.h"
|
||||
#include "cantera/kinetics/ReactionData.h"
|
||||
#include "cantera/base/global.h"
|
||||
#include "cantera/base/stringUtils.h"
|
||||
|
||||
|
|
@ -508,11 +508,12 @@ void getRateCoefficient(const XML_Node& kf, Kinetics& kin,
|
|||
rdata.rateCoeffType = PLOG_REACTION_RATECOEFF_TYPE;
|
||||
for (size_t m = 0; m < kf.nChildren(); m++) {
|
||||
const XML_Node& node = kf.child(m);
|
||||
double A = getFloat(node, "A", "toSI");
|
||||
double b = getFloat(node, "b");
|
||||
double E = getFloat(node, "E", "actEnergy") / GasConstant;
|
||||
double p = getFloat(node, "P", "toSI");
|
||||
rdata.plogParameters[p] = Arrhenius(A, b, E);
|
||||
vector_fp& rate = rdata.plogParameters[p];
|
||||
rate.resize(3);
|
||||
rate[0] = getFloat(node, "A", "toSI");
|
||||
rate[1] = getFloat(node, "b");
|
||||
rate[2] = getFloat(node, "E", "actEnergy") / GasConstant;
|
||||
}
|
||||
|
||||
} else if (rdata.reactionType == CHEBYSHEV_RXN) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue