Skip to content

Commit

Permalink
Deprecate unused methods of class Phase
Browse files Browse the repository at this point in the history
  • Loading branch information
speth authored and ischoegl committed Mar 14, 2023
1 parent 5cd3d8a commit d1a5742
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 8 deletions.
9 changes: 9 additions & 0 deletions include/cantera/thermo/Phase.h
Expand Up @@ -224,6 +224,7 @@ class Phase
//! @param k species index
//! @param atomArray vector containing the atomic number in the species.
//! Length: m_mm
//! @deprecated Unused. To be removed after Cantera 3.0
void getAtoms(size_t k, double* atomArray) const;

//! Returns the index of a species named 'name' within the Phase object.
Expand All @@ -243,6 +244,7 @@ class Phase
//! This is guaranteed to be unique within a Cantera problem.
//! @param k Species index within the phase
//! @return The "phaseName:speciesName" string
//! @deprecated Unused. To be removed after Cantera 3.0
std::string speciesSPName(int k) const;

//! Return a const reference to the vector of species names
Expand Down Expand Up @@ -406,6 +408,7 @@ class Phase
//! @param t Temperature in kelvin
//! @param n molar density (kmol/m^3)
//! @param x vector of species mole fractions, length m_kk
//! @deprecated Unused. To be removed after Cantera 3.0
void setState_TNX(doublereal t, doublereal n, const doublereal* x);

//! Set the internally stored temperature (K) and density (kg/m^3)
Expand All @@ -423,21 +426,25 @@ class Phase
//! Set the internally stored temperature (K) and mole fractions.
//! @param t Temperature in kelvin
//! @param x vector of species mole fractions, length m_kk
//! @deprecated Unused. To be removed after Cantera 3.0
void setState_TX(doublereal t, doublereal* x);

//! Set the internally stored temperature (K) and mass fractions.
//! @param t Temperature in kelvin
//! @param y vector of species mass fractions, length m_kk
//! @deprecated Unused. To be removed after Cantera 3.0
void setState_TY(doublereal t, doublereal* y);

//! Set the density (kg/m^3) and mole fractions.
//! @param rho Density (kg/m^3)
//! @param x vector of species mole fractions, length m_kk
//! @deprecated Unused. To be removed after Cantera 3.0
void setState_RX(doublereal rho, doublereal* x);

//! Set the density (kg/m^3) and mass fractions.
//! @param rho Density (kg/m^3)
//! @param y vector of species mass fractions, length m_kk
//! @deprecated Unused. To be removed after Cantera 3.0
void setState_RY(doublereal rho, doublereal* y);

//! @} end group set thermo state
Expand All @@ -449,6 +456,7 @@ class Phase

//! Copy the vector of molecular weights into vector weights.
//! @param weights Output vector of molecular weights (kg/kmol)
//! @deprecated Unused. To be removed after Cantera 3.0
void getMolecularWeights(vector_fp& weights) const;

//! Copy the vector of molecular weights into array weights.
Expand Down Expand Up @@ -696,6 +704,7 @@ class Phase

//! Set the internally stored molar density (kmol/m^3) of the phase.
//! @param[in] molarDensity Input molar density (kmol/m^3).
//! @deprecated Unused. To be removed after Cantera 3.0
virtual void setMolarDensity(const double molarDensity);

//! Set the internally stored pressure (Pa) at constant temperature and
Expand Down
8 changes: 2 additions & 6 deletions include/cantera/thermo/SurfPhase.h
Expand Up @@ -211,12 +211,8 @@ class SurfPhase : public ThermoPhase

//! Since interface phases have no volume, setting this to a value other than 0.0
//! raises an exception.
virtual void setMolarDensity(const double vm) {
if (vm != 0.0) {
throw CanteraError("SurfPhase::setMolarDensity",
"The volume of an interface is zero");
}
}
//! @deprecated Unused. To be removed after Cantera 3.0
virtual void setMolarDensity(const double vm);

