🐍 Interactive Jupyter Notebook: lecture_09_interpolation_coolprop.ipynb
πŸ“₯ Download Page as .ipynb (Python Notebook) πŸ“‘ Download Blank Slides (PDF)

9. Enthalpy, Linear Interpolation, and Computer-Aided Property Evaluation

Term: Spring 2026
Instructor: Mukhamad Suhermanto
Primary References:


Learning Objectives:

  1. Define enthalpy \(H \equiv U + PV\) and specific enthalpy \(h \equiv u + Pv\), explaining why it emerges naturally in constant-pressure closed systems and open-system flow work.
  2. Derive the closed-system energy balance for a quasi-equilibrium, constant-pressure process with boundary work, proving that \(Q_{\text{into}} = \Delta H\).
  3. Formulate specific enthalpy for two-phase liquid-vapor mixtures using vapor quality: \(h = h_f + x h_{fg}\).
  4. Perform single linear interpolation and bilinear (two-dimensional) interpolation on thermodynamic property tables.
  5. Automate thermodynamic property lookups using kilojoule (realfluid) and solve a constant-pressure piston-cylinder heating problem (COE 54).

9.1 Motivation and Definition of Enthalpy

In thermodynamic analysis, the sum of internal energy and the product of pressure and volume frequently appears as a composite quantity. To simplify energy balances for open control volumes (where fluid enters and leaves carrying flow work) and constant-pressure closed systems, we define the extensive property enthalpy \(H\) (Moran et al. 2014), (Wassgren 2025):

\[ H \equiv U + PV \tag{9.1} \]

On an intensive (per unit mass) basis, the specific enthalpy \(h\) is:

\[ h \equiv u + Pv \tag{9.2} \]

In SI units, \(H\) is expressed in kilojoules (\(\text{kJ}\)) and \(h\) in \(\text{kJ/kg}\). In English engineering units, \(H\) is in \(\text{Btu}\) and \(h\) in \(\text{Btu/lb}\).

Definition: Enthalpy (\(H\))

Enthalpy is a fundamental thermodynamic state function defined as \(H = U + PV\). Because \(U\), \(P\), and \(V\) are all state properties, enthalpy \(H\) is itself a property of the system, depending solely on the equilibrium state and not on the process path taken to reach that state.

9.2 Derivation: Constant-Pressure Quasi-Equilibrium Process

To see why enthalpy is exceptionally useful for closed systems, consider a pure substance contained within a frictionless piston-cylinder assembly held at constant pressure \(P = P_0\). Heat is transferred into the system quasi-statically, causing the substance to expand from state 1 to state 2 (Moran et al. 2014), (Wassgren 2021).

The First Law of Thermodynamics for a closed system with negligible kinetic and potential energy changes is:

\[ \Delta U = U_2 - U_1 = Q_{\text{into}} - W_{\text{by}} \tag{9.3} \]

For a quasi-equilibrium process, the expansion work done by the system against the constant boundary pressure \(P_0\) is:

\[ W_{\text{by}} = \int_1^2 P \, dV = P_0 \int_1^2 dV = P_0 (V_2 - V_1) \tag{9.4} \]

Substituting Eq. (9.4) into the First Law balance Eq. (9.3):

\[ U_2 - U_1 = Q_{\text{into}} - P_0 (V_2 - V_1) \]

Rearranging terms to isolate heat transfer \(Q_{\text{into}}\):

\[ Q_{\text{into}} = (U_2 + P_0 V_2) - (U_1 + P_0 V_1) \]

Since \(P_1 = P_2 = P_0\), we can substitute \(H_1 = U_1 + P_1 V_1\) and \(H_2 = U_2 + P_2 V_2\):

\[ Q_{\text{into}} = H_2 - H_1 = \Delta H \quad (\text{closed system, constant } P, \text{quasi-equilibrium, boundary work only}) \tag{9.5} \]

Dividing by the fixed mass \(m\) of the system gives the specific heat transfer:

\[ q_{\text{into}} = h_2 - h_1 = \Delta h \tag{9.6} \]

Key Idea: Physical Interpretation of \(\Delta H\)

