Deprecate Kinetics::surfacePhaseIndex

The 'reactionPhaseIndex' method is a more general replacement
This commit is contained in:
Ray Speth 2023-01-21 19:05:10 -05:00 committed by Ray Speth
parent 781f7d74a2
commit 633e5d285f
11 changed files with 40 additions and 36 deletions

View File

@ -202,10 +202,10 @@ public:
* This returns the integer index of the phase which has ThermoPhase type
* cSurf. For heterogeneous mechanisms, this identifies the one surface
* phase. For homogeneous mechanisms, this returns -1.
*
* @deprecated To be removed after Cantera 3.0. Use reactionPhaseIndex instead.
*/
size_t surfacePhaseIndex() const {
return m_surfphase;
}
size_t surfacePhaseIndex() const;
/**
* Phase where the reactions occur. For heterogeneous mechanisms, one of
@ -1088,7 +1088,9 @@ public:
*
* - #m_start -> vector of integers, containing the starting position of
* the species for each phase in the kinetics mechanism.
* - #m_surfphase -> index of the surface phase.
* - #m_rxnphase -> index of the phase where reactions occur, which is the lowest-
* dimensional phase in the system, for example the surface in a surface
* mechanism.
* - #m_thermo -> vector of pointers to ThermoPhase phases that
* participate in the kinetics mechanism.
* - #m_phaseindex -> map containing the std::string id of each
@ -1333,6 +1335,7 @@ protected:
std::map<std::string, size_t> m_phaseindex;
//! Index in the list of phases of the one surface phase.
//! @deprecated To be removed after Cantera 3.0.
size_t m_surfphase;
//! Phase Index where reactions are assumed to be taking place

View File

@ -41,13 +41,14 @@ ImplicitSurfChem::ImplicitSurfChem(
for (size_t n = 0; n < k.size(); n++) {
InterfaceKinetics* kinPtr = k[n];
m_vecKinPtrs.push_back(kinPtr);
size_t ns = k[n]->surfacePhaseIndex();
if (ns == npos) {
size_t ns = k[n]->reactionPhaseIndex();
SurfPhase* surf = dynamic_cast<SurfPhase*>(&k[n]->thermo(ns));
if (surf == nullptr) {
throw CanteraError("ImplicitSurfChem::ImplicitSurfChem",
"kinetics manager contains no surface phase");
}
m_surfindex.push_back(ns);
m_surf.push_back((SurfPhase*)&k[n]->thermo(ns));
m_surf.push_back(surf);
size_t nsp = m_surf.back()->nSpecies();
m_nsp.push_back(nsp);
m_nv += m_nsp.back();

View File

@ -60,7 +60,7 @@ void InterfaceKinetics::_update_rates_T()
_update_rates_phi();
// Go find the temperature from the surface
doublereal T = thermo(surfacePhaseIndex()).temperature();
doublereal T = thermo(reactionPhaseIndex()).temperature();
m_redo_rates = true;
if (T != m_temp || m_redo_rates) {
// Calculate the forward rate constant by calling m_rates and store it in m_rfn[]
@ -78,7 +78,7 @@ void InterfaceKinetics::_update_rates_T()
// loop over interface MultiRate evaluators for each reaction type
for (auto& rates : m_interfaceRates) {
bool changed = rates->update(thermo(surfacePhaseIndex()), *this);
bool changed = rates->update(thermo(reactionPhaseIndex()), *this);
if (changed) {
rates->getRateConstants(m_rfn.data());
m_ROP_ok = false;

View File

@ -55,7 +55,7 @@ bool InterfaceData::update(const ThermoPhase& phase, const Kinetics& kin)
double T = phase.temperature();
bool changed = false;
const auto& surf = dynamic_cast<const SurfPhase&>(
kin.thermo(kin.surfacePhaseIndex()));
kin.thermo(kin.reactionPhaseIndex()));
double site_density = surf.siteDensity();
if (density != site_density) {
density = surf.siteDensity();
@ -319,7 +319,7 @@ void StickingCoverage::getStickingParameters(AnyMap& node) const
void StickingCoverage::setContext(const Reaction& rxn, const Kinetics& kin)
{
// Ensure that site density is initialized
const ThermoPhase& phase = kin.thermo(kin.surfacePhaseIndex());
const ThermoPhase& phase = kin.thermo(kin.reactionPhaseIndex());
const auto& surf = dynamic_cast<const SurfPhase&>(phase);
m_siteDensity = surf.siteDensity();
if (!m_explicitMotzWise) {

View File

@ -86,6 +86,13 @@ void Kinetics::checkPhaseArraySize(size_t mm) const
}
}
size_t Kinetics::surfacePhaseIndex() const
{
warn_deprecated("Kinetics::surfacePhaseIndex",
"To be removed after Cantera 3.0. Use reactionPhaseIndex instead.");
return m_surfphase;
}
void Kinetics::checkSpeciesIndex(size_t k) const
{
if (k >= m_kk) {
@ -566,7 +573,6 @@ void Kinetics::addPhase(ThermoPhase& thermo)
// there should only be one surface phase
if (thermo.type() == kineticsType()) {
m_surfphase = nPhases();
m_rxnphase = nPhases();
}
m_thermo.push_back(&thermo);
m_phaseindex[m_thermo.back()->name()] = nPhases();

View File

@ -606,7 +606,7 @@ void Reaction::checkBalance(const Kinetics& kin) const
// Check that the number of surface sites is balanced
double reac_sites = 0.0;
double prod_sites = 0.0;
auto& surf = dynamic_cast<const SurfPhase&>(kin.thermo(kin.surfacePhaseIndex()));
auto& surf = dynamic_cast<const SurfPhase&>(kin.thermo(kin.reactionPhaseIndex()));
for (const auto& reactant : reactants) {
size_t k = surf.speciesIndex(reactant.first);
if (k != npos) {

View File

@ -38,21 +38,16 @@ solveSP::solveSP(ImplicitSurfChem* surfChemPtr, int bulkFunc) :
m_numSurfPhases = 0;
for (size_t n = 0; n < m_objects.size(); n++) {
InterfaceKinetics* kin = m_objects[n];
size_t surfPhaseIndex = kin->surfacePhaseIndex();
if (surfPhaseIndex != npos) {
m_numSurfPhases++;
m_indexKinObjSurfPhase.push_back(n);
m_kinObjPhaseIDSurfPhase.push_back(surfPhaseIndex);
} else {
size_t surfPhaseIndex = kin->reactionPhaseIndex();
SurfPhase* sp = dynamic_cast<SurfPhase*>(&kin->thermo(surfPhaseIndex));
if (sp == nullptr) {
throw CanteraError("solveSP::solveSP",
"InterfaceKinetics object has no surface phase");
}
SurfPhase* sp = dynamic_cast<SurfPhase*>(&kin->thermo(surfPhaseIndex));
if (!sp) {
throw CanteraError("solveSP::solveSP",
"Inconsistent ThermoPhase object within "
"InterfaceKinetics object");
}
m_numSurfPhases++;
m_indexKinObjSurfPhase.push_back(n);
m_kinObjPhaseIDSurfPhase.push_back(surfPhaseIndex);
m_ptrsSurfPhase.push_back(sp);
size_t nsp = sp->nSpecies();
@ -361,7 +356,7 @@ void solveSP::fun_eval(doublereal* resid, const doublereal* CSoln,
for (size_t isp = 0; isp < m_numSurfPhases; isp++) {
size_t nsp = m_nSpeciesSurfPhase[isp];
InterfaceKinetics* kinPtr = m_objects[isp];
size_t surfIndex = kinPtr->surfacePhaseIndex();
size_t surfIndex = kinPtr->reactionPhaseIndex();
size_t kstart = kinPtr->kineticsSpeciesIndex(0, surfIndex);
size_t kins = kindexSP;
kinPtr->getNetProductionRates(m_netProductionRatesSave.data());
@ -383,7 +378,7 @@ void solveSP::fun_eval(doublereal* resid, const doublereal* CSoln,
for (size_t isp = 0; isp < m_numSurfPhases; isp++) {
size_t nsp = m_nSpeciesSurfPhase[isp];
InterfaceKinetics* kinPtr = m_objects[isp];
size_t surfIndex = kinPtr->surfacePhaseIndex();
size_t surfIndex = kinPtr->reactionPhaseIndex();
size_t kstart = kinPtr->kineticsSpeciesIndex(0, surfIndex);
size_t kins = kindexSP;
kinPtr->getNetProductionRates(m_netProductionRatesSave.data());
@ -608,7 +603,7 @@ doublereal solveSP::calc_t(doublereal netProdRateSolnSP[],
// Calculate the start of the species index for surfaces within
// the InterfaceKinetics object
size_t surfIndex = kin->surfacePhaseIndex();
size_t surfIndex = kin->reactionPhaseIndex();
size_t kstart = kin->kineticsSpeciesIndex(0, surfIndex);
kin->getNetProductionRates(m_numEqn1.data());
double sden = kin->thermo(surfIndex).molarDensity();

View File

@ -616,7 +616,7 @@ ReactingSurf1D::ReactingSurf1D(shared_ptr<Solution> solution, const std::string&
m_kin = kin.get();
m_sphase = phase.get();
m_surfindex = m_kin->surfacePhaseIndex();
m_surfindex = m_kin->reactionPhaseIndex();
m_nsp = m_sphase->nSpecies();
m_enabled = true;
}
@ -624,7 +624,7 @@ ReactingSurf1D::ReactingSurf1D(shared_ptr<Solution> solution, const std::string&
void ReactingSurf1D::setKineticsMgr(InterfaceKinetics* kin)
{
m_kin = kin;
m_surfindex = kin->surfacePhaseIndex();
m_surfindex = kin->reactionPhaseIndex();
m_sphase = (SurfPhase*)&kin->thermo(m_surfindex);
m_nsp = m_sphase->nSpecies();
m_enabled = true;

View File

@ -69,7 +69,7 @@ void MoleReactor::evalSurfaces(double* LHS, double* RHS, double* sdot)
size_t nk = surf->nSpecies();
S->syncState();
kin->getNetProductionRates(&m_work[0]);
size_t ns = kin->surfacePhaseIndex();
size_t ns = kin->reactionPhaseIndex();
size_t surfloc = kin->kineticsSpeciesIndex(0,ns);
for (size_t k = 0; k < nk; k++) {
RHS[loc + k] = m_work[surfloc + k] * wallarea / surf->size(k);

View File

@ -293,7 +293,7 @@ void Reactor::evalSurfaces(double* LHS, double* RHS, double* sdot)
double sum = 0.0;
S->syncState();
kin->getNetProductionRates(&m_work[0]);
size_t ns = kin->surfacePhaseIndex();
size_t ns = kin->reactionPhaseIndex();
size_t surfloc = kin->kineticsSpeciesIndex(0,ns);
for (size_t k = 1; k < nk; k++) {
LHS[loc] = 1.0;

View File

@ -36,13 +36,12 @@ void ReactorSurface::setKinetics(Kinetics* kin) {
return;
}
size_t i = kin->surfacePhaseIndex();
if (i == npos) {
m_thermo = dynamic_cast<SurfPhase*>(&kin->thermo(kin->reactionPhaseIndex()));
if (m_thermo == nullptr) {
throw CanteraError("ReactorSurface::setKinetics",
"Specified surface kinetics manager does not represent a surface "
"Specified kinetics manager does not represent a surface "
"kinetics mechanism.");
}
m_thermo = dynamic_cast<SurfPhase*>(&kin->thermo(i));
m_cov.resize(m_thermo->nSpecies());
m_thermo->getCoverages(m_cov.data());
}