Cantera 2.6.0

ReactionFactory.cpp
Go to the documentation of this file.
1 /**
2 * @file ReactionFactory.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
8#include "cantera/thermo/ThermoPhase.h"
9#include "cantera/kinetics/Reaction.h"
10#include "ReactionFactory.h"
11#include "cantera/kinetics/ReactionRateFactory.h"
12#include "cantera/kinetics/Kinetics.h"
13#include "cantera/base/ctml.h"
14#include "cantera/base/AnyMap.h"
15#include "cantera/base/stringUtils.h"
16
17 namespace Cantera
18{
19
20ReactionFactory* ReactionFactory::s_factory = 0;
21std::mutex ReactionFactory::reaction_mutex;
22
23 ReactionFactory::ReactionFactory()
24{
25 // register elementary reactions
26 reg("reaction", [](const AnyMap& node, const Kinetics& kin) {
27 return new Reaction(node, kin);
28 });
29 addAlias("reaction", "elementary");
30 addAlias("reaction", "arrhenius");
31 addAlias("reaction", "Arrhenius");
32 addAlias("reaction", "");
33
34 // register elementary reactions (old framework)
35 reg("elementary-legacy", [](const AnyMap& node, const Kinetics& kin) {
36 ElementaryReaction2* R = new ElementaryReaction2();
37 if (!node.empty()) {
38 setupElementaryReaction(*R, node, kin);
39 }
40 return R;
41 });
42
43 // register three-body reactions
44 reg("three-body", [](const AnyMap& node, const Kinetics& kin) {
45 return new ThreeBodyReaction3(node, kin);
46 });
47 addAlias("three-body", "threebody");
48 addAlias("three-body", "three_body");
49
50 // register three-body reactions (old framework)
51 reg("three-body-legacy", [](const AnyMap& node, const Kinetics& kin) {
52 ThreeBodyReaction2* R = new ThreeBodyReaction2();
53 if (!node.empty()) {
54 setupThreeBodyReaction(*R, node, kin);
55 }
56 return R;
57 });
58
59 // register falloff reactions
60 reg("falloff", [](const AnyMap& node, const Kinetics& kin) {
61 return new FalloffReaction3(node, kin);
62 });
63 addAlias("falloff", "chemically-activated");
64
65 // register falloff reactions (old framework)
66 reg("falloff-legacy", [](const AnyMap& node, const Kinetics& kin) {
67 FalloffReaction2* R = new FalloffReaction2();
68 if (!node.empty()) {
69 setupFalloffReaction(*R, node, kin);
70 }
71 return R;
72 });
73
74 // register falloff reactions
75 reg("chemically-activated-legacy", [](const AnyMap& node, const Kinetics& kin) {
76 FalloffReaction2* R = new ChemicallyActivatedReaction2();
77 if (!node.empty()) {
78 setupFalloffReaction(*R, node, kin);
79 }
80 return R;
81 });
82 addAlias("chemically-activated-legacy", "chemact");
83 addAlias("chemically-activated-legacy", "chemically_activated");
84
85 addAlias("reaction", "pressure-dependent-Arrhenius");
86 addAlias("reaction", "plog");
87 addAlias("reaction", "pdep_arrhenius");
88
89 // register pressure-dependent-Arrhenius reactions (old framework)
90 reg("pressure-dependent-Arrhenius-legacy", [](const AnyMap& node, const Kinetics& kin) {
91 PlogReaction2* R = new PlogReaction2();
92 if (!node.empty()) {
93 setupPlogReaction(*R, node, kin);
94 }
95 return R;
96 });
97
98 // register Chebyshev reactions
99 addAlias("reaction", "Chebyshev");
100 addAlias("reaction", "chebyshev");
101 reg("Chebyshev-legacy", [](const AnyMap& node, const Kinetics& kin) {
102 ChebyshevReaction2* R = new ChebyshevReaction2();
103 if (!node.empty()) {
104 setupChebyshevReaction(*R, node, kin);
105 }
106 return R;
107 });
108
109 // register custom reactions specified by Func1 objects
110 reg("custom-rate-function", [](const AnyMap& node, const Kinetics& kin) {
111 return new CustomFunc1Reaction(node, kin);
112 });
113
114 // register interface reactions
115 reg("interface-legacy", [](const AnyMap& node, const Kinetics& kin) {
116 InterfaceReaction2* R = new InterfaceReaction2();
117 if (!node.empty()) {
118 setupInterfaceReaction(*R, node, kin);
119 }
120 return R;
121 });
122 addAlias("interface-legacy", "interface");
123 addAlias("interface-legacy", "surface");
124 addAlias("interface-legacy", "edge");
125
126 addAlias("reaction", "interface-Arrhenius");
127 addAlias("reaction", "sticking-Arrhenius");
128
129 // register electrochemical reactions
130 reg("electrochemical-legacy", [](const AnyMap& node, const Kinetics& kin) {
131 ElectrochemicalReaction2* R = new ElectrochemicalReaction2();
132 if (!node.empty()) {
133 setupElectrochemicalReaction(*R, node, kin);
134 }
135 return R;
136 });
137 addAlias("electrochemical-legacy", "electrochemical");
138
139 addAlias("reaction", "two-temperature-plasma");
140
141 addAlias("reaction", "Blowers-Masel");
142 addAlias("reaction", "interface-Blowers-Masel");
143 addAlias("reaction", "sticking-Blowers-Masel");
144}
145
146ReactionFactoryXML* ReactionFactoryXML::s_factory = 0;
147std::mutex ReactionFactoryXML::reaction_mutex;
148
149ReactionFactoryXML::ReactionFactoryXML()
150{
151 // register elementary reactions
152 reg("elementary-legacy", [](const XML_Node& node) {
153 Reaction* R = new ElementaryReaction2();
154 setupElementaryReaction(*(ElementaryReaction2*)R, node);
155 return R;
156 });
157 addAlias("elementary-legacy", "elementary");
158 addAlias("elementary-legacy", "arrhenius");
159 addAlias("elementary-legacy", "");
160
161 // register three-body reactions
162 reg("three-body-legacy", [](const XML_Node& node) {
163 Reaction* R = new ThreeBodyReaction2();
164 setupThreeBodyReaction(*(ThreeBodyReaction2*)R, node);
165 return R;
166 });
167 addAlias("three-body-legacy", "three-body");
168 addAlias("three-body-legacy", "threebody");
169 addAlias("three-body-legacy", "three_body");
170
171 // register falloff reactions
172 reg("falloff-legacy", [](const XML_Node& node) {
173 Reaction* R = new FalloffReaction2();
174 setupFalloffReaction(*(FalloffReaction2*)R, node);
175 return R;
176 });
177 addAlias("falloff-legacy", "falloff");
178
179 // register falloff reactions
180 reg("chemically-activated-legacy", [](const XML_Node& node) {
181 Reaction* R = new ChemicallyActivatedReaction2();
182 setupChemicallyActivatedReaction(*(ChemicallyActivatedReaction2*)R, node);
183 return R;
184 });
185 addAlias("chemically-activated-legacy", "chemically-activated");
186 addAlias("chemically-activated-legacy", "chemact");
187 addAlias("chemically-activated-legacy", "chemically_activated");
188
189 // register pressure-depdendent-Arrhenius reactions
190 reg("pressure-dependent-Arrhenius-legacy", [](const XML_Node& node) {
191 Reaction* R = new PlogReaction2();
192 setupPlogReaction(*(PlogReaction2*)R, node);
193 return R;
194 });
195 addAlias("pressure-dependent-Arrhenius-legacy", "pressure-dependent-Arrhenius");
196 addAlias("pressure-dependent-Arrhenius-legacy", "plog");
197 addAlias("pressure-dependent-Arrhenius-legacy", "pdep_arrhenius");
198
199 // register Chebyshev reactions
200 reg("Chebyshev-legacy", [](const XML_Node& node) {
201 Reaction* R = new ChebyshevReaction2();
202 setupChebyshevReaction(*(ChebyshevReaction2*)R, node);
203 return R;
204 });
205 addAlias("Chebyshev-legacy", "chebyshev");
206
207 // register interface reactions
208 reg("interface-legacy", [](const XML_Node& node) {
209 Reaction* R = new InterfaceReaction2();
210 setupInterfaceReaction(*(InterfaceReaction2*)R, node);
211 return R;
212 });
213 addAlias("interface-legacy", "interface");
214 addAlias("interface-legacy", "surface");
215 addAlias("interface-legacy", "edge");
216
217 // register electrochemical reactions
218 reg("electrochemical-legacy", [](const XML_Node& node) {
219 Reaction* R = new ElectrochemicalReaction2();
220 setupElectrochemicalReaction(*(ElectrochemicalReaction2*)R, node);
221 return R;
222 });
223 addAlias("electrochemical-legacy", "electrochemical");
224}
225
226}
AnyMap.h
Kinetics.h
Base class for kinetics managers and also contains the kineticsmgr module documentation (see Kinetics...
ReactionFactory.h
Factory class for reaction functions.
ReactionRateFactory.h
Factory class for reaction rate objects.
Reaction.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::ChebyshevReaction2
A pressure-dependent reaction parameterized by a bi-variate Chebyshev polynomial in temperature and p...
Definition: Reaction.h:386
Cantera::ChemicallyActivatedReaction2
A reaction where the rate decreases as pressure increases due to collisional stabilization of a react...
Definition: Reaction.h:346
Cantera::CustomFunc1Reaction
A reaction which follows mass-action kinetics with a custom reaction rate defined in Python.
Definition: Reaction.h:530
Cantera::ElectrochemicalReaction2
An interface reaction which involves charged species.
Definition: Reaction.h:458
Cantera::ElementaryReaction2
A reaction which follows mass-action kinetics with a modified Arrhenius reaction rate.
Definition: Reaction.h:217
Cantera::Factory< Reaction, const AnyMap &, const Kinetics & >::addAlias
void addAlias(const std::string &original, const std::string &alias)
Add an alias for an existing registered type.
Definition: FactoryBase.h:86
Cantera::Factory< Reaction, const AnyMap &, const Kinetics & >::reg
void reg(const std::string &name, std::function< Reaction *(Args...)> f)
Register a new object construction function.
Definition: FactoryBase.h:81
Cantera::FalloffReaction2
A reaction that is first-order in [M] at low pressure, like a third-body reaction,...
Definition: Reaction.h:297
Cantera::FalloffReaction3
A falloff reaction that is first-order in [M] at low pressure, like a third-body reaction,...
Definition: Reaction.h:504
Cantera::InterfaceReaction2
A reaction occurring on an interface (for example, a SurfPhase or an EdgePhase)
Definition: Reaction.h:419
Cantera::Kinetics
Public interface for kinetics managers.
Definition: Kinetics.h:114
Cantera::PlogReaction2
A pressure-dependent reaction parameterized by logarithmically interpolating between Arrhenius rate e...
Definition: Reaction.h:365
Cantera::ReactionFactory::ReactionFactory
ReactionFactory()
default constructor, which is defined as private
Definition: ReactionFactory.cpp:23
Cantera::ReactionFactory::reaction_mutex
static std::mutex reaction_mutex
Mutex for use when calling the factory.
Definition: ReactionFactory.h:60
Cantera::ReactionFactory::s_factory
static ReactionFactory * s_factory
Pointer to the single instance of the factory.
Definition: ReactionFactory.h:54
Cantera::Reaction
Abstract base class which stores data about a reaction and its rate parameterization so that it can b...
Definition: Reaction.h:33
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::ThreeBodyReaction3
A reaction with a non-reacting third body "M" that acts to add or remove energy from the reacting spe...
Definition: Reaction.h:475
Cantera::XML_Node
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:103
ctml.h
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data.
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:557
Cantera::setupChemicallyActivatedReaction
void setupChemicallyActivatedReaction(ChemicallyActivatedReaction2 &R, const XML_Node &rxn_node)
Definition: Reaction.cpp:1783
stringUtils.h
Contains declarations for string manipulation functions within Cantera.