[Python] Make transport properties accessible with the Water() function

This commit is contained in:
Ray Speth 2018-08-30 10:32:12 -04:00
parent 0ade0acf18
commit b0b66d7211
2 changed files with 64 additions and 3 deletions

View file

@ -1,11 +1,19 @@
# This file is part of Cantera. See License.txt in the top-level directory or
# at http://www.cantera.org/license.txt for license and copyright information.
from . import PureFluid
from . import PureFluid, _cantera
def Water():
"""Create a `PureFluid` object using the equation of state for water."""
return PureFluid('liquidvapor.xml','water')
"""
Create a `PureFluid` object using the equation of state for water and the
`WaterTransport` class for viscosity and thermal conductivity."""
class WaterWithTransport(PureFluid, _cantera.Transport):
__slots__ = ()
return WaterWithTransport('liquidvapor.xml', 'water', transport_model='Water')
def Nitrogen():
"""Create a `PureFluid` object using the equation of state for nitrogen."""

View file

@ -268,6 +268,59 @@ class TestDustyGas(utilities.CanteraTest):
# self.assertNear(sum(fluxes1) / sum(abs(fluxes1)), 0.0)
class TestWaterTransport(utilities.CanteraTest):
"""
Comparison values are taken from the NIST Chemistry WebBook. Agreement is
limited by the use of a different equation of state here (Reynolds) than
in the Webbook (IAPWS95), as well as a different set of coefficients for
the transport property model. Differences are largest in the region near
the critical point.
"""
@classmethod
def setUpClass(cls):
cls.water = ct.Water()
def check_viscosity(self, T, P, mu, rtol):
self.water.TP = T, P
self.assertNear(self.water.viscosity, mu, rtol)
def check_thermal_conductivity(self, T, P, k, rtol):
self.water.TP = T, P
self.assertNear(self.water.thermal_conductivity, k, rtol)
def test_viscosity_liquid(self):
self.check_viscosity(400, 1e6, 2.1880e-4, 1e-3)
self.check_viscosity(400, 8e6, 2.2061e-4, 1e-3)
self.check_viscosity(620, 1.6e7, 6.7489e-5, 2e-3)
self.check_viscosity(620, 2.8e7, 7.5684e-5, 2e-3)
def test_thermal_conductivity_liquid(self):
self.check_thermal_conductivity(400, 1e6, 0.68410, 1e-3)
self.check_thermal_conductivity(400, 8e6, 0.68836, 1e-3)
self.check_thermal_conductivity(620, 1.6e7, 0.45458, 2e-3)
self.check_thermal_conductivity(620, 2.8e7, 0.49705, 2e-3)
def test_viscosity_vapor(self):
self.check_viscosity(600, 1e6, 2.1329e-5, 1e-3)
self.check_viscosity(620, 5e6, 2.1983e-5, 1e-3)
self.check_viscosity(620, 1.5e7, 2.2858e-5, 2e-3)
def test_thermal_conductivity_vapor(self):
self.check_thermal_conductivity(600, 1e6, 0.047636, 1e-3)
self.check_thermal_conductivity(620, 5e6, 0.055781, 1e-3)
self.check_thermal_conductivity(620, 1.5e7, 0.10524, 2e-3)
def test_viscosity_supercritical(self):
self.check_viscosity(660, 2.2e7, 2.7129e-5, 2e-3)
self.check_viscosity(660, 2.54e7, 3.8212e-5, 1e-2)
self.check_viscosity(660, 2.8e7, 5.3159e-5, 1e-2)
def test_thermal_conductivity_supercritical(self):
self.check_thermal_conductivity(660, 2.2e7, 0.14872, 1e-2)
self.check_thermal_conductivity(660, 2.54e7, 0.35484, 2e-2)
self.check_thermal_conductivity(660, 2.8e7, 0.38479, 1e-2)
class TestTransportData(utilities.CanteraTest):
@classmethod
def setUpClass(cls):