From b1a1ce6e2339e7cb40b0f363e772b5ce0d1eea9a Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 19 Oct 2016 19:44:20 -0400 Subject: [PATCH] [Thermo] Fix pure fluid thermal expansion coefficient calculation --- interfaces/cython/cantera/test/test_purefluid.py | 15 +++++++++++++++ src/tpx/Sub.cpp | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/interfaces/cython/cantera/test/test_purefluid.py b/interfaces/cython/cantera/test/test_purefluid.py index 21efc020b..bebee5fc4 100644 --- a/interfaces/cython/cantera/test/test_purefluid.py +++ b/interfaces/cython/cantera/test/test_purefluid.py @@ -105,6 +105,21 @@ class TestPureFluid(utilities.CanteraTest): self.check_fd_properties(self.water.max_temp*(1-1e-5), 101325, self.water.max_temp*(1-1e-4), 101325, 1e-2) + def test_isothermal_compressibility_lowP(self): + # Low-pressure limit corresponds to ideal gas + ref = ct.Solution('gri30.xml') + ref.TPX = 450, 12, 'H2O:1.0' + self.water.TP = 450, 12 + self.assertNear(ref.isothermal_compressibility, + self.water.isothermal_compressibility, 1e-5) + + def test_thermal_expansion_coeff_lowP(self): + # Low-pressure limit corresponds to ideal gas + ref = ct.Solution('gri30.xml') + ref.TPX = 450, 12, 'H2O:1.0' + self.water.TP = 450, 12 + self.assertNear(ref.thermal_expansion_coeff, + self.water.thermal_expansion_coeff, 1e-5) def test_TPX(self): self.water.TX = 400, 0.8 T,P,X = self.water.TPX diff --git a/src/tpx/Sub.cpp b/src/tpx/Sub.cpp index 33ee6c897..a6cdf6f73 100644 --- a/src/tpx/Sub.cpp +++ b/src/tpx/Sub.cpp @@ -90,7 +90,7 @@ double Substance::thermalExpansionCoeff() Set(PropertyPair::TP, T2, p0); double v2 = v(); Set(PropertyPair::TP, Tsave, p0); - return (v2 - v1)/((v2 + v1)*(T2-T1)); + return 2.0*(v2 - v1)/((v2 + v1)*(T2-T1)); } double Substance::isothermalCompressibility()