Cantera 2.6.0
ReactionRateFactory.cpp
Go to the documentation of this file.
1 /**
2 * @file ReactionRateFactory.cpp
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
12#include "cantera/kinetics/Falloff.h"
18#include "cantera/base/AnyMap.h"
19
20namespace Cantera
21{
22
23ReactionRateFactory* ReactionRateFactory::s_factory = 0;
25
27{
28 // ArrheniusRate evaluator
29 reg("Arrhenius", [](const AnyMap& node, const UnitStack& rate_units) {
30 return new ArrheniusRate(node, rate_units);
31 });
32 addAlias("Arrhenius", "");
33 addAlias("Arrhenius", "elementary");
34 addAlias("Arrhenius", "three-body");
35
36 // TwoTempPlasmaRate evaluator
37 reg("two-temperature-plasma", [](const AnyMap& node, const UnitStack& rate_units) {
38 return new TwoTempPlasmaRate(node, rate_units);
39 });
40
41 // BlowersMaselRate evaluator
42 reg("Blowers-Masel", [](const AnyMap& node, const UnitStack& rate_units) {
43 return new BlowersMaselRate(node, rate_units);
44 });
45
46 // Lindemann falloff evaluator
47 reg("Lindemann", [](const AnyMap& node, const UnitStack& rate_units) {
48 return new LindemannRate(node, rate_units);
49 });
50 addAlias("Lindemann", "falloff");
51
52 // Troe falloff evaluator
53 reg("Troe", [](const AnyMap& node, const UnitStack& rate_units) {
54 return new TroeRate(node, rate_units);
55 });
56
57 // SRI falloff evaluator
58 reg("SRI", [](const AnyMap& node, const UnitStack& rate_units) {
59 return new SriRate(node, rate_units);
60 });
61
62 // Tsang falloff evaluator
63 reg("Tsang", [](const AnyMap& node, const UnitStack& rate_units) {
64 return new TsangRate(node, rate_units);
65 });
66
67 // PlogRate evaluator
68 reg("pressure-dependent-Arrhenius", [](const AnyMap& node, const UnitStack& rate_units) {
69 return new PlogRate(node, rate_units);
70 });
71
72 // ChebyshevRate evaluator
73 reg("Chebyshev", [](const AnyMap& node, const UnitStack& rate_units) {
74 return new ChebyshevRate(node, rate_units);
75 });
76
77 // CustomFunc1Rate evaluator
78 reg("custom-rate-function", [](const AnyMap& node, const UnitStack& rate_units) {
79 return new CustomFunc1Rate(node, rate_units);
80 });
81
82 // InterfaceArrheniusRate evaluator
83 reg("interface-Arrhenius", [](const AnyMap& node, const UnitStack& rate_units) {
84 return new InterfaceArrheniusRate(node, rate_units);
85 });
86
87 // StickingArrheniusRate evaluator
88 reg("sticking-Arrhenius", [](const AnyMap& node, const UnitStack& rate_units) {
89 return new StickingArrheniusRate(node, rate_units);
90 });
91
92 // InterfaceBlowersMaselRate evaluator
93 reg("interface-Blowers-Masel", [](const AnyMap& node, const UnitStack& rate_units) {
94 return new InterfaceBlowersMaselRate(node, rate_units);
95 });
96
97 // StickingBlowersMaselRate evaluator
98 reg("sticking-Blowers-Masel", [](const AnyMap& node, const UnitStack& rate_units) {
99 return new StickingBlowersMaselRate(node, rate_units);
100 });
101}
102
103shared_ptr<ReactionRate> newReactionRate(const std::string& type)
104{
105 return shared_ptr<ReactionRate> (
106 ReactionRateFactory::factory()->create(type, AnyMap(), UnitStack({})));
107}
108
109shared_ptr<ReactionRate> newReactionRate(
110 const AnyMap& rate_node, const UnitStack& rate_units)
111{
112 std::string type = ""; // default is to create Arrhenius from empty
113 if (rate_node.hasKey("type")) {
114 type = rate_node["type"].asString();
115 }
116
117 if (type == "falloff" || type == "chemically-activated") {
118 if (rate_node.hasKey("Troe")) {
119 type = "Troe";
120 } else if (rate_node.hasKey("SRI")) {
121 type = "SRI";
122 } else if (rate_node.hasKey("Tsang")) {
123 type = "Tsang";
124 } else {
125 type = "Lindemann";
126 }
127 }
128
129 if (!(ReactionRateFactory::factory()->exists(type))) {
130 throw InputFileError("ReactionRateFactory::newReactionRate", rate_node,
131 "Unknown reaction rate type '{}'", type);
132 }
133
134 return shared_ptr<ReactionRate> (
135 ReactionRateFactory::factory()->create(type, rate_node, rate_units));
136}
137
138shared_ptr<ReactionRate> newReactionRate(const AnyMap& rate_node)
139{
140 const UnitSystem& system = rate_node.units();
141 if (system.convertTo(1., "m") != 1. || system.convertTo(1., "kmol") != 1.) {
142 throw InputFileError("ReactionRateFactory::newReactionRate",
143 rate_node.at("__units__"),
144 "Alternative units for 'length' or 'quantity` are not supported "
145 "when creating\na standalone 'ReactionRate' object.");
146 }
147 AnyMap node(rate_node);
148 return newReactionRate(node, UnitStack({}));
149}
150
151}
Header for reaction rates that occur at interfaces.
Base class for kinetics managers and also contains the kineticsmgr module documentation (see Kinetics...
Factory class for reaction rate objects.
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
Header for plasma reaction rates parameterized by two temperatures (gas and electron).
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:399
const AnyValue & at(const std::string &key) const
Get the value of the item stored in key.
Definition: AnyMap.cpp:1391
const UnitSystem & units() const
Return the default units that should be used to convert stored values.
Definition: AnyMap.h:598
bool hasKey(const std::string &key) const
Returns true if the map contains an item named key.
Definition: AnyMap.cpp:1406
Arrhenius reaction rate type depends only on temperature.
Definition: Arrhenius.h:192
Blowers Masel reaction rate type depends on the enthalpy of reaction.
Pressure-dependent rate expression where the rate coefficient is expressed as a bivariate Chebyshev p...
Definition: ChebyshevRate.h:90
Custom reaction rate depending only on temperature.
Definition: Custom.h:37
void addAlias(const std::string &original, const std::string &alias)
Add an alias for an existing registered type.
Definition: FactoryBase.h:86
void reg(const std::string &name, std::function< ReactionRate *(Args...)> f)
Register a new object construction function.
Definition: FactoryBase.h:81
Error thrown for problems processing information contained in an AnyMap or AnyValue.
Definition: AnyMap.h:702
A class template for interface reaction rate specifications.
The Lindemann falloff parameterization.
Definition: Falloff.h:276
Pressure-dependent reaction rate expressed by logarithmically interpolating between Arrhenius rate ex...
Definition: PlogRate.h:78
static ReactionRateFactory * s_factory
Pointer to the single instance of the factory.
ReactionRateFactory()
default constructor, which is defined as private
static std::mutex rate_mutex
Mutex for use when calling the factory.
static ReactionRateFactory * factory()
Return a pointer to the factory.
The SRI falloff function.
Definition: Falloff.h:437
A class template for interface sticking rate specifications.
The 3- or 4-parameter Troe falloff parameterization.
Definition: Falloff.h:335
The 1- or 2-parameter Tsang falloff parameterization.
Definition: Falloff.h:547
Two temperature plasma reaction rate type depends on both gas temperature and electron temperature.
Unit conversion utility.
Definition: Units.h:161
double convertTo(double value, const std::string &dest) const
Convert value to the specified dest units from the appropriate units for this unit system (defined by...
Definition: Units.cpp:575
Namespace for the Cantera kernel.
Definition: AnyMap.h:29
shared_ptr< ReactionRate > newReactionRate(const std::string &type)
Create a new empty ReactionRate object.
Unit aggregation utility.
Definition: Units.h:99