mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[Kinetics] Transition Kinetics::reactionType(Str)
* Change behavior of Kinetics::reactionType * Deprecate Kinetics::reactionTypeStr * Change f90/clib getters to getReactionType pattern update getReactionType
This commit is contained in:
committed by
Bryan Weber
parent
631522a591
commit
8aaa1138d9
@@ -113,7 +113,7 @@ extern "C" {
|
||||
CANTERA_CAPI size_t kin_reactionPhaseIndex(int n);
|
||||
CANTERA_CAPI double kin_reactantStoichCoeff(int n, int i, int k);
|
||||
CANTERA_CAPI double kin_productStoichCoeff(int n, int i, int k);
|
||||
CANTERA_CAPI int kin_reactionType(int n, int i);
|
||||
CANTERA_CAPI int kin_getReactionType(int n, int i, size_t len, char* name);
|
||||
CANTERA_CAPI int kin_getFwdRatesOfProgress(int n, size_t len, double* fwdROP);
|
||||
CANTERA_CAPI int kin_getRevRatesOfProgress(int n, size_t len, double* revROP);
|
||||
CANTERA_CAPI int kin_getNetRatesOfProgress(int n, size_t len, double* netROP);
|
||||
|
||||
@@ -1000,19 +1000,18 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* Flag specifying the type of reaction. The legal values and their meaning
|
||||
* are specific to the particular kinetics manager.
|
||||
* String specifying the type of reaction.
|
||||
*
|
||||
* @param i reaction index
|
||||
*
|
||||
* @deprecated To be changed after Cantera 2.6.
|
||||
* @version Method returned magic number prior to Cantera 3.0.
|
||||
*/
|
||||
virtual int reactionType(size_t i) const;
|
||||
virtual std::string reactionType(size_t i) const;
|
||||
|
||||
/**
|
||||
* String specifying the type of reaction.
|
||||
*
|
||||
* @param i reaction index
|
||||
* @deprecated To be removed after Cantera 3.0.
|
||||
*/
|
||||
virtual std::string reactionTypeStr(size_t i) const;
|
||||
|
||||
|
||||
@@ -112,14 +112,6 @@ public:
|
||||
//! @param kin Kinetics object
|
||||
bool usesElectrochemistry(const Kinetics& kin) const;
|
||||
|
||||
//! Type of the reaction. The valid types are listed in the file,
|
||||
//! reaction_defs.h (recently removed), with constants ending in `RXN`.
|
||||
/*!
|
||||
* @deprecated To be removed in Cantera 2.6.
|
||||
* Superseded by Reaction::type().
|
||||
*/
|
||||
int reaction_type;
|
||||
|
||||
//! Reactant species and stoichiometric coefficients
|
||||
Composition reactants;
|
||||
|
||||
|
||||
@@ -988,12 +988,12 @@ extern "C" {
|
||||
}
|
||||
}
|
||||
|
||||
int kin_reactionType(int n, int i)
|
||||
int kin_getReactionType(int n, int i, size_t len, char* buf)
|
||||
{
|
||||
try {
|
||||
Kinetics& kin = KineticsCabinet::item(n);
|
||||
kin.checkReactionIndex(i);
|
||||
return kin.reactionType(i);
|
||||
return static_cast<int>(copyString(kin.reactionType(i), buf, len));
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
|
||||
@@ -301,9 +301,9 @@ MODULE CANTERA
|
||||
MODULE PROCEDURE ctkin_reactantStoichCoeff
|
||||
END INTERFACE reactantStoichCoeff
|
||||
|
||||
INTERFACE reactionType
|
||||
MODULE PROCEDURE ctkin_reactionType
|
||||
END INTERFACE reactionType
|
||||
INTERFACE getReactionType
|
||||
MODULE PROCEDURE ctkin_getReactionType
|
||||
END INTERFACE getReactionType
|
||||
|
||||
INTERFACE refPressure
|
||||
MODULE PROCEDURE ctthermo_refPressure
|
||||
|
||||
@@ -114,12 +114,13 @@ module cantera_kinetics
|
||||
ctkin_productstoichcoeff = kin_productstoichcoeff(self%kin_id, k, i)
|
||||
end function ctkin_productstoichcoeff
|
||||
|
||||
integer function ctkin_reactionType(self, i)
|
||||
integer function ctkin_getReactionType(self, i, buf)
|
||||
implicit none
|
||||
type(phase_t), intent(in) :: self
|
||||
type(phase_t), intent(inout) :: self
|
||||
integer, intent(in) :: i
|
||||
ctkin_reactiontype = kin_reactiontype(self%kin_id, i)
|
||||
end function ctkin_reactiontype
|
||||
character*(*), intent(out) :: buf
|
||||
self%err = kin_getreactiontype(self%kin_id, i, buf)
|
||||
end function ctkin_getReactionType
|
||||
|
||||
subroutine ctkin_getFwdRatesOfProgress(self, fwdROP)
|
||||
implicit none
|
||||
|
||||
@@ -780,13 +780,19 @@ extern "C" {
|
||||
}
|
||||
}
|
||||
|
||||
integer kin_reactiontype_(const integer* n, integer* i)
|
||||
status_t kin_getreactiontype_(const integer* n, integer* i, char* buf, ftnlen lenbuf)
|
||||
{
|
||||
try {
|
||||
return _fkin(n)->reactionType(*i-1);
|
||||
std::string r = _fkin(n)->reactionType(*i-1);
|
||||
int lout = std::min(lenbuf, (int) r.size());
|
||||
std::copy(r.c_str(), r.c_str() + lout, buf);
|
||||
for (int nn = lout; nn < lenbuf; nn++) {
|
||||
buf[nn] = ' ';
|
||||
}
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t kin_getfwdratesofprogress_(const integer* n, double* fwdROP)
|
||||
|
||||
@@ -335,10 +335,11 @@ interface
|
||||
integer, intent(in) :: i
|
||||
end function kin_productstoichcoeff
|
||||
|
||||
integer function kin_reactiontype(n, i)
|
||||
integer function kin_getreactiontype(n, i, buf)
|
||||
integer, intent(in) :: n
|
||||
integer, intent(in) :: i
|
||||
end function kin_reactiontype
|
||||
character*(*), intent(out) :: buf
|
||||
end function kin_getreactiontype
|
||||
|
||||
integer function kin_getfwdratesofprogress(n, fwdROP)
|
||||
integer, intent(in) :: n
|
||||
|
||||
@@ -351,16 +351,14 @@ double Kinetics::productStoichCoeff(size_t kSpec, size_t irxn) const
|
||||
return m_productStoich.stoichCoeffs().coeff(kSpec, irxn);
|
||||
}
|
||||
|
||||
int Kinetics::reactionType(size_t i) const {
|
||||
warn_deprecated("Kinetics::reactionType",
|
||||
"To be changed after Cantera 2.6. "
|
||||
"Return string instead of magic number; use "
|
||||
"Kinetics::reactionTypeStr during transition.");
|
||||
return m_reactions[i]->reaction_type;
|
||||
std::string Kinetics::reactionType(size_t i) const {
|
||||
return m_reactions[i]->type();
|
||||
}
|
||||
|
||||
std::string Kinetics::reactionTypeStr(size_t i) const {
|
||||
return m_reactions[i]->type();
|
||||
warn_deprecated("Kinetics::reactionTypeStr",
|
||||
"To be removed after Cantera 3.0.");
|
||||
return reactionType(i);
|
||||
}
|
||||
|
||||
std::string Kinetics::reactionString(size_t i) const
|
||||
|
||||
@@ -683,9 +683,9 @@ string reactionLabel(size_t i, size_t kr, size_t nr,
|
||||
label += " + "+ s.kineticsSpeciesName(slist[j]);
|
||||
}
|
||||
}
|
||||
if (ba::starts_with(s.reactionTypeStr(i), "three-body")) {
|
||||
if (ba::starts_with(s.reactionType(i), "three-body")) {
|
||||
label += " + M ";
|
||||
} else if (ba::starts_with(s.reactionTypeStr(i), "falloff")) {
|
||||
} else if (ba::starts_with(s.reactionType(i), "falloff")) {
|
||||
label += " (+ M)";
|
||||
}
|
||||
return label;
|
||||
@@ -738,9 +738,9 @@ int ReactionPathBuilder::build(Kinetics& s, const string& element,
|
||||
revlabel += " + "+ s.kineticsSpeciesName(m_prod[i][j]);
|
||||
}
|
||||
}
|
||||
if (ba::starts_with(s.reactionTypeStr(i), "three-body")) {
|
||||
if (ba::starts_with(s.reactionType(i), "three-body")) {
|
||||
revlabel += " + M ";
|
||||
} else if (ba::starts_with(s.reactionTypeStr(i), "falloff")) {
|
||||
} else if (ba::starts_with(s.reactionType(i), "falloff")) {
|
||||
revlabel += " (+ M)";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user