//! Returns the site density
/*!
Expand Down
3 changes: 2 additions & 1 deletion samples/cxx/LiC6_electrode/LiC6_electrode.cpp
Expand Up @@ -60,7 +60,8 @@ void calc_potentials()
}
}

electrodebulk->setState_TX(Tk, &xv[0]);
electrodebulk->setMoleFractions(&xv[0]);
electrodebulk->setTemperature(Tk);
electrodebulk->getChemPotentials(spvals.data());

// Calculate the open circuit potential
Expand Down
17 changes: 17 additions & 0 deletions src/thermo/Phase.cpp
Expand Up @@ -109,6 +109,8 @@ doublereal Phase::nAtoms(size_t k, size_t m) const

void Phase::getAtoms(size_t k, double* atomArray) const
{
warn_deprecated("Phase::getAtoms", "To be removed after Cantera 3.0. "
"Use 'nAtoms(species_index, element_index)' instead.");
for (size_t m = 0; m < m_mm; m++) {
atomArray[m] = (double) m_speciesComp[m_mm * k + m];
}
Expand Down Expand Up @@ -173,6 +175,7 @@ void Phase::checkSpeciesArraySize(size_t kk) const

std::string Phase::speciesSPName(int k) const
{
warn_deprecated("Phase::speciesSPName", "To be removed after Cantera 3.0");
return m_name + ":" + speciesName(k);
}

Expand Down Expand Up @@ -384,6 +387,8 @@ void Phase::setState_TRX(doublereal t, doublereal dens, const doublereal* x)

void Phase::setState_TNX(doublereal t, doublereal n, const doublereal* x)
{
warn_deprecated("Phase::setState_TNX", "To be removed after Cantera 3.0. "
"Use 'setMoleFractions' and 'setState_TD' instead.");
setMoleFractions(x);
setTemperature(t);
setMolarDensity(n);
Expand Down Expand Up @@ -431,24 +436,32 @@ void Phase::setState_TD(double t, double rho)

void Phase::setState_TX(doublereal t, doublereal* x)
{
warn_deprecated("Phase::setState_TX", "To be removed after Cantera 3.0. "
"Use calls to 'setTemperature' and 'setMoleFractions' instead.");
setTemperature(t);
setMoleFractions(x);
}

void Phase::setState_TY(doublereal t, doublereal* y)
{
warn_deprecated("Phase::setState_TY", "To be removed after Cantera 3.0. "
"Use calls to 'setTemperature' and 'setMassFractions' instead.");
setTemperature(t);
setMassFractions(y);
}

void Phase::setState_RX(doublereal rho, doublereal* x)
{
warn_deprecated("Phase::setState_RX", "To be removed after Cantera 3.0. "
"Use calls to 'setDensity' and 'setMoleFractions' instead.");
setMoleFractions(x);
setDensity(rho);
}

void Phase::setState_RY(doublereal rho, doublereal* y)
{
warn_deprecated("Phase::setState_RY", "To be removed after Cantera 3.0. "
"Use calls to 'setDensity' and 'setMassFractions' instead.");
setMassFractions(y);
setDensity(rho);
}
Expand All @@ -461,6 +474,8 @@ doublereal Phase::molecularWeight(size_t k) const

void Phase::getMolecularWeights(vector_fp& weights) const
{
warn_deprecated("Phase::getMolecularWeights(vector_fp&)", "To be removed after "
"Cantera 3.0. Use 'getMolecularWeights(vec.data())' instead.");
weights = molecularWeights();
}

Expand Down Expand Up @@ -663,6 +678,8 @@ double Phase::molarDensity() const

void Phase::setMolarDensity(const double molar_density)
{
warn_deprecated("Phase::setMolarDensity", "To be removed after Cantera 3.0. "
"Use 'setDensity(molar_density * meanMolecularWeight())' instead.");
assertCompressible("setMolarDensity");
m_dens = molar_density*meanMolecularWeight();
}
Expand Down
8 changes: 8 additions & 0 deletions src/thermo/SurfPhase.cpp
Expand Up @@ -201,6 +201,14 @@ bool SurfPhase::addSpecies(shared_ptr<Species> spec)
return added;
}

void SurfPhase::setMolarDensity(const double vm) {
warn_deprecated("SurfPhase::setMolarDensity", "To be removed after Cantera 3.0");
if (vm != 0.0) {
throw CanteraError("SurfPhase::setMolarDensity",
"The volume of an interface is zero");
}
}

void SurfPhase::setSiteDensity(doublereal n0)
{
if (n0 <= 0.0) {
Expand Down
3 changes: 2 additions & 1 deletion test_problems/diamondSurf/runDiamond.cpp
Expand Up @@ -53,7 +53,8 @@ int main(int argc, char** argv)
x[i0] = 0.1;
size_t i1 = diamond100->speciesIndex("c6HH");
x[i1] = 0.9;
diamond100->setState_TX(1200., x);
diamond100->setMoleFractions(x);
diamond100->setTemperature(1200.);

for (i = 0; i < 20; i++) {
x[i] = 0.0;
Expand Down

0 comments on commit d1a5742

Please sign in to comment.