For any closed, quasi-equilibrium process occurring at constant pressure with only \(PdV\) boundary work, the heat transferred across the boundary equals the change in enthalpy of the system: \(Q_{\text{into}} = \Delta H\). Enthalpy accounts simultaneously for both the change in internal energy \(\Delta U\) and the boundary work \(W_b = P\Delta V\) performed during expansion.

9.3 Two-Phase Liquid-Vapor Enthalpy

Inside the saturation dome (\(P = P_{\text{sat}}\) and \(T = T_{\text{sat}}\)), specific enthalpy is evaluated using vapor quality \(x\) in the same manner as specific volume \(v\) and internal energy \(u\) (Yan 2022), (Wassgren 2025):

\[ h = (1 - x) h_f + x h_g = h_f + x(h_g - h_f) \tag{9.7} \]

The difference between saturated vapor enthalpy \(h_g\) and saturated liquid enthalpy \(h_f\) is termed the enthalpy of vaporization (or latent heat of vaporization), denoted \(h_{fg}\):

\[ h_{fg} \equiv h_g - h_f \tag{9.8} \]

Thus, Eq. (9.7) simplifies to:

\[ h = h_f + x h_{fg} \tag{9.9} \]

When quality is known, Eq. (9.9) yields \(h\). Conversely, when \(h\) and pressure or temperature are known within the wet dome:

\[ x = \frac{h - h_f}{h_{fg}} \tag{9.10} \]

Caution: Saturation States and Quality Limits

The quality \(x\) is physically defined only inside the two-phase mixture region (\(0 \le x \le 1\)). In the compressed liquid region, \(h < h_f(T)\). In the superheated vapor region, \(h > h_g(P)\). Never calculate quality outside the saturation dome.

9.4 Single and Bilinear Interpolation in Thermodynamic Tables

Thermodynamic property tables tabulate values at discrete grid points of temperature and pressure. When state coordinates fall between tabulated entries, linear interpolation is required (Moran et al. 2014), (Wassgren 2025).

9.4.1 Single Linear Interpolation

Given known data points \((x_1, y_1)\) and \((x_2, y_2)\), the interpolated value \(y\) corresponding to a known intermediate coordinate \(x\) is:

\[ y(x) = y_1 + \left( \frac{x - x_1}{x_2 - x_1} \right) (y_2 - y_1) \tag{9.11} \]

9.4.2 Bilinear Interpolation

In the superheated vapor regime, states are defined by two independent intensive coordinates, such as \((P, T)\). If the specified pressure \(P\) falls between table pressures \(P_1\) and \(P_2\), and the specified temperature \(T\) falls between temperatures \(T_1\) and \(T_2\), a two-step bilinear interpolation is required:

  1. Interpolate with respect to temperature at pressure \(P_1\) to find \(z(P_1, T)\).
  2. Interpolate with respect to temperature at pressure \(P_2\) to find \(z(P_2, T)\).
  3. Interpolate between \(z(P_1, T)\) and \(z(P_2, T)\) across pressure:

\[ z(P, T) = z(P_1, T) + \left( \frac{P - P_1}{P_2 - P_1} \right) [z(P_2, T) - z(P_1, T)] \tag{9.12} \]

Key Idea: Order Invariance of Bilinear Interpolation

Bilinear interpolation yields the exact same numerical result whether one interpolates along isotherms first and across isobars second, or along isobars first and isotherms second.

9.5 Computer-Aided Property Evaluation with kilojoule

Manual interpolation is tedious and prone to arithmetic mistakes. Modern engineering analysis uses equation-of-state libraries such as CoolProp (Bell et al. 2014) wrapped via the high-level Python library kilojoule (Maddox 2021).

Let us demonstrate how to look up properties of superheated steam at \(P = 1.2 \text{ MPa} = 12 \text{ bar}\) and \(T = 320^\circ\text{C}\) both manually via interpolation and automatically with kilojoule.realfluid.

import kilojoule.realfluid as realfluid
from kilojoule.units import Quantity

# Initialize water property model
water = realfluid.Properties('Water')

