The following items in auxi
are discussed and demonstrated in this example:
auxi.tools.materialphysicalproperties.idealgas.BetaT
auxi.tools.materialphysicalproperties.idealgas.RhoT
auxi.tools.materialphysicalproperties.idealgas.RhoTP
auxi.tools.materialphysicalproperties.idealgas.RhoTPx
In [ ]:
# import some tools to use in this example
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
In [ ]:
# import the model class
from auxi.tools.materialphysicalproperties.idealgas import BetaT
# create a model object
βT = BetaT()
# define the state of the gas
T = 500.0 # [K]
# calculate the gas density
β = βT(T=T)
print ("β =", β, βT.units)
In [ ]:
# calculate the gas density
Ts = list(range(400, 1550, 50)) # [K]
β = [βT(T=T) for T in Ts]
# plot a graph
plt.plot(Ts, β, "bo", alpha = 0.5)
plt.xlabel('$T$ [K]')
plt.ylabel('$%s$ [%s]' % (βT.display_symbol, βT.units))
plt.show()
In [ ]:
# import the molar mass function
from auxi.tools.chemistry.stoichiometry import molar_mass as mm
# import the model class
from auxi.tools.materialphysicalproperties.idealgas import RhoT
# create a model object
# Since the model only calculates as a function temperature, we need to specify
# pressure and average molar mass when we create it.
ρT = RhoT(molar_mass=mm('CO2'), P=101325.0)
# define the state of the gas
T = 500.0 # [K]
# calculate the gas density
ρ = ρT.calculate(T=T)
print(ρT.symbol, "=", ρ, ρT.units)
In [ ]:
# calculate the gas density
Ts = list(range(400, 1550, 50)) # [K]
ρs = [ρT(T=T) for T in Ts]
# plot a graph
plt.plot(Ts, ρs, "bo", alpha = 0.7)
plt.xlabel('$T$ [K]')
plt.ylabel('$%s$ [%s]' % (ρT.display_symbol, ρT.units))
plt.show()
In [ ]:
# import the model class
from auxi.tools.materialphysicalproperties.idealgas import RhoTP
# create a model object
# Since the model only calculates as a function of temperature and pressure,
# we need to specify an average molar mass when we create it.
ρTP = RhoTP(mm('CO2'))
# define the state of the gas
T = 500.0 # [K]
P = 101325.0 # [Pa]
# calculate the gas density
ρ = ρTP.calculate(T=T,P=P)
print(ρTP.symbol, "=", ρ, ρTP.units)
In [ ]:
# define the state of the gas
T = 700.0 # [K]
Ps = np.linspace(0.5*101325, 5*101325) # [Pa]
# calculate the gas density
ρs = [ρTP(T=T, P=P) for P in Ps]
# plot a graph
plt.plot(Ps, ρs, "bo", alpha = 0.7)
plt.xlabel('$P$ [Pa]')
plt.ylabel('$%s$ [%s]' % (ρTP.display_symbol, ρTP.units))
plt.show()
This model describes the variation in density of an ideal gas as a function of temperature, pressure, and molar composition.
RhoTP
at a Single Gas StateAs a basic example lets calculate the density at a single temperature, pressure and molar compostion for a mixture of two gases:
In [ ]:
# import the model class
from auxi.tools.materialphysicalproperties.idealgas import RhoTPx
# create a model object
ρTPx = RhoTPx()
# define the state of the gas
T = 700.0 # [K]
P = 101325.0 # [Pa]
x = {'H2':0.5, 'Ar':0.5} # [mole fraction]
# calculate the gas density
ρ = ρTPx(T=700, P=101000, x=x)
print(ρTPx.symbol, "=", ρ, ρTPx.units)
In [ ]:
# define the state of the gas
T = 700.0 # [K]
P = 101325.0 # [Pa]
xs_h2 = np.arange(0,1.1,0.1) # [mole fraction H2]
# calculate density as a function of composition for a binary Ar-H2 gas mixture
ρs = [ρTPx(T=700, P=101325 ,x={'Ar':1-x, 'H2':x}) for x in xs_h2]
# plot a graph
plt.plot(xs_h2, ρs, "bo", alpha = 0.7)
plt.xlim((0,1))
plt.xlabel('$x_{H_2}$ [mol]')
plt.ylabel('$%s$ [%s]' % (ρTPx.display_symbol, ρTPx.units))
plt.show()