11BulkKinetics::BulkKinetics(ThermoPhase* thermo) :
20void BulkKinetics::resizeReactions()
22 Kinetics::resizeReactions();
24 m_multi_concm.resizeCoeffs(nTotalSpecies(), nReactions());
25 for (
auto& rates : m_bulk_rates) {
26 rates->resize(nTotalSpecies(), nReactions(), nPhases());
33bool BulkKinetics::isReversible(
size_t i) {
34 return std::find(m_revindex.begin(), m_revindex.end(), i) < m_revindex.end();
37void BulkKinetics::getDeltaGibbs(doublereal* deltaG)
40 thermo().getChemPotentials(m_grt.data());
42 getReactionDelta(m_grt.data(), deltaG);
45void BulkKinetics::getDeltaEnthalpy(doublereal* deltaH)
48 thermo().getPartialMolarEnthalpies(m_grt.data());
50 getReactionDelta(m_grt.data(), deltaH);
53void BulkKinetics::getDeltaEntropy(doublereal* deltaS)
56 thermo().getPartialMolarEntropies(m_grt.data());
58 getReactionDelta(m_grt.data(), deltaS);
61void BulkKinetics::getDeltaSSGibbs(doublereal* deltaG)
67 thermo().getStandardChemPotentials(m_grt.data());
69 getReactionDelta(m_grt.data(), deltaG);
72void BulkKinetics::getDeltaSSEnthalpy(doublereal* deltaH)
75 thermo().getEnthalpy_RT(m_grt.data());
76 for (
size_t k = 0; k < m_kk; k++) {
77 m_grt[k] *= thermo().RT();
80 getReactionDelta(m_grt.data(), deltaH);
83void BulkKinetics::getDeltaSSEntropy(doublereal* deltaS)
88 thermo().getEntropy_R(m_grt.data());
89 for (
size_t k = 0; k < m_kk; k++) {
93 getReactionDelta(m_grt.data(), deltaS);
96void BulkKinetics::getRevRateConstants(
double* krev,
bool doIrreversible)
100 getFwdRateConstants(krev);
102 if (doIrreversible) {
103 getEquilibriumConstants(m_ropnet.data());
104 for (
size_t i = 0; i < nReactions(); i++) {
105 krev[i] /= m_ropnet[i];
109 for (
size_t i = 0; i < nReactions(); i++) {
110 krev[i] *= m_rkcn[i];
115bool BulkKinetics::addReaction(shared_ptr<Reaction> r,
bool resize)
117 bool added = Kinetics::addReaction(r, resize);
123 for (
const auto& sp : r->products) {
126 for (
const auto& sp : r->reactants) {
133 m_revindex.push_back(nReactions()-1);
135 m_irrev.push_back(nReactions()-1);
138 if (!(r->usesLegacy())) {
139 shared_ptr<ReactionRate> rate = r->rate();
141 if (m_bulk_types.find(rate->type()) == m_bulk_types.end()) {
142 m_bulk_types[rate->type()] = m_bulk_rates.size();
143 m_bulk_rates.push_back(rate->newMultiRate());
144 m_bulk_rates.back()->resize(m_kk, nReactions(), nPhases());
148 rate->setRateIndex(nReactions() - 1);
149 rate->setContext(*r, *
this);
152 size_t index = m_bulk_types[rate->type()];
153 m_bulk_rates[index]->add(nReactions() - 1, *rate);
156 if (r->thirdBody() !=
nullptr) {
161 m_concm.push_back(NAN);
167void BulkKinetics::addThirdBody(shared_ptr<Reaction> r)
169 std::map<size_t, double> efficiencies;
170 for (
const auto& eff : r->thirdBody()->efficiencies) {
171 size_t k = kineticsSpeciesIndex(eff.first);
173 efficiencies[k] = eff.second;
174 }
else if (!m_skipUndeclaredThirdBodies) {
175 throw CanteraError(
"BulkKinetics::addThirdBody",
"Found "
176 "third-body efficiency for undefined species '" + eff.first +
177 "' while adding reaction '" + r->equation() +
"'");
180 m_multi_concm.install(nReactions() - 1, efficiencies,
181 r->thirdBody()->default_efficiency,
182 r->thirdBody()->mass_action);
185void BulkKinetics::addElementaryReaction(ElementaryReaction2& r)
187 m_rates.install(nReactions()-1, r.rate);
190void BulkKinetics::modifyReaction(
size_t i, shared_ptr<Reaction> rNew)
193 Kinetics::modifyReaction(i, rNew);
195 if (!(rNew->usesLegacy())) {
196 shared_ptr<ReactionRate> rate = rNew->rate();
198 if (m_bulk_types.find(rate->type()) == m_bulk_types.end()) {
200 "Evaluator not available for type '{}'.", rate->type());
204 size_t index = m_bulk_types[rate->type()];
205 rate->setRateIndex(i);
206 rate->setContext(*rNew, *
this);
208 m_bulk_rates[index]->replace(i, *rate);
216 m_rates.replace(i, rNew.rate);
219void BulkKinetics::resizeSpecies()
221 Kinetics::resizeSpecies();
222 m_act_conc.resize(m_kk);
223 m_phys_conc.resize(m_kk);
225 for (
auto& rates : m_bulk_rates) {
226 rates->resize(m_kk, nReactions(), nPhases());
230void BulkKinetics::setMultiplier(
size_t i,
double f) {
231 Kinetics::setMultiplier(i, f);
235void BulkKinetics::invalidateCache()
237 Kinetics::invalidateCache();
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
Base class for exceptions thrown by Cantera classes.
A reaction which follows mass-action kinetics with a modified Arrhenius reaction rate.
Namespace for the Cantera kernel.
const size_t npos
index returned by functions to indicate "no position"
const double GasConstant
Universal Gas Constant [J/kmol/K].