20 ReactionStoichMgr::ReactionStoichMgr()
23 "To be removed after Cantera 2.2.");
24 m_dummy.resize(10,1.0);
28 m_reactants(right.m_reactants),
29 m_revproducts(right.m_revproducts),
30 m_irrevproducts(right.m_irrevproducts),
31 m_dummy(right.m_dummy)
35 ReactionStoichMgr& ReactionStoichMgr::operator=(
const ReactionStoichMgr& right)
39 m_reactants = right.m_reactants;
40 m_revproducts = right.m_revproducts;
41 m_irrevproducts = right.m_irrevproducts;
42 m_dummy = right.m_dummy;
48 const std::vector<size_t>& products,
52 m_reactants.add(rxn, reactants);
55 m_revproducts.add(rxn, products);
57 m_irrevproducts.add(rxn, products);
65 std::vector<size_t> rk;
67 doublereal oo, os, of;
68 bool doGlobal =
false;
69 std::vector<size_t> extReactants = r.
reactants;
94 for (
size_t kk = 0; kk < r.
reactants.size(); kk++) {
104 for (k = 0; k < nsp; k++) {
107 if (kHandled[k] == 0) {
111 extReactants.push_back(k);
112 extROrder.push_back(of);
113 extRStoich.push_back(0.0);
120 for (
size_t n = 0; n < r.
reactants.size(); n++) {
121 size_t ns = size_t(r.
rstoich[n]);
126 for (
size_t m = 0; m < ns; m++) {
137 m_reactants.add(rxn, extReactants, extROrder, extRStoich);
142 if (isfrac || r.
global || rk.size() > 3) {
145 m_reactants.add(rxn, rk);
149 std::vector<size_t> pk;
151 for (
size_t n = 0; n < r.
products.size(); n++) {
152 size_t ns = size_t(r.
pstoich[n]);
157 for (
size_t m = 0; m < ns; m++) {
169 m_revproducts.add(rxn, pk);
175 if (isfrac || pk.size() > 3) {
178 m_irrevproducts.add(rxn, pk);
184 const doublereal* ropr, doublereal* c)
187 fill(c, c + nsp, 0.0);
190 m_revproducts.incrementSpecies(ropf, c);
191 m_irrevproducts.incrementSpecies(ropf, c);
194 m_reactants.incrementSpecies(ropr, c);
198 const doublereal* ropr,
201 fill(d, d + nsp, 0.0);
203 m_revproducts.incrementSpecies(ropr, d);
205 m_reactants.incrementSpecies(ropf, d);
209 const doublereal* ropnet,
212 fill(w, w + nsp, 0.0);
214 m_revproducts.incrementSpecies(ropnet, w);
215 m_irrevproducts.incrementSpecies(ropnet, w);
217 m_reactants.decrementSpecies(ropnet, w);
223 fill(dg, dg + nr, 0.0);
225 m_revproducts.incrementReactions(g, dg);
226 m_irrevproducts.incrementReactions(g, dg);
228 m_reactants.decrementReactions(g, dg);
234 fill(dg, dg + nr, 0.0);
235 m_revproducts.incrementReactions(g, dg);
236 m_reactants.decrementReactions(g, dg);
241 m_reactants.multiply(c, r);
246 m_revproducts.multiply(c, r);
251 ofstream f(filename.c_str());
252 f <<
"namespace mech {" << endl;
258 f <<
"} // namespace mech" << endl;
264 f <<
" void getCreationRates(const doublereal* rf, const doublereal* rb," << endl;
265 f <<
" doublereal* c) {" << endl;
266 map<size_t, string> out;
267 m_revproducts.writeIncrementSpecies(
"rf",out);
268 m_irrevproducts.writeIncrementSpecies(
"rf",out);
269 m_reactants.writeIncrementSpecies(
"rb",out);
270 map<size_t, string>::iterator b;
271 for (b = out.begin(); b != out.end(); ++b) {
274 f <<
" c[" << b->first <<
"] " << rhs <<
";" << endl;
276 f <<
" }" << endl << endl << endl;
281 f <<
" void getDestructionRates(const doublereal* rf, const doublereal* rb," << endl;
282 f <<
" doublereal* d) {" << endl;
283 map<size_t, string> out;
284 m_revproducts.writeIncrementSpecies(
"rb",out);
285 m_reactants.writeIncrementSpecies(
"rf",out);
286 map<size_t, string>::iterator b;
287 for (b = out.begin(); b != out.end(); ++b) {
290 f <<
" d[" << b->first <<
"] " << rhs <<
";" << endl;
292 f <<
" }" << endl << endl << endl;
297 f <<
" void getNetProductionRates(const doublereal* r, doublereal* w) {" << endl;
298 map<size_t, string> out;
299 m_revproducts.writeIncrementSpecies(
"r",out);
300 m_irrevproducts.writeIncrementSpecies(
"r",out);
301 m_reactants.writeDecrementSpecies(
"r",out);
302 map<size_t, string>::iterator b;
303 for (b = out.begin(); b != out.end(); ++b) {
306 f <<
" w[" << b->first <<
"] " << rhs <<
";" << endl;
308 f <<
" }" << endl << endl << endl;
313 f <<
" void multiplyReactants(const doublereal* c, doublereal* r) {" << endl;
314 map<size_t, string> out;
315 m_reactants.writeMultiply(
"c",out);
316 map<size_t, string>::iterator b;
317 for (b = out.begin(); b != out.end(); ++b) {
318 string rhs = b->second;
319 f <<
" r[" << b->first <<
"] *= " << rhs <<
";" << endl;
321 f <<
" }" << endl << endl << endl;
326 f <<
" void multiplyRevProducts(const doublereal* c, doublereal* r) {" << endl;
327 map<size_t, string> out;
328 m_revproducts.writeMultiply(
"c",out);
329 map<size_t, string>::iterator b;
330 for (b = out.begin(); b != out.end(); ++b) {
331 string rhs = b->second;
332 f <<
" r[" << b->first <<
"] *= " << rhs <<
";" << endl;
334 f <<
" }" << endl << endl << endl;
virtual void getNetProductionRates(size_t nsp, const doublereal *ropnet, doublereal *w)
Species net production rates.
void writeDestructionRates(std::ostream &f)
virtual void getDestructionRates(size_t nSpecies, const doublereal *fwdRatesOfProgress, const doublereal *revRatesOfProgress, doublereal *destructionRates)
Species destruction rates.
vector_fp forwardFullOrder_
Reaction order for the forward direction of the reaction.
void writeMultiplyReactants(std::ostream &f)
virtual void getCreationRates(size_t nSpecies, const doublereal *fwdRatesOfProgress, const doublereal *revRatesOfProgress, doublereal *creationRates)
Species creation rates.
Header file declaring class ReactionStoichMgr.
virtual void getRevReactionDelta(size_t nr, const doublereal *g, doublereal *dg)
Given an array of species properties 'g', return in array 'dg' the change in this quantity in the rev...
void writeNetProductionRates(std::ostream &f)
vector_fp pstoich
Product stoichiometric coefficients, in the order given by products.
virtual void getReactionDelta(size_t nReactions, const doublereal *g, doublereal *dg)
Calculates the change of a molar species property in a reaction.
vector_fp porder
Reaction order of the reverse reaction with respect to each product species, in the order given by pr...
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
bool isReversibleWithFrac
Some reactions can be elementary reactions but have fractional stoichiometries with respect to some p...
std::vector< int > vector_int
Vector of ints.
void writeMultiplyRevProducts(std::ostream &f)
std::vector< size_t > products
Indices of product species.
virtual void multiplyReactants(const doublereal *C, doublereal *R)
Given an array of concentrations C, multiply the entries in array R by the concentration products for...
void writeCreationRates(std::ostream &f)
virtual void write(const std::string &filename)
Intermediate class which stores data about a reaction and its rate parameterization before adding the...
Reaction mechanism stoichiometry manager.
std::vector< size_t > reactants
Indices of reactant species.
vector_fp rstoich
Reactant stoichiometric coefficients, in the order given by reactants.
std::string wrapString(const std::string &s, const int len)
Line wrap a string via a copy operation.
bool reversible
True if the current reaction is reversible. False otherwise.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
virtual void multiplyRevProducts(const doublereal *c, doublereal *r)
Given an array of concentrations C, multiply the entries in array R by the concentration products for...
bool global
True for "global" reactions which do not follow elementary mass action kinetics, i.e.
vector_fp rorder
Reaction order with respect to each reactant species, in the order given by reactants.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
virtual void add(size_t rxn, const std::vector< size_t > &reactants, const std::vector< size_t > &products, bool reversible)
Add a reaction with mass-action kinetics.