Gas Module#
This module provides simple gas models for thermodynamic calculations. The models implemented include perfect gases and gas mixtures, each with specific assumptions and limitations.
GasModel (Abstract Base Class)#
The GasModel serves as an abstract base class for defining different gas models. It provides a common structure for all gases. It takes two quantities in input, the temperature (\(T\)) and the pressure (\(P\)) and uses them to compute the following properties:
\(\rho\) : the density in \(kg.m^{-3}\)
\(C_p\) : the heat capacity at constant pressure in \(J.K^{-1}\)
\(C_v\) : the heat capacity at constant volume in \(J.K^{-1}\)
\(c\) : the sound velocity in \(m.s^{-1}\)
Assumptions:
Represents a generic gas with thermodynamic properties.
Assumes thermodynamic equilibrium.
Limitations:
Requires subclasses to define actual gas properties.
Hint
If you pass a valid chemical formula (such as “O2”) as name when defining a gas, its molar mass will be computed automatically.
Perfect Gas Model#
The PerfectGas model follows the ideal gas law:
where:
\(P\) : the pressure,
\(V\) : the volume,
\(n\) : the number of moles,
\(R\) : the universal gas constant,
\(T\) : the temperature.
The other quantities are defined as follows:
Assumptions:
The gas behaves ideally with no intermolecular forces.
The heat capacity ratio (\(\gamma\)) remains constant.
Limitations:
Does not account for real gas effects such as compressibility at high pressures.
Assumes uniform temperature and pressure.
For a MonoatomicPerfectGas, the heat capacity ratio is fixed at 5/3.
For a DiatomicPerfectGas, the heat capacity ratio is set to 7/5.
Gas Mixture Model#
The GasMixture model represents a mixture of gases, where the overall properties are derived from the weighted contributions of individual gas components. It assumes Dalton’s Law of Partial Pressures and perfect mixing:
where \(P_i\) is the partial pressure of each gas.
The molar mass of the mixture is computed as:
where:
\(x_i\) is the molar fraction of each gas,
\(M_i\) is the molar mass of each gas.
The heat capacity of the mixture is computed as a weighted sum of each gas:
The sound speed velocity and density are computed using the inverse molar fraction weighting rule:
Other properties, such as density and heat capacities, are obtained as weighted sums of the individual gas contributions.
Assumptions:
The gases mix ideally without chemical interactions.
Follows Dalton’s Law for partial pressures.
Properties are computed as weighted averages.
Follows Wilke’s Law ([Wil50]) for dynamic viscosity of the mixture.
Limitations:
Neglects non-ideal behavior and interactions between different gas species.
Usage Example#
Here is a short example on how to use the module. Please check the Examples section for more details.
from gas_models import MonoatomicPerfectGas
helium = MonoatomicPerfectGas("He")
helium.pressure = 1e5 # Pa
helium.temperature = 273 # K
print(helium.density)
print(helium.Cp)
References#
Charles R Wilke. A viscosity equation for gas mixtures. Journal of Chemical physics, 18(4):517–519, 1950.