# Using the BYU TPL Python Package for Properties¶

Engineering calculations require values for the thermophysical properties of the compounds considered. For example, viscosity and density are needed in pipe flow problems, and the critical temperature and pressure are required for equation of state calculations. Properties are found in multiple compilations including handbooks, textbooks, and databases.

To make homework more time efficient, the Thermophysical Properties Laboratory (TPL) at BYU has created a Python package with properties for some common chemicals of interest. The BYU TPL produces the DIPPR® database which is the gold standard for thermophysical properties for industry. This project is funded by an consortium of companies in the chemical engineering field under the auspices of AIChE®. DIPPR® offers a free "Sample" database which is the origin of the properties for this Python package. The exception is air whose properties come from other sources (acknowledged in the documentation for the package) as DIPPR® properties for air are not available without a license.

2. Click on the green button labeled "Code"
4. Unzip the file.
5. Rename the unzipped folder from byutpl-main to byutpl for convenience. You will use this folder below.

## Install the Package¶

Importing the package requires the byutpl folder (renamed from byutpl-main) to be placed in a location where Python can find it. This can be done multiple ways, and two are described below.

### Option 1:¶

Place the byutpl folder in the same folder as the Python or Jupyter notebook file under development. Call the following commands, which tell the system to search the current directory for packages, at the beginning of the Python file.

import sys
sys.path.append(".")

### Option 2:¶

Place the byutpl folder in the default package repository on the computer. If Anaconda was used to install Python then this is likely in C:\ProgramData\anaconda3\Lib\site-packages or C:\Users\YourUserName\anaconda3\Lib\site-packages.

There are actually several locations where the byutpl folder may be placed. You can find these using the following commands.

import sys
sys.path

The results of the last command is a list of folders on the computer that python searches for packages. Place byutpl in any of these locations.

## Import the Properties Packages¶

This example uses Option 1 above before importing the property packages.

In [1]:
import sys
sys.path.append(".")
import byutpl.properties.water as wtr
import byutpl.properties.benzene as bzn
import byutpl.properties.air as air


## Examples¶

Liquid density of water, in kg/m3, at 300 K.

In [2]:
wtr.ldn(300)

Out[2]:
996.5085063084287

Liquid density of benzene, in kg/m3, at 300 K.

In [3]:
bzn.ldn(300)

Out[3]:
871.1319626628384

Liquid heat capacity of water, in J mol-1 K-1, at 300 K.

In [4]:
wtr.lcp(300)

Out[4]:
75.35580999999999

Liquid heat capacity of benzene, in J mol-1 K-1, at 300 K.

In [5]:
bzn.lcp(300)

Out[5]:
136.4638

Liquid viscosity of water, in Pa$\cdot$s, at 300 K.

In [6]:
wtr.lvs(300)

Out[6]:
0.0008764544531585072

Liquid viscosity of benzene, in Pa$\cdot$s, at 300 K.

In [7]:
bzn.lvs(300)

Out[7]:
0.000585876484725513

Display the units of liquid heat capacity.

In [8]:
wtr.unit('lcp')

Out[8]:
'J mol**-1 K**-1'

The complete list of properties and functions in the package, along with documention on parameters and units, can be seen using the Python help function as shown below.

In [9]:
help(wtr)

Help on module byutpl.properties.water in byutpl.properties:

NAME
byutpl.properties.water

DESCRIPTION
This library contains functions for the properties of water.
The values come from the DIPPR(R) Sample database [1],
and the DIPPR(R) abbreviations are used. Vapor properties that are
dependent on pressure are obtained using the Soave-Redlich-Kwong equation
of state.

This module is part of the byutpl package. Import the module using

import byutpl.properties.water as wtr

When imported in this way, constant properties can be called as

wtr.acen

which returns the acentric factor. Temperature dependent properties
can be called as

wtr.vtc(t)

which returns the vapor thermal conductivity at t where t is
temperature in units of K. Temperature and pressure dependent properties
can be called as

wtr.vcp(t,p)

which returns the vapor heat capacity at t and p where
t is temperature in units of K and p is pressure in units of Pa.

A complete list of properties, and the associated units, are found
below.

