30 f->reg(
"janev-dissociative-recombination-C2Hy",
52 f->reg(
"reverse-two-temperature-plasma",
71 auto plasma =
dynamic_cast<const PlasmaPhase*
>(&phase);
86std::unique_ptr<MultiRateBase>
89 return std::make_unique<
111 if (std::isnan(
m_A)) {
132 return m_A / (std::sqrt(Te_eV) * (1.0 + 0.27 * std::pow(Te_eV, 0.55)));
148 return std::make_unique<MultiRate<DruyvesteynRate, ElectronTemperatureData>>();
162 m_b = node[
"b"].asDouble();
175 if (std::isnan(
m_A)) {
176 throw std::domain_error(
177 "DruyvesteynRate: missing pre-exponential 'A' for reaction '"
181 throw std::domain_error(
182 "DruyvesteynRate: negative pre-exponential 'A' for reaction '"
189 if (std::isnan(
m_A)) {
194 node[
"Ea"].setQuantity(
m_Ea_K,
"K",
true);
205 const double ratio =
m_Ea_K / Te;
209 return m_A * std::pow(Te,
m_b) * std::exp(-ratio * ratio);
223 auto thermo = std::make_shared<IdealGasPhase>();
225 thermo->addUndefinedElements();
226 for (
size_t k = 0; k < phase.
nSpecies(); k++) {
227 thermo->addSpecies(phase.
species(k));
229 thermo->initThermo();
238 skin->addThermo(thermo);
250 auto& mkin =
const_cast<Kinetics&
>(kin);
251 for (
size_t i = 0; i < mkin.nReactions(); i++) {
252 auto r = mkin.reaction(i);
253 std::string t = r->rate() ? r->rate()->type() : std::string();
254 if (t ==
"reverse-two-temperature-plasma") {
257 skin->addReaction(r,
false);
258 fwdIndex[r->equation()] = skin->nReactions() - 1;
263 shadow->setThermo(thermo);
264 shadow->setKinetics(skin);
265 const std::size_t nR = skin->nReactions();
276 auto plasma =
dynamic_cast<const PlasmaPhase*
>(&phase);
278 const double Te = plasma ? plasma->electronTemperature() : Tg;
280 if (Tg == m_Tg && Te == m_Te && P == m_P) {
292 auto sth =
shadow->thermo();
293 auto skin =
shadow->kinetics();
294 std::vector<double> Y(phase.
nSpecies());
295 for (
size_t k = 0; k < phase.
nSpecies(); k++) {
298 sth->setMassFractions(Y);
299 sth->setState_TP(Tg, P);
300 skin->getFwdRateConstants(
kf_Tg);
301 skin->getEquilibriumConstants(
Keq_Tg);
302 sth->setState_TP(Te, P);
303 skin->getFwdRateConstants(
kf_Te);
304 skin->getEquilibriumConstants(
Keq_Te);
314std::unique_ptr<MultiRateBase>
317 return std::make_unique<
352 if (it == shared_data.
fwdIndex.end()) {
353 throw CanteraError(
"ReverseTwoTemperaturePlasmaRate::evalFromStruct",
354 "Forward reaction '{}' not found in the forward (shadow) mechanism.",
361 const bool useTe = (
m_T ==
"Te");
362 const std::vector<double>& kf = useTe ? shared_data.
kf_Te : shared_data.
kf_Tg;
363 const std::vector<double>& Keq = useTe ? shared_data.
Keq_Te : shared_data.
Keq_Tg;
364 const double K = Keq[
m_idx];
365 return (K > 0.0) ? kf[
m_idx] / K : 0.0;
bool hasKey(const string &key) const
const UnitSystem & units() const
const string & getString(const string &key, const string &default_) const
virtual void resizeReactions()
double massFraction(size_t k) const
double temperature() const
shared_ptr< Species > species(const string &name) const
virtual double pressure() const
double electronTemperature() const override
static ReactionRateFactory * factory()
virtual void setParameters(const AnyMap &node, const UnitStack &units)
const Units & conversionUnits() const
static shared_ptr< Solution > create()
double convertRateCoeff(const AnyValue &val, const Units &dest) const
double convertActivationEnergy(double value, const string &src, const string &dest) const
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 [-].
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].
DruyvesteynRate()=default
std::unique_ptr< Cantera::MultiRateBase > newMultiRate() const override
void setParameters(const Cantera::AnyMap &node, const Cantera::UnitStack &rate_units) override
Set the rate parameters from a YAML/AnyMap rate node.
JanevDissociativeRecombinationC2HyRate()=default
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
Reverse of a forward two-temperature-plasma reaction:
std::unique_ptr< Cantera::MultiRateBase > newMultiRate() const override
double evalFromStruct(const ReverseTwoTempData &shared_data) const
Evaluate the reverse rate at the tagged temperature.
ReverseTwoTemperaturePlasmaRate()=default
void getParameters(Cantera::AnyMap &node) const override
std::string m_forward_equation
Equation string of the forward reaction this rate reverses [-].
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 [-].
shared_ptr< Kinetics > newKinetics(const string &model)
constexpr double K_to_eV
K -> eV.
void registerPlasmaRates()
Register the custom plasma reaction rates with Cantera's ReactionRateFactory.
Shared data carrying the electron temperature (mirrors Cantera's own TwoTempPlasmaData but only needs...
double electronTemp
electron temperature [K]
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 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,...
Physical constants and unit conversions, in SI by default.