Skip to content

Commit

Permalink
Make dimensionalization of IAPWS95 EOS consistent
Browse files Browse the repository at this point in the history
The nondimensional EOS should always be dimensionalized to a mass
basis using the value of R given in the original source. Values on
a molar basis can then be computed consistently using the best available
value for the molecular weight of water.

Partially resolves #1315
  • Loading branch information
speth committed Sep 25, 2022
1 parent 959c9cb commit f6744ec
Show file tree
Hide file tree
Showing 12 changed files with 264 additions and 188 deletions.
36 changes: 36 additions & 0 deletions include/cantera/thermo/WaterPropsIAPWS.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,34 +174,70 @@ class WaterPropsIAPWS
*/
void setState_TR(doublereal temperature, doublereal rho);

//! Get the Gibbs free energy (J/kg) at the current temperature and density
double gibbs_mass() const;

//! Get the enthalpy (J/kg) at the current temperature and density
double enthalpy_mass() const;

//! Get the internal energy (J/kg) at the current temperature and density
double intEnergy_mass() const;

//! Get the entropy (J/kg/K) at the current temperature and density
double entropy_mass() const;

//! Get the constant volume heat capacity (J/kg/K) at the current temperature and
//! density
double cv_mass() const;

//! Get the constant pressure heat capacity (J/kg/K) at the current temperature and
//! density
double cp_mass() const;

//! Calculate the Helmholtz free energy in mks units of J kmol-1 K-1,
//! using the last temperature and density
//! @deprecated To be removed after Cantera 3.0. This class provides mass-based
//! values only.
doublereal helmholtzFE() const;

//! Calculate the Gibbs free energy in mks units of J kmol-1 K-1.
//! using the last temperature and density
//! @deprecated To be removed after Cantera 3.0. This class provides mass-based
//! values only.
doublereal Gibbs() const;

//! Calculate the enthalpy in mks units of J kmol-1
//! using the last temperature and density
//! @deprecated To be removed after Cantera 3.0. This class provides mass-based
//! values only.
doublereal enthalpy() const;

//! Calculate the internal energy in mks units of J kmol-1
//! @deprecated To be removed after Cantera 3.0. This class provides mass-based
//! values only.
doublereal intEnergy() const;

//! Calculate the entropy in mks units of J kmol-1 K-1
//! @deprecated To be removed after Cantera 3.0. This class provides mass-based
//! values only.
doublereal entropy() const;

//! Calculate the constant volume heat capacity in mks units of J kmol-1 K-1
//! at the last temperature and density
//! @deprecated To be removed after Cantera 3.0. This class provides mass-based
//! values only.
doublereal cv() const;

//! Calculate the constant pressure heat capacity in mks units of J kmol-1 K-1
//! at the last temperature and density
//! @deprecated To be removed after Cantera 3.0. This class provides mass-based
//! values only.
doublereal cp() const;

//! Calculate the molar volume (kmol m-3) at the last temperature and
//! density
//! @deprecated To be removed after Cantera 3.0. This class provides mass-based
//! values only.
doublereal molarVolume() const;

//! Calculates the pressure (Pascals), given the current value of the
Expand Down
4 changes: 4 additions & 0 deletions samples/python/onedim/diffusion_flame_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
import cantera as ct


import warnings
warnings.filterwarnings("error", module=".*")

class FlameExtinguished(Exception):
pass

Expand All @@ -49,6 +52,7 @@ class FlameExtinguished(Exception):

reaction_mechanism = 'h2o2.yaml'
gas = ct.Solution(reaction_mechanism)
gas.reactant_stoich_coeffs3
width = 18e-3 # 18mm wide
f = ct.CounterflowDiffusionFlame(gas, width=width)

Expand Down
47 changes: 21 additions & 26 deletions src/thermo/PDSS_Water.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,80 +55,75 @@ PDSS_Water::PDSS_Water() :

doublereal PDSS_Water::enthalpy_mole() const
{
return m_sub.enthalpy() + EW_Offset;
return m_sub.enthalpy_mass() * m_mw + EW_Offset;
}

doublereal PDSS_Water::intEnergy_mole() const
{
return m_sub.intEnergy() + EW_Offset;
return m_sub.intEnergy_mass() * m_mw + EW_Offset;
}

doublereal PDSS_Water::entropy_mole() const
{
return m_sub.entropy() + SW_Offset;
return m_sub.entropy_mass() * m_mw + SW_Offset;
}

doublereal PDSS_Water::gibbs_mole() const
{
return m_sub.Gibbs() + EW_Offset - SW_Offset*m_temp;
return m_sub.gibbs_mass() * m_mw+ EW_Offset - SW_Offset * m_temp;
}

doublereal PDSS_Water::cp_mole() const
{
return m_sub.cp();
return m_sub.cp_mass() * m_mw;
}

doublereal PDSS_Water::cv_mole() const
{
return m_sub.cv();
return m_sub.cv_mass() * m_mw;
}

doublereal PDSS_Water::molarVolume() const
{
return m_sub.molarVolume();
return m_mw / m_sub.density();
}

doublereal PDSS_Water::gibbs_RT_ref() const
{
doublereal T = m_temp;
m_sub.density(T, m_p0, m_iState);
doublereal h = m_sub.enthalpy();
m_sub.density(m_temp, m_p0, m_iState);
double h = m_sub.enthalpy_mass() * m_mw;
m_sub.setState_TR(m_temp, m_dens);
return (h + EW_Offset - SW_Offset*T)/(T * GasConstant);
return (h + EW_Offset - SW_Offset * m_temp) / (m_temp * GasConstant);
}

doublereal PDSS_Water::enthalpy_RT_ref() const
{
doublereal T = m_temp;
m_sub.density(T, m_p0, m_iState);
doublereal h = m_sub.enthalpy();
m_sub.density(m_temp, m_p0, m_iState);
double h = m_sub.enthalpy_mass() * m_mw;
m_sub.setState_TR(m_temp, m_dens);
return (h + EW_Offset)/(T * GasConstant);
return (h + EW_Offset) / (m_temp * GasConstant);
}

doublereal PDSS_Water::entropy_R_ref() const
{
doublereal T = m_temp;
m_sub.density(T, m_p0, m_iState);
doublereal s = m_sub.entropy();
m_sub.density(m_temp, m_p0, m_iState);
double s = m_sub.entropy_mass() * m_mw;
m_sub.setState_TR(m_temp, m_dens);
return (s + SW_Offset)/GasConstant;
return (s + SW_Offset) / GasConstant;
}

doublereal PDSS_Water::cp_R_ref() const
{
doublereal T = m_temp;
m_sub.density(T, m_p0, m_iState);
doublereal cp = m_sub.cp();
m_sub.density(m_temp, m_p0, m_iState);
double cp = m_sub.cp_mass() * m_mw;
m_sub.setState_TR(m_temp, m_dens);
return cp/GasConstant;
return cp / GasConstant;
}

doublereal PDSS_Water::molarVolume_ref() const
{
doublereal T = m_temp;
m_sub.density(T, m_p0, m_iState);
doublereal mv = m_sub.molarVolume();
m_sub.density(m_temp, m_p0, m_iState);
double mv = m_mw / m_sub.density();
m_sub.setState_TR(m_temp, m_dens);
return mv;
}
Expand Down
Loading

0 comments on commit f6744ec

Please sign in to comment.