Skip to content

Commit

Permalink
constant gamma pyro mechs
Browse files Browse the repository at this point in the history
  • Loading branch information
anderson2981 committed Nov 8, 2023
1 parent ff40bc0 commit 2f2e870
Show file tree
Hide file tree
Showing 2 changed files with 262 additions and 75 deletions.
194 changes: 119 additions & 75 deletions y3prediction/pyro_mechs/check_mechanism.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,122 @@
import numpy as np
from matplotlib import pyplot as plt

gas = ct.Solution("my_mechanism.yaml")
gas.TP = 300, 101325
gas.X = "C2H4:1"

numpts = 43
visc = np.zeros(numpts,)
enthalpy = np.zeros(numpts,)
cp = np.zeros(numpts,)
cv = np.zeros(numpts,)
temperature_list = np.linspace(300, 2400, numpts)
ii = 0
for temp in temperature_list:
gas.TP = temp, 101325
visc[ii] = gas.viscosity
enthalpy[ii] = gas.enthalpy_mass
cp[ii] = gas.cp_mass
cv[ii] = gas.cv_mass
ii += 1

gamma = cp/cv

plt.close("all")
fig = plt.figure(1, figsize=[6.4, 4.8])
ax1 = fig.add_subplot(111)
ax1.set_position([0.16, 0.12, 0.75, 0.83])
ax1.plot(temperature_list, visc, "--", label="Current")
ax1.set_ylabel(r"$\mathbf{Viscosity \, (Pa-s)}$")
ax1.set_xlabel(r"$\mathbf{Temperature \, (K)}$")
plt.savefig("viscosity.png", dpi=200)
ax1.legend()
plt.show()

plt.close("all")
fig = plt.figure(1, figsize=[6.4, 4.8])
ax1 = fig.add_subplot(111)
ax1.set_position([0.16, 0.12, 0.75, 0.83])
ax1.plot(temperature_list, enthalpy, "--", label="Current")
ax1.set_ylabel(r"$\mathbf{Enthalpy \, (J/kg)}$")
ax1.set_xlabel(r"$\mathbf{Temperature \, (K)}$")
plt.savefig("enthalpy.png", dpi=200)
ax1.legend()
plt.show()

plt.close("all")
fig = plt.figure(1, figsize=[6.4, 4.8])
ax1 = fig.add_subplot(111)
ax1.set_position([0.16, 0.12, 0.75, 0.83])
ax1.plot(temperature_list, cp, "--", label="Current")
ax1.set_ylabel(r"$\mathbf{Heat \; Capacity (Cp)\, (J/kg-K)}$")
ax1.set_xlabel(r"$\mathbf{Temperature \, (K)}$")
plt.savefig("heatCapacityCp.png", dpi=200)
ax1.legend()
plt.show()

plt.close("all")
fig = plt.figure(1, figsize=[6.4, 4.8])
ax1 = fig.add_subplot(111)
ax1.set_position([0.16, 0.12, 0.75, 0.83])
ax1.plot(temperature_list, cv, "--", label="Current")
ax1.set_ylabel(r"$\mathbf{Heat \; Capacity (Cv)\, (J/kg-K)}$")
ax1.set_xlabel(r"$\mathbf{Temperature \, (K)}$")
plt.savefig("heatCapacityCv.png", dpi=200)
ax1.legend()
plt.show()
plt.close("all")

fig = plt.figure(1, figsize=[6.4, 4.8])
ax1 = fig.add_subplot(111)
ax1.set_position([0.16, 0.12, 0.75, 0.83])
ax1.plot(temperature_list, gamma, "--", label="Current")
ax1.set_ylabel(r"$\mathbf{gamma}$")
ax1.set_xlabel(r"$\mathbf{Temperature \, (K)}$")
plt.savefig("gamma.png", dpi=200)
ax1.legend()
plt.show()

def check_mechanism(mech_file):
"""Make plot for material properties for species in a mechanism."""

gas = ct.Solution(f"{mech_file}", "gas")
gas.TP = 300, 101325

species_names = gas.species_names

for species in species_names:
gas.X = f"{species}:1"

numpts = 101
lnumpts = 10
temperature_list = np.linspace(100, 1000, numpts)
low_temp_list = np.linspace(1, 91, lnumpts)
temperature_list = np.insert(temperature_list, 0, low_temp_list)

