| Cantera 3.0.0

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
8#include "cantera/base/AnyMap.h"
9#include "cantera/thermo/ThermoPhase.h"
10#include "cantera/kinetics/Kinetics.h"
11#include "cantera/kinetics/ReactionRateFactory.h"
12#include "cantera/kinetics/Arrhenius.h"
13#include "cantera/kinetics/ChebyshevRate.h"
14#include "cantera/kinetics/Custom.h"
15#include "cantera/kinetics/Falloff.h"
16#include "cantera/kinetics/InterfaceRate.h"
17#include "cantera/kinetics/PlogRate.h"
18#include "cantera/kinetics/TwoTempPlasmaRate.h"
19
20 namespace Cantera
21{
22
23ReactionRateFactory* ReactionRateFactory::s_factory = 0;
24std::mutex ReactionRateFactory::rate_mutex;
25
26 ReactionRateFactory::ReactionRateFactory()
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
103 ReactionRateFactory* ReactionRateFactory::factory() {
104 std::unique_lock<std::mutex> lock(rate_mutex);
105 if (!s_factory) {
106 s_factory = new ReactionRateFactory();
107 }
108 return s_factory;
109}
110
111 void ReactionRateFactory::deleteFactory() {
112 std::unique_lock<std::mutex> lock(rate_mutex);
113 delete s_factory;
114 s_factory = 0;
115}
116
117shared_ptr<ReactionRate> newReactionRate(const string& type)
118{
119 return shared_ptr<ReactionRate> (
120 ReactionRateFactory::factory()->create(type, AnyMap(), UnitStack({})));
121}
122
123shared_ptr<ReactionRate> newReactionRate(
124 const AnyMap& rate_node, const UnitStack& rate_units)
125{
126 string type = ""; // default is to create Arrhenius from empty
127 if (rate_node.hasKey("type")) {
128 type = rate_node["type"].asString();
129 }
130
131 if (type == "falloff" || type == "chemically-activated") {
132 if (rate_node.hasKey("Troe")) {
133 type = "Troe";
134 } else if (rate_node.hasKey("SRI")) {
135 type = "SRI";
136 } else if (rate_node.hasKey("Tsang")) {
137 type = "Tsang";
138 } else {
139 type = "Lindemann";
140 }
141 }
142
143 if (!(ReactionRateFactory::factory()->exists(type))) {
144 throw InputFileError("ReactionRateFactory::newReactionRate", rate_node,
145 "Unknown reaction rate type '{}'", type);
146 }
147
148 return shared_ptr<ReactionRate> (
149 ReactionRateFactory::factory()->create(type, rate_node, rate_units));
150}
151
152shared_ptr<ReactionRate> newReactionRate(const AnyMap& rate_node)
153{
154 return newReactionRate(AnyMap(rate_node), UnitStack({}));
155}
156
157}
AnyMap.h
Arrhenius.h
Header for reaction rates that involve Arrhenius-type kinetics.
ChebyshevRate.h
Custom.h
InterfaceRate.h
Header for reaction rates that occur at interfaces.
Kinetics.h
Base class for kinetics managers and also contains the kineticsmgr module documentation (see Kinetics...
PlogRate.h
ReactionRateFactory.h
Factory class for reaction rate objects.
ThermoPhase.h
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
TwoTempPlasmaRate.h
Header for plasma reaction rates parameterized by two temperatures (gas and electron).
Cantera::AnyMap
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:427
Cantera::AnyMap::hasKey
bool hasKey(const string &key) const
Returns true if the map contains an item named key.
Definition AnyMap.cpp:1423
Cantera::ArrheniusRate
Arrhenius reaction rate type depends only on temperature.
Definition Arrhenius.h:170
Cantera::BlowersMaselRate
Blowers Masel reaction rate type depends on the enthalpy of reaction.
Definition BlowersMaselRate.h:70
Cantera::ChebyshevRate
Pressure-dependent rate expression where the rate coefficient is expressed as a bivariate Chebyshev p...
Definition ChebyshevRate.h:92
Cantera::CustomFunc1Rate
Custom reaction rate depending only on temperature.
Definition Custom.h:38
Cantera::Factory< ReactionRate, const AnyMap &, const UnitStack & >::reg
void reg(const string &name, function< ReactionRate *(Args...)> f)
Register a new object construction function.
Definition FactoryBase.h:80
Cantera::Factory< ReactionRate, const AnyMap &, const UnitStack & >::addAlias
void addAlias(const string &original, const string &alias)
Add an alias for an existing registered type.
Definition FactoryBase.h:85
Cantera::InputFileError
Error thrown for problems processing information contained in an AnyMap or AnyValue.
Definition AnyMap.h:738
Cantera::LindemannRate
The Lindemann falloff parameterization.
Definition Falloff.h:272
Cantera::PlogRate
Pressure-dependent reaction rate expressed by logarithmically interpolating between Arrhenius rate ex...
Definition PlogRate.h:77
Cantera::ReactionRateFactory
Factory class to construct reaction rate calculators.
Definition ReactionRateFactory.h:58
Cantera::ReactionRateFactory::s_factory
static ReactionRateFactory * s_factory
Pointer to the single instance of the factory.
Definition ReactionRateFactory.h:71
Cantera::ReactionRateFactory::ReactionRateFactory
ReactionRateFactory()
default constructor, which is defined as private
Definition ReactionRateFactory.cpp:26
Cantera::ReactionRateFactory::deleteFactory
void deleteFactory() override
Virtual abstract function that deletes the factory.
Definition ReactionRateFactory.cpp:111
Cantera::ReactionRateFactory::rate_mutex
static std::mutex rate_mutex
Mutex for use when calling the factory.
Definition ReactionRateFactory.h:77
Cantera::ReactionRateFactory::factory
static ReactionRateFactory * factory()
Return a pointer to the factory.
Definition ReactionRateFactory.cpp:103
Cantera::SriRate
The SRI falloff function.
Definition Falloff.h:438
Cantera::TroeRate
The 3- or 4-parameter Troe falloff parameterization.
Definition Falloff.h:334
Cantera::TsangRate
The 1- or 2-parameter Tsang falloff parameterization.
Definition Falloff.h:543
Cantera::TwoTempPlasmaRate
Two temperature plasma reaction rate type depends on both gas temperature and electron temperature.
Definition TwoTempPlasmaRate.h:61
Cantera::newReactionRate
shared_ptr< ReactionRate > newReactionRate(const string &type)
Create a new empty ReactionRate object.
Definition ReactionRateFactory.cpp:117
Cantera::InterfaceBlowersMaselRate
InterfaceRate< BlowersMaselRate, InterfaceData > InterfaceBlowersMaselRate
Blowers-Masel-type interface reaction rate specifications.
Definition InterfaceRate.h:457
Cantera::StickingArrheniusRate
StickingRate< ArrheniusRate, InterfaceData > StickingArrheniusRate
Arrhenius-type interface sticking rate specifications.
Definition InterfaceRate.h:589
Cantera::StickingBlowersMaselRate
StickingRate< BlowersMaselRate, InterfaceData > StickingBlowersMaselRate
Blowers-Masel-type interface sticking rate specifications.
Definition InterfaceRate.h:593
Cantera::InterfaceArrheniusRate
InterfaceRate< ArrheniusRate, InterfaceData > InterfaceArrheniusRate
Arrhenius-type interface reaction rate specifications.
Definition InterfaceRate.h:453
Cantera
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
Cantera::UnitStack
Unit aggregation utility.
Definition Units.h:105