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
8#include "cantera/kinetics/ReactionRateFactory.h"
9#include "cantera/kinetics/MultiRate.h"
10#include "cantera/thermo/ThermoPhase.h"
11#include "cantera/kinetics/Kinetics.h"
12#include "cantera/kinetics/Falloff.h"
13#include "cantera/kinetics/TwoTempPlasmaRate.h"
14#include "cantera/kinetics/ChebyshevRate.h"
15#include "cantera/kinetics/Custom.h"
16#include "cantera/kinetics/RxnRates.h"
17#include "cantera/kinetics/InterfaceRate.h"
18#include "cantera/base/AnyMap.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
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}
AnyMap.h
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...
MultiRate.h
ReactionRateFactory.h
Factory class for reaction rate objects.
RxnRates.h
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:399
Cantera::AnyMap::at
const AnyValue & at(const std::string &key) const
Get the value of the item stored in key.
Definition: AnyMap.cpp:1391
Cantera::AnyMap::units
const UnitSystem & units() const
Return the default units that should be used to convert stored values.
Definition: AnyMap.h:598
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::ArrheniusRate
Arrhenius reaction rate type depends only on temperature.
Definition: Arrhenius.h:192
Cantera::BlowersMaselRate
Blowers Masel reaction rate type depends on the enthalpy of reaction.
Definition: BlowersMaselRate.h:71
Cantera::ChebyshevRate
Pressure-dependent rate expression where the rate coefficient is expressed as a bivariate Chebyshev p...
Definition: ChebyshevRate.h:90
Cantera::CustomFunc1Rate
Custom reaction rate depending only on temperature.
Definition: Custom.h:37
Cantera::Factory< ReactionRate, const AnyMap &, const UnitStack & >::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< ReactionRate, const AnyMap &, const UnitStack & >::reg
void reg(const std::string &name, std::function< ReactionRate *(Args...)> f)
Register a new object construction function.
Definition: FactoryBase.h:81
Cantera::InputFileError
Error thrown for problems processing information contained in an AnyMap or AnyValue.
Definition: AnyMap.h:702
Cantera::InterfaceRate
A class template for interface reaction rate specifications.
Definition: InterfaceRate.h:354
Cantera::LindemannRate
The Lindemann falloff parameterization.
Definition: Falloff.h:276
Cantera::PlogRate
Pressure-dependent reaction rate expressed by logarithmically interpolating between Arrhenius rate ex...
Definition: PlogRate.h:78
Cantera::ReactionRateFactory::s_factory
static ReactionRateFactory * s_factory
Pointer to the single instance of the factory.
Definition: ReactionRateFactory.h:57
Cantera::ReactionRateFactory::ReactionRateFactory
ReactionRateFactory()
default constructor, which is defined as private
Definition: ReactionRateFactory.cpp:26
Cantera::ReactionRateFactory::rate_mutex
static std::mutex rate_mutex
Mutex for use when calling the factory.
Definition: ReactionRateFactory.h:63
Cantera::ReactionRateFactory::factory
static ReactionRateFactory * factory()
Return a pointer to the factory.
Definition: ReactionRateFactory.h:41
Cantera::SriRate
The SRI falloff function.
Definition: Falloff.h:437
Cantera::StickingRate
A class template for interface sticking rate specifications.
Definition: InterfaceRate.h:455
Cantera::TroeRate
The 3- or 4-parameter Troe falloff parameterization.
Definition: Falloff.h:335
Cantera::TsangRate
The 1- or 2-parameter Tsang falloff parameterization.
Definition: Falloff.h:547
Cantera::TwoTempPlasmaRate
Two temperature plasma reaction rate type depends on both gas temperature and electron temperature.
Definition: TwoTempPlasmaRate.h:64
Cantera::UnitSystem
Unit conversion utility.
Definition: Units.h:161
Cantera::UnitSystem::convertTo
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
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:557
Cantera::newReactionRate
shared_ptr< ReactionRate > newReactionRate(const std::string &type)
Create a new empty ReactionRate object.
Definition: ReactionRateFactory.cpp:103
Cantera::UnitStack
Unit aggregation utility.
Definition: Units.h:99