diff --git a/include/cantera/thermo/Phase.h b/include/cantera/thermo/Phase.h index 8de76a69f1..040616df5b 100644 --- a/include/cantera/thermo/Phase.h +++ b/include/cantera/thermo/Phase.h @@ -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 diff --git a/src/thermo/IdealSolidSolnPhase.cpp b/src/thermo/IdealSolidSolnPhase.cpp index 06eb854e81..24b0860f35 100644 --- a/src/thermo/IdealSolidSolnPhase.cpp +++ b/src/thermo/IdealSolidSolnPhase.cpp @@ -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) @@ -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; } diff --git a/src/thermo/IdealSolnGasVPSS.cpp b/src/thermo/IdealSolnGasVPSS.cpp index a91b52a875..1a46cbb68a 100644 --- a/src/thermo/IdealSolnGasVPSS.cpp +++ b/src/thermo/IdealSolnGasVPSS.cpp @@ -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 diff --git a/src/thermo/Phase.cpp b/src/thermo/Phase.cpp index 68a4a9428a..8278a14320 100644 --- a/src/thermo/Phase.cpp +++ b/src/thermo/Phase.cpp @@ -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]; }