void InterfaceKinetics:: addElementaryReaction(const ReactionData& r) { int iloc; // install rate coeff calculator vector_fp rp = r.rateCoeffParameters; int ncov = r.cov.size(); if (ncov > 3) { m_has_coverage_dependence = true; } for (int m = 0; m < ncov; m++) rp.push_back(r.cov[m]); iloc = m_rates.install( reactionNumber(), r.rateCoeffType, rp.size(), DATA_PTR(rp) ); // store activation energy m_E.push_back(r.rateCoeffParameters[2]); if (r.beta > 0.0) { m_has_electrochem_rxns = true; m_beta.push_back(r.beta); m_ctrxn.push_back(reactionNumber()); } // add constant term to rate coeff value vector m_kdata->m_rfn.push_back(r.rateCoeffParameters[0]); registerReaction( reactionNumber(), ELEMENTARY_RXN, iloc); }
//==================================================================================================================== void InterfaceKinetics::addElementaryReaction(const ReactionData& r) { int iloc; // install rate coeff calculator vector_fp rp = r.rateCoeffParameters; int ncov = r.cov.size(); if (ncov > 3) { m_has_coverage_dependence = true; } for (int m = 0; m < ncov; m++) { rp.push_back(r.cov[m]); } // iloc = m_rates.install(reactionNumber(), r.rateCoeffType, rp.size(), DATA_PTR(rp)); iloc = m_rates.install(reactionNumber(), ARRHENIUS_REACTION_RATECOEFF_TYPE, rp.size(), DATA_PTR(rp)); // store activation energy m_E.push_back(r.rateCoeffParameters[2]); if (r.beta > 0.0) { m_has_electrochem_rxns = true; m_beta.push_back(r.beta); m_ctrxn.push_back(reactionNumber()); if (r.rateCoeffType == EXCHANGE_CURRENT_REACTION_RATECOEFF_TYPE) { m_has_exchange_current_density_formulation = true; m_ctrxn_ecdf.push_back(1); } else { m_ctrxn_ecdf.push_back(0); } } // add constant term to rate coeff value vector m_kdata->m_rfn.push_back(r.rateCoeffParameters[0]); registerReaction( reactionNumber(), ELEMENTARY_RXN, iloc); }
void GasKinetics::installGroups(size_t irxn, const vector<grouplist_t>& r, const vector<grouplist_t>& p) { if (!r.empty()) { writelog("installing groups for reaction "+int2str(reactionNumber())); m_rgroups[reactionNumber()] = r; m_pgroups[reactionNumber()] = p; } }
void GasKinetics::addChebyshevReaction(ReactionData& r) { // install rate coefficient calculator size_t iloc = m_cheb_rates.install(reactionNumber(), r); // add a dummy entry in m_rfn, where computed rate coeff will be put m_rfn.push_back(0.0); m_fwdOrder.push_back(r.reactants.size()); registerReaction(reactionNumber(), CHEBYSHEV_RXN, iloc); }
void GasKinetics:: addElementaryReaction(ReactionData& r) { // install rate coeff calculator size_t iloc = m_rates.install(reactionNumber(), r); // add constant term to rate coeff value vector m_rfn.push_back(r.rateCoeffParameters[0]); // forward rxn order equals number of reactants m_fwdOrder.push_back(r.reactants.size()); registerReaction(reactionNumber(), ELEMENTARY_RXN, iloc); }
//==================================================================================================================== void GasKinetics:: addThreeBodyReaction(ReactionData& r) { // install rate coeff calculator size_t iloc = m_rates.install(reactionNumber(), r); // add constant term to rate coeff value vector m_rfn.push_back(r.rateCoeffParameters[0]); // forward rxn order equals number of reactants + 1 m_fwdOrder.push_back(r.reactants.size() + 1); m_3b_concm.install(reactionNumber(), r.thirdBodyEfficiencies, r.default_3b_eff); registerReaction(reactionNumber(), THREE_BODY_RXN, iloc); }
//==================================================================================================================== void GasKinetics:: addReaction(ReactionData& r) { switch (r.reactionType) { case ELEMENTARY_RXN: addElementaryReaction(r); break; case THREE_BODY_RXN: addThreeBodyReaction(r); break; case FALLOFF_RXN: addFalloffReaction(r); break; case PLOG_RXN: addPlogReaction(r); break; case CHEBYSHEV_RXN: addChebyshevReaction(r); break; default: throw CanteraError("GasKinetics::addReaction", "Invalid reaction type specified"); } // operations common to all reaction types installReagents(r); installGroups(reactionNumber(), r.rgroups, r.pgroups); incrementRxnCount(); m_rxneqn.push_back(r.equation); }
void AqueousKinetics::addReaction(ReactionData& r) { if (r.reactionType == ELEMENTARY_RXN) { addElementaryReaction(r); } // operations common to all reaction types installReagents(r); installGroups(reactionNumber(), r.rgroups, r.pgroups); incrementRxnCount(); m_rxneqn.push_back(r.equation); }
//==================================================================================================================== void GasKinetics:: addFalloffReaction(ReactionData& r) { // install high and low rate coeff calculators // and add constant terms to high and low rate coeff value vectors size_t iloc = m_falloff_high_rates.install(m_nfall, r); m_rfn_high.push_back(r.rateCoeffParameters[0]); std::swap(r.rateCoeffParameters, r.auxRateCoeffParameters); m_falloff_low_rates.install(m_nfall, r); m_rfn_low.push_back(r.rateCoeffParameters[0]); // add a dummy entry in m_rf, where computed falloff // rate coeff will be put m_rfn.push_back(0.0); // add this reaction number to the list of // falloff reactions m_fallindx.push_back(reactionNumber()); // install the enhanced third-body concentration // calculator for this reaction m_falloff_concm.install(m_nfall, r.thirdBodyEfficiencies, r.default_3b_eff); // install the falloff function calculator for // this reaction m_falloffn.install(m_nfall, r.falloffType, r.falloffParameters); // forward rxn order equals number of reactants, since rate // coeff is defined in terms of the high-pressure limit m_fwdOrder.push_back(r.reactants.size()); // increment the falloff reaction counter ++m_nfall; registerReaction(reactionNumber(), FALLOFF_RXN, iloc); }
void InterfaceKinetics::installReagents(const ReactionData& r) { int n, ns, m; doublereal nsFlt; /* * extend temporary storage by one for this rxn. */ m_kdata->m_ropf.push_back(0.0); m_kdata->m_ropr.push_back(0.0); m_kdata->m_ropnet.push_back(0.0); m_kdata->m_rkcn.push_back(0.0); /* * Obtain the current reaction index for the reaction that we * are adding. The first reaction is labeled 0. */ int rnum = reactionNumber(); // vectors rk and pk are lists of species numbers, with // repeated entries for species with stoichiometric // coefficients > 1. This allows the reaction to be defined // with unity reaction order for each reactant, and so the // faster method 'multiply' can be used to compute the rate of // progress instead of 'power'. vector_int rk; int nr = r.reactants.size(); for (n = 0; n < nr; n++) { nsFlt = r.rstoich[n]; ns = (int) nsFlt; if ((doublereal) ns != nsFlt) { if (ns < 1) ns = 1; } /* * Add to m_rrxn. m_rrxn is a vector of maps. m_rrxn has a length * equal to the total number of species for each species, there * exists a map, with the reaction number being the key, and the * reactant stoichiometric coefficient being the value. */ m_rrxn[r.reactants[n]][rnum] = nsFlt; for (m = 0; m < ns; m++) { rk.push_back(r.reactants[n]); } } /* * Now that we have rk[], we add it into the vector<vector_int> m_reactants * in the rnum index spot. Thus m_reactants[rnum] yields a vector * of reactants for the rnum'th reaction */ m_reactants.push_back(rk); vector_int pk; int np = r.products.size(); for (n = 0; n < np; n++) { nsFlt = r.pstoich[n]; ns = (int) nsFlt; if ((doublereal) ns != nsFlt) { if (ns < 1) ns = 1; } /* * Add to m_prxn. m_prxn is a vector of maps. m_prxn has a length * equal to the total number of species for each species, there * exists a map, with the reaction number being the key, and the * product stoichiometric coefficient being the value. */ m_prxn[r.products[n]][rnum] = nsFlt; for (m = 0; m < ns; m++) { pk.push_back(r.products[n]); } } /* * Now that we have pk[], we add it into the vector<vector_int> m_products * in the rnum index spot. Thus m_products[rnum] yields a vector * of products for the rnum'th reaction */ m_products.push_back(pk); /* * Add this reaction to the stoichiometric coefficient manager. This * calculates rates of species production from reaction rates of * progress. */ m_rxnstoich.add( reactionNumber(), r); /* * register reaction in lists of reversible and irreversible rxns. */ if (r.reversible) { m_revindex.push_back(reactionNumber()); m_nrev++; } else { m_irrev.push_back( reactionNumber() ); m_nirrev++; } }
void GasKinetics::installReagents(const ReactionData& r) { m_ropf.push_back(0.0); // extend by one for new rxn m_ropr.push_back(0.0); m_ropnet.push_back(0.0); size_t n, ns, m; doublereal nsFlt; doublereal reactantGlobalOrder = 0.0; doublereal productGlobalOrder = 0.0; size_t rnum = reactionNumber(); std::vector<size_t> rk; size_t nr = r.reactants.size(); for (n = 0; n < nr; n++) { nsFlt = r.rstoich[n]; reactantGlobalOrder += nsFlt; ns = (size_t) nsFlt; if ((doublereal) ns != nsFlt) { if (ns < 1) { ns = 1; } } if (r.rstoich[n] != 0.0) { m_rrxn[r.reactants[n]][rnum] += r.rstoich[n]; } for (m = 0; m < ns; m++) { rk.push_back(r.reactants[n]); } } m_reactants.push_back(rk); std::vector<size_t> pk; size_t np = r.products.size(); for (n = 0; n < np; n++) { nsFlt = r.pstoich[n]; productGlobalOrder += nsFlt; ns = (size_t) nsFlt; if ((double) ns != nsFlt) { if (ns < 1) { ns = 1; } } if (r.pstoich[n] != 0.0) { m_prxn[r.products[n]][rnum] += r.pstoich[n]; } for (m = 0; m < ns; m++) { pk.push_back(r.products[n]); } } m_products.push_back(pk); m_rkcn.push_back(0.0); m_rxnstoich.add(reactionNumber(), r); if (r.reversible) { m_dn.push_back(productGlobalOrder - reactantGlobalOrder); m_revindex.push_back(reactionNumber()); m_nrev++; } else { m_dn.push_back(productGlobalOrder - reactantGlobalOrder); m_irrev.push_back(reactionNumber()); m_nirrev++; } }