numpts += lnumpts
visc = np.zeros(numpts,)
enthalpy = np.zeros(numpts,)
cp = np.zeros(numpts,)
cv = np.zeros(numpts,)
ii = 0
for temp in temperature_list:
gas.TP = temp, 101325
visc[ii] = gas.viscosity
enthalpy[ii] = gas.enthalpy_mass
cp[ii] = gas.cp_mass
cv[ii] = gas.cv_mass
ii += 1

gamma = cp/cv

plt.close("all")
fig = plt.figure(1, figsize=[6.4, 4.8])
ax1 = fig.add_subplot(111)
ax1.set_title(f"{species}")
ax1.set_position([0.16, 0.12, 0.75, 0.83])
ax1.plot(temperature_list, visc, "--", label="Current")
ax1.set_ylabel(r"$\mathbf{Viscosity \, (Pa-s)}$")
ax1.set_xlabel(r"$\mathbf{Temperature \, (K)}$")
plt.savefig(f"viscosity_{species}.png", dpi=200)
ax1.legend()
plt.show()

plt.close("all")
fig = plt.figure(1, figsize=[6.4, 4.8])
ax1 = fig.add_subplot(111)
ax1.set_title(f"{species}")
ax1.set_position([0.16, 0.12, 0.75, 0.83])
ax1.plot(temperature_list, enthalpy, "--", label="Current")
ax1.set_ylabel(r"$\mathbf{Enthalpy \, (J/kg)}$")
ax1.set_xlabel(r"$\mathbf{Temperature \, (K)}$")
plt.savefig(f"enthalpy_{species}.png", dpi=200)
ax1.legend()
plt.show()

plt.close("all")
fig = plt.figure(1, figsize=[6.4, 4.8])
ax1 = fig.add_subplot(111)
ax1.set_title(f"{species}")
ax1.set_position([0.16, 0.12, 0.75, 0.83])
ax1.plot(temperature_list, cp, "--", label="Current")
ax1.set_ylabel(r"$\mathbf{Heat \; Capacity (Cp)\, (J/kg-K)}$")
ax1.set_xlabel(r"$\mathbf{Temperature \, (K)}$")
plt.savefig(f"heatCapacityCp_{species}.png", dpi=200)
ax1.legend()
plt.show()

plt.close("all")
fig = plt.figure(1, figsize=[6.4, 4.8])
ax1 = fig.add_subplot(111)
ax1.set_title(f"{species}")
ax1.set_position([0.16, 0.12, 0.75, 0.83])
ax1.plot(temperature_list, cv, "--", label="Current")
ax1.set_ylabel(r"$\mathbf{Heat \; Capacity (Cv)\, (J/kg-K)}$")
ax1.set_xlabel(r"$\mathbf{Temperature \, (K)}$")
plt.savefig(f"heatCapacityCv_{species}.png", dpi=200)
ax1.legend()
plt.show()
plt.close("all")

fig = plt.figure(1, figsize=[6.4, 4.8])
ax1 = fig.add_subplot(111)
ax1.set_title(f"{species}")
ax1.set_position([0.16, 0.12, 0.75, 0.83])
ax1.plot(temperature_list, gamma, "--", label="Current")
ax1.set_ylabel(r"$\mathbf{gamma}$")
ax1.set_xlabel(r"$\mathbf{Temperature \, (K)}$")
plt.savefig(f"gamma_{species}.png", dpi=200)
ax1.legend()
plt.show()


import sys
import argparse

if __name__ == "__main__":

parser = argparse.ArgumentParser(
description="Generate Pyrometheus mechanisms")
parser.add_argument("-f", "--mech_file", type=ascii, dest="mech_file",
nargs="?", action="store", help="mechanism file")

args = parser.parse_args()

# get mechanism name from the arguments
from mirgecom.simutil import ApplicationOptionsError
mech_file = ""
if args.mech_file:
print(f"Processing Cantera mechanism file {args.mech_file}")
mech_file = args.mech_file.replace("'", "")
else:
raise ApplicationOptionsError("Missing Cantera mechanism file from input")

print(f"Running {sys.argv[0]}\n")

check_mechanism(mech_file)
143 changes: 143 additions & 0 deletions y3prediction/pyro_mechs/uiuc_const_gamma.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
description: |-
Modified version of UIUC mechanism
generator: cti2yaml
cantera-version: 2.6.0
date: Wed, 27 Jul 2022 18:13:24 -0500
input-files: [uiuc_Sharp.cti]

units: {length: cm, quantity: mol, activation-energy: cal/mol}

