#
# 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))

f.close()
print("File closed. Done.")
Ejemplo n.º 2
0
# ideal-shock-test.py
#
# $ prep-gas ideal-air.inp ideal-air-gas-model.lua
# $ python3 ideal-shock-test.py
#
# PJ, 2019-11-28
# 
import math
from eilmer.gas import GasModel, GasState, GasFlow

gmodel = GasModel('ideal-air-gas-model.lua')
state1 = GasState(gmodel)
state1.p = 125.0e3 # Pa
state1.T = 300.0 # K
state1.update_thermo_from_pT()
state1.update_sound_speed()
print("state1: %s" % state1)
print("normal shock (in ideal gas), given shock speed")
vs = 2414.0
state2 = GasState(gmodel)
flow = GasFlow(gmodel)
v2, vg = flow.ideal_shock(state1, vs, state2)
print("v2=%g vg=%g" % (v2, vg))
print("state2: %s" % state2)
Ejemplo n.º 3
0
print(sample_header)

# Gas model setup
gmodel = GasModel("h2-o2-n2-9sp.lua")
nsp = gmodel.n_species
nmodes = gmodel.n_modes
if debug: print("nsp=", nsp, " nmodes=", nmodes, " gmodel=", gmodel)

print("# Gas properties at the start of the pipe.")
gas0 = GasState(gmodel)
gas0.p = 96.87e3  # Pa
x = 0.0  # m  (inlet of pipe)
v = 4551.73  # m/s
gas0.T = 1559.0  # degree K
gas0.molef = {"O2": 0.1480, "N2": 0.5562, "H2": 0.2958}
gas0.update_thermo_from_pT()
dt_suggest = 1.0e-8  # suggested starting time-step for chemistry updater
print(sample_data(x, v, gas0, dt_suggest))

print("# Start reactions...")
reactor = ThermochemicalReactor(gmodel, "h2-o2-n2-9sp-18r.lua")
t = 0  # time is in seconds
t_final = 22.0e-6
t_inc = 0.05e-6
nsteps = int(t_final / t_inc)
for j in range(1, nsteps + 1):
    # At the start of the step...
    rho = gas0.rho
    T = gas0.T
    p = gas0.p
    u = gas0.u