Showing posts with label Library. Show all posts
Showing posts with label Library. Show all posts

Steam properties library

The steam properties library is one of the most important tools used by energy engineers. In the past, we used to refer to Steam tables books, but now there are tools available for multiple platforms, including Windows programs and Excel addins.

IAPWS?


The steam property library expresses actual experimental property results in a regression equation. Standardization is managed by the IAPWS organization (http://www.iapws.org). In Python, Among the many Python packages that follow the IAPWS formula, recommend pyXSteam (https://pypi.org/project/pyXSteam).

Use of pyXSteam


pyXSteam provides (mostly) accurate steam and water properties from 0 ~ 1000 bar and from 0 ~ 2000 °C according to the IAPWS release IF-97. Also includes thermal conductivity and viscosity, which are not part of the IF97 release.
There are no requirements for installing pyXSteam with Python 3.6 and up.
When installing the pyXSteam package on a Windows computer, if Python is already installed and you type "pip install pyXSteam" in the command line window, it will be installed immediately if you are connected to the Internet. The steam properties provided by pyXSteam are as follows.

Property Description
t Temperature (°C or °F)
p Pressure (bar or psi)
h Enthalpy (kJ/kg or btu/lb)
v Specific volume (m3/kg or ft^3/lb)
rho Density (kg/m3 or lb/ft^3)
s Specific entropy (kJ/(kg °C) or btu/(lb °F))
u Specific internal energy (kJ/kg or btu/lb)
Cp Specific isobaric heat capacity (kJ/(kg °C) or btu/(lb °F))
Cv Specific isochoric heat capacity (kJ/(kg °C) or btu/(lb °F))
w Speed of sound (m/s or ft/s)
my Viscosity (N s/m^2 or lbm/ft/hr)
tc Thermal Conductivity (W/(m °C) or btu/(h ft °F))
st Surface Tension (N/m or lb/ft)
x Vapor fraction
vx Vapor Volume Fraction

The unit group supports 3 groups as shown below. Please select one of the three.
steamTable = XSteam(XSteam.UNIT_SYSTEM_MKS) # m/kg/sec/°C/bar/W
steamTable = XSteam(XSteam.UNIT_SYSTEM_FLS) # ft/lb/sec/°F/psi/btu
steamTable = XSteam(XSteam.UNIT_SYSTEM_BARE) # m/kg/sec/K/MPa/W


Python code

Please see below for an example of calculating steam properties using pyXSteam.

from pyXSteam.XSteam import XSteam

steamTable = XSteam(XSteam.UNIT_SYSTEM_FLS) # ft/lb/sec/°F/psi/btu

psat = steamTable.psat_t(337)
print("psat : saturation pressure of steam T = 337 degF = ", psat - 14.696, " psig")

tsat = steamTable.tsat_p(100+14.696)
print("tsat : saturation temperature of steam P = 100 psig = ", tsat, " degF")

h_pt = steamTable.h_pt(100+14.696, 400)
print("h_pt : enthalpy a of steam P = 100 psig and T = 400 degF = ", h_pt, " btu/lb")

h_ps = steamTable.h_ps(100+14.696, 1.635)
print("h_ps : enthalpy a of steam P = 100 psig and S = 1.635 btu/lb-F = ", h_ps, " btu/lb")

s_pt = steamTable.s_pt(100+14.696, 400)
print("s_pt : entropy a of steam P = 100 psig and T = 400 degF = ", s_pt, " btu/lb-F")

s_ph = steamTable.s_ph(100+14.696, 1225)
print("s_ph : entropy a of steam P = 100 psig and H = 1225 btu/lb = ", s_ph, " btu/lb-F")

rho_pt = steamTable.rho_pt(100+14.696, 400)
print("rho_pt : density a of steam P = 100 psig and T = 400 degF = ", rho_pt, " lb/ft3")

Cp_pt = steamTable.Cp_pt(100+14.696, 400)
print("Cp_pt : Specific isobaric heat capacity a of steam P = 100 psig and T = 400 degF = ", Cp_pt, " btu/lb-F")

Cv_pt = steamTable.Cv_pt(100+14.696, 400)
print("Cv_pt : Specific isochoric heat capacity a of steam P = 100 psig and T = 400 degF = ", Cv_pt, " btu/lb-F")

When run the code, you get the results below.

psat : saturation pressure of steam T = 337 degF =  98.647  psig
tsat : saturation temperature of steam P = 100 psig =  337.882  degF
h_pt : enthalpy a of steam P = 100 psig and T = 400 degF =  1225.473  btu/lb
h_ps : enthalpy a of steam P = 100 psig and S = 1.635 btu/lb-F =  1225.517  btu/lb
s_pt : entropy a of steam P = 100 psig and T = 400 degF =  1.635  btu/lb-F
s_ph : entropy a of steam P = 100 psig and H = 1225 btu/lb =  1.634  btu/lb-F
rho_pt : density a of steam P = 100 psig and T = 400 degF =  0.234  lb/ft3
Cp_pt : Specific isobaric heat capacity a of steam P = 100 psig and T = 400 degF =  0.544  btu/lb-F
Cv_pt : Specific isochoric heat capacity a of steam P = 100 psig and T = 400 degF =  0.399  btu/lb-F