From 3441bc208d4d38ce9a083bceb1fcc6fc7f63da70 Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Sun, 6 Feb 2022 16:29:22 -0600 Subject: [PATCH] [Kinetics] Define TwoTempPlasmaRate as BulkRate --- include/cantera/kinetics/Arrhenius.h | 64 ++++++++++------------------ src/kinetics/Arrhenius.cpp | 29 +++---------- 2 files changed, 29 insertions(+), 64 deletions(-) diff --git a/include/cantera/kinetics/Arrhenius.h b/include/cantera/kinetics/Arrhenius.h index 9eca8673d6..75e5f78cbb 100644 --- a/include/cantera/kinetics/Arrhenius.h +++ b/include/cantera/kinetics/Arrhenius.h @@ -210,12 +210,13 @@ class Arrhenius3 : public ArrheniusBase * Kinetic scheme of the non-equilibrium discharge in nitrogen-oxygen mixtures. * Plasma Sources Science and Technology, 1(3), 207. * doi: 10.1088/0963-0252/1/3/011 + * * @ingroup arrheniusGroup */ -class TwoTempPlasmaRate final : public ArrheniusBase, public ReactionRate +class TwoTempPlasma : public ArrheniusBase { public: - TwoTempPlasmaRate(); + TwoTempPlasma(); //! Constructor. /*! @@ -225,43 +226,19 @@ class TwoTempPlasmaRate final : public ArrheniusBase, public ReactionRate * @param Ea Activation energy in energy units [J/kmol] * @param EE Activation electron energy in energy units [J/kmol] */ - TwoTempPlasmaRate(double A, double b, double Ea=0.0, double EE=0.0); - - unique_ptr newMultiRate() const override { - return unique_ptr( - new MultiRate); - } + TwoTempPlasma(double A, double b, double Ea=0.0, double EE=0.0); - //! Constructor based on AnyMap content - TwoTempPlasmaRate(const AnyMap& node, const UnitStack& rate_units={}) - : TwoTempPlasmaRate() - { - setParameters(node, rate_units); - } - - //! Identifier of reaction rate type - virtual const std::string type() const override { + const std::string rateType() const { return "two-temperature-plasma"; } - //! Perform object setup based on AnyMap node information - /*! - * @param node AnyMap containing rate information - * @param rate_units Unit definitions specific to rate information - */ - virtual void setParameters(const AnyMap& node, const UnitStack& rate_units) override; - - virtual void getParameters(AnyMap& node) const override; - - void check(const std::string& equation, const AnyMap& node) override { - checkRate(equation, node); + //! Context (unused) + void setRateContext(const Reaction& rxn, const Kinetics& kin) { } //! Evaluate reaction rate - /*! - * @param shared_data data shared by all reactions of a given type - */ - double evalFromStruct(const TwoTempPlasmaData& shared_data) { + //! @internal Non-virtual method that should not be overloaded + double evalRate(const TwoTempPlasmaData& shared_data) const { // m_E4_R is the electron activation (in temperature units) return m_A * std::exp(m_b * shared_data.logTe - m_Ea_R * shared_data.recipT + @@ -269,11 +246,14 @@ class TwoTempPlasmaRate final : public ArrheniusBase, public ReactionRate * shared_data.recipTe * shared_data.recipT); } - //! Return the activation energy divided by the gas constant (i.e. the - //! activation temperature) [K] - double activationEnergy_R() const { - return m_Ea_R; - } + //! Evaluate derivative of reaction rate with respect to temperature + //! divided by reaction rate + /*! + * This method does not consider changes of electron temperature. + * A corresponding warning is raised. + * @internal Non-virtual method that should not be overloaded + */ + double ddTScaled(const TwoTempPlasmaData& shared_data) const; //! Return the electron activation energy *Ea* [J/kmol] double activationElectronEnergy() const { @@ -338,6 +318,7 @@ class BlowersMasel : public ArrheniusBase return "Blowers-Masel"; } + //! Set context void setRateContext(const Reaction& rxn, const Kinetics& kin); //! Update information specific to reaction @@ -456,12 +437,12 @@ class BulkRate final : public RateType, public ReactionRate } void check(const std::string& equation, const AnyMap& node) override { - checkRate(equation, node); + RateType::checkRate(equation, node); } virtual void setContext(const Reaction& rxn, const Kinetics& kin) override { // as this method is virtual, it cannot be templated - setRateContext(rxn, kin); + RateType::setRateContext(rxn, kin); } //! Evaluate reaction rate @@ -469,7 +450,7 @@ class BulkRate final : public RateType, public ReactionRate * @param shared_data data shared by all reactions of a given type */ double evalFromStruct(const DataType& shared_data) const { - return evalRate(shared_data); + return RateType::evalRate(shared_data); } //! Evaluate derivative of reaction rate with respect to temperature @@ -478,11 +459,12 @@ class BulkRate final : public RateType, public ReactionRate * @param shared_data data shared by all reactions of a given type */ double ddTScaledFromStruct(const DataType& shared_data) const { - return ddTScaled(shared_data); + return RateType::ddTScaled(shared_data); } }; typedef BulkRate ArrheniusRate; +typedef BulkRate TwoTempPlasmaRate; typedef BulkRate BlowersMaselRate; } diff --git a/src/kinetics/Arrhenius.cpp b/src/kinetics/Arrhenius.cpp index c6319b6174..8aab83b4e7 100644 --- a/src/kinetics/Arrhenius.cpp +++ b/src/kinetics/Arrhenius.cpp @@ -126,14 +126,14 @@ void ArrheniusBase::checkRate(const std::string& equation, const AnyMap& node) } } -TwoTempPlasmaRate::TwoTempPlasmaRate() +TwoTempPlasma::TwoTempPlasma() : ArrheniusBase() { m_Ea_str = "Ea-gas"; m_E4_str = "Ea-electron"; } -TwoTempPlasmaRate::TwoTempPlasmaRate(double A, double b, double Ea, double EE) +TwoTempPlasma::TwoTempPlasma(double A, double b, double Ea, double EE) : ArrheniusBase(A, b, Ea) { m_Ea_str = "Ea-gas"; @@ -141,28 +141,11 @@ TwoTempPlasmaRate::TwoTempPlasmaRate(double A, double b, double Ea, double EE) m_E4_R = EE / GasConstant; } -void TwoTempPlasmaRate::setParameters(const AnyMap& node, const UnitStack& rate_units) +double TwoTempPlasma::ddTScaled(const TwoTempPlasmaData& shared_data) const { - m_negativeA_ok = node.getBool("negative-A", false); - if (!node.hasKey("rate-constant")) { - setRateParameters(AnyValue(), node.units(), rate_units); - return; - } - setRateParameters(node["rate-constant"], node.units(), rate_units); -} - -void TwoTempPlasmaRate::getParameters(AnyMap& rateNode) const -{ - if (m_negativeA_ok) { - rateNode["negative-A"] = true; - } - AnyMap node; - ArrheniusBase::getRateParameters(node); - if (!node.empty()) { - // object is configured - rateNode["rate-constant"] = std::move(node); - } - rateNode["type"] = type(); + warn_user("TwoTempPlasma::ddTScaled", + "Temperature derivative does not consider changes of electron temperature."); + return (m_Ea_R - m_E4_R) * shared_data.recipT * shared_data.recipT; } BlowersMasel::BlowersMasel()