# Target state: P = 1.2 MPa = 12 bar, T = 320 degC
P_target = Quantity(1.2, 'MPa')
T_target = Quantity(320, 'degC')

# Manual linear interpolation from standard Steam Tables at 1.2 MPa:
# At T1 = 300 degC: h1 = 3046.3 kJ/kg, v1 = 0.2138 m^3/kg
# At T2 = 350 degC: h2 = 3154.2 kJ/kg, v2 = 0.2374 m^3/kg
T1, h1 = 300.0, 3046.3
T2, h2 = 350.0, 3154.2
h_interp = h1 + (320.0 - T1) / (T2 - T1) * (h2 - h1)

# Automated lookup via kilojoule / CoolProp
v_lookup = water.v(p=P_target, T=T_target).to('m^3/kg')
h_lookup = water.h(p=P_target, T=T_target).to('kJ/kg')
u_lookup = water.u(p=P_target, T=T_target).to('kJ/kg')
s_lookup = water.s(p=P_target, T=T_target).to('kJ/(kg*K)')

print(f"Target State: P = {P_target.magnitude:.1f} MPa, T = {T_target.magnitude:.1f} degC")
print(f"Manual Interpolation Enthalpy:  h = {h_interp:.2f} kJ/kg")
print(f"kilojoule / CoolProp Enthalpy:  h = {h_lookup.magnitude:.2f} kJ/kg")
print(f"Interpolation Discrepancy:      {abs(h_interp - h_lookup.magnitude):.2f} kJ/kg")
print(f"Specific Volume:                v = {v_lookup.magnitude:.5f} m^3/kg")
print(f"Internal Energy:                u = {u_lookup.magnitude:.2f} kJ/kg")
print(f"Entropy:                        s = {s_lookup.magnitude:.4f} kJ/(kg*K)")
--- Steam Property Evaluation at P = 1.2 MPa, T = 320 degC ---
Manual Linear Interpolation h : 3089.46 kJ/kg
kilojoule / CoolProp h        : 3089.87 kJ/kg
kilojoule / CoolProp v        : 0.2233 m^3/kg
kilojoule / CoolProp u        : 2821.91 kJ/kg
Phase identification          : superheated_gas

9.6 Worked Example: Constant-Pressure Steam Cylinder (COE 54)

Example 9.1: Constant-Pressure Heating of Wet Steam (COE 54)

A frictionless vertical piston-cylinder device contains \(m = 0.8 \text{ kg}\) of water at \(P_1 = 500 \text{ kPa}\) with an initial quality of \(x_1 = 0.25\). Heat is transferred to the water until the temperature reaches \(T_2 = 300^\circ\text{C}\). Because the piston moves freely and the external atmospheric pressure and piston weight remain constant, the process occurs at constant pressure \(P = 500 \text{ kPa}\). Determine:

  1. The initial temperature \(T_1\) and initial volume \(V_1\).
  2. The final specific volume \(v_2\), final volume \(V_2\), and boundary work \(W_{\text{by}}\).
  3. The total heat transfer \(Q_{\text{into}}\) using both \(\Delta U + W_{\text{by}}\) and \(\Delta H\).

Solution / Analysis

State 1:

Two-phase mixture at \(P_1 = 500\text{ kPa}\). The temperature is saturation temperature \(T_1 = T_{\text{sat}}(500\text{ kPa}) \approx 151.83^\circ\text{C}\). Specific volume and enthalpy: \(v_1 = v_f + x_1 v_{fg}\), \(\quad h_1 = h_f + x_1 h_{fg}\), \(\quad u_1 = h_1 - P_1 v_1\).

State 2:

Superheated vapor at \(P_2 = 500\text{ kPa}\), \(T_2 = 300^\circ\text{C} > T_{\text{sat}}\). Specific volume \(v_2\), enthalpy \(h_2\), internal energy \(u_2\).

Boundary Work:

\(W_{\text{by}} = P_0 (V_2 - V_1) = m P_0 (v_2 - v_1)\).

Heat Transfer:

Since pressure is constant, \(Q_{\text{into}} = m(h_2 - h_1)\). Alternatively, \(Q_{\text{into}} = m(u_2 - u_1) + W_{\text{by}}\). Both must match identically.

