Ejemplo n.º 1
0
    # print("a=",a, "b=",b, "rel=",(a-b)/b, "abs=",a-b, "result=",result) 
    return result
from eilmer.gas import GasModel, GasState, GasFlow

m1 = 1.5
print("Conical-shock demo for m1=%g" % m1)

gmodel = GasModel('cea-air13species-gas-model.lua')
state1 = GasState(gmodel)
state1.p = 100.0e3 # Pa
state1.T = 300.0 # K ideal air, not high T
state1.update_thermo_from_pT()
state1.update_sound_speed()
print("state1: %s" % state1)
v1 = m1*state1.a
print("v1=%g" % v1)

beta = 45.0 * math.pi/180.0
print("  given beta(degrees)=%g" % (beta*180/math.pi))
state_c = GasState(gmodel)
flow = GasFlow(gmodel)
theta_c, v_c = flow.theta_cone(state1, v1, beta, state_c)
print("  theta_c=%g degrees" % (theta_c*180/math.pi))
print("  v_c=%g" % (v_c))
print("  state_c: %s" % state_c)

print("Conical shock angle from deflection.")
beta2 = flow.beta_cone(state1, v1, theta_c)
print("  beta2(degrees)=%g" % (beta2*180/math.pi))
assert approxEqual(beta, beta2), "conical shock wave angle fail" 
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
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)

#------------------------------------------------------------------
print("Decide what to write to the output file.")
output_filename = "air-Mach_12.3.data"
write_massfractions = True
write_molefractions = True

# Output data format is a little like the old poshax code.
header = "# 1:x(m) 2:T(degK) 3:p(Pa) 4:rho(kg/m**3) 5:e(J/kg) 6:v(m/s)"
columnNum = 7
for name in gmodel.species_names:
Ejemplo n.º 4
0
from eilmer.gas import GasModel, GasState, GasFlow

gmodel = GasModel('cea-air13species-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("Initial test gas:")
print("  state1: %s" % state1)

print("normal shock, given shock speed")
vs = 2414.0
print("  vs=%g" % vs)
state2 = GasState(gmodel)
flow = GasFlow(gmodel)
v2, vg = flow.normal_shock(state1, vs, state2)
print("  v2=%g vg=%g" % (v2, vg))
print("  state2: %s" % state2)
assert approxEqual(v2, 361.9), "v2 number after shock fail"
assert approxEqual(vg, 2052.1), "vg number after shock fail"
assert approxEqual(state2.p, 7.314e6), "p2 number after shock fail"
assert approxEqual(state2.T, 2630.0), "T2 number after shock fail"

print("normal shock, given pressure ratio")
p2p1 = 58.516
print("  p2p1=%g" % p2p1)
vs, v2, vg = flow.normal_shock_p2p1(state1, p2p1, state2)
print("  vs=%g v2=%g vg=%g" % (vs, v2, vg))
print("  state2: %s" % state2)
assert approxEqual(vs, 2414.0), "vs number after p2p1 shock fail"
Ejemplo n.º 5
0
print("Unsteady expansion.")
gmodel = GasModel('cea-air13species-gas-model.lua')
state1 = GasState(gmodel)
state1.p = 100.0e3 # Pa
state1.T = 320.0 # K  ideal air, not high T
state1.update_thermo_from_pT()
state1.update_sound_speed()
print("  state1: %s" % state1)
v1 = 0.0
jplus = v1 + 2*state1.a/(1.4-1)
print("  v1=%g jplus=%g" % (v1,jplus))

print("Finite wave process along a cplus characteristic, stepping in pressure.")
state2 = GasState(gmodel)
flow = GasFlow(gmodel)
v2 = flow.finite_wave_dp(state1, v1, "cplus", 60.0e3, state2, 500)
print("  v2=%g" % v2)
print("  state2: %s" % state2)
print("  ideal v2=%g" % (jplus - 2*state2.a/(1.4-1)))
assert approxEqual(v2, 126.2), "velocity after finite_wave_dp fail"
assert approxEqual(state2.p, 60.0e3), "pressure after finite_wave_dp fail"
assert approxEqual(state2.T, 276.5), "temperature after finite_wave_dp fail"

print("Finite wave process along a cplus characteristic, stepping in velocity.")
v2 = flow.finite_wave_dv(state1, v1, "cplus", 125.0, state2)
print("  v2=%g" % v2)
print("  state2: %s" % state2)
print("  ideal v2=%g" % (jplus - 2*state2.a/(1.4-1)))
assert approxEqual(v2, 125.0), "velocity after finite_wave_dv fail"
assert approxEqual(state2.p, 60.3e3), "pressure after finite_wave_dv fail"
Ejemplo n.º 6
0

from eilmer.gas import GasModel, GasState, GasFlow

m1 = 1.5
print("Oblique-shock demo for m1=%g" % m1)

gmodel = GasModel('cea-air13species-gas-model.lua')
state1 = GasState(gmodel)
state1.p = 100.0e3  # Pa
state1.T = 300.0  # K ideal air, not high T
state1.update_thermo_from_pT()
state1.update_sound_speed()
print("state1: %s" % state1)
v1 = m1 * state1.a
print("v1=%g" % v1)

beta = 45.0 * math.pi / 180.0
print("  given beta(degrees)=%g" % (beta * 180 / math.pi))
state2 = GasState(gmodel)
flow = GasFlow(gmodel)
theta, v2 = flow.theta_oblique(state1, v1, beta, state2)
print("  theta=%g degrees" % (theta * 180 / math.pi))
print("  v2=%g" % (v2))
print("  state2: %s" % state2)

print("Oblique shock angle from deflection.")
beta2 = flow.beta_oblique(state1, v1, theta)
print("  beta2(degrees)=%g" % (beta2 * 180 / math.pi))
assert approxEqual(beta, beta2), "shock wave angle fail"
Ejemplo n.º 7
0
from eilmer.gas import GasModel, GasState, GasFlow

gmodel = GasModel('cea-air13species-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, given shock speed")
vs = 2414.0
print("vs=%g" % vs)
state2 = GasState(gmodel)
flow = GasFlow(gmodel)
v2, vg = flow.normal_shock(state1, vs, state2)
print("v2=%g vg=%g" % (v2, vg))
print("state2: %s" % state2)
assert approxEqual(v2, 361.9), "v2 number after shock fail"
assert approxEqual(vg, 2052.1), "vg number after shock fail"
assert approxEqual(state2.p, 7.314e6), "p2 number after shock fail"
assert approxEqual(state2.T, 2630.0), "T2 number after shock fail"

print("normal shock, given pressure ratio")
p2p1 = 58.516
print("p2p1=%g" % p2p1)
vs, v2, vg = flow.normal_shock_p2p1(state1, p2p1, state2)
print("vs=%g v2=%g vg=%g" % (vs, v2, vg))
print("state2: %s" % state2)
assert approxEqual(vs, 2414.0), "vs number after p2p1 shock fail"