rizer.cantera_ext
C++ Cantera 1-D plasma extension (custom Domain1D models and solvers)
Loading...
Searching...
No Matches
PlasmaRates.h
Go to the documentation of this file.
1// PlasmaRates.h
2//
3// C++ ports of the custom plasma reaction rates that rizer defines in
4// Python as `ct.ExtensibleRate`s (rizer/kin/extensible_rate.py):
5//
6// * janev-dissociative-recombination-C2Hy — a closed-form rate in Te only.
7// * Druyvesteyn — modified Arrhenius in Te with
8// a squared-ratio exponential, k = A Te^b exp(-(Ea/Te)^2).
9// * reverse-two-temperature-plasma — the reverse of a forward
10// `two-temperature-plasma` reaction, k_rev = k_fwd / K_eq.
11//
12// Python `ct.ExtensibleRate`s are unknown to Cantera's C++ ReactionRateFactory,
13// so a mechanism that uses them (e.g. data/mechanisms/Goutier2025/CH4_to_C2H2.yaml)
14// fails to load in C++. Registering these C++ rates via `registerPlasmaRates()`
15// before `newSolution()` lets that mechanism load and evaluate natively in the
16// PlasmaChannel1D extension.
17
18#ifndef RIZER_PLASMARATES_H
19#define RIZER_PLASMARATES_H
20
23#include "cantera/base/AnyMap.h"
24
25#include <memory>
26#include <string>
27#include <unordered_map>
28#include <vector>
29
30namespace Cantera { class Solution; }
31
32namespace rizer {
33
40
41
42// ---------------------------------------------------------------------------
43// janev-dissociative-recombination-C2Hy
44// ---------------------------------------------------------------------------
45
49{
54 bool update(const Cantera::ThermoPhase& phase,
55 const Cantera::Kinetics& kin) override;
61 double electronTemp = 1.0;
62};
63
72{
73public:
75
82 const Cantera::UnitStack& rate_units);
83
84 std::unique_ptr<Cantera::MultiRateBase> newMultiRate() const override;
85
86 const std::string type() const override {
87 return "janev-dissociative-recombination-C2Hy";
88 }
89
95 void setParameters(const Cantera::AnyMap& node,
96 const Cantera::UnitStack& rate_units) override;
97
101 double evalFromStruct(const ElectronTemperatureData& shared_data) const;
102
103protected:
104 void getParameters(Cantera::AnyMap& node) const override;
105
106 double m_A = NAN;
109};
110
111
112// ---------------------------------------------------------------------------
113// Druyvesteyn
114// ---------------------------------------------------------------------------
115
124{
125public:
126 DruyvesteynRate() = default;
127
134 const Cantera::UnitStack& rate_units);
135
136 std::unique_ptr<Cantera::MultiRateBase> newMultiRate() const override;
137
138 const std::string type() const override { return "Druyvesteyn"; }
139
145 void setParameters(const Cantera::AnyMap& node,
146 const Cantera::UnitStack& rate_units) override;
147
153 void validate(const std::string& equation,
154 const Cantera::Kinetics& kin) override;
155
159 double evalFromStruct(const ElectronTemperatureData& shared_data) const;
160
161protected:
162 void getParameters(Cantera::AnyMap& node) const override;
163
164 double m_A = NAN;
166 double m_b = NAN;
167 double m_Ea_K = NAN;
168};
169
170
171// ---------------------------------------------------------------------------
172// reverse-two-temperature-plasma
173// ---------------------------------------------------------------------------
174
187{
194 bool update(const Cantera::ThermoPhase& phase,
195 const Cantera::Kinetics& kin) override;
197 void invalidateCache() override {
199 m_Tg = m_Te = m_P = NAN;
200 }
201
208 void buildShadow(const Cantera::ThermoPhase& phase,
209 const Cantera::Kinetics& kin);
210
212 std::shared_ptr<Cantera::Solution> shadow;
215 std::vector<double> kf_Tg, Keq_Tg;
218 std::vector<double> kf_Te, Keq_Te;
221 std::unordered_map<std::string, size_t> fwdIndex;
222
223private:
224 double m_Tg = NAN;
225 double m_Te = NAN;
226 double m_P = NAN;
227};
228
235{
236public:
238
245 const Cantera::UnitStack& rate_units);
246
247 std::unique_ptr<Cantera::MultiRateBase> newMultiRate() const override;
248
249 const std::string type() const override {
250 return "reverse-two-temperature-plasma";
251 }
252
258 void setParameters(const Cantera::AnyMap& node,
259 const Cantera::UnitStack& rate_units) override;
260
265 double evalFromStruct(const ReverseTwoTempData& shared_data) const;
266
267protected:
268 void getParameters(Cantera::AnyMap& node) const override;
269
274 std::string m_T = "Tg";
277 mutable size_t m_idx = Cantera::npos;
278};
279
280} // namespace rizer
281
282#endif // RIZER_PLASMARATES_H
void setParameters(const Cantera::AnyMap &node, const Cantera::UnitStack &rate_units) override
Set the rate parameters from a YAML/AnyMap rate node.
std::unique_ptr< Cantera::MultiRateBase > newMultiRate() const override
double m_b
Te exponent [-].
const std::string type() const override
double m_A
Pre-factor in Cantera's internal (kmol, m, s) rate-coefficient units [order-dependent].
void getParameters(Cantera::AnyMap &node) const override
void validate(const std::string &equation, const Cantera::Kinetics &kin) override
Reject a missing or negative pre-factor (mirrors the Python rate's validate; missing "A" leaves m_A a...
double evalFromStruct(const ElectronTemperatureData &shared_data) const
Evaluate the Druyvesteyn rate .
double m_Ea_K
Activation energy expressed in Kelvin [K].
std::unique_ptr< Cantera::MultiRateBase > newMultiRate() const override
const std::string type() const override
Definition PlasmaRates.h:86
void setParameters(const Cantera::AnyMap &node, const Cantera::UnitStack &rate_units) override
Set the rate parameters from a YAML/AnyMap rate node.
double evalFromStruct(const ElectronTemperatureData &shared_data) const
Evaluate the Janev dissociative-recombination rate .
double m_A
Rate pre-factor, in Cantera's internal (kmol, m, s) rate-coefficient units [kmol/m^3/s units,...
void getParameters(Cantera::AnyMap &node) const override
std::unique_ptr< Cantera::MultiRateBase > newMultiRate() const override
double evalFromStruct(const ReverseTwoTempData &shared_data) const
Evaluate the reverse rate at the tagged temperature.
void getParameters(Cantera::AnyMap &node) const override
std::string m_forward_equation
Equation string of the forward reaction this rate reverses [-].
const std::string type() const override
size_t m_idx
Cached index of the forward reaction in the shadow kinetics' reaction list [-].
void setParameters(const Cantera::AnyMap &node, const Cantera::UnitStack &rate_units) override
Set the rate parameters from a YAML/AnyMap rate node.
std::string m_T
Which temperature tags this reaction ("Te" or "Tg"); informational, kept for YAML round-trip [-].
const size_t npos
void registerPlasmaRates()
Register the custom plasma reaction rates with Cantera's ReactionRateFactory.
virtual void update(double T)
virtual void invalidateCache()
Shared data carrying the electron temperature (mirrors Cantera's own TwoTempPlasmaData but only needs...
Definition PlasmaRates.h:49
void invalidateCache() override
Definition PlasmaRates.h:57
double electronTemp
electron temperature [K]
Definition PlasmaRates.h:61
bool update(const Cantera::ThermoPhase &phase, const Cantera::Kinetics &kin) override
Read the electron temperature from the phase.
Shared data for all reverse-two-temperature-plasma reactions.
bool update(const Cantera::ThermoPhase &phase, const Cantera::Kinetics &kin) override
Refresh the cached Tg, Te, P and the shadow-solution rate/equilibrium constants.
std::shared_ptr< Cantera::Solution > shadow
Forward-only ideal-gas shadow solution [-].
std::vector< double > Keq_Tg
std::vector< double > kf_Te
Per-reaction forward rate constant [kmol/m^3/s units, order-dependent] and dimensionless Kc,...
std::vector< double > Keq_Te
std::unordered_map< std::string, size_t > fwdIndex
Forward reaction equation string -> index into the shadow kinetics' reaction list [-].
void invalidateCache() override
void buildShadow(const Cantera::ThermoPhase &phase, const Cantera::Kinetics &kin)
Lazily build the ideal-gas shadow Solution from the main phase + kinetics.
std::vector< double > kf_Tg
Per-reaction forward rate constant [kmol/m^3/s units, order-dependent] and dimensionless Kc,...