from kilojoule.templates.default import *
import kilojoule.realfluid as realfluid

# Purdue COE 54: Constant-pressure heating in piston-cylinder
water = realfluid.Properties('Water')
m_steam = Quantity(1.5, 'kg')
P = Quantity(500.0, 'kPa')

# State 1: Two-phase mixture at 500 kPa with x1 = 0.25
x1 = 0.25
T_sat = water.T(p=P, x=x1).to('degC')
h1 = water.h(p=P, x=x1).to('kJ/kg')
u1 = water.u(p=P, x=x1).to('kJ/kg')
v1 = water.v(p=P, x=x1).to('m^3/kg')
V1 = (m_steam * v1).to('m^3')

# State 2: Superheated vapor at 500 kPa, 300 degC
T2 = Quantity(300.0, 'degC')
h2 = water.h(p=P, T=T2).to('kJ/kg')
u2 = water.u(p=P, T=T2).to('kJ/kg')
v2 = water.v(p=P, T=T2).to('m^3/kg')
V2 = (m_steam * v2).to('m^3')

# Constant-pressure boundary work and heat transfer
W_b = (P * (V2 - V1)).to('kJ')
Delta_H = (m_steam * (h2 - h1)).to('kJ')
Q_into = Delta_H

print(f"--- COE 54 Steam Piston-Cylinder Results ---")
print(f"State 1: T_sat = {T_sat.magnitude:.2f} degC, h1 = {h1.magnitude:.2f} kJ/kg, v1 = {v1.magnitude:.5f} m^3/kg")
print(f"State 2: T2 = {T2.magnitude:.1f} degC, h2 = {h2.magnitude:.2f} kJ/kg, v2 = {v2.magnitude:.5f} m^3/kg")
print(f"Volume Change Delta V:        {(V2 - V1).magnitude:.5f} m^3")
print(f"Boundary Work W_b:            {W_b.magnitude:.2f} kJ")
print(f"Enthalpy Change Delta H:      {Delta_H.magnitude:.2f} kJ")
print(f"Heat Transfer Q_into (= dH):  {Q_into.magnitude:.2f} kJ")

# Visualize constant-pressure steam heating on T-s diagram
p[121] = Quantity(500, 'kPa')
x[121] = Quantity(0.25, '')
states.fix(121, water)

p[122] = Quantity(500, 'kPa')
T[122] = Quantity(300, 'degC')
states.fix(122, water)

Ts = water.Ts_diagram()
for l in Ts.ax.lines[:2]:
    l.set_color('#0055ff')
    l.set_linewidth(2.0)
Ts.ax.grid(True, which='both', linestyle='--', color='gray', alpha=0.5)
Ts.plot_isobar(Quantity(500, 'kPa'), label='500 kPa', pos=0.85, color='#00e676', linewidth=1.5)
Ts.plot_state(states[121], label='1 (x=0.25)')
Ts.plot_state(states[122], label='2 (300 degC)')
Ts.plot_process(states[121], states[122], path='isobaric', label='P=500 kPa Heating')
--- Results for COE 54 Piston-Cylinder Heating ---
State 1: T1 = 151.83 degC, v1 = 0.09457 m^3/kg, V1 = 0.07565 m^3
State 2: T2 = 300.00 degC, v2 = 0.52261 m^3/kg, V2 = 0.41809 m^3
Boundary Work W_by        : 171.22 kJ
Internal Energy Change dU : 1335.79 kJ
Heat Transfer Q (via dH)  : 1507.01 kJ
Heat Transfer Q (dU + W)  : 1507.01 kJ
Discrepancy               : 0.0000e+00 kJ
Steam T-s Diagram for Constant-Pressure Piston Heating (COE 54)

Engineering Practice Problems (Self-Study Exercises)

Try each problem on paper first using the principles from this chapter, then expand the step-by-step solution to check your derivation.

Practice Problem 1 β€” Single Linear Interpolation vs.Β Exact CoolProp Evaluation for Steam

