How to compute Sutherland gas viscosity in Python using UliEngineering
You can easily compute the Sutherland gas viscosity using the UliEngineering Python library. The Sutherland model is widely used to describe the temperature dependence of gas viscosity:
from UliEngineering.Physics.Viscosity import sutherland_gas_viscosity, CommonGases
from UliEngineering.EngineerIO import *
# Compute Sutherland viscosity of air at 20°C
T = 20 + 273.15 # Convert to Kelvin
mu = sutherland_gas_viscosity(T, CommonGases.Air.sutherland)
print(f"Air viscosity at 20°C: {format_value(mu, 'Pa·s')}")
# Compute Sutherland viscosity of nitrogen at 100°C
T = 100 + 273.15
mu = sutherland_gas_viscosity(T, CommonGases.Nitrogen.sutherland)
print(f"Nitrogen viscosity at 100°C: {format_value(mu, 'Pa·s')}")
# Using custom Sutherland constants
from UliEngineering.Physics.Viscosity import SutherlandConstants
custom = SutherlandConstants(name="Custom gas", mu0=1.8e-5, T0=273.15, C=120.0)
mu = sutherland_gas_viscosity(300.0, custom)
print(f"Custom gas viscosity at 300K: {format_value(mu, 'Pa·s')}")Example output
Air viscosity at 20°C: 18.3 µPa·s
Nitrogen viscosity at 100°C: 20.9 µPa·s
Custom gas viscosity at 300K: 18.4 µPa·sThe Sutherland equation is given by:
$$ \mu = \mu_0 \cdot \frac{T_0 + C}{T + C} \cdot \left(\frac{T}{T_0}\right)^{3/2} $$where $\mu$ is the dynamic viscosity, $T$ is the absolute temperature in Kelvin, $\mu_0$ is the reference viscosity at reference temperature $T_0$, and $C$ is the Sutherland constant specific to each gas.
Unlike liquids, gas viscosity increases with temperature due to increased molecular motion and collisions. The Sutherland model captures this behavior accurately for a wide range of temperatures and is particularly useful for engineering calculations involving gases.
The plot above shows the Sutherland viscosity model for common gases (Air, Nitrogen, Oxygen, Carbon Dioxide, and Helium) over a temperature range from 0°C to 1000°C. Notice that all gases show increasing viscosity with temperature, with Helium having the highest viscosity overall.
The UliEngineering library provides pre-defined Sutherland constants for common gases like Air, Nitrogen, Oxygen, Carbon Dioxide, and Helium through the CommonGases class.
Related posts
- How to compute Andrade viscosity in Python using UliEngineering
- How to compute VFT viscosity in Python using UliEngineering
- How to compute Swindells viscosity in Python using UliEngineering
Plot generation script
#!/usr/bin/env python3
import matplotlib.pyplot as plt
import numpy as np
import sys
sys.path.insert(0, '/home/uli/dev/UliEngineering')
from UliEngineering.Physics.Viscosity import (
sutherland_gas_viscosity,
CommonGases,
)
# Temperature range in Celsius for plotting (-273 to 1000°C as user suggested)
T_C = np.linspace(0, 1000, 200) # 0 to 1000°C
T_K = T_C + 273.15 # Convert to Kelvin
# Create plot
plt.figure(figsize=(10, 6))
# Plot for different common gases
gases_to_plot = [
('Air', CommonGases.Air.sutherland, 'blue'),
('Nitrogen', CommonGases.Nitrogen.sutherland, 'green'),
('Oxygen', CommonGases.Oxygen.sutherland, 'red'),
('Carbon Dioxide', CommonGases.CarbonDioxide.sutherland, 'purple'),
('Helium', CommonGases.Helium.sutherland, 'orange'),
]
for name, constants, color in gases_to_plot:
mu = sutherland_gas_viscosity(T_K, constants) * 1e6 # Convert to µPa·s
plt.plot(T_C, mu, label=name, color=color, linewidth=2)
plt.xlabel('Temperature (°C)', fontsize=12)
plt.ylabel('Dynamic Viscosity (µPa·s)', fontsize=12)
plt.title('Sutherland Gas Viscosity Model for Common Gases', fontsize=14, fontweight='bold')
plt.legend(loc='upper left', fontsize=10)
plt.grid(True, alpha=0.3)
plt.tight_layout()
plt.savefig('sutherland_viscosity_plot.svg', format='svg', dpi=300)
print("Plot saved to sutherland_viscosity_plot.svg")