mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
Deprecate Kinetics::surfacePhaseIndex
The 'reactionPhaseIndex' method is a more general replacement
This commit is contained in:
parent
781f7d74a2
commit
633e5d285f
@ -202,10 +202,10 @@ public:
|
|||||||
* This returns the integer index of the phase which has ThermoPhase type
|
* This returns the integer index of the phase which has ThermoPhase type
|
||||||
* cSurf. For heterogeneous mechanisms, this identifies the one surface
|
* cSurf. For heterogeneous mechanisms, this identifies the one surface
|
||||||
* phase. For homogeneous mechanisms, this returns -1.
|
* phase. For homogeneous mechanisms, this returns -1.
|
||||||
|
*
|
||||||
|
* @deprecated To be removed after Cantera 3.0. Use reactionPhaseIndex instead.
|
||||||
*/
|
*/
|
||||||
size_t surfacePhaseIndex() const {
|
size_t surfacePhaseIndex() const;
|
||||||
return m_surfphase;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Phase where the reactions occur. For heterogeneous mechanisms, one of
|
* 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
|
* - #m_start -> vector of integers, containing the starting position of
|
||||||
* the species for each phase in the kinetics mechanism.
|
* 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
|
* - #m_thermo -> vector of pointers to ThermoPhase phases that
|
||||||
* participate in the kinetics mechanism.
|
* participate in the kinetics mechanism.
|
||||||
* - #m_phaseindex -> map containing the std::string id of each
|
* - #m_phaseindex -> map containing the std::string id of each
|
||||||
@ -1333,6 +1335,7 @@ protected:
|
|||||||
std::map<std::string, size_t> m_phaseindex;
|
std::map<std::string, size_t> m_phaseindex;
|
||||||
|
|
||||||
//! Index in the list of phases of the one surface phase.
|
//! Index in the list of phases of the one surface phase.
|
||||||
|
//! @deprecated To be removed after Cantera 3.0.
|
||||||
size_t m_surfphase;
|
size_t m_surfphase;
|
||||||
|
|
||||||
//! Phase Index where reactions are assumed to be taking place
|
//! Phase Index where reactions are assumed to be taking place
|
||||||
|
@ -41,13 +41,14 @@ ImplicitSurfChem::ImplicitSurfChem(
|
|||||||
for (size_t n = 0; n < k.size(); n++) {
|
for (size_t n = 0; n < k.size(); n++) {
|
||||||
InterfaceKinetics* kinPtr = k[n];
|
InterfaceKinetics* kinPtr = k[n];
|
||||||
m_vecKinPtrs.push_back(kinPtr);
|
m_vecKinPtrs.push_back(kinPtr);
|
||||||
size_t ns = k[n]->surfacePhaseIndex();
|
size_t ns = k[n]->reactionPhaseIndex();
|
||||||
if (ns == npos) {
|
SurfPhase* surf = dynamic_cast<SurfPhase*>(&k[n]->thermo(ns));
|
||||||
|
if (surf == nullptr) {
|
||||||
throw CanteraError("ImplicitSurfChem::ImplicitSurfChem",
|
throw CanteraError("ImplicitSurfChem::ImplicitSurfChem",
|
||||||
"kinetics manager contains no surface phase");
|
"kinetics manager contains no surface phase");
|
||||||
}
|
}
|
||||||
m_surfindex.push_back(ns);
|
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();
|
size_t nsp = m_surf.back()->nSpecies();
|
||||||
m_nsp.push_back(nsp);
|
m_nsp.push_back(nsp);
|
||||||
m_nv += m_nsp.back();
|
m_nv += m_nsp.back();
|
||||||
|
@ -60,7 +60,7 @@ void InterfaceKinetics::_update_rates_T()
|
|||||||
_update_rates_phi();
|
_update_rates_phi();
|
||||||
|
|
||||||
// Go find the temperature from the surface
|
// Go find the temperature from the surface
|
||||||
doublereal T = thermo(surfacePhaseIndex()).temperature();
|
doublereal T = thermo(reactionPhaseIndex()).temperature();
|
||||||
m_redo_rates = true;
|
m_redo_rates = true;
|
||||||
if (T != m_temp || m_redo_rates) {
|
if (T != m_temp || m_redo_rates) {
|
||||||
// Calculate the forward rate constant by calling m_rates and store it in m_rfn[]
|
// 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
|
// loop over interface MultiRate evaluators for each reaction type
|
||||||
for (auto& rates : m_interfaceRates) {
|
for (auto& rates : m_interfaceRates) {
|
||||||
bool changed = rates->update(thermo(surfacePhaseIndex()), *this);
|
bool changed = rates->update(thermo(reactionPhaseIndex()), *this);
|
||||||
if (changed) {
|
if (changed) {
|
||||||
rates->getRateConstants(m_rfn.data());
|
rates->getRateConstants(m_rfn.data());
|
||||||
m_ROP_ok = false;
|
m_ROP_ok = false;
|
||||||
|
@ -55,7 +55,7 @@ bool InterfaceData::update(const ThermoPhase& phase, const Kinetics& kin)
|
|||||||
double T = phase.temperature();
|
double T = phase.temperature();
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
const auto& surf = dynamic_cast<const SurfPhase&>(
|
const auto& surf = dynamic_cast<const SurfPhase&>(
|
||||||
kin.thermo(kin.surfacePhaseIndex()));
|
kin.thermo(kin.reactionPhaseIndex()));
|
||||||
double site_density = surf.siteDensity();
|
double site_density = surf.siteDensity();
|
||||||
if (density != site_density) {
|
if (density != site_density) {
|
||||||
density = surf.siteDensity();
|
density = surf.siteDensity();
|
||||||
@ -319,7 +319,7 @@ void StickingCoverage::getStickingParameters(AnyMap& node) const
|
|||||||
void StickingCoverage::setContext(const Reaction& rxn, const Kinetics& kin)
|
void StickingCoverage::setContext(const Reaction& rxn, const Kinetics& kin)
|
||||||
{
|
{
|
||||||
// Ensure that site density is initialized
|
// 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);
|
const auto& surf = dynamic_cast<const SurfPhase&>(phase);
|
||||||
m_siteDensity = surf.siteDensity();
|
m_siteDensity = surf.siteDensity();
|
||||||
if (!m_explicitMotzWise) {
|
if (!m_explicitMotzWise) {
|
||||||
|
@ -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
|
void Kinetics::checkSpeciesIndex(size_t k) const
|
||||||
{
|
{
|
||||||
if (k >= m_kk) {
|
if (k >= m_kk) {
|
||||||
@ -566,7 +573,6 @@ void Kinetics::addPhase(ThermoPhase& thermo)
|
|||||||
// there should only be one surface phase
|
// there should only be one surface phase
|
||||||
if (thermo.type() == kineticsType()) {
|
if (thermo.type() == kineticsType()) {
|
||||||
m_surfphase = nPhases();
|
m_surfphase = nPhases();
|
||||||
m_rxnphase = nPhases();
|
|
||||||
}
|
}
|
||||||
m_thermo.push_back(&thermo);
|
m_thermo.push_back(&thermo);
|
||||||
m_phaseindex[m_thermo.back()->name()] = nPhases();
|
m_phaseindex[m_thermo.back()->name()] = nPhases();
|
||||||
|
@ -606,7 +606,7 @@ void Reaction::checkBalance(const Kinetics& kin) const
|
|||||||
// Check that the number of surface sites is balanced
|
// Check that the number of surface sites is balanced
|
||||||
double reac_sites = 0.0;
|
double reac_sites = 0.0;
|
||||||
double prod_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) {
|
for (const auto& reactant : reactants) {
|
||||||
size_t k = surf.speciesIndex(reactant.first);
|
size_t k = surf.speciesIndex(reactant.first);
|
||||||
if (k != npos) {
|
if (k != npos) {
|
||||||
|
@ -38,21 +38,16 @@ solveSP::solveSP(ImplicitSurfChem* surfChemPtr, int bulkFunc) :
|
|||||||
m_numSurfPhases = 0;
|
m_numSurfPhases = 0;
|
||||||
for (size_t n = 0; n < m_objects.size(); n++) {
|
for (size_t n = 0; n < m_objects.size(); n++) {
|
||||||
InterfaceKinetics* kin = m_objects[n];
|
InterfaceKinetics* kin = m_objects[n];
|
||||||
size_t surfPhaseIndex = kin->surfacePhaseIndex();
|
size_t surfPhaseIndex = kin->reactionPhaseIndex();
|
||||||
if (surfPhaseIndex != npos) {
|
SurfPhase* sp = dynamic_cast<SurfPhase*>(&kin->thermo(surfPhaseIndex));
|
||||||
m_numSurfPhases++;
|
if (sp == nullptr) {
|
||||||
m_indexKinObjSurfPhase.push_back(n);
|
|
||||||
m_kinObjPhaseIDSurfPhase.push_back(surfPhaseIndex);
|
|
||||||
} else {
|
|
||||||
throw CanteraError("solveSP::solveSP",
|
throw CanteraError("solveSP::solveSP",
|
||||||
"InterfaceKinetics object has no surface phase");
|
"InterfaceKinetics object has no surface phase");
|
||||||
}
|
}
|
||||||
SurfPhase* sp = dynamic_cast<SurfPhase*>(&kin->thermo(surfPhaseIndex));
|
|
||||||
if (!sp) {
|
m_numSurfPhases++;
|
||||||
throw CanteraError("solveSP::solveSP",
|
m_indexKinObjSurfPhase.push_back(n);
|
||||||
"Inconsistent ThermoPhase object within "
|
m_kinObjPhaseIDSurfPhase.push_back(surfPhaseIndex);
|
||||||
"InterfaceKinetics object");
|
|
||||||
}
|
|
||||||
|
|
||||||
m_ptrsSurfPhase.push_back(sp);
|
m_ptrsSurfPhase.push_back(sp);
|
||||||
size_t nsp = sp->nSpecies();
|
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++) {
|
for (size_t isp = 0; isp < m_numSurfPhases; isp++) {
|
||||||
size_t nsp = m_nSpeciesSurfPhase[isp];
|
size_t nsp = m_nSpeciesSurfPhase[isp];
|
||||||
InterfaceKinetics* kinPtr = m_objects[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 kstart = kinPtr->kineticsSpeciesIndex(0, surfIndex);
|
||||||
size_t kins = kindexSP;
|
size_t kins = kindexSP;
|
||||||
kinPtr->getNetProductionRates(m_netProductionRatesSave.data());
|
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++) {
|
for (size_t isp = 0; isp < m_numSurfPhases; isp++) {
|
||||||
size_t nsp = m_nSpeciesSurfPhase[isp];
|
size_t nsp = m_nSpeciesSurfPhase[isp];
|
||||||
InterfaceKinetics* kinPtr = m_objects[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 kstart = kinPtr->kineticsSpeciesIndex(0, surfIndex);
|
||||||
size_t kins = kindexSP;
|
size_t kins = kindexSP;
|
||||||
kinPtr->getNetProductionRates(m_netProductionRatesSave.data());
|
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
|
// Calculate the start of the species index for surfaces within
|
||||||
// the InterfaceKinetics object
|
// the InterfaceKinetics object
|
||||||
size_t surfIndex = kin->surfacePhaseIndex();
|
size_t surfIndex = kin->reactionPhaseIndex();
|
||||||
size_t kstart = kin->kineticsSpeciesIndex(0, surfIndex);
|
size_t kstart = kin->kineticsSpeciesIndex(0, surfIndex);
|
||||||
kin->getNetProductionRates(m_numEqn1.data());
|
kin->getNetProductionRates(m_numEqn1.data());
|
||||||
double sden = kin->thermo(surfIndex).molarDensity();
|
double sden = kin->thermo(surfIndex).molarDensity();
|
||||||
|
@ -616,7 +616,7 @@ ReactingSurf1D::ReactingSurf1D(shared_ptr<Solution> solution, const std::string&
|
|||||||
m_kin = kin.get();
|
m_kin = kin.get();
|
||||||
m_sphase = phase.get();
|
m_sphase = phase.get();
|
||||||
|
|
||||||
m_surfindex = m_kin->surfacePhaseIndex();
|
m_surfindex = m_kin->reactionPhaseIndex();
|
||||||
m_nsp = m_sphase->nSpecies();
|
m_nsp = m_sphase->nSpecies();
|
||||||
m_enabled = true;
|
m_enabled = true;
|
||||||
}
|
}
|
||||||
@ -624,7 +624,7 @@ ReactingSurf1D::ReactingSurf1D(shared_ptr<Solution> solution, const std::string&
|
|||||||
void ReactingSurf1D::setKineticsMgr(InterfaceKinetics* kin)
|
void ReactingSurf1D::setKineticsMgr(InterfaceKinetics* kin)
|
||||||
{
|
{
|
||||||
m_kin = kin;
|
m_kin = kin;
|
||||||
m_surfindex = kin->surfacePhaseIndex();
|
m_surfindex = kin->reactionPhaseIndex();
|
||||||
m_sphase = (SurfPhase*)&kin->thermo(m_surfindex);
|
m_sphase = (SurfPhase*)&kin->thermo(m_surfindex);
|
||||||
m_nsp = m_sphase->nSpecies();
|
m_nsp = m_sphase->nSpecies();
|
||||||
m_enabled = true;
|
m_enabled = true;
|
||||||
|
@ -69,7 +69,7 @@ void MoleReactor::evalSurfaces(double* LHS, double* RHS, double* sdot)
|
|||||||
size_t nk = surf->nSpecies();
|
size_t nk = surf->nSpecies();
|
||||||
S->syncState();
|
S->syncState();
|
||||||
kin->getNetProductionRates(&m_work[0]);
|
kin->getNetProductionRates(&m_work[0]);
|
||||||
size_t ns = kin->surfacePhaseIndex();
|
size_t ns = kin->reactionPhaseIndex();
|
||||||
size_t surfloc = kin->kineticsSpeciesIndex(0,ns);
|
size_t surfloc = kin->kineticsSpeciesIndex(0,ns);
|
||||||
for (size_t k = 0; k < nk; k++) {
|
for (size_t k = 0; k < nk; k++) {
|
||||||
RHS[loc + k] = m_work[surfloc + k] * wallarea / surf->size(k);
|
RHS[loc + k] = m_work[surfloc + k] * wallarea / surf->size(k);
|
||||||
|
@ -293,7 +293,7 @@ void Reactor::evalSurfaces(double* LHS, double* RHS, double* sdot)
|
|||||||
double sum = 0.0;
|
double sum = 0.0;
|
||||||
S->syncState();
|
S->syncState();
|
||||||
kin->getNetProductionRates(&m_work[0]);
|
kin->getNetProductionRates(&m_work[0]);
|
||||||
size_t ns = kin->surfacePhaseIndex();
|
size_t ns = kin->reactionPhaseIndex();
|
||||||
size_t surfloc = kin->kineticsSpeciesIndex(0,ns);
|
size_t surfloc = kin->kineticsSpeciesIndex(0,ns);
|
||||||
for (size_t k = 1; k < nk; k++) {
|
for (size_t k = 1; k < nk; k++) {
|
||||||
LHS[loc] = 1.0;
|
LHS[loc] = 1.0;
|
||||||
|
@ -36,13 +36,12 @@ void ReactorSurface::setKinetics(Kinetics* kin) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t i = kin->surfacePhaseIndex();
|
m_thermo = dynamic_cast<SurfPhase*>(&kin->thermo(kin->reactionPhaseIndex()));
|
||||||
if (i == npos) {
|
if (m_thermo == nullptr) {
|
||||||
throw CanteraError("ReactorSurface::setKinetics",
|
throw CanteraError("ReactorSurface::setKinetics",
|
||||||
"Specified surface kinetics manager does not represent a surface "
|
"Specified kinetics manager does not represent a surface "
|
||||||
"kinetics mechanism.");
|
"kinetics mechanism.");
|
||||||
}
|
}
|
||||||
m_thermo = dynamic_cast<SurfPhase*>(&kin->thermo(i));
|
|
||||||
m_cov.resize(m_thermo->nSpecies());
|
m_cov.resize(m_thermo->nSpecies());
|
||||||
m_thermo->getCoverages(m_cov.data());
|
m_thermo->getCoverages(m_cov.data());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user