Skip to content
This repository was archived by the owner on Feb 20, 2021. It is now read-only.

Commit 6e0c4a6

Browse files
committed
Closes #86, add Pr_pT and tests.
1 parent f9dd7b7 commit 6e0c4a6

File tree

6 files changed

+59
-0
lines changed

6 files changed

+59
-0
lines changed

Reference/EnglishUnits.xlsm

-742 Bytes
Binary file not shown.

Reference/SIUnits.xlsm

494 Bytes
Binary file not shown.

XSteamPython/XSteamPython.py

+17
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,23 @@ def my_ps(pressure, entropy):
12731273
#Rem tc = toSIunit_tc(tc_pT(p, T))
12741274
#Rem Pr_pT = Cp * 1000 * my / tc
12751275
#Rem End Function
1276+
def Pr_pT(pressure, temperature):
1277+
heatCapacity = cp_pT(pressure, temperature)
1278+
viscosity = my_pT(pressure, temperature)
1279+
thermalConductivity = tc_pT(pressure, temperature)
1280+
1281+
if Constants._errorValue in (heatCapacity, viscosity, thermalConductivity):
1282+
return Constants._errorValue
1283+
1284+
if englishUnits:
1285+
heatCapacity = Convert.toSIUnit(heatCapacity, 'entropy')
1286+
viscosity = Convert.toSIUnit(viscosity, 'viscosity')
1287+
thermalConductivity = Convert.toSIUnit(thermalConductivity, 'thermal conductivity')
1288+
1289+
1290+
return heatCapacity*1000.0*viscosity/thermalConductivity
1291+
1292+
12761293
#Rem Function Pr_ph(ByVal p As Double, ByVal h As Double) As Double
12771294
#Rem Dim Cp As Double
12781295
#Rem Dim my As Double

tests/Prandtl_Tests.py

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# -*- coding: utf-8 -*-
2+
'''
3+
* Water and steam properties according to IAPWS IF-97
4+
* By Magnus Holmgren, www.x-eng.com
5+
* The steam tables are free and provided as is.
6+
* We take no responsibilities for any errors in the code or damage thereby.
7+
* You are free to use, modify and distribute the code as long as authorship is properly acknowledged.
8+
* Please notify me at magnus@x-eng.com if the code is used in commercial applications
9+
'''
10+
import os
11+
import sys
12+
import unittest
13+
14+
import numpy as np
15+
16+
file_directory = os.path.dirname(__file__)
17+
src_path = os.path.join(os.path.abspath(file_directory), "..", "XSteamPython")
18+
sys.path.append(src_path)
19+
import Data
20+
import XSteamPython as stm
21+
22+
class Test_Pr_pT(unittest.TestCase):
23+
24+
def tearDown(self):
25+
stm.englishUnits = False
26+
27+
def test_Pr_pT(self):
28+
pressure, temperature, prandtlCompare = Data.getTwoDimensionalTestData('SIUnits_Pr_pT.npz')
29+
prandtl = Data.calculatePropertyFromTwoDimensions(stm.Pr_pT, pressure, temperature)
30+
np.testing.assert_array_almost_equal(prandtl, prandtlCompare, decimal=1)
31+
32+
def test_Pr_pT_English(self):
33+
stm.englishUnits = True
34+
pressure, temperature, prandtlCompare = Data.getTwoDimensionalTestData('EnglishUnits_Pr_pT.npz')
35+
prandtl = Data.calculatePropertyFromTwoDimensions(stm.Pr_pT, pressure, temperature)
36+
np.testing.assert_array_almost_equal(prandtl, prandtlCompare, decimal=1)
37+
38+
def test_Pr_pT_error(self):
39+
self.assertAlmostEqual(stm.Pr_pT(-1.0, -1.0), 2015.0, places=2)
40+
41+
if __name__ == '__main__':
42+
unittest.main()

tests/TestData/EnglishUnits_Pr_pT.npz

11 KB
Binary file not shown.

tests/TestData/SIUnits_Pr_pT.npz

11 KB
Binary file not shown.

0 commit comments

Comments
 (0)