#
# Author: Peter J. and Rowan J. Gollan
# Date: 2019-11-21
#
# To run this script:
# $ prep-gas thermally-perfect-N2-O2.inp thermally-perfect-N2-O2.lua
# $ python3 transport-properties-for-air.py
#
from eilmer.gas import GasModel, GasState

gasModelFile = 'thermally-perfect-N2-O2.lua'
gmodel = GasModel(gasModelFile)

gs = GasState(gmodel)
gs.p = 1.0e5 # Pa
gs.massf = {"N2":0.78, "O2":0.22} # approximation for the composition of air

outputFile = 'trans-props-air.dat'
print("Opening file for writing: %s" % outputFile)
f = open(outputFile, "w")
f.write("#  1:T[K]      2:mu[Pa.s]      3:k[W/(m.K)]\n")

lowT = 200.0
dT = 100.0

for i in range(199):
    gs.T = dT*i + lowT
    gs.update_thermo_from_pT()
    gs.update_trans_coeffs()
    f.write(" %12.6e %12.6e %12.6e\n" % (gs.T, gs.mu, gs.k))
Beispiel #2
0
#------------------------------------------------------------------
from eilmer.gas import GasModel, GasState, GasFlow, ThermochemicalReactor
debug = False

print("Initialise a gas model.")
print("air 7 species Gupta-et-al reactions")
gmodel = GasModel("air-7sp-gas-model.lua")
nsp = gmodel.n_species
nmodes = gmodel.n_modes
if debug: print("nsp=", nsp, " nmodes=", nmodes, " gmodel=", gmodel)
reactor = ThermochemicalReactor(gmodel, "air-7sp-chemistry.lua")
# The example here matches the case discussed on page 63 of the thesis.
state1 = GasState(gmodel)
state1.p = 133.3  # Pa
state1.T = 300.0  # degree K
state1.massf = {"N2": 0.78, "O2": 0.22}
print("Free stream conditions, before the shock.")
state1.update_thermo_from_pT()
state1.update_sound_speed()
print("    state1: %s" % state1)
mach1 = 12.28
v1 = mach1 * state1.a
print("mach1:", mach1, "v1:", v1)

print("Stationary normal shock with chemically-frozen gas.")
flow = GasFlow(gmodel)
state2 = GasState(gmodel)
v2, vg = flow.normal_shock(state1, v1, state2)
print("    v2=", v2, "vg=", vg)
print("    state2: %s" % state2)
Beispiel #3
0
# the gas-model Lua file is visible, as given by the path below.
#
# PJ 2019-07-24 direct use of FFI
#    2019-07-25 using Pythonic wrapper
#
from eilmer.gas import GasModel, GasState

gmodel = GasModel("ideal-air-gas-model.lua")
print("gmodel=", gmodel)
print("n_species=", gmodel.n_species, ", n_modes=", gmodel.n_modes)
print("species_names=", gmodel.species_names)
print("mol_masses=", gmodel.mol_masses)

gs = GasState(gmodel)
print("freshly minted gs=", gs)
gs.rho=1.1; gs.p=1.0e5; gs.T=300.0; gs.u=1.44e6; gs.massf=[1.0]
print("after setting some values")
print("  gs.rho=%g p=%g T=%g u=%g massf=%s a=%g k=%g mu=%g" %
      (gs.rho, gs.p, gs.T, gs.u, gs.massf, gs.a, gs.k, gs.mu))
gmodel.update_thermo_from_pT(gs) # the way that we do the update in D
gmodel.update_sound_speed(gs) # not necessary from Python but is available
gmodel.update_trans_coeffs(gs)
print("after update thermo from pT")
print("  gs.rho=%g p=%g T=%g u=%g massf=%s a=%g k=%g mu=%g" %
      (gs.rho, gs.p, gs.T, gs.u, gs.massf, gs.a, gs.k, gs.mu))
gs.p=3000.0; gs.T=99.0; gs.massf={'air':1.0}
gs.update_thermo_from_rhou() # update another way
gs.update_trans_coeffs()
print("after update thermo from rhou")
print("  gs.rho=%g p=%g T=%g u=%g massf=%s a=%g k=%g mu=%g" %
      (gs.rho, gs.p, gs.T, gs.u, gs.massf, gs.a, gs.k, gs.mu))
print("Park et al mars atmosphere reaction scheme.")
gmodel = GasModel("mars-atm-with-ions.lua")
nsp = gmodel.n_species
nmodes = gmodel.n_modes
if debug: print("nsp=", nsp, " nmodes=", nmodes, " gmodel=", gmodel)
reactor = ThermochemicalReactor(gmodel, "mars-atm-with-ions-chemistry.lua")
# The example here matches the case on p.17 of Park's publication
v1 = 8000
state1 = GasState(gmodel)
state1.rho = 0.15 * 101300 / v1**2  # freestream density according to Park to keep p after the shock at 0.15atm
print("Free stream desnity:", state1.rho)
state1.T = 210.0  # K, Mars surface temp
state1.massf = {
    "CO2": 0.9664,
    "N2": 0.0174,
    "Ar": 0.0147,
    "O2": 0.001,
    "CO": 0.0005
}
print("Free stream conditions, before the shock.")
state1.update_thermo_from_rhoT()
state1.update_sound_speed()
print("    state1: %s" % state1)
mach1 = v1 / state1.a
print("mach1:", mach1, "v1:", v1)

print("Stationary normal shock with chemically-frozen gas.")
flow = GasFlow(gmodel)
state2 = GasState(gmodel)
v2, vg = flow.normal_shock(state1, v1, state2)
print("    v2=", v2, "vg=", vg)
Beispiel #5
0
#
# Author: Peter J. and Rowan J. Gollan
# Date: 2019-11-21
#
# To run this script:
# $ prep-gas O2.inp O2-gas-model.lua
# $ python3 thermo-curves-for-O2.py
#
from eilmer.gas import GasModel, GasState

gasModelFile = 'O2-gas-model.lua'
gmodel = GasModel(gasModelFile)

gs = GasState(gmodel)
gs.p = 1.0e5  # Pa
gs.massf = {"O2": 1.0}

outputFile = 'O2-thermo.dat'
print("Opening file for writing: %s" % outputFile)
f = open(outputFile, "w")
f.write("#  1:T[K]      2:Cp[J/kg/K]     3:h[J/kg]\n")

lowT = 200.0
dT = 100.0

for i in range(199):
    gs.T = dT * i + lowT
    gs.update_thermo_from_pT()
    f.write(" %12.6e %12.6e %12.6e\n" % (gs.T, gs.Cp, gs.enthalpy))

f.close()