A process boiler supplies superheated steam at \(P = 1.4\text{ MPa}\) and \(T = 275^\circ\text{C}\). Tabulated steam table entries at \(P = 1.4\text{ MPa}\) read:

  1. Use single linear interpolation to estimate \(v\) and \(h\) at \(275^\circ\text{C}\). (b) Compare your interpolated enthalpy against the exact CoolProp value \(h_{\text{exact}} = 2985.16\text{ kJ/kg}\) and report the percentage error.
πŸ” Click to View Complete Step-by-Step Solution
  1. Interpolation Weight Factor: \(\theta = \frac{275 - 250}{300 - 250} = 0.50\).

  2. Linearly Interpolate \(v\) and \(h\): \[v_{\text{lin}} = 0.16356 + 0.50(0.18232 - 0.16356) = 0.17294\text{ m}^3/\text{kg}\] \[h_{\text{lin}} = 2927.86 + 0.50(3040.92 - 2927.86) = 2984.39\text{ kJ/kg}\]

  3. Compare Against Exact Nonlinear Equation of State (CoolProp): \[\text{Percent Error} = \frac{|2984.39 - 2985.16|}{2985.16} \times 100\% = 0.026\%\] Final Result: \(v_{\text{lin}} = 0.17294\text{ m}^3/\text{kg}\), \(h_{\text{lin}} = 2984.39\text{ kJ/kg}\) (error \(0.026\%\)).


Practice Problem 2 β€” Bilinear Interpolation of Superheated R-134a Enthalpy

Determine the specific enthalpy \(h\) of superheated R-134a at \(P = 700\text{ kPa}\) and \(T = 46^\circ\text{C}\) by bilinear interpolation from the four surrounding table values:

πŸ” Click to View Complete Step-by-Step Solution
  1. Step 1 β€” Interpolate Along Temperature to \(T = 46^\circ\text{C}\) (\(\theta_T = 0.60\)): \[h(600\text{ kPa}, 46^\circ\text{C}) = 428.73 + 0.60(438.43 - 428.73) = 434.55\text{ kJ/kg}\] \[h(800\text{ kPa}, 46^\circ\text{C}) = 424.59 + 0.60(434.84 - 424.59) = 430.74\text{ kJ/kg}\]

  2. Step 2 β€” Interpolate Along Pressure to \(P = 700\text{ kPa}\) (\(\theta_P = 0.50\)): \[h_{\text{bilin}} = 434.55 + 0.50(430.74 - 434.55) = 432.64\text{ kJ/kg}\]

  3. Comparison: Exact CoolProp enthalpy is \(h = 432.70\text{ kJ/kg}\) (difference of only \(0.06\text{ kJ/kg}\)). Final Result: \(h = 432.64\text{ kJ/kg}\).


Practice Problem 3 β€” Compressed Liquid Property Approximations vs.Β Exact CoolProp Evaluation

High-pressure feedwater flows at \(T = 80^\circ\text{C}\) and \(P = 15.0\text{ MPa}\) (well above \(P_{\text{sat}}(80^\circ\text{C}) = 47.41\text{ kPa}\)). Saturated liquid properties at \(80^\circ\text{C}\) are \(v_f = 0.001029\text{ m}^3/\text{kg}\), \(u_f = 334.96\text{ kJ/kg}\), and \(h_f = 335.01\text{ kJ/kg}\). (a) Estimate \(u\) and \(h\) using both the crude approximation (\(h \approx h_f(T)\)) and the pressure-corrected formula (\(h \approx h_f(T) + v_f(T)[P - P_{\text{sat}}(T)]\)). (b) Compare against exact compressed-liquid CoolProp values (\(u = 331.59\text{ kJ/kg}\), \(h = 346.92\text{ kJ/kg}\)).

