Cantera 2.6.0

GasKinetics.cpp
Go to the documentation of this file.
1/**
2 * @file GasKinetics.cpp Homogeneous kinetics in ideal gases
3 */
4
5// This file is part of Cantera. See License.txt in the top-level directory or
6// at https://cantera.org/license.txt for license and copyright information.
7
8#include "cantera/kinetics/GasKinetics.h"
9#include "cantera/thermo/ThermoPhase.h"
10
11 using namespace std;
12
13 namespace Cantera
14{
15 GasKinetics::GasKinetics(ThermoPhase* thermo) :
16 BulkKinetics(thermo),
17 m_logStandConc(0.0),
18 m_pres(0.0)
19{
20 setDerivativeSettings(AnyMap()); // use default settings
21}
22
23 void GasKinetics::resizeReactions()
24{
25 m_rbuf0.resize(nReactions());
26 m_rbuf1.resize(nReactions());
27 m_rbuf2.resize(nReactions());
28 m_sbuf0.resize(nTotalSpecies());
29 m_state.resize(thermo().stateSize());
30
31 BulkKinetics::resizeReactions();
32}
33
34 void GasKinetics::getThirdBodyConcentrations(double* concm)
35{
36 updateROP();
37 std::copy(m_concm.begin(), m_concm.end(), concm);
38}
39
40 void GasKinetics::update_rates_T()
41{
42 double T = thermo().temperature();
43 double P = thermo().pressure();
44 m_logStandConc = log(thermo().standardConcentration());
45 double logT = log(T);
46
47 if (T != m_temp) {
48 // Update forward rate constant for each reaction
49 if (!m_rfn.empty()) {
50 m_rates.update(T, logT, m_rfn.data());
51 }
52
53 // Falloff reactions (legacy)
54 if (!m_rfn_low.empty()) {
55 m_falloff_low_rates.update(T, logT, m_rfn_low.data());
56 m_falloff_high_rates.update(T, logT, m_rfn_high.data());
57 }
58 if (!falloff_work.empty()) {
59 m_falloffn.updateTemp(T, falloff_work.data());
60 }
61
62 updateKc();
63 m_ROP_ok = false;
64 }
65
66 // loop over MultiRate evaluators for each reaction type
67 for (auto& rates : m_bulk_rates) {
68 bool changed = rates->update(thermo(), *this);
69 if (changed) {
70 rates->getRateConstants(m_rfn.data());
71 m_ROP_ok = false;
72 }
73 }
74 if (T != m_temp || P != m_pres) {
75 // P-log reactions (legacy)
76 if (m_plog_rates.nReactions()) {
77 m_plog_rates.update(T, logT, m_rfn.data());
78 m_ROP_ok = false;
79 }
80
81 // Chebyshev reactions (legacy)
82 if (m_cheb_rates.nReactions()) {
83 m_cheb_rates.update(T, logT, m_rfn.data());
84 m_ROP_ok = false;
85 }
86 }
87 m_pres = P;
88 m_temp = T;
89}
90
91 void GasKinetics::update_rates_C()
92{
93 thermo().getActivityConcentrations(m_act_conc.data());
94 thermo().getConcentrations(m_phys_conc.data());
95 doublereal ctot = thermo().molarDensity();
96
97 // Third-body objects interacting with MultiRate evaluator
98 m_multi_concm.update(m_phys_conc, ctot, m_concm.data());
99
100 // 3-body reactions (legacy)
101 if (!concm_3b_values.empty()) {
102 m_3b_concm.update(m_phys_conc, ctot, concm_3b_values.data());
103 m_3b_concm.copy(concm_3b_values, m_concm.data());
104 }
105
106 // Falloff reactions (legacy)
107 if (!concm_falloff_values.empty()) {
108 m_falloff_concm.update(m_phys_conc, ctot, concm_falloff_values.data());
109 m_falloff_concm.copy(concm_falloff_values, m_concm.data());
110 }
111
112 // P-log reactions (legacy)
113 if (m_plog_rates.nReactions()) {
114 double logP = log(thermo().pressure());
115 m_plog_rates.update_C(&logP);
116 }
117
118 // Chebyshev reactions (legacy)
119 if (m_cheb_rates.nReactions()) {
120 double log10P = log10(thermo().pressure());
121 m_cheb_rates.update_C(&log10P);
122 }
123
124 m_ROP_ok = false;
125}
126
127 void GasKinetics::updateKc()
128{
129 thermo().getStandardChemPotentials(m_grt.data());
130 fill(m_delta_gibbs0.begin(), m_delta_gibbs0.end(), 0.0);
131
132 // compute Delta G^0 for all reversible reactions
133 getRevReactionDelta(m_grt.data(), m_delta_gibbs0.data());
134
135 double rrt = 1.0 / thermo().RT();
136 for (size_t i = 0; i < m_revindex.size(); i++) {
137 size_t irxn = m_revindex[i];
138 m_rkcn[irxn] = std::min(
139 exp(m_delta_gibbs0[irxn] * rrt - m_dn[irxn] * m_logStandConc),
140 BigNumber);
141 }
142
143 for (size_t i = 0; i != m_irrev.size(); ++i) {
144 m_rkcn[ m_irrev[i] ] = 0.0;
145 }
146}
147
148 void GasKinetics::processFwdRateCoefficients(double* ropf)
149{
150 update_rates_C();
151 update_rates_T();
152
153 // copy rate coefficients into ropf
154 copy(m_rfn.begin(), m_rfn.end(), ropf);
155
156 if (m_falloff_high_rates.nReactions()) {
157 processFalloffReactions(ropf);
158 }
159
160 // Scale the forward rate coefficient by the perturbation factor
161 for (size_t i = 0; i < nReactions(); ++i) {
162 ropf[i] *= m_perturb[i];
163 }
164}
165
166 void GasKinetics::processThirdBodies(double* rop)
167{
168 // multiply rop by enhanced 3b conc for all 3b rxns
169 if (!concm_3b_values.empty()) {
170 m_3b_concm.multiply(rop, concm_3b_values.data());
171 }
172
173 // reactions involving third body
174 if (!m_concm.empty()) {
175 m_multi_concm.multiply(rop, m_concm.data());
176 }
177}
178
179 void GasKinetics::processEquilibriumConstants(double* rop)
180{
181 // For reverse rates computed from thermochemistry, multiply the forward
182 // rate coefficients by the reciprocals of the equilibrium constants
183 for (size_t i = 0; i < nReactions(); ++i) {
184 rop[i] *= m_rkcn[i];
185 }
186}
187
188 void GasKinetics::getEquilibriumConstants(doublereal* kc)
189{
190 update_rates_T(); // this step ensures that m_grt is updated
191
192 vector_fp& delta_gibbs0 = m_rbuf0;
193 fill(delta_gibbs0.begin(), delta_gibbs0.end(), 0.0);
194
195 // compute Delta G^0 for all reactions
196 getReactionDelta(m_grt.data(), delta_gibbs0.data());
197
198 double rrt = 1.0 / thermo().RT();
199 for (size_t i = 0; i < nReactions(); i++) {
200 kc[i] = exp(-delta_gibbs0[i] * rrt + m_dn[i] * m_logStandConc);
201 }
202}
203
204 void GasKinetics::processFalloffReactions(double* ropf)
205{
206 // use m_ropr for temporary storage of reduced pressure
207 vector_fp& pr = m_ropr;
208
209 for (size_t i = 0; i < m_falloff_low_rates.nReactions(); i++) {
210 pr[i] = concm_falloff_values[i] * m_rfn_low[i] / (m_rfn_high[i] + SmallNumber);
211 AssertFinite(pr[i], "GasKinetics::processFalloffReactions",
212 "pr[{}] is not finite.", i);
213 }
214
215 m_falloffn.pr_to_falloff(pr.data(), falloff_work.data());
216
217 for (size_t i = 0; i < m_falloff_low_rates.nReactions(); i++) {
218 if (reactionTypeStr(m_fallindx[i]) == "falloff-legacy") {
219 pr[i] *= m_rfn_high[i];
220 } else { // CHEMACT_RXN
221 pr[i] *= m_rfn_low[i];
222 }
223 ropf[m_fallindx[i]] = pr[i];
224 }
225}
226
227 void GasKinetics::updateROP()
228{
229 processFwdRateCoefficients(m_ropf.data());
230 processThirdBodies(m_ropf.data());
231 copy(m_ropf.begin(), m_ropf.end(), m_ropr.begin());
232
233 // multiply ropf by concentration products
234 m_reactantStoich.multiply(m_act_conc.data(), m_ropf.data());
235
236 // for reversible reactions, multiply ropr by concentration products
237 processEquilibriumConstants(m_ropr.data());
238 m_revProductStoich.multiply(m_act_conc.data(), m_ropr.data());
239 for (size_t j = 0; j != nReactions(); ++j) {
240 m_ropnet[j] = m_ropf[j] - m_ropr[j];
241 }
242
243 for (size_t i = 0; i < m_rfn.size(); i++) {
244 AssertFinite(m_rfn[i], "GasKinetics::updateROP",
245 "m_rfn[{}] is not finite.", i);
246 AssertFinite(m_ropf[i], "GasKinetics::updateROP",
247 "m_ropf[{}] is not finite.", i);
248 AssertFinite(m_ropr[i], "GasKinetics::updateROP",
249 "m_ropr[{}] is not finite.", i);
250 }
251 m_ROP_ok = true;
252}
253
254 void GasKinetics::getFwdRateConstants(double* kfwd)
255{
256 processFwdRateCoefficients(m_ropf.data());
257
258 if (legacy_rate_constants_used()) {
259 warn_deprecated("GasKinetics::getFwdRateConstants",
260 "Behavior to change after Cantera 2.6;\nresults will no longer include "
261 "third-body concentrations for three-body reactions.\nTo switch to new "
262 "behavior, use 'cantera.use_legacy_rate_constants(False)' (Python),\n"
263 "'useLegacyRateConstants(0)' (MATLAB), 'Cantera::use_legacy_rate_constants"
264 "(false)' (C++),\nor 'ct_use_legacy_rate_constants(0)' (clib).");
265
266 processThirdBodies(m_ropf.data());
267 }
268
269 // copy result
270 copy(m_ropf.begin(), m_ropf.end(), kfwd);
271}
272
273 void GasKinetics::getDerivativeSettings(AnyMap& settings) const
274{
275 settings["skip-third-bodies"] = m_jac_skip_third_bodies;
276 settings["skip-falloff"] = m_jac_skip_falloff;
277 settings["rtol-delta"] = m_jac_rtol_delta;
278}
279
280 void GasKinetics::setDerivativeSettings(const AnyMap& settings)
281{
282 bool force = settings.empty();
283 if (force || settings.hasKey("skip-third-bodies")) {
284 m_jac_skip_third_bodies = settings.getBool("skip-third-bodies", false);
285 }
286 if (force || settings.hasKey("skip-falloff")) {
287 m_jac_skip_falloff = settings.getBool("skip-falloff", false);
288 }
289 if (force || settings.hasKey("rtol-delta")) {
290 m_jac_rtol_delta = settings.getDouble("rtol-delta", 1e-8);
291 }
292}
293
294 void GasKinetics::assertDerivativesValid(const std::string& name)
295{
296 if (m_legacy.size()) {
297 // Do not support legacy CTI/XML-based reaction rate evaluators
298 throw CanteraError(name, "Not supported for legacy (CTI/XML) input format.");
299 }
300
301 if (!thermo().isIdeal()) {
302 throw NotImplementedError(name,
303 "Not supported for non-ideal ThermoPhase models.");
304 }
305}
306
307 void GasKinetics::processEquilibriumConstants_ddT(double* drkcn)
308{
309 double T = thermo().temperature();
310 double P = thermo().pressure();
311 double rrt = 1. / thermo().RT();
312
313 vector_fp& grt = m_sbuf0;
314 vector_fp& delta_gibbs0 = m_rbuf1;
315 fill(delta_gibbs0.begin(), delta_gibbs0.end(), 0.0);
316
317 // compute perturbed Delta G^0 for all reversible reactions
318 thermo().saveState(m_state);
319 thermo().setState_TP(T * (1. + m_jac_rtol_delta), P);
320 thermo().getStandardChemPotentials(grt.data());
321 getRevReactionDelta(grt.data(), delta_gibbs0.data());
322
323 // apply scaling for derivative of inverse equilibrium constant
324 double Tinv = 1. / T;
325 double rrt_dTinv = rrt * Tinv / m_jac_rtol_delta;
326 double rrtt = rrt * Tinv;
327 for (size_t i = 0; i < m_revindex.size(); i++) {
328 size_t irxn = m_revindex[i];
329 double factor = delta_gibbs0[irxn] - m_delta_gibbs0[irxn];
330 factor *= rrt_dTinv;
331 factor += m_dn[irxn] * Tinv - m_delta_gibbs0[irxn] * rrtt;
332 drkcn[irxn] *= factor;
333 }
334
335 for (size_t i = 0; i < m_irrev.size(); ++i) {
336 drkcn[m_irrev[i]] = 0.0;
337 }
338
339 thermo().restoreState(m_state);
340}
341
342 void GasKinetics::process_ddT(const vector_fp& in, double* drop)
343{
344 // apply temperature derivative
345 copy(in.begin(), in.end(), drop);
346 for (auto& rates : m_bulk_rates) {
347 rates->processRateConstants_ddT(drop, m_rfn.data(), m_jac_rtol_delta);
348 }
349}
350
351 void GasKinetics::getFwdRateConstants_ddT(double* dkfwd)
352{
353 assertDerivativesValid("GasKinetics::getFwdRateConstants_ddT");
354 updateROP();
355 process_ddT(m_rfn, dkfwd);
356}
357
358 void GasKinetics::getFwdRatesOfProgress_ddT(double* drop)
359{
360 assertDerivativesValid("GasKinetics::getFwdRatesOfProgress_ddT");
361 updateROP();
362 process_ddT(m_ropf, drop);
363}
364
365 void GasKinetics::getRevRatesOfProgress_ddT(double* drop)
366{
367 assertDerivativesValid("GasKinetics::getRevRatesOfProgress_ddT");
368 updateROP();
369 process_ddT(m_ropr, drop);
370 Eigen::Map<Eigen::VectorXd> dRevRop(drop, nReactions());
371
372 // reverse rop times scaled inverse equilibrium constant derivatives
373 Eigen::Map<Eigen::VectorXd> dRevRop2(m_rbuf2.data(), nReactions());
374 copy(m_ropr.begin(), m_ropr.end(), m_rbuf2.begin());
375 processEquilibriumConstants_ddT(dRevRop2.data());
376 dRevRop += dRevRop2;
377}
378
379 void GasKinetics::getNetRatesOfProgress_ddT(double* drop)
380{
381 assertDerivativesValid("GasKinetics::getNetRatesOfProgress_ddT");
382 updateROP();
383 process_ddT(m_ropnet, drop);
384 Eigen::Map<Eigen::VectorXd> dNetRop(drop, nReactions());
385
386 // reverse rop times scaled inverse equilibrium constant derivatives
387 Eigen::Map<Eigen::VectorXd> dNetRop2(m_rbuf2.data(), nReactions());
388 copy(m_ropr.begin(), m_ropr.end(), m_rbuf2.begin());
389 processEquilibriumConstants_ddT(dNetRop2.data());
390 dNetRop -= dNetRop2;
391}
392
393 void GasKinetics::process_ddP(const vector_fp& in, double* drop)
394{
395 // apply pressure derivative
396 copy(in.begin(), in.end(), drop);
397 for (auto& rates : m_bulk_rates) {
398 rates->processRateConstants_ddP(drop, m_rfn.data(), m_jac_rtol_delta);
399 }
400}
401
402 void GasKinetics::getFwdRateConstants_ddP(double* dkfwd)
403{
404 assertDerivativesValid("GasKinetics::getFwdRateConstants_ddP");
405 updateROP();
406 process_ddP(m_rfn, dkfwd);
407}
408
409 void GasKinetics::getFwdRatesOfProgress_ddP(double* drop)
410{
411 assertDerivativesValid("GasKinetics::getFwdRatesOfProgress_ddP");
412 updateROP();
413 process_ddP(m_ropf, drop);
414}
415
416 void GasKinetics::getRevRatesOfProgress_ddP(double* drop)
417{
418 assertDerivativesValid("GasKinetics::getRevRatesOfProgress_ddP");
419 updateROP();
420 process_ddP(m_ropr, drop);
421}
422
423 void GasKinetics::getNetRatesOfProgress_ddP(double* drop)
424{
425 assertDerivativesValid("GasKinetics::getNetRatesOfProgress_ddP");
426 updateROP();
427 process_ddP(m_ropnet, drop);
428}
429
430 void GasKinetics::process_ddC(
431 StoichManagerN& stoich, const vector_fp& in,
432 double* drop, bool mass_action)
433{
434 Eigen::Map<Eigen::VectorXd> out(drop, nReactions());
435 out.setZero();
436 double ctot_inv = 1. / thermo().molarDensity();
437
438 // derivatives due to concentrations in law of mass action
439 if (mass_action) {
440 stoich.scale(in.data(), out.data(), ctot_inv);
441 }
442 if (m_jac_skip_third_bodies || m_multi_concm.empty()) {
443 return;
444 }
445
446 // derivatives due to third-body colliders in law of mass action
447 Eigen::Map<Eigen::VectorXd> outM(m_rbuf1.data(), nReactions());
448 if (mass_action) {
449 outM.fill(0.);
450 m_multi_concm.scale(in.data(), outM.data(), ctot_inv);
451 out += outM;
452 }
453
454 // derivatives due to reaction rates depending on third-body colliders
455 if (!m_jac_skip_falloff) {
456 m_multi_concm.scaleM(in.data(), outM.data(), m_concm.data(), ctot_inv);
457 for (auto& rates : m_bulk_rates) {
458 // processing step assigns zeros to entries not dependent on M
459 rates->processRateConstants_ddM(
460 outM.data(), m_rfn.data(), m_jac_rtol_delta);
461 }
462 out += outM;
463 }
464}
465
466 void GasKinetics::getFwdRateConstants_ddC(double* dkfwd)
467{
468 assertDerivativesValid("GasKinetics::getFwdRateConstants_ddC");
469 updateROP();
470 process_ddC(m_reactantStoich, m_rfn, dkfwd, false);
471}
472
473 void GasKinetics::getFwdRatesOfProgress_ddC(double* drop)
474{
475 assertDerivativesValid("GasKinetics::getFwdRatesOfProgress_ddC");
476 updateROP();
477 process_ddC(m_reactantStoich, m_ropf, drop);
478}
479
480 void GasKinetics::getRevRatesOfProgress_ddC(double* drop)
481{
482 assertDerivativesValid("GasKinetics::getRevRatesOfProgress_ddC");
483 updateROP();
484 return process_ddC(m_revProductStoich, m_ropr, drop);
485}
486
487 void GasKinetics::getNetRatesOfProgress_ddC(double* drop)
488{
489 assertDerivativesValid("GasKinetics::getNetRatesOfProgress_ddC");
490 updateROP();
491 process_ddC(m_reactantStoich, m_ropf, drop);
492 Eigen::Map<Eigen::VectorXd> dNetRop(drop, nReactions());
493
494 process_ddC(m_revProductStoich, m_ropr, m_rbuf2.data());
495 Eigen::Map<Eigen::VectorXd> dNetRop2(m_rbuf2.data(), nReactions());
496 dNetRop -= dNetRop2;
497}
498
499Eigen::SparseMatrix<double> GasKinetics::process_ddX(
500 StoichManagerN& stoich, const vector_fp& in)
501{
502 Eigen::SparseMatrix<double> out;
503 vector_fp& scaled = m_rbuf1;
504 vector_fp& outV = m_rbuf2;
505
506 // convert from concentration to mole fraction output
507 double ctot = thermo().molarDensity();
508 for (size_t i = 0; i < nReactions(); ++i) {
509 scaled[i] = ctot * in[i];
510 }
511
512 // derivatives handled by StoichManagerN
513 copy(scaled.begin(), scaled.end(), outV.begin());
514 processThirdBodies(outV.data());
515 out = stoich.derivatives(m_act_conc.data(), outV.data());
516 if (m_jac_skip_third_bodies || m_multi_concm.empty()) {
517 return out;
518 }
519
520 // derivatives due to law of mass action
521 copy(scaled.begin(), scaled.end(), outV.begin());
522 stoich.multiply(m_act_conc.data(), outV.data());
523
524 // derivatives due to reaction rates depending on third-body colliders
525 if (!m_jac_skip_falloff) {
526 for (auto& rates : m_bulk_rates) {
527 // processing step does not modify entries not dependent on M
528 rates->processRateConstants_ddM(
529 outV.data(), m_rfn.data(), m_jac_rtol_delta, false);
530 }
531 }
532
533 // derivatives handled by ThirdBodyCalc
534 out += m_multi_concm.derivatives(outV.data());
535
536 return out;
537}
538
539Eigen::SparseMatrix<double> GasKinetics::fwdRatesOfProgress_ddX()
540{
541 assertDerivativesValid("GasKinetics::fwdRatesOfProgress_ddX");
542
543 // forward reaction rate coefficients
544 vector_fp& rop_rates = m_rbuf0;
545 processFwdRateCoefficients(rop_rates.data());
546 return process_ddX(m_reactantStoich, rop_rates);
547}
548
549Eigen::SparseMatrix<double> GasKinetics::revRatesOfProgress_ddX()
550{
551 assertDerivativesValid("GasKinetics::revRatesOfProgress_ddX");
552
553 // reverse reaction rate coefficients
554 vector_fp& rop_rates = m_rbuf0;
555 processFwdRateCoefficients(rop_rates.data());
556 processEquilibriumConstants(rop_rates.data());
557 return process_ddX(m_revProductStoich, rop_rates);
558}
559
560Eigen::SparseMatrix<double> GasKinetics::netRatesOfProgress_ddX()
561{
562 assertDerivativesValid("GasKinetics::netRatesOfProgress_ddX");
563
564 // forward reaction rate coefficients
565 vector_fp& rop_rates = m_rbuf0;
566 processFwdRateCoefficients(rop_rates.data());
567 Eigen::SparseMatrix<double> jac = process_ddX(m_reactantStoich, rop_rates);
568
569 // reverse reaction rate coefficients
570 processEquilibriumConstants(rop_rates.data());
571 return jac - process_ddX(m_revProductStoich, rop_rates);
572}
573
574 bool GasKinetics::addReaction(shared_ptr<Reaction> r, bool resize)
575{
576 // operations common to all reaction types
577 bool added = BulkKinetics::addReaction(r, resize);
578 if (!added) {
579 return false;
580 } else if (!(r->usesLegacy())) {
581 // Rate object already added in BulkKinetics::addReaction
582 return true;
583 }
584
585 if (r->type() == "elementary-legacy") {
586 addElementaryReaction(dynamic_cast<ElementaryReaction2&>(*r));
587 } else if (r->type() == "three-body-legacy") {
588 addThreeBodyReaction(dynamic_cast<ThreeBodyReaction2&>(*r));
589 } else if (r->type() == "falloff-legacy") {
590 addFalloffReaction(dynamic_cast<FalloffReaction2&>(*r));
591 } else if (r->type() == "chemically-activated-legacy") {
592 addFalloffReaction(dynamic_cast<FalloffReaction2&>(*r));
593 } else if (r->type() == "pressure-dependent-Arrhenius-legacy") {
594 addPlogReaction(dynamic_cast<PlogReaction2&>(*r));
595 } else if (r->type() == "Chebyshev-legacy") {
596 addChebyshevReaction(dynamic_cast<ChebyshevReaction2&>(*r));
597 } else {
598 throw CanteraError("GasKinetics::addReaction",
599 "Unknown reaction type specified: '{}'", r->type());
600 }
601 m_legacy.push_back(nReactions() - 1);
602 return true;
603}
604
605 void GasKinetics::addFalloffReaction(FalloffReaction2& r)
606{
607 // install high and low rate coeff calculators and extend the high and low
608 // rate coeff value vectors
609 size_t nfall = m_falloff_high_rates.nReactions();
610 m_falloff_high_rates.install(nfall, r.high_rate);
611 m_rfn_high.push_back(0.0);
612 m_falloff_low_rates.install(nfall, r.low_rate);
613 m_rfn_low.push_back(0.0);
614
615 // add this reaction number to the list of falloff reactions
616 m_fallindx.push_back(nReactions()-1);
617 m_rfallindx[nReactions()-1] = nfall;
618
619 // install the enhanced third-body concentration calculator
620 map<size_t, double> efficiencies;
621 for (const auto& eff : r.third_body.efficiencies) {
622 size_t k = kineticsSpeciesIndex(eff.first);
623 if (k != npos) {
624 efficiencies[k] = eff.second;
625 }
626 }
627 m_falloff_concm.install(nfall, efficiencies,
628 r.third_body.default_efficiency,
629 nReactions() - 1);
630 concm_falloff_values.resize(m_falloff_concm.workSize());
631
632 // install the falloff function calculator for this reaction
633 m_falloffn.install(nfall, r.type(), r.falloff);
634 falloff_work.resize(m_falloffn.workSize());
635}
636
637 void GasKinetics::addThreeBodyReaction(ThreeBodyReaction2& r)
638{
639 m_rates.install(nReactions()-1, r.rate);
640 map<size_t, double> efficiencies;
641 for (const auto& eff : r.third_body.efficiencies) {
642 size_t k = kineticsSpeciesIndex(eff.first);
643 if (k != npos) {
644 efficiencies[k] = eff.second;
645 }
646 }
647 m_3b_concm.install(nReactions()-1, efficiencies,
648 r.third_body.default_efficiency);
649 concm_3b_values.resize(m_3b_concm.workSize());
650}
651
652 void GasKinetics::addPlogReaction(PlogReaction2& r)
653{
654 m_plog_rates.install(nReactions()-1, r.rate);
655}
656
657 void GasKinetics::addChebyshevReaction(ChebyshevReaction2& r)
658{
659 m_cheb_rates.install(nReactions()-1, r.rate);
660}
661
662 void GasKinetics::modifyReaction(size_t i, shared_ptr<Reaction> rNew)
663{
664 // operations common to all bulk reaction types
665 BulkKinetics::modifyReaction(i, rNew);
666
667 // invalidate all cached data
668 invalidateCache();
669
670 if (!(rNew->usesLegacy())) {
671 // Rate object already modified in BulkKinetics::modifyReaction
672 return;
673 }
674
675 if (rNew->type() == "elementary-legacy") {
676 modifyElementaryReaction(i, dynamic_cast<ElementaryReaction2&>(*rNew));
677 } else if (rNew->type() == "three-body-legacy") {
678 modifyThreeBodyReaction(i, dynamic_cast<ThreeBodyReaction2&>(*rNew));
679 } else if (rNew->type() == "falloff-legacy") {
680 modifyFalloffReaction(i, dynamic_cast<FalloffReaction2&>(*rNew));
681 } else if (rNew->type() == "chemically-activated-legacy") {
682 modifyFalloffReaction(i, dynamic_cast<FalloffReaction2&>(*rNew));
683 } else if (rNew->type() == "pressure-dependent-Arrhenius-legacy") {
684 modifyPlogReaction(i, dynamic_cast<PlogReaction2&>(*rNew));
685 } else if (rNew->type() == "Chebyshev-legacy") {
686 modifyChebyshevReaction(i, dynamic_cast<ChebyshevReaction2&>(*rNew));
687 } else {
688 throw CanteraError("GasKinetics::modifyReaction",
689 "Unknown reaction type specified: '{}'", rNew->type());
690 }
691}
692
693 void GasKinetics::modifyThreeBodyReaction(size_t i, ThreeBodyReaction2& r)
694{
695 m_rates.replace(i, r.rate);
696}
697
698 void GasKinetics::modifyFalloffReaction(size_t i, FalloffReaction2& r)
699{
700 size_t iFall = m_rfallindx[i];
701 m_falloff_high_rates.replace(iFall, r.high_rate);
702 m_falloff_low_rates.replace(iFall, r.low_rate);
703 m_falloffn.replace(iFall, r.falloff);
704}
705
706 void GasKinetics::modifyPlogReaction(size_t i, PlogReaction2& r)
707{
708 m_plog_rates.replace(i, r.rate);
709}
710
711 void GasKinetics::modifyChebyshevReaction(size_t i, ChebyshevReaction2& r)
712{
713 m_cheb_rates.replace(i, r.rate);
714}
715
716 void GasKinetics::invalidateCache()
717{
718 BulkKinetics::invalidateCache();
719 m_pres += 0.13579;
720}
721
722}
GasKinetics.h
ThermoPhase.h
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
Cantera::AnyMap
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:399
Cantera::AnyMap::empty
bool empty() const
Return boolean indicating whether AnyMap is empty.
Definition: AnyMap.cpp:1401
Cantera::AnyMap::getBool
bool getBool(const std::string &key, bool default_) const
If key exists, return it as a bool, otherwise return default_.
Definition: AnyMap.cpp:1487
Cantera::AnyMap::getDouble
double getDouble(const std::string &key, double default_) const
If key exists, return it as a double, otherwise return default_.
Definition: AnyMap.cpp:1492
Cantera::AnyMap::hasKey
bool hasKey(const std::string &key) const
Returns true if the map contains an item named key.
Definition: AnyMap.cpp:1406
Cantera::BulkKinetics
Partial specialization of Kinetics for chemistry in a single bulk phase.
Definition: BulkKinetics.h:24
Cantera::BulkKinetics::resizeReactions
virtual void resizeReactions()
Finalize Kinetics object and associated objects.
Definition: BulkKinetics.cpp:20
Cantera::BulkKinetics::m_act_conc
vector_fp m_act_conc
Activity concentrations, as calculated by ThermoPhase::getActivityConcentrations.
Definition: BulkKinetics.h:76
Cantera::BulkKinetics::m_revindex
std::vector< size_t > m_revindex
Indices of reversible reactions.
Definition: BulkKinetics.h:62
Cantera::BulkKinetics::m_bulk_rates
std::vector< unique_ptr< MultiRateBase > > m_bulk_rates
Vector of rate handlers.
Definition: BulkKinetics.h:58
Cantera::BulkKinetics::m_multi_concm
ThirdBodyCalc3 m_multi_concm
used with MultiRate evaluator
Definition: BulkKinetics.h:70
Cantera::BulkKinetics::m_dn
vector_fp m_dn
Difference between the global reactants order and the global products order.
Definition: BulkKinetics.h:68
Cantera::BulkKinetics::addReaction
virtual bool addReaction(shared_ptr< Reaction > r, bool resize=true)
Add a single reaction to the mechanism.
Definition: BulkKinetics.cpp:115
Cantera::BulkKinetics::m_irrev
std::vector< size_t > m_irrev
Indices of irreversible reactions.
Definition: BulkKinetics.h:63
Cantera::BulkKinetics::m_rates
Rate1< Arrhenius2 > m_rates
Definition: BulkKinetics.h:61
Cantera::BulkKinetics::modifyReaction
virtual void modifyReaction(size_t i, shared_ptr< Reaction > rNew)
Modify the rate expression associated with a reaction.
Definition: BulkKinetics.cpp:190
Cantera::BulkKinetics::m_concm
vector_fp m_concm
Third body concentrations.
Definition: BulkKinetics.h:73
Cantera::BulkKinetics::m_phys_conc
vector_fp m_phys_conc
Physical concentrations, as calculated by ThermoPhase::getConcentrations.
Definition: BulkKinetics.h:79
Cantera::CanteraError
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
Cantera::ChebyshevReaction2
A pressure-dependent reaction parameterized by a bi-variate Chebyshev polynomial in temperature and p...
Definition: Reaction.h:386
Cantera::ElementaryReaction2
A reaction which follows mass-action kinetics with a modified Arrhenius reaction rate.
Definition: Reaction.h:217
Cantera::FalloffMgr::workSize
size_t workSize()
Size of the work array required to store intermediate results.
Definition: FalloffMgr.h:85
Cantera::FalloffMgr::pr_to_falloff
void pr_to_falloff(doublereal *values, const doublereal *work)
Given a vector of reduced pressures for each falloff reaction, replace each entry by the value of the...
Definition: FalloffMgr.h:105
Cantera::FalloffMgr::install
void install(size_t rxn, int reactionType, shared_ptr< Falloff > f)
Install a new falloff function calculator.
Definition: FalloffMgr.h:45
Cantera::FalloffMgr::replace
void replace(size_t rxn, shared_ptr< Falloff > f)
Definition: FalloffMgr.h:80
Cantera::FalloffMgr::updateTemp
void updateTemp(doublereal t, doublereal *work)
Update the cached temperature-dependent intermediate results for all installed falloff functions.
Definition: FalloffMgr.h:95
Cantera::FalloffReaction2
A reaction that is first-order in [M] at low pressure, like a third-body reaction,...
Definition: Reaction.h:297
Cantera::FalloffReaction2::falloff
shared_ptr< FalloffRate > falloff
Falloff function which determines how low_rate and high_rate are combined to determine the rate const...
Definition: Reaction.h:327
Cantera::FalloffReaction2::high_rate
Arrhenius2 high_rate
The rate constant in the high-pressure limit.
Definition: Reaction.h:320
Cantera::FalloffReaction2::third_body
ThirdBody third_body
Relative efficiencies of third-body species in enhancing the reaction rate.
Definition: Reaction.h:323
Cantera::FalloffReaction2::type
virtual std::string type() const
The type of reaction.
Definition: Reaction.h:304
Cantera::FalloffReaction2::low_rate
Arrhenius2 low_rate
The rate constant in the low-pressure limit.
Definition: Reaction.h:317
Cantera::GasKinetics::processFalloffReactions
void processFalloffReactions(double *ropf)
Definition: GasKinetics.cpp:204
Cantera::GasKinetics::resizeReactions
virtual void resizeReactions()
Finalize Kinetics object and associated objects.
Definition: GasKinetics.cpp:23
Cantera::GasKinetics::process_ddX
Eigen::SparseMatrix< double > process_ddX(StoichManagerN &stoich, const vector_fp &in)
Process mole fraction derivative.
Definition: GasKinetics.cpp:499
Cantera::GasKinetics::getFwdRatesOfProgress_ddP
virtual void getFwdRatesOfProgress_ddP(double *drop)
Calculate derivatives for forward rates-of-progress with respect to pressure at constant temperature,...
Definition: GasKinetics.cpp:409
Cantera::GasKinetics::m_rfn_low
vector_fp m_rfn_low
Definition: GasKinetics.h:175
Cantera::GasKinetics::revRatesOfProgress_ddX
virtual Eigen::SparseMatrix< double > revRatesOfProgress_ddX()
Calculate derivatives for reverse rates-of-progress with respect to species mole fractions at constan...
Definition: GasKinetics.cpp:549
Cantera::GasKinetics::m_rfallindx
std::map< size_t, size_t > m_rfallindx
Map of reaction index to falloff reaction index (i.e indices in m_falloff_low_rates and m_falloff_hig...
Definition: GasKinetics.h:156
Cantera::GasKinetics::getFwdRateConstants
virtual void getFwdRateConstants(double *kfwd)
Return the forward rate constants.
Definition: GasKinetics.cpp:254
Cantera::GasKinetics::getDerivativeSettings
virtual void getDerivativeSettings(AnyMap &settings) const
Retrieve derivative settings.
Definition: GasKinetics.cpp:273
Cantera::GasKinetics::getFwdRateConstants_ddC
virtual void getFwdRateConstants_ddC(double *dkfwd)
Calculate derivatives for forward rate constants with respect to molar concentration at constant temp...
Definition: GasKinetics.cpp:466
Cantera::GasKinetics::m_falloff_low_rates
Rate1< Arrhenius2 > m_falloff_low_rates
Rate expressions for falloff reactions at the low-pressure limit.
Definition: GasKinetics.h:159
Cantera::GasKinetics::m_cheb_rates
Rate1< ChebyshevRate > m_cheb_rates
Definition: GasKinetics.h:170
Cantera::GasKinetics::getRevRatesOfProgress_ddP
virtual void getRevRatesOfProgress_ddP(double *drop)
Calculate derivatives for reverse rates-of-progress with respect to pressure at constant temperature,...
Definition: GasKinetics.cpp:416
Cantera::GasKinetics::m_pres
doublereal m_pres
Last pressure at which rates were evaluated.
Definition: GasKinetics.h:178
Cantera::GasKinetics::netRatesOfProgress_ddX
virtual Eigen::SparseMatrix< double > netRatesOfProgress_ddX()
Calculate derivatives for net rates-of-progress with respect to species mole fractions at constant te...
Definition: GasKinetics.cpp:560
Cantera::GasKinetics::addFalloffReaction
void addFalloffReaction(FalloffReaction2 &r)
Definition: GasKinetics.cpp:605
Cantera::GasKinetics::processFwdRateCoefficients
void processFwdRateCoefficients(double *ropf)
Calculate rate coefficients.
Definition: GasKinetics.cpp:148
Cantera::GasKinetics::m_plog_rates
Rate1< Plog > m_plog_rates
Definition: GasKinetics.h:169
Cantera::GasKinetics::getRevRatesOfProgress_ddC
virtual void getRevRatesOfProgress_ddC(double *drop)
Calculate derivatives for reverse rates-of-progress with respect to molar concentration at constant t...
Definition: GasKinetics.cpp:480
Cantera::GasKinetics::getNetRatesOfProgress_ddP
virtual void getNetRatesOfProgress_ddP(double *drop)
Calculate derivatives for net rates-of-progress with respect to pressure at constant temperature,...
Definition: GasKinetics.cpp:423
Cantera::GasKinetics::addPlogReaction
void addPlogReaction(PlogReaction2 &r)
Definition: GasKinetics.cpp:652
Cantera::GasKinetics::modifyFalloffReaction
void modifyFalloffReaction(size_t i, FalloffReaction2 &r)
Definition: GasKinetics.cpp:698
Cantera::GasKinetics::m_falloff_high_rates
Rate1< Arrhenius2 > m_falloff_high_rates
Rate expressions for falloff reactions at the high-pressure limit.
Definition: GasKinetics.h:162
Cantera::GasKinetics::modifyPlogReaction
void modifyPlogReaction(size_t i, PlogReaction2 &r)
Definition: GasKinetics.cpp:706
Cantera::GasKinetics::GasKinetics
GasKinetics(ThermoPhase *thermo=0)
Constructor.
Definition: GasKinetics.cpp:15
Cantera::GasKinetics::m_jac_skip_third_bodies
bool m_jac_skip_third_bodies
Derivative settings.
Definition: GasKinetics.h:193
Cantera::GasKinetics::addReaction
virtual bool addReaction(shared_ptr< Reaction > r, bool resize=true)
Add a single reaction to the mechanism.
Definition: GasKinetics.cpp:574
Cantera::GasKinetics::process_ddP
void process_ddP(const vector_fp &in, double *drop)
Process pressure derivative.
Definition: GasKinetics.cpp:393
Cantera::GasKinetics::assertDerivativesValid
void assertDerivativesValid(const std::string &name)
Helper function ensuring that all rate derivatives can be calculated.
Definition: GasKinetics.cpp:294
Cantera::GasKinetics::m_rfn_high
vector_fp m_rfn_high
Definition: GasKinetics.h:176
Cantera::GasKinetics::processEquilibriumConstants
void processEquilibriumConstants(double *rop)
Multiply rate with inverse equilibrium constant.
Definition: GasKinetics.cpp:179
Cantera::GasKinetics::updateKc
void updateKc()
Update the equilibrium constants in molar units.
Definition: GasKinetics.cpp:127
Cantera::GasKinetics::processThirdBodies
void processThirdBodies(double *rop)
Multiply rate with third-body collider concentrations.
Definition: GasKinetics.cpp:166
Cantera::GasKinetics::process_ddC
void process_ddC(StoichManagerN &stoich, const vector_fp &in, double *drop, bool mass_action=true)
Process concentration (molar density) derivative.
Definition: GasKinetics.cpp:430
Cantera::GasKinetics::concm_falloff_values
vector_fp concm_falloff_values
Definition: GasKinetics.h:181
Cantera::GasKinetics::getFwdRateConstants_ddT
virtual void getFwdRateConstants_ddT(double *dkfwd)
Calculate derivatives for forward rate constants with respect to temperature at constant pressure,...
Definition: GasKinetics.cpp:351
Cantera::GasKinetics::m_legacy
std::vector< size_t > m_legacy
Reaction index of each legacy reaction (old framework)
Definition: GasKinetics.h:152
Cantera::GasKinetics::m_3b_concm
ThirdBodyCalc m_3b_concm
Definition: GasKinetics.h:166
Cantera::GasKinetics::modifyReaction
virtual void modifyReaction(size_t i, shared_ptr< Reaction > rNew)
Modify the rate expression associated with a reaction.
Definition: GasKinetics.cpp:662
Cantera::GasKinetics::getThirdBodyConcentrations
virtual void getThirdBodyConcentrations(double *concm)
Return a vector of values of effective concentrations of third-body collision partners of any reactio...
Definition: GasKinetics.cpp:34
Cantera::GasKinetics::update_rates_C
virtual void update_rates_C()
Update properties that depend on concentrations.
Definition: GasKinetics.cpp:91
Cantera::GasKinetics::update_rates_T
virtual void update_rates_T()
Update temperature-dependent portions of reaction rates and falloff functions.
Definition: GasKinetics.cpp:40
Cantera::GasKinetics::getFwdRateConstants_ddP
virtual void getFwdRateConstants_ddP(double *dkfwd)
Calculate derivatives for forward rate constants with respect to pressure at constant temperature,...
Definition: GasKinetics.cpp:402
Cantera::GasKinetics::getFwdRatesOfProgress_ddT
virtual void getFwdRatesOfProgress_ddT(double *drop)
Calculate derivatives for forward rates-of-progress with respect to temperature at constant pressure,...
Definition: GasKinetics.cpp:358
Cantera::GasKinetics::m_fallindx
std::vector< size_t > m_fallindx
Reaction index of each falloff reaction.
Definition: GasKinetics.h:149
Cantera::GasKinetics::getEquilibriumConstants
virtual void getEquilibriumConstants(doublereal *kc)
Return a vector of Equilibrium constants.
Definition: GasKinetics.cpp:188
Cantera::GasKinetics::m_rbuf0
vector_fp m_rbuf0
Buffers for partial rop results with length nReactions()
Definition: GasKinetics.h:186
Cantera::GasKinetics::process_ddT
void process_ddT(const vector_fp &in, double *drop)
Process temperature derivative.
Definition: GasKinetics.cpp:342
Cantera::GasKinetics::getNetRatesOfProgress_ddT
virtual void getNetRatesOfProgress_ddT(double *drop)
Calculate derivatives for net rates-of-progress with respect to temperature at constant pressure,...
Definition: GasKinetics.cpp:379
Cantera::GasKinetics::getFwdRatesOfProgress_ddC
virtual void getFwdRatesOfProgress_ddC(double *drop)
Calculate derivatives for forward rates-of-progress with respect to molar concentration at constant t...
Definition: GasKinetics.cpp:473
Cantera::GasKinetics::setDerivativeSettings
virtual void setDerivativeSettings(const AnyMap &settings)
Set/modify derivative settings.
Definition: GasKinetics.cpp:280
Cantera::GasKinetics::modifyThreeBodyReaction
void modifyThreeBodyReaction(size_t i, ThreeBodyReaction2 &r)
Definition: GasKinetics.cpp:693
Cantera::GasKinetics::m_falloffn
FalloffMgr m_falloffn
Definition: GasKinetics.h:164
Cantera::GasKinetics::modifyChebyshevReaction
void modifyChebyshevReaction(size_t i, ChebyshevReaction2 &r)
Definition: GasKinetics.cpp:711
Cantera::GasKinetics::falloff_work
vector_fp falloff_work
Definition: GasKinetics.h:179
Cantera::GasKinetics::addChebyshevReaction
void addChebyshevReaction(ChebyshevReaction2 &r)
Definition: GasKinetics.cpp:657
Cantera::GasKinetics::addThreeBodyReaction
void addThreeBodyReaction(ThreeBodyReaction2 &r)
Definition: GasKinetics.cpp:637
Cantera::GasKinetics::getNetRatesOfProgress_ddC
virtual void getNetRatesOfProgress_ddC(double *drop)
Calculate derivatives for net rates-of-progress with respect to molar concentration at constant tempe...
Definition: GasKinetics.cpp:487
Cantera::GasKinetics::concm_3b_values
vector_fp concm_3b_values
Definition: GasKinetics.h:180
Cantera::GasKinetics::fwdRatesOfProgress_ddX
virtual Eigen::SparseMatrix< double > fwdRatesOfProgress_ddX()
Calculate derivatives for forward rates-of-progress with respect to species mole fractions at constan...
Definition: GasKinetics.cpp:539
Cantera::GasKinetics::processEquilibriumConstants_ddT
void processEquilibriumConstants_ddT(double *drkcn)
Multiply rate with scaled temperature derivatives of the inverse equilibrium constant.
Definition: GasKinetics.cpp:307
Cantera::GasKinetics::getRevRatesOfProgress_ddT
virtual void getRevRatesOfProgress_ddT(double *drop)
Calculate derivatives for reverse rates-of-progress with respect to temperature at constant pressure,...
Definition: GasKinetics.cpp:365
Cantera::GasKinetics::m_falloff_concm
ThirdBodyCalc m_falloff_concm
Definition: GasKinetics.h:167
Cantera::Kinetics::m_delta_gibbs0
vector_fp m_delta_gibbs0
Delta G^0 for all reactions.
Definition: Kinetics.h:1372
Cantera::Kinetics::thermo
ThermoPhase & thermo(size_t n=0)
This method returns a reference to the nth ThermoPhase object defined in this kinetics mechanism.
Definition: Kinetics.h:231
Cantera::Kinetics::getRevReactionDelta
virtual void getRevReactionDelta(const double *g, double *dg) const
Given an array of species properties 'g', return in array 'dg' the change in this quantity in the rev...
Definition: Kinetics.cpp:450
Cantera::Kinetics::m_ropnet
vector_fp m_ropnet
Net rate-of-progress for each reaction.
Definition: Kinetics.h:1384
Cantera::Kinetics::getReactionDelta
virtual void getReactionDelta(const double *property, double *deltaProperty) const
Change in species properties.
Definition: Kinetics.cpp:441
Cantera::Kinetics::m_perturb
vector_fp m_perturb
Vector of perturbation factors for each reaction's rate of progress vector.
Definition: Kinetics.h:1321
Cantera::Kinetics::m_rkcn
vector_fp m_rkcn
Reciprocal of the equilibrium constant in concentration units.
Definition: Kinetics.h:1375
Cantera::Kinetics::m_ropf
vector_fp m_ropf
Forward rate-of-progress for each reaction.
Definition: Kinetics.h:1378
Cantera::Kinetics::m_ropr
vector_fp m_ropr
Reverse rate-of-progress for each reaction.
Definition: Kinetics.h:1381
Cantera::Kinetics::m_revProductStoich
StoichManagerN m_revProductStoich
Stoichiometry manager for the products of reversible reactions.
Definition: Kinetics.h:1306
Cantera::Kinetics::nReactions
size_t nReactions() const
Number of reactions in the reaction mechanism.
Definition: Kinetics.h:139
Cantera::Kinetics::kineticsSpeciesIndex
size_t kineticsSpeciesIndex(size_t k, size_t n) const
The location of species k of phase n in species arrays.
Definition: Kinetics.h:265
Cantera::Kinetics::m_rfn
vector_fp m_rfn
Forward rate constant for each reaction.
Definition: Kinetics.h:1369
Cantera::Kinetics::reactionTypeStr
virtual std::string reactionTypeStr(size_t i) const
String specifying the type of reaction.
Definition: Kinetics.cpp:402
Cantera::Kinetics::m_reactantStoich
StoichManagerN m_reactantStoich
Stoichiometry manager for the reactants for each reaction.
Definition: Kinetics.h:1300
Cantera::Kinetics::nTotalSpecies
size_t nTotalSpecies() const
The total number of species in all phases participating in the kinetics mechanism.
Definition: Kinetics.h:243
Cantera::NotImplementedError
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:187
Cantera::Phase::getConcentrations
void getConcentrations(double *const c) const
Get the species concentrations (kmol/m^3).
Definition: Phase.cpp:596
Cantera::Phase::molarDensity
double molarDensity() const
Molar density (kmol/m^3).
Definition: Phase.cpp:671
Cantera::Phase::saveState
void saveState(vector_fp &state) const
Save the current internal state of the phase.
Definition: Phase.cpp:286
Cantera::Phase::temperature
doublereal temperature() const
Temperature (K).
Definition: Phase.h:654
Cantera::Phase::restoreState
void restoreState(const vector_fp &state)
Restore a state saved on a previous call to saveState.
Definition: Phase.cpp:310
Cantera::Phase::pressure
virtual double pressure() const
Return the thermodynamic pressure (Pa).
Definition: Phase.h:672
Cantera::PlogReaction2
A pressure-dependent reaction parameterized by logarithmically interpolating between Arrhenius rate e...
Definition: Reaction.h:365
Cantera::StoichManagerN
Definition: StoichManager.h:595
Cantera::StoichManagerN::derivatives
Eigen::SparseMatrix< double > derivatives(const double *conc, const double *rates)
Calculate derivatives with respect to species concentrations.
Definition: StoichManager.h:794
Cantera::StoichManagerN::scale
void scale(const double *in, double *out, double factor) const
Scale input by reaction order and factor.
Definition: StoichManager.h:809
Cantera::ThermoPhase
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:102
Cantera::ThermoPhase::setState_TP
virtual void setState_TP(doublereal t, doublereal p)
Set the temperature (K) and pressure (Pa)
Definition: ThermoPhase.cpp:138
Cantera::ThermoPhase::RT
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
Definition: ThermoPhase.h:782
Cantera::ThermoPhase::getActivityConcentrations
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
Definition: ThermoPhase.h:404
Cantera::ThermoPhase::getStandardChemPotentials
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
Definition: ThermoPhase.h:580
Cantera::ThirdBodyCalc3::scaleM
void scaleM(const double *in, double *out, const double *concm, double factor) const
Scale entries involving third-body collider in rate expression by third-body concentration and factor...
Definition: ThirdBodyCalc.h:181
Cantera::ThirdBodyCalc3::update
void update(const vector_fp &conc, double ctot, double *concm) const
Update third-body concentrations in full vector.
Definition: ThirdBodyCalc.h:144
Cantera::ThirdBodyCalc3::empty
bool empty() const
Return boolean indicating whether ThirdBodyCalc3 is empty.
Definition: ThirdBodyCalc.h:191
Cantera::ThirdBodyCalc3::multiply
void multiply(double *output, const double *concm)
Multiply output with effective third-body concentration.
Definition: ThirdBodyCalc.h:155
Cantera::ThirdBodyCalc3::derivatives
Eigen::SparseMatrix< double > derivatives(const double *product)
Calculate derivatives with respect to species concentrations.
Definition: ThirdBodyCalc.h:166
Cantera::ThirdBodyCalc3::scale
void scale(const double *in, double *out, double factor) const
Scale entries involving third-body collider in law of mass action by factor.
Definition: ThirdBodyCalc.h:172
Cantera::ThirdBodyCalc::copy
void copy(const vector_fp &work, double *concm)
Update third-body concentrations in full vector.
Definition: ThirdBodyCalc.h:52
Cantera::ThirdBody::default_efficiency
double default_efficiency
The default third body efficiency for species not listed in efficiencies.
Definition: Reaction.h:255
Cantera::ThirdBody::efficiencies
Composition efficiencies
Map of species to third body efficiency.
Definition: Reaction.h:251
Cantera::ThreeBodyReaction2
A reaction with a non-reacting third body "M" that acts to add or remove energy from the reacting spe...
Definition: Reaction.h:269
Cantera::ThreeBodyReaction2::third_body
ThirdBody third_body
Relative efficiencies of third-body species in enhancing the reaction rate.
Definition: Reaction.h:286
AssertFinite
#define AssertFinite(expr, procedure,...)
Throw an exception if the specified exception is not a finite number.
Definition: ctexceptions.h:278
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:557
Cantera::npos
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:192
Cantera::warn_deprecated
void warn_deprecated(const std::string &source, const AnyBase &node, const std::string &message)
A deprecation warning for syntax in an input file.
Definition: AnyMap.cpp:1901
Cantera::SmallNumber
const double SmallNumber
smallest number to compare to zero.
Definition: ct_defs.h:153
Cantera::legacy_rate_constants_used
bool legacy_rate_constants_used()
Returns true if legacy rate constant definition should be used.
Definition: global.cpp:109
Cantera::vector_fp
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:184
Cantera::BigNumber
const double BigNumber
largest number to compare to inf.
Definition: ct_defs.h:155