Function    Return Value                             Input Value(s)
---------   --------------------------------------   -----------------
tc          critical temperature in K                none
pc          critical pressure in Pa                  none
vc          critical volume in m**3/mol              none
zc          critical compress. factor (unitless)     none
mw          molecular weight in kg/mol               none
acen        acentric factor (unitless)               none
ldn(t)      liquid density in kg/m**3                temperature in K
lcp(t)      liquid heat capacity in J/(mol*K)        temperature in K
ltc(t)      liquid thermal conductivity in W/(m*K)   temperature in K
vp(t)       liquid vapor pressure in Pa              temperature in K
hvp(t)      heat of vaporization in J/mol            temperature in K
lpr(t)      liquid Prandtl number (unitless)         temperature in K
lvs(t)      liquid viscosity in Pa*s                 temperature in K
lnu(t)      liquid kinematic viscosity in m**2/s     temperature in K
tsat(p)     temperature at saturation in K           pressure in Pa
vvs(t)      vapor (steam) viscosity in Pa*s          temperature in K
vtc(t)      vapor (steam) therm. conduct. in W/(m*K) temperature in K
vdn(t,p)    vapor (steam) density in kg/m**3         temperature in K
pressure in Pa
vcp(t,p)    vapor (steam) isobaric heat capacity     temperature in K
in J/(mol*K)                             pressure in Pa
vnu(t,p)    vapor (steam) kinematic viscosity        temperature in K
in m**2/s                                pressure in Pa
vpr(t,p)    vapor (steam) Prandtl number (unitless)  temperature in K
pressure in Pa

References
----------
.. [1] W. V. Wilding, T. A. Knotts, N. F. Giles, R. L. Rowley, J. L. Oscarson,
for Physical Properties, AIChE, New York, NY (2017).

FUNCTIONS
ftsat(t, p)
function supplied to fsolve in tsat function

Function supplied to fsolve (in the f(x)=0 form) to solve for the
temperature at saturation for a given pressure.  This
function is of little use to users.  Users should use
the function tsat.

Parameters
----------
t : float
The temperature (K) at which to evaluate the function.  It is
the "x" value for which fsolve solves.

p : float
The pressure (Pa) at which the saturated temperature is desired.

Returns
-------
float
The value of the function supplied to fsolve.  This value will be
zero if 't' is the saturated temperature for p.

References
----------
.. W. V. Wilding, T. A. Knotts, N. F. Giles, R. L. Rowley, J. L. Oscarson,
for Physical Properties, AIChE, New York, NY (2017).

hvp(t)
heat of vaporization of water

Heat of vaporization of water from the DIPPR(R) correlation
(Correlation A: DIPPR Equation 106; valid from 273.16 - 647.096 K;
uncertainty: < 1%)

Parameters
----------
t : float
The temperature (K) at which to evaluate the heat of vaporization of
water.

Returns
-------
float
The heat of vaporization (J/mol) of water at t.

References
----------
.. W. V. Wilding, T. A. Knotts, N. F. Giles, R. L. Rowley, J. L. Oscarson,
for Physical Properties, AIChE, New York, NY (2017).

lcp(t)
liquid heat capacity of water

Liquid heat capacity of water from the DIPPR(R) correlation
(Correlation A: DIPPR Equation 100; valid from 273.16 - 533.15 K;
uncertainty: < 1%)

Parameters
----------
t : float
The temperature (K) at which to evaluate the liquid heat capacity
of water.

Returns
-------
float
The value of the liquid heat capacity (J mol**-1 K**-1) of water at
t.

References
----------
.. W. V. Wilding, T. A. Knotts, N. F. Giles, R. L. Rowley, J. L. Oscarson,
for Physical Properties, AIChE, New York, NY (2017).

ldn(t)
liquid density of water

Liquid density of water from the DIPPR(R) correlation.
(Correlation C: DIPPR Equation 119; valid from 273.16 - 647.096 K;
uncertainty: < 0.2%)

Parameters
----------
t : float
The temperature (K) at which to evaluate the liquid density of water.

Returns
-------
float
The value of the liquid density (kg/m**3) of water at t.

References
----------
.. W. V. Wilding, T. A. Knotts, N. F. Giles, R. L. Rowley, J. L. Oscarson,
for Physical Properties, AIChE, New York, NY (2017).

lnu(t)
liquid kinematic viscosity of water

Liquid kinematic viscosity of water calculated from the lvs and ldn
functions in this module.

Parameters
----------
t : float
The temperature (K) at which to evaluate the liquid kinematic
viscosity of water.

Returns
-------
float
The liquid kinematic viscosity (m**2/s) of water at t.

