[Equil] Deprecate get/setElementPotentials
This commit is contained in:
parent
74167cc3eb
commit
3c978cdff6
6 changed files with 17 additions and 27 deletions
|
|
@ -123,6 +123,8 @@ public:
|
||||||
*/
|
*/
|
||||||
int equilibrate(thermo_t& s, const char* XY, vector_fp& elMoles,
|
int equilibrate(thermo_t& s, const char* XY, vector_fp& elMoles,
|
||||||
int loglevel = 0);
|
int loglevel = 0);
|
||||||
|
|
||||||
|
//! @deprecated To be removed after Cantera 2.4.
|
||||||
const vector_fp& elementPotentials() const {
|
const vector_fp& elementPotentials() const {
|
||||||
return m_lambda;
|
return m_lambda;
|
||||||
}
|
}
|
||||||
|
|
@ -266,6 +268,7 @@ protected:
|
||||||
vector_fp m_molefractions;
|
vector_fp m_molefractions;
|
||||||
|
|
||||||
//! Current value of the dimensional element potentials. length = #m_mm
|
//! Current value of the dimensional element potentials. length = #m_mm
|
||||||
|
//! @deprecated To be removed after Cantera 2.4.
|
||||||
vector_fp m_lambda;
|
vector_fp m_lambda;
|
||||||
|
|
||||||
//! Current value of the sum of the element abundances given the current
|
//! Current value of the sum of the element abundances given the current
|
||||||
|
|
|
||||||
|
|
@ -1618,10 +1618,12 @@ protected:
|
||||||
doublereal m_phi;
|
doublereal m_phi;
|
||||||
|
|
||||||
//! Vector of element potentials. Length equal to number of elements.
|
//! Vector of element potentials. Length equal to number of elements.
|
||||||
|
//! @deprecated To be removed after Cantera 2.4.
|
||||||
vector_fp m_lambdaRRT;
|
vector_fp m_lambdaRRT;
|
||||||
|
|
||||||
//! Boolean indicating whether there is a valid set of saved element
|
//! Boolean indicating whether there is a valid set of saved element
|
||||||
//! potentials for this phase
|
//! potentials for this phase
|
||||||
|
//! @deprecated To be removed after Cantera 2.4.
|
||||||
bool m_hasElementPotentials;
|
bool m_hasElementPotentials;
|
||||||
|
|
||||||
//! Boolean indicating whether a charge neutrality condition is a necessity
|
//! Boolean indicating whether a charge neutrality condition is a necessity
|
||||||
|
|
|
||||||
|
|
@ -1331,6 +1331,9 @@ cdef class ThermoPhase(_SolutionBase):
|
||||||
defined for equilibrium states. This method first sets the composition
|
defined for equilibrium states. This method first sets the composition
|
||||||
to a state of equilibrium at constant T and P, then computes the
|
to a state of equilibrium at constant T and P, then computes the
|
||||||
element potentials for this equilibrium state.
|
element potentials for this equilibrium state.
|
||||||
|
|
||||||
|
.. deprecated:: 2.3
|
||||||
|
To be removed after Cantera 2.4.
|
||||||
"""
|
"""
|
||||||
self.equilibrate('TP')
|
self.equilibrate('TP')
|
||||||
cdef np.ndarray[np.double_t, ndim=1] data = np.zeros(self.n_elements)
|
cdef np.ndarray[np.double_t, ndim=1] data = np.zeros(self.n_elements)
|
||||||
|
|
|
||||||
|
|
@ -585,9 +585,6 @@ int ChemEquil::equilibrate(thermo_t& s, const char* XYstr,
|
||||||
adjustEloc(s, elMolesGoal);
|
adjustEloc(s, elMolesGoal);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the calculated and converged element potentials to the
|
|
||||||
// original ThermoPhase object.
|
|
||||||
s.setElementPotentials(m_lambda);
|
|
||||||
if (s.temperature() > s.maxTemp() + 1.0 ||
|
if (s.temperature() > s.maxTemp() + 1.0 ||
|
||||||
s.temperature() < s.minTemp() - 1.0) {
|
s.temperature() < s.minTemp() - 1.0) {
|
||||||
writelog("Warning: Temperature ({} K) outside valid range of "
|
writelog("Warning: Temperature ({} K) outside valid range of "
|
||||||
|
|
|
||||||
|
|
@ -702,7 +702,11 @@ void ThermoPhase::equilibrate(const std::string& XY, const std::string& solver,
|
||||||
throw CanteraError("ThermoPhase::equilibrate",
|
throw CanteraError("ThermoPhase::equilibrate",
|
||||||
"ChemEquil solver failed. Return code: {}", ret);
|
"ChemEquil solver failed. Return code: {}", ret);
|
||||||
}
|
}
|
||||||
setElementPotentials(E.elementPotentials());
|
m_lambdaRRT.resize(nElements());
|
||||||
|
for (size_t m = 0; m < nElements(); m++) {
|
||||||
|
m_lambdaRRT[m] = E.elementPotentials()[m] / RT();
|
||||||
|
}
|
||||||
|
m_hasElementPotentials = true;
|
||||||
debuglog("ChemEquil solver succeeded\n", log_level);
|
debuglog("ChemEquil solver succeeded\n", log_level);
|
||||||
return;
|
return;
|
||||||
} catch (std::exception& err) {
|
} catch (std::exception& err) {
|
||||||
|
|
@ -733,6 +737,8 @@ void ThermoPhase::equilibrate(const std::string& XY, const std::string& solver,
|
||||||
|
|
||||||
void ThermoPhase::setElementPotentials(const vector_fp& lambda)
|
void ThermoPhase::setElementPotentials(const vector_fp& lambda)
|
||||||
{
|
{
|
||||||
|
warn_deprecated("ThermoPhase::setElementPotentials",
|
||||||
|
"To be removed after Cantera 2.4");
|
||||||
size_t mm = nElements();
|
size_t mm = nElements();
|
||||||
if (lambda.size() < mm) {
|
if (lambda.size() < mm) {
|
||||||
throw CanteraError("setElementPotentials", "lambda too small");
|
throw CanteraError("setElementPotentials", "lambda too small");
|
||||||
|
|
@ -746,6 +752,8 @@ void ThermoPhase::setElementPotentials(const vector_fp& lambda)
|
||||||
|
|
||||||
bool ThermoPhase::getElementPotentials(doublereal* lambda) const
|
bool ThermoPhase::getElementPotentials(doublereal* lambda) const
|
||||||
{
|
{
|
||||||
|
warn_deprecated("ThermoPhase::getElementPotentials",
|
||||||
|
"To be removed after Cantera 2.4");
|
||||||
if (m_hasElementPotentials) {
|
if (m_hasElementPotentials) {
|
||||||
scale(m_lambdaRRT.begin(), m_lambdaRRT.end(), lambda, RT());
|
scale(m_lambdaRRT.begin(), m_lambdaRRT.end(), lambda, RT());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,29 +23,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(ThermoPhase_Fixture, SetAndGetElementPotentials)
|
|
||||||
{
|
|
||||||
initializeElements();
|
|
||||||
|
|
||||||
// Check that getElementPotentials returns false if no element potentials have been set yet.
|
|
||||||
vector_fp getLambda(3);
|
|
||||||
EXPECT_FALSE(test_phase.getElementPotentials(&getLambda[0]));
|
|
||||||
|
|
||||||
vector_fp tooSmall(2);
|
|
||||||
EXPECT_THROW(test_phase.setElementPotentials(tooSmall), CanteraError);
|
|
||||||
|
|
||||||
vector_fp setLambda(3);
|
|
||||||
setLambda[0] = 1.;
|
|
||||||
setLambda[1] = 2.;
|
|
||||||
setLambda[2] = 3.;
|
|
||||||
test_phase.setElementPotentials(setLambda);
|
|
||||||
|
|
||||||
EXPECT_TRUE(test_phase.getElementPotentials(&getLambda[0]));
|
|
||||||
EXPECT_DOUBLE_EQ(setLambda[0], getLambda[0]);
|
|
||||||
EXPECT_DOUBLE_EQ(setLambda[1], getLambda[1]);
|
|
||||||
EXPECT_DOUBLE_EQ(setLambda[2], getLambda[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
class TestThermoMethods : public testing::Test
|
class TestThermoMethods : public testing::Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue