Gas Example#
Imports#
[1]:
# Python imports
import os
import sys
sys.path.append("..")
# Flight-Mech imports
from flight_mech.gas import MonoatomicPerfectGas, DiatomicPerfectGas, GasMixture
Monoatomic perfect gas#
Let us define a monoatomic perfect gas such as helium and check its properties.
[2]:
helium = MonoatomicPerfectGas("helium",molar_mass=4e-3)
helium.pressure = 1e5 # Pa
helium.temperature = 273 # K
print("density [kg.m-3]", helium.density)
print("sound velocity [m.s-1]", helium.sound_velocity)
density [kg.m-3] 0.17622323083183306
sound velocity [m.s-1] 972.507132526508
Diatomic perfect gas#
It is also possible to define a gas using its chemical formula. In that case, it is not necessary to provide a molar mass. Let us try with O2.
[3]:
oxygen = DiatomicPerfectGas("O2", pressure=1e5, temperature=293)
print("Cp [J.K-1]", oxygen.Cp)
print("Cv [J.K-1]", oxygen.Cv)
Cp [J.K-1] 909.4511895598583
Cv [J.K-1] 649.6079925427559
Gas mixture#
If you need to study a gas mixture, you can either provide its molar mass directly or define it using the gas mixture class. Let us try with air.
[4]:
oxygen = DiatomicPerfectGas("O2")
nitrogen = DiatomicPerfectGas("N2")
gas_model_dict = {
"O2": oxygen,
"N2": nitrogen
}
gas_molar_fraction_dict = {
"O2": 0.21,
"N2": 0.79
}
air = GasMixture(gas_model_dict, gas_molar_fraction_dict)
air.temperature = 283
air.P = 1e5
print("density [kg.m-3]", air.density)
print("sound velocity [m.s-1]", air.sound_velocity)
density [kg.m-3] 1.2261252357914747
sound velocity [m.s-1] 338.0352369810981
After defining a gas, you can change the temperature or pressure to compute its properties in other conditions.
[5]:
air.T = 750 # K
print("density [kg.m-3]", air.density)
density [kg.m-3] 0.4626579223053165