References
----------
.. W. V. Wilding, T. A. Knotts, N. F. Giles, R. L. Rowley, J. L. Oscarson,
for Physical Properties, AIChE, New York, NY (2017).

lpr(t)
Prandtl number of liquid water

Prandtl number of liquid water calculated from the lcp, lvs, and ltc
functions in this module.

Parameters
----------
t : float
The temperature (K) at which to evaluate the Prandtl number of
liquid water.

Returns
-------
float
The Prandtl number (dimensionless) of liquid water at t.

References
----------
.. W. V. Wilding, T. A. Knotts, N. F. Giles, R. L. Rowley, J. L. Oscarson,
for Physical Properties, AIChE, New York, NY (2017).

ltc(t)
liquid thermal conductivity of water

Liquid thermal conductivity of water from the DIPPR(R) correlation
(Correlation A: DIPPR Equation 100; valid from 273.16 - 633.15 K;
uncertainty: < 1%)

Parameters
----------
t : float
The temperature (K) at which to evaluate the liquid thermal
conductivity of water.

Returns
-------
float
The liquid thermal conductivity (W m**-1 K**-1) of water at t.

References
----------
.. W. V. Wilding, T. A. Knotts, N. F. Giles, R. L. Rowley, J. L. Oscarson,
for Physical Properties, AIChE, New York, NY (2017).

lvs(t)
liquid viscosity of water

Liquid viscosity of water from the DIPPR(R) correlation
(Correlation A: DIPPR Equation 101; valid from 273.16 - 647.096 K;
uncertainty: < 3%)

Parameters
----------
t : float
The temperature (K) at which to evaluate the liquid viscosity of
water.

Returns
-------
float
The liquid viscosity (Pa*s) of water at t.

References
----------
.. W. V. Wilding, T. A. Knotts, N. F. Giles, R. L. Rowley, J. L. Oscarson,
for Physical Properties, AIChE, New York, NY (2017).

tsat(p)
saturated temperature for water

Saturation temperature of water for a given pressure 'p'.  It is
the temperature for which the following equation is true:
vp(t)= p
where vp is the function in this module and t is the value
this function (tsat) returns.

Parameters
----------
p : float
The pressure (Pa) at which to find the saturated temperature.

Returns
-------
float
The temperature (K) of water at saturation at pressure p.

References
----------
.. W. V. Wilding, T. A. Knotts, N. F. Giles, R. L. Rowley, J. L. Oscarson,
for Physical Properties, AIChE, New York, NY (2017).

unit(key)
Returns the units of key

Returns the units of the constant or function in this module identified
by 'key'

Parameters
----------
key : string
The name of the constant or function in this module for which the
units are needed.

Returns
-------
string
The units for the constant or function identified by key.

References
----------
.. W. V. Wilding, T. A. Knotts, N. F. Giles, R. L. Rowley, J. L. Oscarson,
for Physical Properties, AIChE, New York, NY (2017).

vcp(t, p)
vapor heat capacity water (steam)

Heat capacity of vapor water (steam) calculated from the DIPPR(R)
correlation for ideal gas heat capacity and the residual property
from the Soave-Redlich-Kwong equation of state.
(ICP Correlation A: DIPPR Equation 107; valid from 100 - 2273.15 K;
uncertainty: < 3%)

Parameters
----------
t : float
The temperature (K) at which to evaluate the heat
capacity of vapor water (steam).

p : float
The pressure (Pa) at which to evaluate the heat capacity
of vapor water (steam).

Returns
-------
float
The heat capacity (J/(mol*K)) of vapor water (steam)
at t and p.

References
----------
.. W. V. Wilding, T. A. Knotts, N. F. Giles, R. L. Rowley, J. L. Oscarson,
for Physical Properties, AIChE, New York, NY (2017).

vdn(t, p)
vapor density of water (steam)

The vapor density of water (density of steam) at temperature t and
pressure p from the Soave-Redlich-Kwong equation of state. This
will not be as accurate as the value from the steam tables.
(valid from 273.16 - 1073.15 K; uncertainty at saturation:
< 0.1% at 300 K, < 1.5% at 400 K, < 3% at 500 K, < 10% at 600 K)

Parameters
----------
t : float
The temperature (K) at which to evaluate the vapor density of water
(the density of steam).

p : float
The pressure (Pa) at which to evaluate the vapor density of water
(the density of steam).

