From 06732a65812ebf189dbffad9951a12658ce62173 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Thu, 30 Oct 2014 21:10:12 +0000 Subject: [PATCH] [Kinetics] Merge SRI5 and SRI3 implementations --- include/cantera/kinetics/Falloff.h | 104 +++++------------------ include/cantera/kinetics/reaction_defs.h | 3 +- src/kinetics/FalloffFactory.cpp | 7 +- src/kinetics/importKinetics.cpp | 15 +--- 4 files changed, 24 insertions(+), 105 deletions(-) diff --git a/include/cantera/kinetics/Falloff.h b/include/cantera/kinetics/Falloff.h index b7915189d..50136bd00 100644 --- a/include/cantera/kinetics/Falloff.h +++ b/include/cantera/kinetics/Falloff.h @@ -172,80 +172,7 @@ protected: doublereal m_t2; }; -//! The 3-parameter SRI falloff function for F -/*! - * The falloff function defines the value of \f$ F \f$ in the following - * rate expression - * - * \f[ k = k_{\infty} \left( \frac{P_r}{1 + P_r} \right) F \f] - * where - * \f[ P_r = \frac{k_0 [M]}{k_{\infty}} \f] - * - * \f[ F = {\left( a \; exp(\frac{-b}{T}) + exp(\frac{-T}{c})\right)}^n \f] - * where - * \f[ n = \frac{1.0}{1.0 + {\log_{10} P_r}^2} \f] - * - * \f$ c \f$ s required to greater than or equal to zero. If it is zero, - * then the corresponding term is set to zero. - * - * @ingroup falloffGroup - */ -class SRI3 : public Falloff -{ -public: - //! Constructor - SRI3() : m_a(-1.0), m_b(-1.0), m_c(-1.0) {} - - //! Initialization of the object - /*! - * @param c Vector of three doubles: The doubles are the parameters, - * a, b, and c of the SRI parameterization - */ - virtual void init(const vector_fp& c) { - if (c[2] < 0.0) { - throw CanteraError("SRI3::init()", - "m_c parameter is less than zero: " + fp2str(c[2])); - } - m_a = c[0]; - m_b = c[1]; - m_c = c[2]; - } - - //! Update the temperature parameters in the representation - /*! - * @param T Temperature (Kelvin) - * @param work Vector of working space, length 1, representing the - * temperature-dependent part of the parameterization. - */ - virtual void updateTemp(doublereal T, doublereal* work) const { - *work = m_a * exp(- m_b / T); - if (m_c != 0.0) { - *work += exp(- T/m_c); - } - } - - virtual doublereal F(doublereal pr, const doublereal* work) const { - doublereal lpr = log10(std::max(pr,SmallNumber)); - doublereal xx = 1.0/(1.0 + lpr*lpr); - return pow(*work , xx); - } - - virtual size_t workSize() { - return 1; - } - -protected: - //! parameter a in the 3-parameter SRI falloff function. Dimensionless. - doublereal m_a; - - //! parameter b in the 3-parameter SRI falloff function. [K] - doublereal m_b; - - //! parameter c in the 3-parameter SRI falloff function. [K] - doublereal m_c; -}; - -//! The 5-parameter SRI falloff function. +//! The SRI falloff function /*! * The falloff function defines the value of \f$ F \f$ in the following * rate expression @@ -266,31 +193,38 @@ protected: * * @ingroup falloffGroup */ -class SRI5 : public Falloff +class SRI : public Falloff { public: //! Constructor - SRI5() : m_a(-1.0), m_b(-1.0), m_c(-1.0), m_d(-1.0), m_e(-1.0) {} + SRI() : m_a(-1.0), m_b(-1.0), m_c(-1.0), m_d(-1.0), m_e(-1.0) {} //! Initialization of the object /*! - * @param c Vector of five doubles: The doubles are the parameters, - * a, b, c, d, and e of the SRI parameterization + * @param c Vector of three or five doubles: The doubles are the parameters, + * a, b, c, d (optional; default 1.0), and e (optional; default + * 0.0) of the SRI parameterization */ virtual void init(const vector_fp& c) { if (c[2] < 0.0) { - throw CanteraError("SRI5::init()", + throw CanteraError("SRI::init()", "m_c parameter is less than zero: " + fp2str(c[2])); } - if (c[3] < 0.0) { - throw CanteraError("SRI5::init()", - "m_d parameter is less than zero: " + fp2str(c[3])); - } m_a = c[0]; m_b = c[1]; m_c = c[2]; - m_d = c[3]; - m_e = c[4]; + + if (c.size() == 5) { + if (c[3] < 0.0) { + throw CanteraError("SRI::init()", + "m_d parameter is less than zero: " + fp2str(c[3])); + } + m_d = c[3]; + m_e = c[4]; + } else { + m_d = 1.0; + m_e = 0.0; + } } //! Update the temperature parameters in the representation diff --git a/include/cantera/kinetics/reaction_defs.h b/include/cantera/kinetics/reaction_defs.h index 76c387458..3ca3320ae 100644 --- a/include/cantera/kinetics/reaction_defs.h +++ b/include/cantera/kinetics/reaction_defs.h @@ -133,8 +133,7 @@ const int CHEBYSHEV_REACTION_RATECOEFF_TYPE = 8; //@{ const int SIMPLE_FALLOFF = 100; const int TROE_FALLOFF = 110; -const int SRI3_FALLOFF = 112; -const int SRI5_FALLOFF = 113; +const int SRI_FALLOFF = 112; //@} } diff --git a/src/kinetics/FalloffFactory.cpp b/src/kinetics/FalloffFactory.cpp index a6f3ce380..21856387d 100644 --- a/src/kinetics/FalloffFactory.cpp +++ b/src/kinetics/FalloffFactory.cpp @@ -22,11 +22,8 @@ Falloff* FalloffFactory::newFalloff(int type, const vector_fp& c) case TROE_FALLOFF: f = new Troe(); break; - case SRI3_FALLOFF: - f = new SRI3(); - break; - case SRI5_FALLOFF: - f = new SRI5(); + case SRI_FALLOFF: + f = new SRI(); break; default: return 0; diff --git a/src/kinetics/importKinetics.cpp b/src/kinetics/importKinetics.cpp index 10ed90bec..fae896b83 100644 --- a/src/kinetics/importKinetics.cpp +++ b/src/kinetics/importKinetics.cpp @@ -670,19 +670,8 @@ static void getFalloff(const XML_Node& f, ReactionData& rdata) + int2str(np) + ", is not equal to 3 or 4"); } } else if (type == "SRI") { - if (np == 5) { - rdata.falloffType = SRI5_FALLOFF; - if (c[2] < 0.0) { - throw CanteraError("getFalloff()", "SRI5 m_c parameter is less than zero: " + fp2str(c[2])); - } - if (c[3] < 0.0) { - throw CanteraError("getFalloff()", "SRI5 m_d parameter is less than zero: " + fp2str(c[3])); - } - } else if (np == 3) { - rdata.falloffType = SRI3_FALLOFF; - if (c[2] < 0.0) { - throw CanteraError("getFalloff()", "SRI3 m_c parameter is less than zero: " + fp2str(c[2])); - } + if (np == 3 || np == 5) { + rdata.falloffType = SRI_FALLOFF; } else { throw CanteraError("getFalloff()", "SRI parameterization is specified by number of parameters, " + int2str(np) + ", is not equal to 3 or 5");