如何使用 UliEngineering 在 Python 中计算萨瑟兰气体粘度
你可以使用 UliEngineering Python 库轻松计算萨瑟兰气体粘度。萨瑟兰模型广泛用于描述气体粘度随温度的变化:
sutherland_viscosity.py
from UliEngineering.Physics.Viscosity import sutherland_gas_viscosity, CommonGases
from UliEngineering.EngineerIO import *
# 计算 20°C 时空气的萨瑟兰粘度
T = 20 + 273.15 # 转换为开尔文
mu = sutherland_gas_viscosity(T, CommonGases.Air.sutherland)
print(f"Air viscosity at 20°C: {format_value(mu, 'Pa·s')}")
# 计算 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')}")
# 使用自定义的萨瑟兰常数
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')}")示例输出
sutherland_viscosity_output.txt
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·s萨瑟兰方程的表达式为:
$$ \mu = \mu_0 \cdot \frac{T_0 + C}{T + C} \cdot \left(\frac{T}{T_0}\right)^{3/2} $$其中 $\mu$ 是动力粘度,$T$ 是开尔文绝对温度,$\mu_0$ 是参考温度 $T_0$ 下的参考粘度,$C$ 是每种气体特有的萨瑟兰常数。
与液体不同,气体的粘度会随温度升高而增大,这是由于分子运动和碰撞增加所致。萨瑟兰模型能在很宽的温度范围内准确描述这一行为,特别适用于涉及气体的工程计算。
上图展示了常见气体(空气、氮气、氧气、二氧化碳和氦气)在 0°C 到 1000°C 温度范围内的萨瑟兰粘度模型。可以看到所有气体的粘度都随温度升高而增大,其中氦气的粘度整体最高。
UliEngineering 库通过 CommonGases 类为空气、氮气、氧气、二氧化碳和氦气等常见气体提供了预定义的萨瑟兰常数。
相关文章
- 如何使用 UliEngineering 在 Python 中计算 Andrade 粘度
- 如何使用 UliEngineering 在 Python 中计算 VFT 粘度
- 如何使用 UliEngineering 在 Python 中计算 Swindells 粘度
绘图生成脚本
plot_sutherland_viscosity.py
#!/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,
)
# 用于绘图的摄氏温度范围(-273 到 1000°C,按用户建议)
T_C = np.linspace(0, 1000, 200) # 0 到 1000°C
T_K = T_C + 273.15 # 转换为开尔文
# 创建图形
plt.figure(figsize=(10, 6))
# 绘制不同常见气体的曲线
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 # 转换为 µ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")If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow