Skip to content

Commit

Permalink
Eliminate usage of and deprecate Phase::moleFractdivMMW
Browse files Browse the repository at this point in the history
  • Loading branch information
speth authored and ischoegl committed Mar 14, 2023
1 parent 7ce825a commit 4e16561
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
2 changes: 2 additions & 0 deletions include/cantera/thermo/Phase.h
Expand Up @@ -631,6 +631,8 @@ class Phase
//! Returns a const pointer to the start of the moleFraction/MW array.
//! This array is the array of mole fractions, each divided by the mean
//! molecular weight.
//! @deprecated To be removed after Cantera 3.0. Generally replaceable by using
//! getMoleFractions() and meanMolecularWeight().
const double* moleFractdivMMW() const;

//! Dimensionless electrical charge of a single molecule of species k
Expand Down
19 changes: 6 additions & 13 deletions src/thermo/IdealSolidSolnPhase.cpp
Expand Up @@ -51,13 +51,11 @@ doublereal IdealSolidSolnPhase::cp_mole() const
void IdealSolidSolnPhase::calcDensity()
{
// Calculate the molarVolume of the solution (m**3 kmol-1)
const doublereal* const dtmp = moleFractdivMMW();
double invDens = dot(m_speciesMolarVolume.begin(),
m_speciesMolarVolume.end(), dtmp);
double v_mol = mean_X(m_speciesMolarVolume);

// Set the density in the parent State object directly, by calling the
// Set the density in the parent object directly, by calling the
// Phase::assignDensity() function.
Phase::assignDensity(1.0/invDens);
Phase::assignDensity(meanMolecularWeight()/v_mol);
}

void IdealSolidSolnPhase::setPressure(doublereal p)
Expand Down Expand Up @@ -86,23 +84,18 @@ Units IdealSolidSolnPhase::standardConcentrationUnits() const

void IdealSolidSolnPhase::getActivityConcentrations(doublereal* c) const
{
const doublereal* const dtmp = moleFractdivMMW();
const double mmw = meanMolecularWeight();
getMoleFractions(c);
switch (m_formGC) {
case 0:
for (size_t k = 0; k < m_kk; k++) {
c[k] = dtmp[k] * mmw;
}
break;
case 1:
for (size_t k = 0; k < m_kk; k++) {
c[k] = dtmp[k] * mmw / m_speciesMolarVolume[k];
c[k] /= m_speciesMolarVolume[k];
}
break;
case 2:
double atmp = mmw / m_speciesMolarVolume[m_kk-1];
for (size_t k = 0; k < m_kk; k++) {
c[k] = dtmp[k] * atmp;
c[k] /= m_speciesMolarVolume[m_kk-1];
}
break;
}
Expand Down
9 changes: 3 additions & 6 deletions src/thermo/IdealSolnGasVPSS.cpp
Expand Up @@ -73,12 +73,9 @@ void IdealSolnGasVPSS::setPressure(doublereal p)

void IdealSolnGasVPSS::calcDensity()
{
const doublereal* const dtmp = moleFractdivMMW();
const vector_fp& vss = getStandardVolumes();
double dens = 1.0 / dot(vss.begin(), vss.end(), dtmp);

// Set the density in the parent State object directly
Phase::assignDensity(dens);
double v_mol = mean_X(getStandardVolumes());
// Set the density in the parent object directly
Phase::assignDensity(meanMolecularWeight() / v_mol);
}

Units IdealSolnGasVPSS::standardConcentrationUnits() const
Expand Down
2 changes: 2 additions & 0 deletions src/thermo/Phase.cpp
Expand Up @@ -547,6 +547,8 @@ double Phase::moleFraction(const std::string& nameSpec) const

const double* Phase::moleFractdivMMW() const
{
warn_deprecated("Phase::moleFractdivMMW", "To be removed after Cantera 3.0. "
"Generally replaceable by 'getMoleFractions' and 'meanMolecularWeight'.");
return &m_ym[0];
}

Expand Down

0 comments on commit 4e16561

Please sign in to comment.