phases:
- name: gas
thermo: ideal-gas
elements: [O, H, C, N]
species: [C2H4, O2, CO2, CO, H2O, H2, N2]
kinetics: gas
reactions: all
transport: mixture-averaged
state:
T: 300.0
P: 1.01325e+05

species:
- name: O2
composition: {O: 2}
thermo:
model: NASA7
temperature-ranges: [200.0, 1000.0, 3500.0]
data:
- [3.74, -0.0, 0.0, 0.0, 0.0, -1063.94356, 3.65767573]
- [3.74, -0.0, 0.0, 0.0, 0.0, -1063.94356, 3.65767573]
transport:
model: gas
geometry: linear
diameter: 3.458
well-depth: 107.4
polarizability: 1.6
rotational-relaxation: 3.8
note: TPIS89
- name: H2O
composition: {H: 2, O: 1}
thermo:
model: NASA7
temperature-ranges: [200.0, 1000.0, 3500.0]
data:
- [4.24, -0.0, 0.0, 0.0, 0.0, -3.02937267e+04, -0.849032208]
- [4.24, -0.0, 0.0, 0.0, 0.0, -3.02937267e+04, -0.849032208]
transport:
model: gas
geometry: nonlinear
diameter: 2.605
well-depth: 572.4
dipole: 1.844
rotational-relaxation: 4.0
note: L8/89
- name: CO
composition: {C: 1, O: 1}
thermo:
model: NASA7
temperature-ranges: [200.0, 1000.0, 3500.0]
data:
- [4.59, -0.0, 0.0, 0.0, 0.0, -1.4344086e+04, 3.50840928]
- [4.59, -0.0, 0.0, 0.0, 0.0, -1.4344086e+04, 3.50840928]
transport:
model: gas
geometry: linear
diameter: 3.65
well-depth: 98.1
polarizability: 1.95
rotational-relaxation: 1.8
note: TPIS79
- name: CO2
composition: {C: 1, O: 2}
thermo:
model: NASA7
temperature-ranges: [200.0, 1000.0, 3500.0]
data:
- [5.37, -0.0, 0.0, 0.0, 0.0, -4.83719697e+04, 9.90105222]
- [5.37, -0.0, 0.0, 0.0, 0.0, -4.83719697e+04, 9.90105222]
transport:
model: gas
geometry: linear
diameter: 3.763
well-depth: 244.0
polarizability: 2.65
rotational-relaxation: 2.1
note: L7/88
- name: C2H4
composition: {H: 4, C: 2}
thermo:
model: NASA7
temperature-ranges: [200.0, 1000.0, 3500.0]
data:
- [7.51, 0.0, 0.0, 0.0, 0.0, 5089.77593, 4.09733096]
- [7.51, 0.0, 0.0, 0.0, 0.0, 5089.77593, 4.09733096]
transport:
model: gas
geometry: nonlinear
diameter: 3.971
well-depth: 280.8
rotational-relaxation: 1.5
note: L1/91
- name: N2
composition: {N: 2}
thermo:
model: NASA7
temperature-ranges: [300.0, 1000.0, 5000.0]
data:
- [3.56, -0.0, 0.0, 0.0, 0.0, -1020.8999, 3.950372]
- [3.56, -0.0, 0.0, 0.0, 0.0, -1020.8999, 3.950372]
transport:
model: gas
geometry: linear
diameter: 3.621
well-depth: 97.53
polarizability: 1.76
rotational-relaxation: 4.0
note: '121286'
- name: H2
composition: {H: 2}
thermo:
model: NASA7
temperature-ranges: [300.0, 1000.0, 5000.0]
data:
- [3.52, -0.0, 0.0, 0.0, 0.0, -917.935173, 0.683010238]
- [3.52, -0.0, 0.0, 0.0, 0.0, -917.935173, 0.683010238]
transport:
model: gas
geometry: linear
diameter: 2.92
well-depth: 38.0
polarizability: 0.79
rotational-relaxation: 280.0
note: '000000'

reactions:
- equation: C2H4 + O2 => 2 CO + 2 H2 # Reaction 1
rate-constant: {A: 1.0e+10, b: 0.75, Ea: 40000}
orders: {C2H4: 0.5, O2: 0.65}
- equation: ' CO + 0.5 O2 <=> CO2' # Reaction 2
rate-constant: {A: 1.03e+07, b: 0.7, Ea: 11000}
- equation: ' H2 + 0.5 O2 <=> H2O' # Reaction 3
rate-constant: {A: 7.0e+08, b: 0.0, Ea: 9000.0}

0 comments on commit 2f2e870

Please sign in to comment.