Commit of upper level dir.
This commit is contained in:
parent
371d130a70
commit
53b937679d
9 changed files with 20 additions and 824 deletions
|
|
@ -1,17 +1,33 @@
|
|||
#!/bin/sh
|
||||
|
||||
PY_DEMOS = flame1.py flame2.py stflame1.py npflame1.py free_h2_air.py \
|
||||
adiabatic_flame.py fixed_T_flame.py
|
||||
PY_DEMOS = flame1 flame2 stflame1 npflame1 free_h2_air \
|
||||
adiabatic_flame fixed_T_flame
|
||||
PYTHON_CMD = @PYTHON_CMD@
|
||||
|
||||
all:
|
||||
@(for py in $(PY_DEMOS) ; do \
|
||||
echo "running $${py}..."; \
|
||||
(cd $${py} ; @MAKE@ ) \
|
||||
done)
|
||||
|
||||
run:
|
||||
@(for py in $(PY_DEMOS) ; do \
|
||||
echo "running $${py}..."; \
|
||||
$(PYTHON_CMD) "$${py}"; \
|
||||
(cd $${py} ; @MAKE@ run ) \
|
||||
done)
|
||||
|
||||
test:
|
||||
@(for py in $(PY_DEMOS) ; do \
|
||||
echo "running $${py}..."; \
|
||||
(cd $${py} ; @MAKE@ test ) \
|
||||
done)
|
||||
|
||||
clean:
|
||||
rm -f *.log *.csv *.xml
|
||||
@(for py in $(PY_DEMOS) ; do \
|
||||
echo "running $${py}..."; \
|
||||
(cd $${py} ; @MAKE@ clean ) \
|
||||
done)
|
||||
|
||||
|
||||
# end of file
|
||||
|
||||
|
|
|
|||
|
|
@ -1,84 +0,0 @@
|
|||
#
|
||||
# ADIABATIC_FLAME - A freely-propagating, premixed methane/air flat
|
||||
# flame with multicomponent transport properties
|
||||
#
|
||||
from Cantera import *
|
||||
from Cantera.OneD import *
|
||||
from Cantera.OneD.FreeFlame import FreeFlame
|
||||
|
||||
################################################################
|
||||
#
|
||||
# parameter values
|
||||
#
|
||||
p = OneAtm # pressure
|
||||
tin = 300.0 # unburned gas temperature
|
||||
mdot = 0.04 # kg/m^2/s
|
||||
|
||||
comp = 'CH4:0.45, O2:1, N2:3.76' # premixed gas composition
|
||||
|
||||
initial_grid = [0.0, 0.001, 0.01, 0.02, 0.029, 0.03] # m
|
||||
|
||||
tol_ss = [1.0e-5, 1.0e-9] # [rtol atol] for steady-state
|
||||
# problem
|
||||
tol_ts = [1.0e-5, 1.0e-9] # [rtol atol] for time stepping
|
||||
|
||||
loglevel = 1 # amount of diagnostic output (0
|
||||
# to 5)
|
||||
|
||||
refine_grid = 1 # 1 to enable refinement, 0 to
|
||||
# disable
|
||||
|
||||
|
||||
gas = GRI30('Mix')
|
||||
gas.addTransportModel('Multi')
|
||||
|
||||
# set its state to that of the unburned gas
|
||||
gas.setState_TPX(tin, p, comp)
|
||||
|
||||
f = FreeFlame(gas = gas, grid = initial_grid, tfix = 600.0)
|
||||
|
||||
# set the upstream properties
|
||||
f.inlet.set(mole_fractions = comp, temperature = tin)
|
||||
|
||||
f.set(tol = tol_ss, tol_time = tol_ts)
|
||||
f.showSolution()
|
||||
|
||||
f.set(energy = 'off')
|
||||
f.setRefineCriteria(ratio = 10.0, slope = 1, curve = 1)
|
||||
f.setMaxJacAge(50, 50)
|
||||
f.setTimeStep(1.0e-5, [1, 2, 5, 10, 20])
|
||||
|
||||
f.solve(loglevel, refine_grid)
|
||||
f.save('ch4_adiabatic.xml','no_energy',
|
||||
'solution with the energy equation disabled')
|
||||
|
||||
f.set(energy = 'on')
|
||||
f.setRefineCriteria(ratio = 3.0, slope = 0.1, curve = 0.2)
|
||||
f.solve(loglevel, refine_grid)
|
||||
f.save('ch4_adiabatic.xml','energy',
|
||||
'solution with the energy equation enabled')
|
||||
print 'mixture-averaged flamespeed = ',f.u()[0]
|
||||
|
||||
gas.switchTransportModel('Multi')
|
||||
f.flame.setTransportModel(gas)
|
||||
f.solve(loglevel, refine_grid)
|
||||
f.save('ch4_adiabatic.xml','energy_multi',
|
||||
'solution with the energy equation enabled and multicomponent transport')
|
||||
|
||||
# write the velocity, temperature, density, and mole fractions to a CSV file
|
||||
z = f.flame.grid()
|
||||
T = f.T()
|
||||
u = f.u()
|
||||
V = f.V()
|
||||
fcsv = open('adiabatic_flame.csv','w')
|
||||
writeCSV(fcsv, ['z (m)', 'u (m/s)', 'V (1/s)', 'T (K)', 'rho (kg/m3)']
|
||||
+ list(gas.speciesNames()))
|
||||
for n in range(f.flame.nPoints()):
|
||||
f.setGasState(n)
|
||||
writeCSV(fcsv, [z[n], u[n], V[n], T[n], gas.density()]
|
||||
+list(gas.moleFractions()))
|
||||
fcsv.close()
|
||||
|
||||
print 'solution saved to adiabatic_flame.csv'
|
||||
print 'multicomponent flamespeed = ',u[0]
|
||||
f.showStats()
|
||||
|
|
@ -1,149 +0,0 @@
|
|||
#
|
||||
# FIXED_T_FLAME - A burner-stabilized, premixed methane/air flat flame
|
||||
# with multicomponent transport properties and a specified
|
||||
# temperature profile
|
||||
#
|
||||
from Cantera import *
|
||||
from Cantera.OneD import *
|
||||
from Cantera.OneD.BurnerFlame import BurnerFlame
|
||||
from string import atof
|
||||
|
||||
|
||||
# read temperature vs. position data from a file.
|
||||
# The file is assumed to have one z, T pair per line, separated by a comma.
|
||||
|
||||
def getTempData(filename):
|
||||
# open the file containing the temperature data for reading
|
||||
f = open(filename)
|
||||
z = []
|
||||
t = []
|
||||
lines = f.readlines()
|
||||
|
||||
# check for unix/Windows/Mac line ending problems
|
||||
if len(lines) == 1:
|
||||
print 'Warning: only one line found. Possible text file line-ending'
|
||||
print 'problem?'
|
||||
print 'The one line found is: ',lines[0]
|
||||
|
||||
|
||||
for line in lines:
|
||||
if line[0] == '#': # use '#' as the comment character
|
||||
pass
|
||||
else:
|
||||
try:
|
||||
zval, tval = line.split(',')
|
||||
z.append(atof(zval))
|
||||
t.append(atof(tval))
|
||||
except:
|
||||
pass
|
||||
print 'read',len(z),'temperature values.'
|
||||
f.close()
|
||||
|
||||
# convert z values into non-dimensional relative positions.
|
||||
n = len(z)
|
||||
zmax = z[n-1]
|
||||
for i in range(n):
|
||||
z[i] = z[i]/zmax
|
||||
|
||||
return [z,t]
|
||||
|
||||
|
||||
|
||||
################################################################
|
||||
#
|
||||
# parameter values
|
||||
#
|
||||
p = OneAtm # pressure
|
||||
tburner = 373.7 # burner temperature
|
||||
mdot = 0.04 # kg/m^2/s
|
||||
|
||||
comp = 'CH4:0.65, O2:1, N2:3.76' # premixed gas composition
|
||||
|
||||
# The solution domain is chosen to be 1 cm, and a point very near the
|
||||
# downstream boundary is added to help with the zero-gradient boundary
|
||||
# condition at this boundary.
|
||||
initial_grid = [0.0, 0.0025, 0.005, 0.0075, 0.0099, 0.01] # m
|
||||
|
||||
tol_ss = [1.0e-5, 1.0e-9] # [rtol atol] for steady-state
|
||||
# problem
|
||||
tol_ts = [1.0e-5, 1.0e-4] # [rtol atol] for time stepping
|
||||
|
||||
loglevel = 1 # amount of diagnostic output (0
|
||||
# to 5)
|
||||
|
||||
refine_grid = 1 # 1 to enable refinement, 0 to
|
||||
# disable
|
||||
|
||||
|
||||
################ create the gas object ########################
|
||||
#
|
||||
# This object will be used to evaluate all thermodynamic, kinetic, and
|
||||
# transport properties. It is created with two transport managers, to
|
||||
# enable switching from mixture-averaged to multicomponent transport
|
||||
# on the last solution.
|
||||
gas = GRI30('Mix')
|
||||
gas.addTransportModel('Multi')
|
||||
|
||||
# set its state to that of the unburned gas at the burner
|
||||
gas.setState_TPX(tburner, p, comp)
|
||||
|
||||
# create the BurnerFlame object.
|
||||
f = BurnerFlame(gas = gas, grid = initial_grid)
|
||||
|
||||
# set the properties at the burner
|
||||
f.burner.set(massflux = mdot, mole_fractions = comp, temperature = tburner)
|
||||
|
||||
# read in the fixed temperature profile
|
||||
[zloc, tvalues] = getTempData('tdata.dat')
|
||||
|
||||
# set the temperature profile to the values read in
|
||||
f.flame.setFixedTempProfile(zloc, tvalues)
|
||||
|
||||
f.set(tol = tol_ss, tol_time = tol_ts)
|
||||
|
||||
# show the initial estimate for the solution
|
||||
f.showSolution()
|
||||
|
||||
# don't solve the energy equation
|
||||
f.set(energy = 'off')
|
||||
|
||||
# first solve the flame with mixture-averaged transport properties
|
||||
f.setRefineCriteria(ratio = 3.0, slope = 0.3, curve = 1)
|
||||
f.setMaxJacAge(50, 50)
|
||||
f.setTimeStep(1.0e-5, [1, 2, 5, 10, 20])
|
||||
|
||||
f.solve(loglevel, refine_grid)
|
||||
f.save('ch4_flame_fixed_T.xml','mixav',
|
||||
'solution with mixture-averaged transport')
|
||||
|
||||
print '\n\n switching to multicomponent transport...\n\n'
|
||||
gas.switchTransportModel('Multi')
|
||||
f.flame.setTransportModel(gas)
|
||||
|
||||
f.setRefineCriteria(ratio = 3.0, slope = 0.1, curve = 0.2)
|
||||
f.solve(loglevel, refine_grid)
|
||||
f.save('ch4_flame_fixed_T.xml','multi',
|
||||
'solution with multicomponent transport')
|
||||
|
||||
# write the velocity, temperature, density, and mole fractions to a CSV file
|
||||
z = f.flame.grid()
|
||||
T = f.T()
|
||||
u = f.u()
|
||||
V = f.V()
|
||||
fcsv = open('flame_fixed_T.csv','w')
|
||||
writeCSV(fcsv, ['z (m)', 'u (m/s)', 'V (1/s)', 'T (K)', 'rho (kg/m3)']
|
||||
+ list(gas.speciesNames()))
|
||||
for n in range(f.flame.nPoints()):
|
||||
f.setGasState(n)
|
||||
writeCSV(fcsv, [z[n], u[n], V[n], T[n], gas.density()]
|
||||
+list(gas.moleFractions()))
|
||||
fcsv.close()
|
||||
|
||||
print 'solution saved to flame_fixed_T.csv'
|
||||
|
||||
f.showStats()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
#
|
||||
# FLAME1 - A burner-stabilized flat flame
|
||||
#
|
||||
# This script simulates a burner-stablized lean hydrogen-oxygen flame
|
||||
# at low pressure.
|
||||
#
|
||||
from Cantera import *
|
||||
from Cantera.OneD import *
|
||||
from Cantera.OneD.BurnerFlame import BurnerFlame
|
||||
|
||||
################################################################
|
||||
#
|
||||
# parameter values
|
||||
#
|
||||
p = 0.05*OneAtm # pressure
|
||||
tburner = 373.0 # burner temperature
|
||||
mdot = 0.06 # kg/m^2/s
|
||||
|
||||
rxnmech = 'h2o2.cti' # reaction mechanism file
|
||||
mix = 'ohmech' # gas mixture model
|
||||
comp = 'H2:1.8, O2:1, AR:7' # premixed gas composition
|
||||
|
||||
# The solution domain is chosen to be 50 cm, and a point very near the
|
||||
# downstream boundary is added to help with the zero-gradient boundary
|
||||
# condition at this boundary.
|
||||
initial_grid = [0.0, 0.02, 0.04, 0.06, 0.08, 0.1,
|
||||
0.15, 0.2, 0.4, 0.49, 0.5] # m
|
||||
|
||||
tol_ss = [1.0e-5, 1.0e-13] # [rtol atol] for steady-state
|
||||
# problem
|
||||
tol_ts = [1.0e-4, 1.0e-9] # [rtol atol] for time stepping
|
||||
|
||||
loglevel = 1 # amount of diagnostic output (0
|
||||
# to 5)
|
||||
|
||||
refine_grid = 1 # 1 to enable refinement, 0 to
|
||||
# disable
|
||||
|
||||
|
||||
################ create the gas object ########################
|
||||
#
|
||||
# This object will be used to evaluate all thermodynamic, kinetic,
|
||||
# and transport properties
|
||||
#
|
||||
gas = IdealGasMix(rxnmech, mix)
|
||||
|
||||
# set its state to that of the unburned gas at the burner
|
||||
gas.set(T = tburner, P = p, X = comp)
|
||||
|
||||
f = BurnerFlame(gas = gas, grid = initial_grid)
|
||||
|
||||
# set the properties at the burner
|
||||
f.burner.set(massflux = mdot, mole_fractions = comp, temperature = tburner)
|
||||
|
||||
f.set(tol = tol_ss, tol_time = tol_ts)
|
||||
f.setMaxJacAge(5, 10)
|
||||
f.set(energy = 'off')
|
||||
f.init()
|
||||
f.showSolution()
|
||||
|
||||
f.solve(loglevel, refine_grid)
|
||||
|
||||
f.setRefineCriteria(ratio = 200.0, slope = 0.05, curve = 0.1)
|
||||
f.set(energy = 'on')
|
||||
f.solve(loglevel,refine_grid)
|
||||
|
||||
f.save('flame1.xml')
|
||||
f.showSolution()
|
||||
|
||||
|
||||
# write the velocity, temperature, and mole fractions to a CSV file
|
||||
z = f.flame.grid()
|
||||
T = f.T()
|
||||
u = f.u()
|
||||
V = f.V()
|
||||
fcsv = open('flame1.csv','w')
|
||||
writeCSV(fcsv, ['z (m)', 'u (m/s)', 'V (1/s)', 'T (K)', 'rho (kg/m3)']
|
||||
+ list(gas.speciesNames()))
|
||||
for n in range(f.flame.nPoints()):
|
||||
f.setGasState(n)
|
||||
writeCSV(fcsv, [z[n], u[n], V[n], T[n], gas.density()]
|
||||
+list(gas.moleFractions()))
|
||||
fcsv.close()
|
||||
|
||||
print 'solution saved to flame1.csv'
|
||||
|
||||
f.showStats()
|
||||
|
||||
|
|
@ -1,101 +0,0 @@
|
|||
#
|
||||
# FLAME2 - A burner-stabilized, premixed methane/air flat flame
|
||||
# with multicomponent transport properties
|
||||
#
|
||||
from Cantera import *
|
||||
from Cantera.OneD import *
|
||||
from Cantera.OneD.BurnerFlame import BurnerFlame
|
||||
|
||||
################################################################
|
||||
#
|
||||
# parameter values
|
||||
#
|
||||
p = OneAtm # pressure
|
||||
tburner = 373.7 # burner temperature
|
||||
mdot = 0.04 # kg/m^2/s
|
||||
|
||||
comp = 'CH4:0.65, O2:1, N2:3.76' # premixed gas composition
|
||||
|
||||
# The solution domain is chosen to be 1 cm, and a point very near the
|
||||
# downstream boundary is added to help with the zero-gradient boundary
|
||||
# condition at this boundary.
|
||||
initial_grid = [0.0, 0.0025, 0.005, 0.0075, 0.0099, 0.01] # m
|
||||
|
||||
tol_ss = [1.0e-5, 1.0e-9] # [rtol atol] for steady-state
|
||||
# problem
|
||||
tol_ts = [1.0e-5, 1.0e-4] # [rtol atol] for time stepping
|
||||
|
||||
loglevel = 1 # amount of diagnostic output (0
|
||||
# to 5)
|
||||
|
||||
refine_grid = 1 # 1 to enable refinement, 0 to
|
||||
# disable
|
||||
|
||||
|
||||
################ create the gas object ########################
|
||||
#
|
||||
# This object will be used to evaluate all thermodynamic, kinetic, and
|
||||
# transport properties. It is created with two transport managers, to
|
||||
# enable switching from mixture-averaged to multicomponent transport
|
||||
# on the last solution.
|
||||
gas = GRI30('Mix')
|
||||
gas.addTransportModel('Multi')
|
||||
|
||||
# set its state to that of the unburned gas at the burner
|
||||
gas.setState_TPX(tburner, p, comp)
|
||||
|
||||
f = BurnerFlame(gas = gas, grid = initial_grid)
|
||||
|
||||
# set the properties at the burner
|
||||
f.burner.set(massflux = mdot, mole_fractions = comp, temperature = tburner)
|
||||
|
||||
f.set(tol = tol_ss, tol_time = tol_ts)
|
||||
f.showSolution()
|
||||
|
||||
f.set(energy = 'off')
|
||||
f.setRefineCriteria(ratio = 10.0, slope = 1, curve = 1)
|
||||
f.setMaxJacAge(50, 50)
|
||||
f.setTimeStep(1.0e-5, [1, 2, 5, 10, 20])
|
||||
|
||||
f.solve(loglevel, refine_grid)
|
||||
f.save('ch4_flame1.xml','no_energy',
|
||||
'solution with the energy equation disabled')
|
||||
|
||||
f.set(energy = 'on')
|
||||
f.setRefineCriteria(ratio = 3.0, slope = 0.1, curve = 0.2)
|
||||
f.solve(loglevel, refine_grid)
|
||||
f.save('ch4_flame1.xml','energy',
|
||||
'solution with the energy equation enabled')
|
||||
|
||||
gas.switchTransportModel('Multi')
|
||||
f.flame.setTransportModel(gas)
|
||||
f.solve(loglevel, refine_grid)
|
||||
f.save('ch4_flame1.xml','energy_multi',
|
||||
'solution with the energy equation enabled and multicomponent transport')
|
||||
f.flame.enableSoret()
|
||||
f.solve(loglevel, refine_grid)
|
||||
f.save('ch4_flame1.xml','energy_multi_soret',
|
||||
'solution with the energy equation enabled and multicomponent transport with thermal diffusion')
|
||||
|
||||
# write the velocity, temperature, density, and mole fractions to a CSV file
|
||||
z = f.flame.grid()
|
||||
T = f.T()
|
||||
u = f.u()
|
||||
V = f.V()
|
||||
fcsv = open('flame2.csv','w')
|
||||
writeCSV(fcsv, ['z (m)', 'u (m/s)', 'V (1/s)', 'T (K)', 'rho (kg/m3)']
|
||||
+ list(gas.speciesNames()))
|
||||
for n in range(f.flame.nPoints()):
|
||||
f.setGasState(n)
|
||||
writeCSV(fcsv, [z[n], u[n], V[n], T[n], gas.density()]
|
||||
+list(gas.moleFractions()))
|
||||
fcsv.close()
|
||||
|
||||
print 'solution saved to flame2.csv'
|
||||
|
||||
f.showStats()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
#
|
||||
# A freely-propagating premixed hydrogen/air flame
|
||||
#
|
||||
#
|
||||
from Cantera import *
|
||||
from Cantera.OneD import *
|
||||
from Cantera.OneD.FreeFlame import FreeFlame
|
||||
|
||||
################################################################
|
||||
#
|
||||
# parameter values
|
||||
#
|
||||
p = OneAtm # pressure
|
||||
tin = 300.0 # unburned gas temperature
|
||||
|
||||
rxnmech = 'ohn.cti' # reaction mechanism file
|
||||
mix = 'gas' # gas mixture model
|
||||
comp = 'H2:2, O2:1, N2:3.76' # premixed gas composition
|
||||
|
||||
# The solution domain is chosen to be 50 cm, and a point very near the
|
||||
# downstream boundary is added to help with the zero-gradient boundary
|
||||
# condition at this boundary.
|
||||
initial_grid = [0.0, 0.001, 0.02, 0.04, 0.07, 0.099, 0.1] # m
|
||||
|
||||
tol_ss = [1.0e-5, 1.0e-13] # [rtol atol] for steady-state
|
||||
# problem
|
||||
tol_ts = [1.0e-4, 1.0e-9] # [rtol atol] for time stepping
|
||||
|
||||
loglevel = 1 # amount of diagnostic output (0
|
||||
# to 5)
|
||||
|
||||
refine_grid = 1 # 1 to enable refinement, 0 to
|
||||
# disable
|
||||
|
||||
|
||||
################ create the gas object ########################
|
||||
#
|
||||
# This object will be used to evaluate all thermodynamic, kinetic,
|
||||
# and transport properties
|
||||
#
|
||||
gas = IdealGasMix(rxnmech, mix)
|
||||
|
||||
# set its state to that of the unburned gas at the burner
|
||||
gas.set(T = tin, P = p, X = comp)
|
||||
|
||||
f = FreeFlame(gas = gas, grid = initial_grid)
|
||||
|
||||
# set the properties at the inlet
|
||||
f.inlet.set(mole_fractions = comp, temperature = tin)
|
||||
|
||||
f.set(tol = tol_ss, tol_time = tol_ts)
|
||||
f.setMaxJacAge(5, 10)
|
||||
f.set(energy = 'off')
|
||||
#f.init()
|
||||
f.showSolution()
|
||||
|
||||
f.solve(loglevel, refine_grid)
|
||||
|
||||
f.setRefineCriteria(ratio = 5.0, slope = 0.05, curve = 0.005, prune = 0.0)
|
||||
f.set(energy = 'on')
|
||||
f.solve(loglevel,refine_grid)
|
||||
|
||||
f.save('freeflame1.xml')
|
||||
f.showSolution()
|
||||
|
||||
|
||||
# write the velocity, temperature, and mole fractions to a CSV file
|
||||
z = f.flame.grid()
|
||||
T = f.T()
|
||||
u = f.u()
|
||||
V = f.V()
|
||||
fcsv = open('freeflame1.csv','w')
|
||||
writeCSV(fcsv, ['z (m)', 'u (m/s)', 'V (1/s)', 'T (K)', 'rho (kg/m3)']
|
||||
+ list(gas.speciesNames()))
|
||||
for n in range(f.flame.nPoints()):
|
||||
f.setGasState(n)
|
||||
writeCSV(fcsv, [z[n], u[n], V[n], T[n], gas.density()]
|
||||
+list(gas.moleFractions()))
|
||||
fcsv.close()
|
||||
|
||||
print 'solution saved to freeflame1.csv'
|
||||
print 'flamespeed = ',u[0],'m/s'
|
||||
f.showStats()
|
||||
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
# NPFLAME1 - A nonpremixed counterflow flame.
|
||||
#
|
||||
# This script computes an atmospheric-pressure ethane/air
|
||||
# counterflow flame using GRI-Mech 3.0.
|
||||
# Run time on a Mac G4: ~ 5 minutes
|
||||
#
|
||||
from Cantera import *
|
||||
from Cantera.OneD import *
|
||||
from Cantera.OneD.CounterFlame import CounterFlame
|
||||
from Cantera.num import array
|
||||
|
||||
##################################################################
|
||||
# parameter values
|
||||
#
|
||||
# These are grouped here to simplify changing flame conditions
|
||||
|
||||
p = OneAtm # pressure
|
||||
tin_f = 300.0 # fuel inlet temperature
|
||||
tin_o = 300.0 # oxidizer inlet temperature
|
||||
mdot_o = 0.72 # kg/m^2/s
|
||||
mdot_f = 0.24 # kg/m^2/s
|
||||
|
||||
comp_o = 'O2:0.21, N2:0.78, AR:0.01'; # air composition
|
||||
comp_f = 'C2H6:1'; # fuel composition
|
||||
|
||||
# distance between inlets is 2 cm; start with an evenly-spaced 6-point
|
||||
# grid
|
||||
initial_grid = 0.02*array([0.0, 0.2, 0.4, 0.6, 0.8, 1.0],'d')
|
||||
|
||||
|
||||
tol_ss = [1.0e-5, 1.0e-9] # [rtol, atol] for steady-state
|
||||
# problem
|
||||
tol_ts = [1.0e-3, 1.0e-9] # [rtol, atol] for time stepping
|
||||
|
||||
loglevel = 1 # amount of diagnostic output (0
|
||||
# to 5)
|
||||
|
||||
refine_grid = 1 # 1 to enable refinement, 0 to
|
||||
# disable
|
||||
|
||||
|
||||
################ create the gas object ########################
|
||||
#
|
||||
# This object will be used to evaluate all thermodynamic, kinetic,
|
||||
# and transport properties
|
||||
#
|
||||
|
||||
# Here we use GRI-Mech 3.0 with mixture-averaged transport
|
||||
# properties. To use your own mechanism, use function
|
||||
# IdealGasMix('mech.cti') to read a mechanism in Cantera format. If
|
||||
# you need to convert from Chemkin format, use the ck2cti utility
|
||||
# program first.
|
||||
gas = GRI30('Mix')
|
||||
|
||||
# create an object representing the counterflow flame configuration,
|
||||
# which consists of a fuel inlet on the left, the flow in the middle,
|
||||
# and the oxidizer inlet on the right. Class CounterFlame creates this
|
||||
# configuration.
|
||||
|
||||
f = CounterFlame(gas = gas, grid = initial_grid)
|
||||
|
||||
# Set the state of the two inlets
|
||||
|
||||
f.fuel_inlet.set(massflux = mdot_f,
|
||||
mole_fractions = comp_f,
|
||||
temperature = tin_f)
|
||||
|
||||
f.oxidizer_inlet.set(massflux = mdot_o,
|
||||
mole_fractions = comp_o,
|
||||
temperature = tin_o)
|
||||
|
||||
# set the error tolerances
|
||||
f.set(tol = tol_ss, tol_time = tol_ts)
|
||||
|
||||
# construct the initial solution estimate. To do so, it is necessary
|
||||
# to specify the fuel species. If a fuel mixture is being used,
|
||||
# specify a representative species here for the purpose of
|
||||
# constructing an initial guess.
|
||||
f.init(fuel = 'C2H6')
|
||||
|
||||
# show the starting estimate
|
||||
f.showSolution()
|
||||
|
||||
# First disable the energy equation and solve the problem without
|
||||
# refining the grid
|
||||
f.set(energy = 'off')
|
||||
f.solve(loglevel, 0)
|
||||
|
||||
# Now specify grid refinement criteria, turn on the energy equation,
|
||||
# and solve the problem again. The ratio parameter controls the
|
||||
# maximum size ratio between adjacent cells; slope and curve should be
|
||||
# between 0 and 1 and control adding points in regions of high
|
||||
# gradients and high curvature, respectively. If prune > 0, points
|
||||
# will be removed if the relative slope and curvature for all
|
||||
# components fall below the prune level. Set prune < min(slope,
|
||||
# curve), or to zero to disable removing grid points.
|
||||
f.setRefineCriteria(ratio = 200.0, slope = 0.1, curve = 0.2, prune = 0.02)
|
||||
f.set(energy = 'on')
|
||||
f.solve(1)
|
||||
|
||||
# Save the solution
|
||||
f.save('npflame1.xml')
|
||||
|
||||
# write the velocity, temperature, and mole fractions to a CSV file
|
||||
z = f.flame.grid()
|
||||
T = f.T()
|
||||
u = f.u()
|
||||
V = f.V()
|
||||
fcsv = open('npflame1.csv','w')
|
||||
writeCSV(fcsv, ['z (m)', 'u (m/s)', 'V (1/s)', 'T (K)']
|
||||
+ list(gas.speciesNames()))
|
||||
for n in range(f.flame.nPoints()):
|
||||
f.setGasState(n)
|
||||
writeCSV(fcsv, [z[n], u[n], V[n], T[n]]+list(gas.moleFractions()))
|
||||
fcsv.close()
|
||||
|
||||
print 'solution saved to npflame1.csv'
|
||||
|
||||
f.showSolution()
|
||||
f.showStats()
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,117 +0,0 @@
|
|||
#
|
||||
# STFLAME1 - A detached flat flame stabilized at a stagnation point
|
||||
#
|
||||
|
||||
# This script simulates a lean hydrogen-oxygen flame stabilized in
|
||||
# a strained flowfield at an axisymmetric stagnation point on a
|
||||
# non-reacting surface. The solution begins with a flame attached
|
||||
# to the inlet (burner), and the mass flow rate is progressively
|
||||
# increased, causing the flame to detach and move closer to the
|
||||
# surface. This example illustrates use of the new 'prune' grid
|
||||
# refinement parameter, which allows grid points to be removed if
|
||||
# they are no longer required to resolve the solution. This is
|
||||
# important here, since the flamefront moves as the mass flowrate
|
||||
# is increased. Without using 'prune', a large number of grid
|
||||
# points would be concentrated upsteam of the flame, where the
|
||||
# flamefront had been previously. (To see this, try setting prune
|
||||
# to zero.)
|
||||
|
||||
from Cantera import *
|
||||
from Cantera.OneD import *
|
||||
from Cantera.OneD.StagnationFlow import StagnationFlow
|
||||
|
||||
################################################################
|
||||
#
|
||||
# parameter values
|
||||
#
|
||||
p = 0.05*OneAtm # pressure
|
||||
tburner = 373.0 # burner temperature
|
||||
tsurf = 600.0
|
||||
|
||||
# each mdot value will be solved to convergence, with grid refinement,
|
||||
# and then that solution will be used for the next mdot
|
||||
mdot = [0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12] # kg/m^2/s
|
||||
|
||||
rxnmech = 'h2o2.cti' # reaction mechanism file
|
||||
comp = 'H2:1.8, O2:1, AR:7' # premixed gas composition
|
||||
|
||||
# The solution domain is chosen to be 50 cm, and a point very near the
|
||||
# downstream boundary is added to help with the zero-gradient boundary
|
||||
# condition at this boundary.
|
||||
initial_grid = [0.0, 0.02, 0.04, 0.06, 0.08, 0.1,
|
||||
0.15, 0.2] # m
|
||||
|
||||
tol_ss = [1.0e-5, 1.0e-13] # [rtol atol] for steady-state
|
||||
# problem
|
||||
tol_ts = [1.0e-4, 1.0e-9] # [rtol atol] for time stepping
|
||||
|
||||
loglevel = 1 # amount of diagnostic output (0
|
||||
# to 5)
|
||||
|
||||
refine_grid = 1 # 1 to enable refinement, 0 to
|
||||
# disable
|
||||
ratio = 5.0
|
||||
slope = 0.1
|
||||
curve = 0.2
|
||||
prune = 0.05
|
||||
|
||||
|
||||
|
||||
################ create the gas object ########################
|
||||
#
|
||||
# This object will be used to evaluate all thermodynamic, kinetic,
|
||||
# and transport properties
|
||||
#
|
||||
gas = IdealGasMix(rxnmech)
|
||||
|
||||
# set its state to that of the unburned gas at the burner
|
||||
gas.setState_TPX(tburner, p, comp)
|
||||
|
||||
# Create the stagnation flow object with a non-reactive surface. (To
|
||||
# make the surface reactive, supply a surface reaction mechanism. see
|
||||
# example catcomb.py for how to do this.)
|
||||
f = StagnationFlow(gas = gas, grid = initial_grid)
|
||||
|
||||
# set the properties at the inlet
|
||||
f.inlet.set(massflux = mdot[0], mole_fractions = comp, temperature = tburner)
|
||||
|
||||
# set the surface state
|
||||
f.surface.setTemperature(tsurf)
|
||||
|
||||
f.set(tol = tol_ss, tol_time = tol_ts)
|
||||
f.setMaxJacAge(5, 10)
|
||||
f.set(energy = 'off')
|
||||
f.init(products = 'equil') # assume adiabatic equilibrium products
|
||||
f.showSolution()
|
||||
|
||||
f.solve(loglevel, refine_grid)
|
||||
|
||||
f.setRefineCriteria(ratio = ratio, slope = slope,
|
||||
curve = curve, prune = prune)
|
||||
f.set(energy = 'on')
|
||||
|
||||
m = 0
|
||||
for md in mdot:
|
||||
f.inlet.set(mdot = md)
|
||||
f.solve(loglevel,refine_grid)
|
||||
m = m + 1
|
||||
f.save('stflame1.xml','mdot'+`m`,'mdot = '+`md`+' kg/m2/s')
|
||||
|
||||
|
||||
# write the velocity, temperature, and mole fractions to a CSV file
|
||||
z = f.flow.grid()
|
||||
T = f.T()
|
||||
u = f.u()
|
||||
V = f.V()
|
||||
fcsv = open('stflame1_'+`m`+'.csv','w')
|
||||
writeCSV(fcsv, ['z (m)', 'u (m/s)', 'V (1/s)', 'T (K)']
|
||||
+ list(gas.speciesNames()))
|
||||
for n in range(f.flow.nPoints()):
|
||||
f.setGasState(n)
|
||||
writeCSV(fcsv, [z[n], u[n], V[n], T[n]]+list(gas.moleFractions()))
|
||||
fcsv.close()
|
||||
|
||||
print 'solution saved to flame1.csv'
|
||||
|
||||
f.showStats()
|
||||
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
#
|
||||
# This data file lists temperature vs. height values for a burner-stabilized flame.
|
||||
# This file is used by example 'fixed_T_flame.py'.
|
||||
#
|
||||
0, 373.7
|
||||
0.00015625, 465.4070428
|
||||
0.000234375, 510.4311676
|
||||
0.000390625, 599.5552837
|
||||
0.00046875, 643.8342938
|
||||
0.000507813, 665.9335545
|
||||
0.000546875, 688.0122338
|
||||
0.000625, 732.1284327
|
||||
0.000664062, 754.1744755
|
||||
0.000703125, 776.2170662
|
||||
0.000742188, 798.2588757
|
||||
0.00078125, 820.3020011
|
||||
0.000820313, 842.348001
|
||||
0.000859375, 864.3979228
|
||||
0.000898437, 886.4523159
|
||||
0.0009375, 908.5112198
|
||||
0.001015625, 952.6396629
|
||||
0.001054688, 974.7018199
|
||||
0.00109375, 996.7515831
|
||||
0.001132813, 1018.777651
|
||||
0.001171875, 1040.765863
|
||||
0.001210938, 1062.69948
|
||||
0.00125, 1084.558639
|
||||
0.001289062, 1106.320078
|
||||
0.001328125, 1127.956918
|
||||
0.001367187, 1149.438472
|
||||
0.00140625, 1170.730129
|
||||
0.001445313, 1191.793309
|
||||
0.001484375, 1212.585506
|
||||
0.001523438, 1233.060477
|
||||
0.0015625, 1253.168589
|
||||
0.001601563, 1272.857384
|
||||
0.001640625, 1292.072391
|
||||
0.00171875, 1328.859767
|
||||
0.001757812, 1346.323998
|
||||
0.001796875, 1363.101361
|
||||
0.001835937, 1379.147594
|
||||
0.001875, 1394.425274
|
||||
0.001914063, 1408.905834
|
||||
0.001953125, 1422.569115
|
||||
0.001992188, 1435.40408
|
||||
0.00203125, 1447.410648
|
||||
0.002070313, 1458.597668
|
||||
0.002109375, 1468.982722
|
||||
0.002148438, 1478.590978
|
||||
0.0021875, 1487.453914
|
||||
0.002226563, 1495.607879
|
||||
0.002265625, 1503.092709
|
||||
0.002304688, 1509.950449
|
||||
0.00234375, 1516.224147
|
||||
0.002382813, 1521.956853
|
||||
0.002421875, 1527.19079
|
||||
0.002460938, 1531.966722
|
||||
0.0025, 1536.32348
|
||||
0.002578125, 1543.891739
|
||||
0.00265625, 1550.203579
|
||||
0.002734375, 1555.480771
|
||||
0.0028125, 1559.908135
|
||||
0.002890625, 1563.637879
|
||||
0.00296875, 1566.794144
|
||||
0.003046875, 1569.477867
|
||||
0.003125, 1571.77099
|
||||
0.00328125, 1575.385829
|
||||
0.0034375, 1578.108169
|
||||
0.00359375, 1580.194856
|
||||
0.00375, 1581.820666
|
||||
0.00390625, 1583.106578
|
||||
0.0087, 1589.51315
|
||||
0.01, 1589.578955
|
||||
|
||||
Loading…
Add table
Reference in a new issue