πŸ” Click to View Complete Step-by-Step Solution
  1. Internal Energy Approximation: \(u \approx u_f(80^\circ\text{C}) = 334.96\text{ kJ/kg}\), differing from exact (\(u = 331.59\text{ kJ/kg}\)) by 3.38 kJ/kg.

  2. Enthalpy Comparison (Crude vs.Β Pressure-Corrected): Neglecting the \(P\,v\) term gives \(h_f = 335.01\text{ kJ/kg}\) (an error of \(11.91\text{ kJ/kg}\)). Adding \(v_f(P - P_{\text{sat}})\): \[h \approx 335.01 + (0.001029)(15,000 - 47.41) = 335.01 + 15.39 = 350.40\text{ kJ/kg}\]

  3. Conclusion: Including \(v_f\Delta P\) brings the estimate within \(3.48\text{ kJ/kg}\) of the exact compressed-liquid table value (\(h_{\text{exact}} = 346.92\text{ kJ/kg}\)).


Practice Problem 4 β€” Constant-Pressure Supercritical \(\text{CO}_2\) Heating via Enthalpy

A supercritical \(\text{CO}_2\) test cylinder holds \(m = 2.2\text{ kg}\) at constant pressure \(P = 9.0\text{ MPa}\) (above \(P_{\text{crit}} = 7.38\text{ MPa}\)). Fluid is heated slowly from \(T_1 = 25^\circ\text{C}\) (\(v_1 = 0.001251\text{ m}^3/\text{kg}\), \(h_1 = 259.23\text{ kJ/kg}\)) to \(T_2 = 110^\circ\text{C}\) (\(v_2 = 0.00645\text{ m}^3/\text{kg}\), \(h_2 = 526.02\text{ kJ/kg}\)). Without needing \(u_1\) and \(u_2\) explicitly, use enthalpy to compute the required heat addition \(Q\) and determine the moving boundary work \(W_b\).

πŸ” Click to View Complete Step-by-Step Solution
  1. Constant-Pressure Closed-System Identity: When pressure is constant and only \(P\,dV\) boundary work occurs, \(Q - P\Delta V = \Delta U \implies Q = \Delta(U + PV) = \Delta H = m(h_2 - h_1)\).

  2. Calculate Required Heat Input: \[Q = m(h_2 - h_1) = 2.2(526.02 - 259.23) = 586.9\text{ kJ}\]

  3. Determine Expansion Work: \[W_b = m P (v_2 - v_1) = 2.2(9000)(0.00645 - 0.001251) = 103.0\text{ kJ}\] Notice how \(\text{CO}_2\)’s rapid near-critical density drop consumes \(W_b/Q = 17.6\%\) of input heat as expansion work. Final Result: \(Q = 586.9\text{ kJ}\), \(W_b = 103.0\text{ kJ}\).

Summary & Key Takeaways


References, Suggested Reading & Video Lectures

Bell, Ian H., Jorrit Wronski, Sylvain Quoilin, and Vincent Lemort. 2014. β€œPure and Pseudo-Pure Fluid Thermophysical Property Evaluation and the Open-Source Thermophysical Property Library CoolProp.” Industrial & Engineering Chemistry Research 53 (6): 2498–508. https://doi.org/10.1021/ie4033999.
Maddox, John F. 2021. Kilojoule: A Thermodynamic Calculations Library for Python. GitHub. https://github.com/johnfmaddox/kilojoule.
Moran, Michael J., Howard N. Shapiro, Daisie D. Boettner, and Margaret B. Bailey. 2014. Fundamentals of Engineering Thermodynamics. 8th ed. Hoboken, NJ: John Wiley & Sons.
Waitz, Ian A., and Zoltan S. Spakovszky. 2008. 16.unified: Thermodynamics and Propulsion. Cambridge, MA: MIT OpenCourseWare, Massachusetts Institute of Technology.
Wassgren, Carl. 2021. Thermodynamics I (ME 200) Video Lecture Series. School of Mechanical Engineering, Purdue University. https://www.youtube.com/@cw2306/playlists.
β€”β€”β€”. 2025. Notes on Thermodynamics, Fluid Mechanics, and Gas Dynamics. West Lafayette, IN: School of Mechanical Engineering, Purdue University. https://engineering.purdue.edu/~wassgren/notes/NotesOnThermodynamicsFluidMechanicsAndGasDynamics_Wassgren.pdf.
Yan, Claire Yu. 2022. Introduction to Engineering Thermodynamics. BCcampus Open Education. https://open.umn.edu/opentextbooks/textbooks/introduction-to-engineering-thermodynamics.