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

10. The Ideal Gas Model and Compressibility Factor

Term: Spring 2026
Instructor: Mukhamad Suhermanto
Primary References:


Learning Objectives:

  1. State the ideal gas equation of state in molar and mass-specific forms: \(P\bar{v} = \bar{R}T\) and \(Pv = RT\).
  2. Define the universal gas constant \(\bar{R}\) and calculate the specific gas constant \(R = \bar{R}/M\) for common engineering gases.
  3. Evaluate the compressibility factor \(Z = Pv/(RT)\) and apply the Principle of Corresponding States using reduced coordinates \(P_R = P/P_c\) and \(T_R = T/T_c\).
  4. Explain Joule’s free expansion experiment and demonstrate why internal energy and enthalpy depend solely on temperature (\(u = u(T)\), \(h = h(T)\)) for an ideal gas.
  5. Apply the First Law of Thermodynamics to closed systems containing ideal gases using kilojoule (COE 50, COE 42, COE 16).

10.1 The Ideal Gas Equation of State

At sufficiently low pressures and high temperatures relative to their critical points, gases exhibit behavior where intermolecular forces (van der Waals attractions and repulsions) and the finite volume of individual molecules become negligible (Moran et al. 2014), (Wassgren 2025). Under these conditions, the gas satisfies the ideal gas equation of state.

On a molar basis, the equation of state is:

\[ P \bar{v} = \bar{R} T \quad \iff \quad P V = n \bar{R} T \tag{10.1} \]

where:

Dividing by the molar mass \(M\) (\(\text{kg/kmol}\)) yields the mass-specific form (Moran et al. 2014), (Yan 2022):

\[ P v = R T \quad \iff \quad P V = m R T \tag{10.2} \]

where \(R = \bar{R}/M\) is the specific gas constant for the particular gas. For dry air (\(M \approx 28.97 \text{ kg/kmol}\)), \(R_{\text{air}} = 0.2870 \text{ kJ/(kg}\cdot\text{K)}\).

Caution: Always Use Absolute Units

In all ideal gas equations \(Pv = RT\), temperature must be expressed in absolute units (\(\text{Kelvin}\) or \(\text{Rankine}\)), and pressure must be absolute (not gauge). Mixing Celsius or gauge pressure into \(Pv = RT\) is a catastrophic source of error.

10.2 Compressibility Factor and Principle of Corresponding States

Real gases deviate from ideal gas behavior at elevated pressures or near the critical point. To quantify this deviation, we define the dimensionless compressibility factor \(Z\) (Moran et al. 2014), (Wassgren 2025):

\[ Z \equiv \frac{P v}{R T} = \frac{v_{\text{actual}}}{v_{\text{ideal}}} \tag{10.3} \]

For an ideal gas, \(Z \equiv 1\) identically under all conditions. When \(Z < 1\), attractive intermolecular forces dominate, making the actual specific volume smaller than the ideal prediction. When \(Z > 1\), repulsive intermolecular forces dominate.

According to the Principle of Corresponding States, all fluids at the same reduced pressure \(P_R\) and reduced temperature \(T_R\) exhibit approximately the same compressibility factor \(Z\) (Moran et al. 2014), (Yan 2022):

\[ P_R \equiv \frac{P}{P_c}, \qquad T_R \equiv \frac{T}{T_c} \tag{10.4} \]

where \(P_c\) and \(T_c\) are the critical pressure and critical temperature of the substance. Alternatively, the pseudo-reduced specific volume is defined as:

