Skip to content

Commit

Permalink
[thermo] Make intEnergy_mole consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Jan 7, 2025
1 parent 987dfbe commit e6d5de4
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 23 deletions.
1 change: 1 addition & 0 deletions include/cantera/thermo/HMWSoln.h
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ class HMWSoln : public MolalityVPSSTP
*/
virtual double relative_molal_enthalpy() const;

double intEnergy_mole() const override;
double cv_mole() const override;

//! @}
Expand Down
16 changes: 0 additions & 16 deletions include/cantera/thermo/IdealMolalSoln.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,6 @@ class IdealMolalSoln : public MolalityVPSSTP
return true;
}

//! @name Molar Thermodynamic Properties of the Solution
//! @{

//! Molar internal energy of the solution: Units: J/kmol.
/*!
* Returns the amount of internal energy per mole of solution. For an ideal
* molal solution,
* @f[
* \bar{u}(T, P, X_k) = \sum_k X_k \bar{u}_k(T)
* @f]
* The formula is written in terms of the partial molar internal energy.
* @f$ \bar{u}_k(T, p, m_k) @f$.
*/
double intEnergy_mole() const override;

//! @}
//! @name Mechanical Equation of State Properties
//!
//! In this equation of state implementation, the density is a function only
Expand Down
2 changes: 2 additions & 0 deletions include/cantera/thermo/IdealSolidSolnPhase.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class IdealSolidSolnPhase : public ThermoPhase
//! @name Molar Thermodynamic Properties of the Solution
//! @{

double intEnergy_mole() const override;

/**
* Molar entropy of the solution. Units: J/kmol/K. For an ideal, constant
* partial molar volume solution mixture with pure species phases which
Expand Down
2 changes: 2 additions & 0 deletions include/cantera/thermo/LatticePhase.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ class LatticePhase : public ThermoPhase
*/
double enthalpy_mole() const override;

double intEnergy_mole() const override;

//! Molar entropy of the solution. Units: J/kmol/K
/*!
* For an ideal, constant partial molar volume solution mixture with
Expand Down
1 change: 1 addition & 0 deletions include/cantera/thermo/MargulesVPSSTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ class MargulesVPSSTP : public GibbsExcessVPSSTP
//! @name Molar Thermodynamic Properties
//! @{

double intEnergy_mole() const override;
double cv_mole() const override;

//! @}
Expand Down
1 change: 1 addition & 0 deletions include/cantera/thermo/MixtureFugacityTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class MixtureFugacityTP : public ThermoPhase
//! @{

double enthalpy_mole() const override;
double intEnergy_mole() const override;
double entropy_mole() const override;

//! @}
Expand Down
13 changes: 12 additions & 1 deletion include/cantera/thermo/ThermoPhase.h
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,19 @@ class ThermoPhase : public Phase
}

//! Molar internal energy. Units: J/kmol.
/*!
* Returns the amount of internal energy per mole of solution. For an ideal
* molal solution,
* @f[
* \bar{u}(T, P, X_k) = \sum_k X_k \bar{u}_k(T)
* @f]
* The formula is written in terms of the partial molar internal energy.
* @f$ \bar{u}_k(T, p, m_k) @f$.
* @relates getPartialMolarIntEnergies
*/
virtual double intEnergy_mole() const {
return enthalpy_mole() - pressure()* molarVolume();
getPartialMolarIntEnergies(m_tmpV.data());
return mean_X(m_tmpV);
}

//! Molar entropy. Units: J/kmol/K.
Expand Down
5 changes: 5 additions & 0 deletions src/thermo/HMWSoln.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ double HMWSoln::relative_molal_enthalpy() const
return L / xuse;
}

double HMWSoln::intEnergy_mole() const
{
return enthalpy_mole() - pressure() * molarVolume();
}

double HMWSoln::cv_mole() const
{
double kappa_t = isothermalCompressibility();
Expand Down
6 changes: 0 additions & 6 deletions src/thermo/IdealMolalSoln.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ IdealMolalSoln::IdealMolalSoln(const string& inputFile, const string& id_) :
initThermoFile(inputFile, id_);
}

double IdealMolalSoln::intEnergy_mole() const
{
getPartialMolarIntEnergies(m_tmpV.data());
return mean_X(m_tmpV);
}

// ------- Mechanical Equation of State Properties ------------------------

double IdealMolalSoln::isothermalCompressibility() const
Expand Down
5 changes: 5 additions & 0 deletions src/thermo/IdealSolidSolnPhase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ IdealSolidSolnPhase::IdealSolidSolnPhase(const string& inputFile, const string&

// Molar Thermodynamic Properties of the Solution

double IdealSolidSolnPhase::intEnergy_mole() const
{
return enthalpy_mole() - pressure() * molarVolume();
}

double IdealSolidSolnPhase::entropy_mole() const
{
return GasConstant * (mean_X(entropy_R_ref()) - sum_xlogx());
Expand Down
5 changes: 5 additions & 0 deletions src/thermo/LatticePhase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ double LatticePhase::entropy_mole() const
return GasConstant * (mean_X(entropy_R_ref()) - sum_xlogx());
}

double LatticePhase::intEnergy_mole() const
{
return enthalpy_mole() - pressure() * molarVolume();
}

double LatticePhase::gibbs_mole() const {
return enthalpy_mole() - temperature() * entropy_mole();
}
Expand Down
5 changes: 5 additions & 0 deletions src/thermo/MargulesVPSSTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ void MargulesVPSSTP::getChemPotentials(double* mu) const
}
}

double MargulesVPSSTP::intEnergy_mole() const
{
return enthalpy_mole() - pressure() * molarVolume();
}

double MargulesVPSSTP::cv_mole() const
{
return cp_mole() - GasConstant;
Expand Down
6 changes: 6 additions & 0 deletions src/thermo/MixtureFugacityTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ double MixtureFugacityTP::enthalpy_mole() const
}


double MixtureFugacityTP::intEnergy_mole() const
{
return enthalpy_mole() - pressure() * molarVolume();
}


double MixtureFugacityTP::entropy_mole() const
{
double s_ideal = GasConstant * (mean_X(m_s0_R) - sum_xlogx()
Expand Down

0 comments on commit e6d5de4

Please sign in to comment.