[Kinetics] Replace numerical constants for Kinetics types with strings

This commit is contained in:
Ray Speth 2016-07-06 23:03:07 -04:00
parent 3b0cf9f832
commit 7f21aa0f45
12 changed files with 42 additions and 19 deletions

View file

@ -39,9 +39,15 @@ public:
virtual Kinetics* duplMyselfAsKinetics(const std::vector<thermo_t*> & 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();

View file

@ -44,8 +44,14 @@ public:
}
virtual int type() const {
warn_deprecated("EdgeKinetics::type",
"To be removed after Cantera 2.3.");
return cEdgeKinetics;
}
virtual std::string kineticsType() const {
return "Edge";
}
};
}

View file

@ -37,9 +37,15 @@ public:
virtual Kinetics* duplMyselfAsKinetics(const std::vector<thermo_t*> & 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
//! @{

View file

@ -74,6 +74,10 @@ public:
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.

View file

@ -158,9 +158,18 @@ public:
/*!
* 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();

View file

@ -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;

View file

@ -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()

View file

@ -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 = {}

View file

@ -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(<CxxInterfaceKinetics*>kin.kinetics)

View file

@ -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",

View file

@ -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;
}

View file

@ -74,6 +74,7 @@ Kinetics* Kinetics::duplMyselfAsKinetics(const std::vector<thermo_t*> & 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();
}