\[ v_R' \equiv \frac{v}{R T_c / P_c} \tag{10.5} \]

Key Idea: Validity Criteria for the Ideal Gas Model

A gas can be modeled accurately as an ideal gas (\(Z \approx 1\) within 1-2%) whenever:

  1. \(P_R \ll 1\) (typically \(P_R < 0.05\)), regardless of temperature.
  2. \(T_R > 2.0\) for moderate pressures (\(P_R < 10\)).
  3. Steam at atmospheric pressure and ambient temperatures behaves remarkably like an ideal gas because its reduced pressure is \(P_R = 0.1013 / 22.06 \approx 0.0046 \ll 1\).

10.3 Joule’s Experiment: \(u = u(T)\) and \(h = h(T)\)

In 1843, James Prescott Joule performed a classic experiment to test whether internal energy depends on pressure or volume. Two interconnected rigid vessels submerged in an insulated water bath were used (Moran et al. 2014), (Waitz and Spakovszky 2008). One vessel contained high-pressure gas; the other was evacuated. When the connecting valve was opened, the gas expanded freely into the vacuum.

Applying the First Law to the gas:

As gas pressure approaches zero, experimental measurements show that:

\[ \left( \frac{\partial u}{\partial v} \right)_T = 0, \qquad \left( \frac{\partial u}{\partial P} \right)_T = 0 \tag{10.6} \]

Consequently, for an ideal gas, specific internal energy is a function solely of temperature:

\[ u = u(T) \tag{10.7} \]

Furthermore, by definition of enthalpy \(h = u + Pv = u(T) + RT\):

\[ h = h(T) \tag{10.8} \]

Key Idea: Ideal Gas State Postulate

For an ideal gas, specific internal energy \(u\) and specific enthalpy \(h\) depend strictly on temperature alone: \(u = u(T)\) and \(h = h(T)\). They do not depend on pressure or specific volume.

10.4 Comparing Ideal Gas vs.Β Real Fluid Behavior with kilojoule

To visualize the range of validity of the ideal gas model, we compute the compressibility factor \(Z\) of nitrogen (\(N_2\)) across pressures from \(0.1 \text{ bar}\) to \(200 \text{ bar}\) at \(T = 300 \text{ K}\) (\(T_c = 126.2 \text{ K}\), \(P_c = 33.96 \text{ bar}\), so \(T_R = 300 / 126.2 \approx 2.38\)).

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

n2 = realfluid.Properties('Nitrogen')
R_n2 = Quantity(8.31446 / 28.0134, 'kJ/(kg*K)')
T = Quantity(300, 'K')

pressures_bar = [0.1, 1.0, 10.0, 50.0, 100.0, 200.0]

print(f"{'P (bar)':>8} | {'v_real (m^3/kg)':>16} | {'v_ideal (m^3/kg)':>16} | {'Z':>8} | {'Error (%)':>10}")
print("-" * 66)

for p_val in pressures_bar:
    P = Quantity(p_val, 'bar')
    v_real = n2.v(p=P, T=T).to('m^3/kg')
    v_ideal = (R_n2 * T / P).to('m^3/kg')
    Z = float(v_real / v_ideal)
    err = float((v_ideal - v_real) / v_real * 100)
    print(f"{p_val:8.1f} | {v_real.magnitude:16.5e} | {v_ideal.magnitude:16.5e} | {Z:8.4f} | {err:10.2f}%")
P (bar) |  v_real (m^3/kg) | v_ideal (m^3/kg) |        Z |  Error (%)
------------------------------------------------------------------
     0.1 |      8.90806e-01 |      8.90807e-01 |   1.0000 |       0.00%
     1.0 |      8.90562e-02 |      8.90807e-02 |   0.9997 |       0.03%
    10.0 |      8.88126e-03 |      8.90807e-03 |   0.9970 |       0.30%
    50.0 |      1.77259e-03 |      1.78161e-03 |   0.9949 |       0.51%
   100.0 |      9.01423e-04 |      8.90807e-04 |   1.0119 |      -1.18%
   200.0 |      4.87158e-04 |      4.45404e-04 |   1.0937 |      -8.57%

10.5 Worked Example: Rigid Tank Cooling (COE 50)

Example 10.1: Rigid Vessel Cooled Under Ideal Gas Model (COE 50)

A rigid, closed tank with volume \(V = 0.5 \text{ m}^3\) initially contains nitrogen gas (\(N_2\)) at \(P_1 = 300 \text{ kPa}\) and \(T_1 = 300 \text{ K}\). Heat is removed until the temperature drops to \(T_2 = 200 \text{ K}\). Treating nitrogen as an ideal gas:

  1. Determine the mass \(m\) of nitrogen in the tank.
  2. Determine the final pressure \(P_2\).
  3. Calculate the internal energy change \(\Delta U\) and heat transfer \(Q_{\text{into}}\).

Solution / Analysis

Since the tank is rigid and closed:

  • Constant volume: \(V_1 = V_2 = V\), so \(v_1 = v_2 = v\).
  • From ideal gas law at state 1: \(m = \frac{P_1 V}{R T_1}\).
  • Final pressure: \(\frac{P_2 v}{T_2} = \frac{P_1 v}{T_1} \implies P_2 = P_1 \left( \frac{T_2}{T_1} \right)\).
  • Boundary work: \(W_{\text{by}} = \int P dV = 0\) since \(dV = 0\).
  • First Law: \(Q_{\text{into}} = \Delta U = m(u(T_2) - u(T_1))\).
import kilojoule.idealgas as idealgas
from kilojoule.units import Quantity

n2 = idealgas.Properties('N2')
V = Quantity(0.5, 'm^3')
P1 = Quantity(300, 'kPa')
T1 = Quantity(300, 'K')
T2 = Quantity(200, 'K')

# State 1
v1 = n2.v(p=P1, T=T1)
R = n2.R
m = (P1 * V / (R * T1)).to('kg')

# State 2 (rigid tank -> v2 = v1)
v2 = v1
P2 = (P1 * (T2 / T1)).to('kPa')

# Boundary work for rigid tank is zero
W_by = Quantity(0, 'kJ')

# Energy balance: Q = Delta U = m * (u2 - u1)
u1 = n2.u(T=T1)
u2 = n2.u(T=T2)
Delta_U = (m * (u2 - u1)).to('kJ')
Q_into = Delta_U

print(f"--- COE 50 Rigid Tank Nitrogen Cooling ---")
print(f"Nitrogen Mass m           : {m.magnitude:.4f} kg")
print(f"Final Pressure P2         : {P2.magnitude:.2f} kPa")
print(f"Specific u1 at 300 K      : {u1.to('kJ/kg').magnitude:.2f} kJ/kg")
print(f"Specific u2 at 200 K      : {u2.to('kJ/kg').magnitude:.2f} kJ/kg")
print(f"Boundary Work W_by        : {W_by.magnitude:.2f} kJ")
print(f"Internal Energy Change dU : {Delta_U.magnitude:.2f} kJ")
print(f"Heat Transfer Q_into      : {Q_into.magnitude:.2f} kJ")
--- COE 50 Rigid Tank Nitrogen Cooling ---
Nitrogen Mass m           : 1.6845 kg
Final Pressure P2         : 200.00 kPa
Specific u1 at 300 K      : 222.18 kJ/kg
Specific u2 at 200 K      : 147.88 kJ/kg
Boundary Work W_by        : 0.00 kJ
Internal Energy Change dU : -125.16 kJ
Heat Transfer Q_into      : -125.16 kJ

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 β€” Ideal Gas Accounting in a High-Pressure Hydrogen Storage Cylinder

A Type-IV composite hydrogen storage tank (\(V = 0.085\text{ m}^3\), \(R_{\text{H}_2} = 4.124\text{ kJ}/(\text{kg}\cdot\text{K})\)) is initially pressurized to \(P_1 = 25.0\text{ MPa}\) at \(T_1 = 20^\circ\text{C}\). Hydrogen is gradually withdrawn to feed a fuel cell until tank conditions settle at \(P_2 = 18.0\text{ MPa}\) and \(T_2 = 30^\circ\text{C}\). Assuming ideal gas behavior, calculate the initial hydrogen mass \(m_1\), final mass \(m_2\), and mass withdrawn \(\Delta m\).

πŸ” Click to View Complete Step-by-Step Solution
  1. Convert Temperatures to Kelvin & Apply \(m = PV/(RT)\): \(T_1 = 293.15\text{ K}\) and \(T_2 = 303.15\text{ K}\): \[m_1 = \frac{P_1 V}{R T_1} = \frac{(25,000)(0.085)}{(4.124)(293.15)} = 1.758\text{ kg}\]

  2. Final Hydrogen Mass: \[m_2 = \frac{P_2 V}{R T_2} = \frac{(18,000)(0.085)}{(4.124)(303.15)} = 1.224\text{ kg}\]

  3. Mass Withdrawn: \[\Delta m = m_1 - m_2 = 1.758 - 1.224 = 0.534\text{ kg}\] Final Result: \(m_1 = 1.758\text{ kg}\), \(m_2 = 1.224\text{ kg}\), \(\Delta m = 0.534\text{ kg}\).


Practice Problem 2 β€” Compressibility Factor \(Z\) & Ideal Gas Deviation for Pressurized \(\text{CO}_2\)

Carbon dioxide (\(R = 0.1889\text{ kJ}/(\text{kg}\cdot\text{K})\), \(T_{\text{crit}} = 304.1\text{ K}\), \(P_{\text{crit}} = 7.38\text{ MPa}\)) is stored at \(T = 310\text{ K}\) in two pipelines: a high-pressure sequestration header at \(P_A = 6.0\text{ MPa}\) (\(v_{\text{real},A} = 0.00645\text{ m}^3/\text{kg}\)) and a low-pressure vent line at \(P_B = 200\text{ kPa}\) (\(v_{\text{real},B} = 0.2903\text{ m}^3/\text{kg}\)). Compute the compressibility factor \(Z = Pv/(RT)\) at both states and determine the percentage error in density caused by assuming ideal gas behavior in Pipeline A.

πŸ” Click to View Complete Step-by-Step Solution
  1. Calculate Reduced Coordinates & Ideal-Gas Volumes: At \(310\text{ K}\), \(T_R = 310/304.1 = 1.019\) (right above critical temperature): \[v_{\text{ig},A} = \frac{RT}{P_A} = \frac{(0.18892)(310)}{6000} = 0.00976\text{ m}^3/\text{kg}, \qquad v_{\text{ig},B} = \frac{(0.18892)(310)}{200} = 0.2928\text{ m}^3/\text{kg}\]

  2. Evaluate Compressibility Factors \(Z = v_{\text{real}} / v_{\text{ig}}\): \[Z_A = \frac{0.00645}{0.00976} = 0.661, \qquad Z_B = \frac{0.2903}{0.2928} = 0.9912\]

  3. Density Error Check in Pipeline A: Because \(\rho \propto 1/v\), ideal-gas density is \(\rho_{\text{ig}}/\rho_{\text{real}} = Z_A\) (ideal gas predicts \(v\) too high by 51.3%, underpredicting true mass capacity by 33.9%!). Final Result: \(Z_A = 0.661\) (ideal gas fails by 51.3%), \(Z_B = 0.9912\) (ideal gas accurate within 1%).


Practice Problem 3 β€” Spring-Loaded Piston-Cylinder Expansion of an Ideal Gas (Helium)

A frictionless piston-cylinder assembly controlled by a linear spring (\(P\) varies linearly with \(V\)) holds \(m = 0.045\text{ kg}\) of helium (\(R = 2.077\text{ kJ}/(\text{kg}\cdot\text{K})\), \(c_v = 3.116\text{ kJ}/(\text{kg}\cdot\text{K})\)) initially at \(P_1 = 160\text{ kPa}\) and \(T_1 = 300\text{ K}\). Electrical heat is supplied until the helium volume grows by 75% (\(V_2 = 1.75 V_1\)) and pressure rises to \(P_2 = 340\text{ kPa}\). Calculate \(V_1\), final temperature \(T_2\), boundary work \(W_b\), and total heat transfer \(Q\).

πŸ” Click to View Complete Step-by-Step Solution
  1. Initial & Final Volumes and Final Temperature: From \(PV = mRT\): \[V_1 = \frac{(0.045)(2.0769)(300)}{160} = 0.17524\text{ m}^3 \implies V_2 = 1.75(0.17524) = 0.30667\text{ m}^3\] \[T_2 = \frac{P_2 V_2}{m R} = T_1\left(\frac{P_2}{P_1}\right)\left(\frac{V_2}{V_1}\right) = 300\left(\frac{340}{160}\right)(1.75) = 1115.6\text{ K}\]

  2. Trapezoidal Boundary Work & Internal Energy Change: \[W_b = \frac{P_1 + P_2}{2}(V_2 - V_1) = \frac{160 + 340}{2}(0.30667 - 0.17524) = 32.86\text{ kJ}\] \[\Delta U = m c_v (T_2 - T_1) = (0.045)(3.1156)(1115.6 - 300) = 114.35\text{ kJ}\]

  3. First Law Heat Addition: \[Q = \Delta U + W_b = 114.35 + 32.86 = 147.21\text{ kJ}\] Final Result: \(V_1 = 0.1752\text{ m}^3\), \(T_2 = 1115.6\text{ K}\), \(W_b = 32.86\text{ kJ}\), \(Q = 147.21\text{ kJ}\).


Practice Problem 4 β€” Unrestrained Adiabatic Mixing of Air Between Partitioned Rigid Chambers

An insulated, rigid steel tank is divided by a thin burst diaphragm into two compartments:

πŸ” Click to View Complete Step-by-Step Solution
  1. Mass in Each Chamber: \[m_A = \frac{(500)(0.30)}{(0.287)(420)} = 1.2444\text{ kg}, \qquad m_B = \frac{(150)(0.20)}{(0.287)(290)} = 0.3604\text{ kg}\]

  2. First Law on Total Isolated System (\(Q = 0, W = 0 \implies \Delta U = 0\)): Constant \(c_v\) yields the mass-weighted temperature average: \[m_A c_v (T_f - T_A) + m_B c_v (T_f - T_B) = 0 \implies T_f = \frac{m_A T_A + m_B T_B}{m_A + m_B} = \frac{(1.2444)(420) + (0.3604)(290)}{1.6048} = 390.80\text{ K}\]

  3. Final Equilibrium Pressure Across \(V_{\text{tot}} = V_A + V_B = 0.50\text{ m}^3\): \[P_f = \frac{(m_A + m_B) R T_f}{V_A + V_B} = \frac{(1.6048)(0.287)(390.80)}{0.50} = 360.0\text{ kPa}\] Final Result: \(T_f = 390.80\text{ K}\), \(P_f = 360.0\text{ kPa}\).

Summary & Key Takeaways


References, Suggested Reading & Video Lectures

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.