Cantera  3.1.0a1
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"
15 #include "cantera/kinetics/Falloff.h"
19 
20 namespace Cantera
21 {
22 
23 ReactionRateFactory* 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 
104  std::unique_lock<std::mutex> lock(rate_mutex);
105  if (!s_factory) {
107  }
108  return s_factory;
109 }
110 
112  std::unique_lock<std::mutex> lock(rate_mutex);
113  delete s_factory;
114  s_factory = 0;
115 }
116 
117 shared_ptr<ReactionRate> newReactionRate(const string& type)
118 {
119  return shared_ptr<ReactionRate> (
120  ReactionRateFactory::factory()->create(type, AnyMap(), UnitStack({})));
121 }
122 
123 shared_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 
152 shared_ptr<ReactionRate> newReactionRate(const AnyMap& rate_node)
153 {
154  return newReactionRate(AnyMap(rate_node), UnitStack({}));
155 }
156 
157 }
Header for reaction rates that involve Arrhenius-type kinetics.
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:427
bool hasKey(const string &key) const
Returns true if the map contains an item named key.
Definition: AnyMap.cpp:1423
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...
Definition: ChebyshevRate.h:92
Custom reaction rate depending only on temperature.
Definition: Custom.h:38
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:738
The Lindemann falloff parameterization.
Definition: Falloff.h:242
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:564
Unit aggregation utility.
Definition: Units.h:105