added fixed T flame example
This commit is contained in:
parent
351c9b8dac
commit
141dff9da5
2 changed files with 221 additions and 0 deletions
147
Cantera/python/examples/flames/fixed_T_flame.py
Normal file
147
Cantera/python/examples/flames/fixed_T_flame.py
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
#
|
||||
# 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.csv')
|
||||
|
||||
# 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')
|
||||
|
||||
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()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
74
Cantera/python/examples/flames/tdata.csv
Normal file
74
Cantera/python/examples/flames/tdata.csv
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
#
|
||||
# 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