Skip to content

Commit

Permalink
[Thermo] Fix error in PDSS_Water reference state calculations
Browse files Browse the repository at this point in the history
The water property calculator needs to be given the correct phase guess,
otherwise it will return in an invalid state.
  • Loading branch information
speth committed Feb 13, 2017
1 parent 38d291c commit 7b529ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/thermo/PDSS_Water.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ doublereal PDSS_Water::molarVolume() const
doublereal PDSS_Water::gibbs_RT_ref() const
{
doublereal T = m_temp;
m_sub.density(T, m_p0);
m_sub.density(T, m_p0, m_iState);
doublereal h = m_sub.enthalpy();
m_sub.setState_TR(m_temp, m_dens);
return (h + EW_Offset - SW_Offset*T)/(T * GasConstant);
Expand All @@ -151,7 +151,7 @@ doublereal PDSS_Water::gibbs_RT_ref() const
doublereal PDSS_Water::enthalpy_RT_ref() const
{
doublereal T = m_temp;
m_sub.density(T, m_p0);
m_sub.density(T, m_p0, m_iState);
doublereal h = m_sub.enthalpy();
m_sub.setState_TR(m_temp, m_dens);
return (h + EW_Offset)/(T * GasConstant);
Expand All @@ -160,7 +160,7 @@ doublereal PDSS_Water::enthalpy_RT_ref() const
doublereal PDSS_Water::entropy_R_ref() const
{
doublereal T = m_temp;
m_sub.density(T, m_p0);
m_sub.density(T, m_p0, m_iState);
doublereal s = m_sub.entropy();
m_sub.setState_TR(m_temp, m_dens);
return (s + SW_Offset)/GasConstant;
Expand All @@ -169,7 +169,7 @@ doublereal PDSS_Water::entropy_R_ref() const
doublereal PDSS_Water::cp_R_ref() const
{
doublereal T = m_temp;
m_sub.density(T, m_p0);
m_sub.density(T, m_p0, m_iState);
doublereal cp = m_sub.cp();
m_sub.setState_TR(m_temp, m_dens);
return cp/GasConstant;
Expand All @@ -178,7 +178,7 @@ doublereal PDSS_Water::cp_R_ref() const
doublereal PDSS_Water::molarVolume_ref() const
{
doublereal T = m_temp;
m_sub.density(T, m_p0);
m_sub.density(T, m_p0, m_iState);
doublereal mv = m_sub.molarVolume();
m_sub.setState_TR(m_temp, m_dens);
return mv;
Expand Down
6 changes: 6 additions & 0 deletions test/thermo/standardStateManagers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ TEST(HMW, VPSSMgrGeneral_vs_VPSSMgrWater_ConstVol)
EXPECT_NEAR(v1[i], v2[i], 1e-10) << p1.speciesName(i);
}

p1.getGibbs_ref(v1.data());
p2.getGibbs_ref(v2.data());
for (size_t i = 0; i < n; i++) {
EXPECT_NEAR(v1[i], v2[i], 1e-4) << p1.speciesName(i);
}

EXPECT_NEAR(p1.entropy_mole(), p2.entropy_mole(), 1e-7);
EXPECT_NEAR(p1.enthalpy_mole(), p2.enthalpy_mole(), 1e-4);
}

0 comments on commit 7b529ac

Please sign in to comment.