Returns
-------
float
The vapor density of water (kg/m**3) (the density of steam) at t
and p.

vnu(t, p)
vapor kinematic viscosity of water (steam)

Kinematic viscosity of vapor water (steam) calculated from the vvs and
vdn functions in this module. The calculation uses the Soave-Redlich-
Kwong equation of state for the vapor density which is not as accurate
as the values from the the steam tables.
(valid from 273.16 - 647.096 K; uncertainty at saturation:
< 0.1% at 300 K, < 1.5% at 400 K, < 3% at 500 K, < 10% at 600 K)

Parameters
----------
t : float
The temperature (K) at which to evaluate the kinematic
viscosity of vapor water (steam).

p : float
The pressure (Pa) at which to evaluate the kinematic viscosity
of vapor water (steam).

Returns
-------
float
The kinematic viscosity (m**2/s) of vapor water (steam)
at t and p.

References
----------
.. W. V. Wilding, T. A. Knotts, N. F. Giles, R. L. Rowley, J. L. Oscarson,
for Physical Properties, AIChE, New York, NY (2017).

vp(t)
liquid vapor pressure of water

Liquid vapor pressure of water from the DIPPR(R) correlation
(Correlation A: DIPPR Equation 101; valid from 273.16 - 647.096 K;
uncertainty: < 0.2%)

Parameters
----------
t : float
The temperature (K) at which to evaluate the liquid vapor pressure of
water.

Returns
-------
float
The liquid vapor pressure (Pa) of water at t.

References
----------
.. W. V. Wilding, T. A. Knotts, N. F. Giles, R. L. Rowley, J. L. Oscarson,
for Physical Properties, AIChE, New York, NY (2017).

vpr(t, p)
Prandtl number of vapor water (steam)

Prandtl number of vapor water (steam) calculated from the vcp, vvs,
and vtc functions in this module. The calculation uses the Soave-
Redlich-Kwong equation of state to correct the ideal gas heat capacity
to the real gas at t and p. This is not as accurate as the values
from the the steam tables.
(valid from 273.16 - 647.096 K; uncertainty at saturation:
< 0.1% at 300 K, < 1.5% at 400 K, < 3% at 500 K, < 10% at 600 K)

Parameters
----------
t : float
The temperature (K) at which to evaluate the Prandtl number of vapor
water (steam).

p : float
The pressure (Pa) at which to evaluate the Prandtl number of vapor
water (steam).

Returns
-------
float
The Prandtl number (dimensionless) of vapor water (steam) at t
and p.

References
----------
.. W. V. Wilding, T. A. Knotts, N. F. Giles, R. L. Rowley, J. L. Oscarson,
for Physical Properties, AIChE, New York, NY (2017).

vtc(t)
thermal conductivity of vaporized water (steam)

The vapor thermal conductivity of water (the thermal conductivity of steam)
at temperature t from the DIPPR(R) correlation.
(Correlation A: DIPPR Equation 102; valid from 273.16 - 1073.15 K;
uncertainty: < 3%)

Parameters
----------
t : float
The temperature (K) at which to evaluate the vapor thermal conductivity
of water (the thermal conductivity of steam).

Returns
-------
float
The vapor thermal conductivity of water (W m**-1 K**-1)
(the thermal conductivity of steam) at t.

References
----------
.. W. V. Wilding, T. A. Knotts, N. F. Giles, R. L. Rowley, J. L. Oscarson,
for Physical Properties, AIChE, New York, NY (2017).

vvs(t)
viscosity of vaporized water (steam)

Vapor viscosity of water (the viscosity of steam) at temperature t
from the DIPPR(R) correlation.
(Correlation A: DIPPR Equation 102; valid from 273.16 - 1073.15 K;
uncertainty: < 3%)

Parameters
----------
t : float
The temperature (K) at which to evaluate the vapor viscosity of water
(the viscosity of steam).

Returns
-------
float
The vapor viscosity of water (Pa*s) (the viscosity of steam) at t.

References
----------
.. W. V. Wilding, T. A. Knotts, N. F. Giles, R. L. Rowley, J. L. Oscarson,
for Physical Properties, AIChE, New York, NY (2017).

DATA
acen = 0.344861
mw = 0.01801528
pc = 22064000.0
tc = 647.096
vc = 5.59472e-05
zc = 0.229

FILE
c:\users\tak6\box\1 classes\chen376\skills\properties\byutpl\properties\water.py