diff --git a/include/cantera/kinetics/AqueousKinetics.h b/include/cantera/kinetics/AqueousKinetics.h index 6775aa8a0f..f5d55460f8 100644 --- a/include/cantera/kinetics/AqueousKinetics.h +++ b/include/cantera/kinetics/AqueousKinetics.h @@ -39,9 +39,15 @@ class AqueousKinetics : public BulkKinetics virtual Kinetics* duplMyselfAsKinetics(const std::vector & tpVector) const; virtual int type() const { + warn_deprecated("AqueousKinetics::type", + "To be removed after Cantera 2.3."); return cAqueousKinetics; } + virtual std::string kineticsType() const { + return "Aqueous"; + } + virtual void getEquilibriumConstants(doublereal* kc); virtual void getFwdRateConstants(doublereal* kfwd); void updateROP(); diff --git a/include/cantera/kinetics/EdgeKinetics.h b/include/cantera/kinetics/EdgeKinetics.h index 164890b07e..1da38c4ca5 100644 --- a/include/cantera/kinetics/EdgeKinetics.h +++ b/include/cantera/kinetics/EdgeKinetics.h @@ -44,8 +44,14 @@ class EdgeKinetics : public InterfaceKinetics } virtual int type() const { + warn_deprecated("EdgeKinetics::type", + "To be removed after Cantera 2.3."); return cEdgeKinetics; } + + virtual std::string kineticsType() const { + return "Edge"; + } }; } diff --git a/include/cantera/kinetics/GasKinetics.h b/include/cantera/kinetics/GasKinetics.h index dfde9bb4ca..f7378ded14 100644 --- a/include/cantera/kinetics/GasKinetics.h +++ b/include/cantera/kinetics/GasKinetics.h @@ -37,9 +37,15 @@ class GasKinetics : public BulkKinetics virtual Kinetics* duplMyselfAsKinetics(const std::vector & tpVector) const; virtual int type() const { + warn_deprecated("GasKinetics::type", + "To be removed after Cantera 2.3."); return cGasKinetics; } + virtual std::string kineticsType() const { + return "Gas"; + } + //! @} //! @name Reaction Rates Of Progress //! @{ diff --git a/include/cantera/kinetics/InterfaceKinetics.h b/include/cantera/kinetics/InterfaceKinetics.h index 6291b74d1c..2cc362045d 100644 --- a/include/cantera/kinetics/InterfaceKinetics.h +++ b/include/cantera/kinetics/InterfaceKinetics.h @@ -74,6 +74,10 @@ class InterfaceKinetics : public Kinetics virtual int type() const; + virtual std::string kineticsType() const { + return "Surf"; + } + //! Set the electric potential in the nth phase /*! * @param n phase Index in this kinetics object. diff --git a/include/cantera/kinetics/Kinetics.h b/include/cantera/kinetics/Kinetics.h index 1b48970fd9..8beb6e3ea4 100644 --- a/include/cantera/kinetics/Kinetics.h +++ b/include/cantera/kinetics/Kinetics.h @@ -158,9 +158,18 @@ class Kinetics /*! * Each class derived from Kinetics should overload this method to return * a unique integer. Standard values are defined in file mix_defs.h. + * @deprecated Use kineticsType() instead. To be removed after Cantera + * 2.3. */ virtual int type() const; + //! Identifies the Kinetics manager type. + //! Each class derived from Kinetics should override this method to return + //! a meaningful identifier. + virtual std::string kineticsType() const { + return "Kinetics"; + } + //! Number of reactions in the reaction mechanism. size_t nReactions() const { return m_reactions.size(); diff --git a/include/cantera/thermo/mix_defs.h b/include/cantera/thermo/mix_defs.h index d52df6ed69..c2608e66b0 100644 --- a/include/cantera/thermo/mix_defs.h +++ b/include/cantera/thermo/mix_defs.h @@ -1,4 +1,6 @@ //! @file mix_defs.h +//! @deprecated All of the constants defined in this header are no longer used. +//! To be removed after Cantera 2.3. #ifndef CT_MIX_DEFS_H #define CT_MIX_DEFS_H @@ -135,6 +137,7 @@ enum VPSSMgr_enumType { // kinetic manager types +// @deprecated To be removed after Cantera 2.3. const int cGasKinetics = 2; const int cInterfaceKinetics = 4; const int cLineKinetics = 5; diff --git a/interfaces/cython/cantera/_cantera.pxd b/interfaces/cython/cantera/_cantera.pxd index abe0b90b3f..d9424a4140 100644 --- a/interfaces/cython/cantera/_cantera.pxd +++ b/interfaces/cython/cantera/_cantera.pxd @@ -42,12 +42,6 @@ cdef extern from "cantera/base/global.h" namespace "Cantera": cdef XML_Node* CxxGetXmlFromString "Cantera::get_XML_from_string" (string) except + cdef void Cxx_make_deprecation_warnings_fatal "Cantera::make_deprecation_warnings_fatal" () -cdef extern from "cantera/thermo/mix_defs.h": - cdef int kinetics_type_gas "Cantera::cGasKinetics" - cdef int kinetics_type_interface "Cantera::cInterfaceKinetics" - cdef int kinetics_type_edge "Cantera::cEdgeKinetics" - - cdef extern from "cantera/cython/funcWrapper.h": ctypedef double (*callback_wrapper)(double, void*, void**) cdef int translate_exception() @@ -342,7 +336,7 @@ cdef extern from "cantera/kinetics/FalloffFactory.h" namespace "Cantera": cdef extern from "cantera/kinetics/Kinetics.h" namespace "Cantera": cdef cppclass CxxKinetics "Cantera::Kinetics": CxxKinetics() - int type() + string kineticsType() int nTotalSpecies() int nReactions() int nPhases() diff --git a/interfaces/cython/cantera/kinetics.pyx b/interfaces/cython/cantera/kinetics.pyx index 50950c054d..a849ce1da5 100644 --- a/interfaces/cython/cantera/kinetics.pyx +++ b/interfaces/cython/cantera/kinetics.pyx @@ -336,8 +336,7 @@ cdef class InterfaceKinetics(Kinetics): """ def __init__(self, infile='', phaseid='', phases=(), *args, **kwargs): super().__init__(infile, phaseid, phases, *args, **kwargs) - if self.kinetics.type() not in (kinetics_type_interface, - kinetics_type_edge): + if pystr(self.kinetics.kineticsType()) not in ("Surf", "Edge"): raise TypeError("Underlying Kinetics class is not of the correct type.") self._phase_indices = {} diff --git a/interfaces/cython/cantera/onedim.pyx b/interfaces/cython/cantera/onedim.pyx index 1e604e5cb7..d62781a8ce 100644 --- a/interfaces/cython/cantera/onedim.pyx +++ b/interfaces/cython/cantera/onedim.pyx @@ -370,8 +370,7 @@ cdef class ReactingSurface1D(Boundary1D): def set_kinetics(self, Kinetics kin): """Set the kinetics manager (surface reaction mechanism object).""" - if kin.kinetics.type() not in (kinetics_type_interface, - kinetics_type_edge): + if pystr(kin.kinetics.kineticsType()) not in ("Surf", "Edge"): raise TypeError('Kinetics object must be derived from ' 'InterfaceKinetics.') self.surf.setKineticsMgr(kin.kinetics) diff --git a/src/fortran/fct.cpp b/src/fortran/fct.cpp index 7ee84de4cb..396d8c53ea 100644 --- a/src/fortran/fct.cpp +++ b/src/fortran/fct.cpp @@ -881,7 +881,7 @@ extern "C" { { try { Kinetics* k = _fkin(n); - if (k->type() == cInterfaceKinetics) { + if (k->kineticsType() == "Surf" || k->kineticsType() == "Edge") { ((InterfaceKinetics*)k)->advanceCoverages(*tstep); } else { throw CanteraError("kin_advanceCoverages", diff --git a/src/kinetics/InterfaceKinetics.cpp b/src/kinetics/InterfaceKinetics.cpp index 661307ae9c..f163a98dd4 100644 --- a/src/kinetics/InterfaceKinetics.cpp +++ b/src/kinetics/InterfaceKinetics.cpp @@ -103,6 +103,8 @@ InterfaceKinetics& InterfaceKinetics::operator=(const InterfaceKinetics& right) int InterfaceKinetics::type() const { + warn_deprecated("InterfaceKinetics::type", + "To be removed after Cantera 2.3."); return cInterfaceKinetics; } diff --git a/src/kinetics/Kinetics.cpp b/src/kinetics/Kinetics.cpp index 90fc25bcc5..880245f536 100644 --- a/src/kinetics/Kinetics.cpp +++ b/src/kinetics/Kinetics.cpp @@ -74,6 +74,7 @@ Kinetics* Kinetics::duplMyselfAsKinetics(const std::vector & tpVector int Kinetics::type() const { + warn_deprecated("Kinetics::type", "To be removed after Cantera 2.3."); return 0; } @@ -485,13 +486,7 @@ void Kinetics::addPhase(thermo_t& thermo) } // there should only be one surface phase - string ptype; - if (type() == cEdgeKinetics) { - ptype = "Edge"; - } else if (type() == cInterfaceKinetics) { - ptype = "Surf"; - } - if (thermo.type() == ptype) { + if (thermo.type() == kineticsType()) { m_surfphase = nPhases(); m_rxnphase = nPhases(); }