Cantera
Loading...
Searching...
No Matches
TwoTempPlasmaRate.cpp
Go to the documentation of this file.
1//! @file TwoTempPlasmaRate.cpp
2
3// This file is part of Cantera. See License.txt in the top-level directory or
4// at https://cantera.org/license.txt for license and copyright information.
5
9
10namespace Cantera
11{
12
13bool TwoTempPlasmaData::update(const ThermoPhase& phase, const Kinetics& kin)
14{
15 double T = phase.temperature();
16 double Te = phase.electronTemperature();
17 bool changed = false;
18 if (T != temperature) {
20 changed = true;
21 }
22 if (Te != electronTemp) {
23 updateTe(Te);
24 changed = true;
25 }
26 return changed;
27}
28
30{
31 throw CanteraError("TwoTempPlasmaData::update",
32 "Missing state information: 'TwoTempPlasmaData' requires electron temperature.");
33}
34
35void TwoTempPlasmaData::update(double T, double Te)
36{
38 updateTe(Te);
39}
40
41void TwoTempPlasmaData::updateTe(double Te)
42{
43 electronTemp = Te;
44 logTe = std::log(Te);
45 recipTe = 1./Te;
46}
47
48TwoTempPlasmaRate::TwoTempPlasmaRate()
49{
50 m_Ea_str = "Ea-gas";
51 m_E4_str = "Ea-electron";
52}
53
54TwoTempPlasmaRate::TwoTempPlasmaRate(double A, double b, double Ea, double EE,
55 double bg, double Tinv)
56 : ArrheniusBase(A, b, Ea)
57{
58 m_Ea_str = "Ea-gas";
59 m_E4_str = "Ea-electron";
60 m_E4_R = EE / GasConstant;
61 m_bg = bg;
62 if (Tinv != 0) {
63 m_recip_Tinv = 1.0 / Tinv;
64 } // no else required here because m_recip_Tinv is otherwise initialized at 0.
65}
66
67TwoTempPlasmaRate::TwoTempPlasmaRate(const AnyMap& node, const UnitStack& rate_units)
68 : TwoTempPlasmaRate()
69{
70 setParameters(node, rate_units);
71}
72
74{
76
77 if (!node.hasKey("rate-constant")) {
78 return;
79 }
80
81 auto& rateNode = node["rate-constant"].as<AnyMap>();
82
83 if (m_bg != 0.0) {
84 rateNode["b-gas"] = m_bg;
85 }
86
87 if (m_recip_Tinv != 0.0) {
88 rateNode["T-inv"] = 1.0/m_recip_Tinv;
89 }
90
91 rateNode.setFlowStyle();
92}
93
94void TwoTempPlasmaRate::setParameters(const AnyMap& node, const UnitStack& rate_units)
95{
96 // First, set back to zero these two first parameters to avoid any unwanted
97 // remanence should setParameters be called several times and not contain b-gas or
98 // T-inv in one of the calls.
99 m_bg = 0.0;
100 m_recip_Tinv = 0.0;
101
102 // Option 1: there is no rate constant provided
103 if (!node.hasKey("rate-constant")) {
104 ArrheniusBase::setParameters(node, rate_units);
105 return;
106 }
107
108 // Option 2: the rate constant is an AnyMap
109 if (node["rate-constant"].is<AnyMap>()) {
110 ArrheniusBase::setParameters(node, rate_units);
111
112 const auto& rate = node["rate-constant"].as<AnyMap>();
113
114 m_bg = rate.getDouble("b-gas", 0.0);
115
116 double Tinv = 0.0;
117 if (rate.hasKey("T-inv")) {
118 Tinv = rate.convert("T-inv", "K");
119 }
120
121 if (Tinv != 0) {
122 m_recip_Tinv = 1.0 / Tinv;
123 }
124 return;
125 }
126
127 // If both other cases fail, the rate constant is
128 // a vector and is treated below.
129 const auto& rate = node["rate-constant"].asVector<AnyValue>(2, 6);
130
131 // Option 3a: the vector is classical Arrhenius
132 if (rate.size() <= 4) {
133 ArrheniusBase::setParameters(node, rate_units);
134 return;
135 }
136
137 ReactionRate::setParameters(node, rate_units);
138 m_negativeA_ok = node.getBool("negative-A", false);
139
140 AnyValue baseRate = node["rate-constant"];
141 baseRate.asVector<AnyValue>().resize(4);
142
143 setRateParameters(baseRate, node.units(), rate_units);
144
145 // Option 3b: the vector has the b-gas parameter
146 m_bg = rate[4].asDouble();
147
148 // Option 3c: the vector has the T-inv parameter
149 if (rate.size() == 6) {
150 double Tinv = node.units().convert(rate[5], "K");
151 m_recip_Tinv = Tinv != 0.0 ? 1.0 / Tinv : 0.0;
152 }
153}
154
156{
157 warn_user("TwoTempPlasmaRate::ddTScaledFromStruct",
158 "Temperature derivative does not consider changes of electron temperature.");
159 return m_bg * shared_data.recipT + (m_Ea_R - m_E4_R)
160 * shared_data.recipT * shared_data.recipT - m_recip_Tinv;
161}
162
164{
165 // TwoTempPlasmaReaction is for a non-equilibrium plasma, and the reverse rate
166 // cannot be calculated from the conventional thermochemistry.
167 // @todo implement the reversible rate for non-equilibrium plasma
168 if (rxn.reversible) {
169 throw InputFileError("TwoTempPlasmaRate::setContext", rxn.input,
170 "TwoTempPlasmaRate does not support reversible reactions");
171 }
172}
173
174}
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
const UnitSystem & units() const
Return the default units that should be used to convert stored values.
Definition AnyMap.h:640
void setFlowStyle(bool flow=true)
Use "flow" style when outputting this AnyMap to YAML.
Definition AnyMap.cpp:1794
bool getBool(const string &key, bool default_) const
If key exists, return it as a bool, otherwise return default_.
Definition AnyMap.cpp:1575
A wrapper for a variable whose type is determined at runtime.
Definition AnyMap.h:88
const vector< T > & asVector(size_t nMin=npos, size_t nMax=npos) const
Return the held value, if it is a vector of type T.
Definition AnyMap.inl.h:109
void setParameters(const AnyMap &node, const UnitStack &rate_units) override
Set parameters.
string m_E4_str
The string for an optional 4th parameter.
Definition Arrhenius.h:156
double m_E4_R
Optional 4th energy parameter (in temperature units).
Definition Arrhenius.h:150
string m_Ea_str
The string for activation energy.
Definition Arrhenius.h:155
void getParameters(AnyMap &node) const override
Get parameters.
void setRateParameters(const AnyValue &rate, const UnitSystem &units, const UnitStack &rate_units)
Perform object setup based on AnyValue node information.
Definition Arrhenius.cpp:35
bool m_negativeA_ok
Permissible negative A values.
Definition Arrhenius.h:146
ArrheniusBase()
Default constructor.
Definition Arrhenius.h:47
double m_Ea_R
Activation energy (in temperature units).
Definition Arrhenius.h:149
Base class for exceptions thrown by Cantera classes.
Error thrown for problems processing information contained in an AnyMap or AnyValue.
Definition AnyMap.h:749
Public interface for kinetics managers.
Definition Kinetics.h:124
double temperature() const
Temperature (K).
Definition Phase.h:586
virtual double electronTemperature() const
Electron Temperature (K).
Definition Phase.h:592
virtual void setParameters(const AnyMap &node, const UnitStack &units)
Set parameters.
Abstract base class which stores data about a reaction and its rate parameterization so that it can b...
Definition Reaction.h:25
bool reversible
True if the current reaction is reversible. False otherwise.
Definition Reaction.h:126
AnyMap input
Input data used for specific models.
Definition Reaction.h:139
Base class for a phase with thermodynamic properties.
void setContext(const Reaction &rxn, const Kinetics &kin) override
Check that the reaction does not have the 'reversible: true' attribute.
double ddTScaledFromStruct(const TwoTempPlasmaData &shared_data) const
Evaluate derivative of reaction rate with respect to temperature divided by reaction rate.
double m_recip_Tinv
Reciprocate of the temperature scale for the optional term .
void setParameters(const AnyMap &node, const UnitStack &rate_units) override
Set parameters from an AnyMap object.
double m_bg
Gas temperature exponent.
void getParameters(AnyMap &node) const override
Get parameters.
double convert(double value, const string &src, const string &dest) const
Convert value from the units of src to the units of dest.
Definition Units.cpp:541
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition ct_defs.h:123
void warn_user(const string &method, const string &msg, const Args &... args)
Print a user warning raised from method as CanteraWarning.
Definition global.h:263
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
double recipT
inverse of temperature
virtual void update(double T)
Update data container based on temperature T.
double temperature
temperature
Data container holding shared data specific to TwoTempPlasmaRate.
bool update(const ThermoPhase &phase, const Kinetics &kin) override
Update data container based on thermodynamic phase state.
double electronTemp
electron temperature
double logTe
logarithm of electron temperature
double recipTe
inverse of electron temperature
Unit aggregation utility.
Definition Units.h:105