From 0590b2cda80aa4e8ba7e4ccf4555ae03948f7623 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 22 Jun 2015 18:11:32 -0400 Subject: [PATCH] [Reactor] Deprecate possibly-ambiguous names in componentIndex Resolves #274. --- include/cantera/zeroD/ConstPressureReactor.h | 5 +++-- .../cantera/zeroD/IdealGasConstPressureReactor.h | 5 +++-- include/cantera/zeroD/IdealGasReactor.h | 4 ++++ include/cantera/zeroD/Reactor.h | 5 +++-- src/zeroD/ConstPressureReactor.cpp | 10 ++++++++++ src/zeroD/IdealGasConstPressureReactor.cpp | 10 ++++++++++ src/zeroD/IdealGasReactor.cpp | 15 +++++++++++++++ src/zeroD/Reactor.cpp | 15 +++++++++++++++ 8 files changed, 63 insertions(+), 6 deletions(-) diff --git a/include/cantera/zeroD/ConstPressureReactor.h b/include/cantera/zeroD/ConstPressureReactor.h index ffef058ce..c5b5c86ec 100644 --- a/include/cantera/zeroD/ConstPressureReactor.h +++ b/include/cantera/zeroD/ConstPressureReactor.h @@ -39,8 +39,9 @@ public: virtual void updateState(doublereal* y); //! Return the index in the solution vector for this reactor of the - //! component named *nm*. Possible values for *nm* are "m", "H", the name - //! of a homogeneous phase species, or the name of a surface species. + //! component named *nm*. Possible values for *nm* are "mass", "enthalpy", + //! the name of a homogeneous phase species, or the name of a surface + //! species. virtual size_t componentIndex(const std::string& nm) const; }; diff --git a/include/cantera/zeroD/IdealGasConstPressureReactor.h b/include/cantera/zeroD/IdealGasConstPressureReactor.h index f0eb0c739..2546b8f4b 100644 --- a/include/cantera/zeroD/IdealGasConstPressureReactor.h +++ b/include/cantera/zeroD/IdealGasConstPressureReactor.h @@ -41,8 +41,9 @@ public: virtual void updateState(doublereal* y); //! Return the index in the solution vector for this reactor of the - //! component named *nm*. Possible values for *nm* are "m", "T", the name - //! of a homogeneous phase species, or the name of a surface species. + //! component named *nm*. Possible values for *nm* are "mass", + //! "temperature", the name of a homogeneous phase species, or the name of a + //! surface species. virtual size_t componentIndex(const std::string& nm) const; protected: diff --git a/include/cantera/zeroD/IdealGasReactor.h b/include/cantera/zeroD/IdealGasReactor.h index b214d77ec..ada758cda 100644 --- a/include/cantera/zeroD/IdealGasReactor.h +++ b/include/cantera/zeroD/IdealGasReactor.h @@ -38,6 +38,10 @@ public: virtual void updateState(doublereal* y); + //! Return the index in the solution vector for this reactor of the + //! component named *nm*. Possible values for *nm* are "mass", + //! "volume", "temperature", the name of a homogeneous phase species, or the + //! name of a surface species. virtual size_t componentIndex(const std::string& nm) const; protected: diff --git a/include/cantera/zeroD/Reactor.h b/include/cantera/zeroD/Reactor.h index 090142cdf..f16619efa 100644 --- a/include/cantera/zeroD/Reactor.h +++ b/include/cantera/zeroD/Reactor.h @@ -142,8 +142,9 @@ public: std::vector > getSensitivityOrder() const; //! Return the index in the solution vector for this reactor of the - //! component named *nm*. Possible values for *nm* are "m", "V", "T", the - //! name of a homogeneous phase species, or the name of a surface species. + //! component named *nm*. Possible values for *nm* are "mass", "volume", + //! "int_energy", the name of a homogeneous phase species, or the name of a + //! surface species. virtual size_t componentIndex(const std::string& nm) const; protected: diff --git a/src/zeroD/ConstPressureReactor.cpp b/src/zeroD/ConstPressureReactor.cpp index 766198d0a..b230d0201 100644 --- a/src/zeroD/ConstPressureReactor.cpp +++ b/src/zeroD/ConstPressureReactor.cpp @@ -127,8 +127,18 @@ size_t ConstPressureReactor::componentIndex(const string& nm) const if (k != npos) { return k + 2; } else if (nm == "m" || nm == "mass") { + if (nm == "m") { + warn_deprecated("ConstPressureReactor::componentIndex(\"m\")", + "Using the name 'm' for mass is deprecated, and will be " + "disabled after Cantera 2.3. Use 'mass' instead."); + } return 0; } else if (nm == "H" || nm == "enthalpy") { + if (nm == "H") { + warn_deprecated("ConstPressureReactor::componentIndex(\"H\")", + "Using the name 'H' for enthalpy is deprecated, and will be " + "disabled after Cantera 2.3. Use 'enthalpy' instead."); + } return 1; } else { return npos; diff --git a/src/zeroD/IdealGasConstPressureReactor.cpp b/src/zeroD/IdealGasConstPressureReactor.cpp index 413fad98c..2454c4150 100644 --- a/src/zeroD/IdealGasConstPressureReactor.cpp +++ b/src/zeroD/IdealGasConstPressureReactor.cpp @@ -139,8 +139,18 @@ size_t IdealGasConstPressureReactor::componentIndex(const string& nm) const if (k != npos) { return k + 2; } else if (nm == "m" || nm == "mass") { + if (nm == "m") { + warn_deprecated("IdealGasConstPressureReactor::componentIndex(\"m\")", + "Using the name 'm' for mass is deprecated, and will be " + "disabled after Cantera 2.3. Use 'mass' instead."); + } return 0; } else if (nm == "T" || nm == "temperature") { + if (nm == "T") { + warn_deprecated("IdealGasConstPressureReactor::componentIndex(\"T\")", + "Using the name 'T' for temperature is deprecated, and will be " + "disabled after Cantera 2.3. Use 'temperature' instead."); + } return 1; } else { return npos; diff --git a/src/zeroD/IdealGasReactor.cpp b/src/zeroD/IdealGasReactor.cpp index 14906b06f..560a244c4 100644 --- a/src/zeroD/IdealGasReactor.cpp +++ b/src/zeroD/IdealGasReactor.cpp @@ -156,10 +156,25 @@ size_t IdealGasReactor::componentIndex(const string& nm) const if (k != npos) { return k + 3; } else if (nm == "m" || nm == "mass") { + if (nm == "m") { + warn_deprecated("IdealGasReactor::componentIndex(\"m\")", + "Using the name 'm' for mass is deprecated, and will be " + "disabled after Cantera 2.3. Use 'mass' instead."); + } return 0; } else if (nm == "V" || nm == "volume") { + if (nm == "V") { + warn_deprecated("IdealGasReactor::componentIndex(\"V\")", + "Using the name 'V' for volume is deprecated, and will be " + "disabled after Cantera 2.3. Use 'volume' instead."); + } return 1; } else if (nm == "T" || nm == "temperature") { + if (nm == "T") { + warn_deprecated("IdealGasReactor::componentIndex(\"T\")", + "Using the name 'T' for temperature is deprecated, and will be " + "disabled after Cantera 2.3. Use 'temperature' instead."); + } return 2; } else { return npos; diff --git a/src/zeroD/Reactor.cpp b/src/zeroD/Reactor.cpp index 8dbcdf0cf..e229099df 100644 --- a/src/zeroD/Reactor.cpp +++ b/src/zeroD/Reactor.cpp @@ -382,10 +382,25 @@ size_t Reactor::componentIndex(const string& nm) const if (k != npos) { return k + 3; } else if (nm == "m" || nm == "mass") { + if (nm == "m") { + warn_deprecated("Reactor::componentIndex(\"m\")", + "Using the name 'm' for mass is deprecated, and will be " + "disabled after Cantera 2.3. Use 'mass' instead."); + } return 0; } else if (nm == "V" || nm == "volume") { + if (nm == "V") { + warn_deprecated("Reactor::componentIndex(\"V\")", + "Using the name 'V' for volume is deprecated, and will be " + "disabled after Cantera 2.3. Use 'volume' instead."); + } return 1; } else if (nm == "U" || nm == "int_energy") { + if (nm == "U") { + warn_deprecated("Reactor::componentIndex(\"U\")", + "Using the name 'U' for internal energy is deprecated, and " + "will be disabled after Cantera 2.3. Use 'int_energy' instead."); + } return 2; } else { return npos;