Cantera  3.1.0b1
Loading...
Searching...
No Matches
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
16#include "cantera/kinetics/Falloff.h"
21
22namespace Cantera
23{
24
25ReactionRateFactory* ReactionRateFactory::s_factory = 0;
27
29{
30 // ArrheniusRate evaluator
31 reg("Arrhenius", [](const AnyMap& node, const UnitStack& rate_units) {
32 return new ArrheniusRate(node, rate_units);
33 });
34 addAlias("Arrhenius", "");
35 addAlias("Arrhenius", "elementary");
36 addAlias("Arrhenius", "three-body");
37
38 // TwoTempPlasmaRate evaluator
39 reg("two-temperature-plasma", [](const AnyMap& node, const UnitStack& rate_units) {
40 return new TwoTempPlasmaRate(node, rate_units);
41 });
42
43 // ElectronCollisionPlasmaRate evaluator
44 reg("electron-collision-plasma", [](const AnyMap& node, const UnitStack& rate_units) {
45 return new ElectronCollisionPlasmaRate(node, rate_units);
46 });
47
48 // BlowersMaselRate evaluator
49 reg("Blowers-Masel", [](const AnyMap& node, const UnitStack& rate_units) {
50 return new BlowersMaselRate(node, rate_units);
51 });
52
53 // Lindemann falloff evaluator
54 reg("Lindemann", [](const AnyMap& node, const UnitStack& rate_units) {
55 return new LindemannRate(node, rate_units);
56 });
57 addAlias("Lindemann", "falloff");
58
59 // Troe falloff evaluator
60 reg("Troe", [](const AnyMap& node, const UnitStack& rate_units) {
61 return new TroeRate(node, rate_units);
62 });
63
64 // SRI falloff evaluator
65 reg("SRI", [](const AnyMap& node, const UnitStack& rate_units) {
66 return new SriRate(node, rate_units);
67 });
68
69 // Tsang falloff evaluator
70 reg("Tsang", [](const AnyMap& node, const UnitStack& rate_units) {
71 return new TsangRate(node, rate_units);
72 });
73
74 // PlogRate evaluator
75 reg("pressure-dependent-Arrhenius", [](const AnyMap& node, const UnitStack& rate_units) {
76 return new PlogRate(node, rate_units);
77 });
78
79 // LinearBurkeRate evaluator
80 reg("linear-Burke", [](const AnyMap& node, const UnitStack& rate_units) {
81 return new LinearBurkeRate(node, rate_units);
82 });
83
84 // ChebyshevRate evaluator
85 reg("Chebyshev", [](const AnyMap& node, const UnitStack& rate_units) {
86 return new ChebyshevRate(node, rate_units);
87 });
88
89 // CustomFunc1Rate evaluator
90 reg("custom-rate-function", [](const AnyMap& node, const UnitStack& rate_units) {
91 return new CustomFunc1Rate(node, rate_units);
92 });
93
94 // InterfaceArrheniusRate evaluator
95 reg("interface-Arrhenius", [](const AnyMap& node, const UnitStack& rate_units) {
96 return new InterfaceArrheniusRate(node, rate_units);
97 });
98
99 // StickingArrheniusRate evaluator
100 reg("sticking-Arrhenius", [](const AnyMap& node, const UnitStack& rate_units) {
101 return new StickingArrheniusRate(node, rate_units);
102 });
103
104 // InterfaceBlowersMaselRate evaluator
105 reg("interface-Blowers-Masel", [](const AnyMap& node, const UnitStack& rate_units) {
106 return new InterfaceBlowersMaselRate(node, rate_units);
107 });
108
109 // StickingBlowersMaselRate evaluator
110 reg("sticking-Blowers-Masel", [](const AnyMap& node, const UnitStack& rate_units) {
111 return new StickingBlowersMaselRate(node, rate_units);
112 });
113}
114
116 std::unique_lock<std::mutex> lock(rate_mutex);
117 if (!s_factory) {
119 }
120 return s_factory;
121}
122
124 std::unique_lock<std::mutex> lock(rate_mutex);
125 delete s_factory;
126 s_factory = 0;
127}
128
129shared_ptr<ReactionRate> newReactionRate(const string& type)
130{
131 return shared_ptr<ReactionRate> (
132 ReactionRateFactory::factory()->create(type, AnyMap(), UnitStack({})));
133}
134
135shared_ptr<ReactionRate> newReactionRate(
136 const AnyMap& rate_node, const UnitStack& rate_units)
137{
138 string type = ""; // default is to create Arrhenius from empty
139 if (rate_node.hasKey("type")) {
140 type = rate_node["type"].asString();
141 }
142
143 if (type == "falloff" || type == "chemically-activated") {
144 if (rate_node.hasKey("Troe")) {
145 type = "Troe";
146 } else if (rate_node.hasKey("SRI")) {
147 type = "SRI";
148 } else if (rate_node.hasKey("Tsang")) {
149 type = "Tsang";
150 } else {
151 type = "Lindemann";
152 }
153 }
154
155 if (!(ReactionRateFactory::factory()->exists(type))) {
156 throw InputFileError("ReactionRateFactory::newReactionRate", rate_node,
157 "Unknown reaction rate type '{}'", type);
158 }
159
160 return shared_ptr<ReactionRate> (
161 ReactionRateFactory::factory()->create(type, rate_node, rate_units));
162}
163
164shared_ptr<ReactionRate> newReactionRate(const AnyMap& rate_node)
165{
166 return newReactionRate(AnyMap(rate_node), UnitStack({}));
167}
168
169}
Header for reaction rates that involve Arrhenius-type kinetics.
Header for plasma reaction rates parameterized by electron collision cross section and electron energ...
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:431
bool hasKey(const string &key) const
Returns true if the map contains an item named key.
Definition AnyMap.cpp:1477
Arrhenius reaction rate type depends only on temperature.
Definition Arrhenius.h:170
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...
Custom reaction rate depending only on temperature.
Definition Custom.h:38
Electron collision plasma reaction rate type.
void reg(const string &name, function< ReactionRate *(Args...)> f)
Register a new object construction function.
Definition FactoryBase.h:80
void addAlias(const string &original, const string &alias)
Add an alias for an existing registered type.
Definition FactoryBase.h:85
Error thrown for problems processing information contained in an AnyMap or AnyValue.
Definition AnyMap.h:749
The Lindemann falloff parameterization.
Definition Falloff.h:242
Pressure-dependent and composition-dependent reaction rate calculated according to the reduced-pressu...
Pressure-dependent reaction rate expressed by logarithmically interpolating between Arrhenius rate ex...
Definition PlogRate.h:77
Factory class to construct reaction rate calculators.
static ReactionRateFactory * s_factory
Pointer to the single instance of the factory.
ReactionRateFactory()
default constructor, which is defined as private
void deleteFactory() override
Virtual abstract function that deletes the factory.
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:398
The 3- or 4-parameter Troe falloff parameterization.
Definition Falloff.h:304
The 1- or 2-parameter Tsang falloff parameterization.
Definition Falloff.h:492
Two temperature plasma reaction rate type depends on both gas temperature and electron temperature.
shared_ptr< ReactionRate > newReactionRate(const string &type)
Create a new empty ReactionRate object.
InterfaceRate< BlowersMaselRate, InterfaceData > InterfaceBlowersMaselRate
Blowers-Masel-type interface reaction rate specifications.
StickingRate< ArrheniusRate, InterfaceData > StickingArrheniusRate
Arrhenius-type interface sticking rate specifications.
StickingRate< BlowersMaselRate, InterfaceData > StickingBlowersMaselRate
Blowers-Masel-type interface sticking rate specifications.
InterfaceRate< ArrheniusRate, InterfaceData > InterfaceArrheniusRate
Arrhenius-type interface reaction rate specifications.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
Unit aggregation utility.
Definition Units.h:105