mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
reorganized
This commit is contained in:
@@ -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,97 +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')
|
||||
|
||||
# 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,14 +0,0 @@
|
||||
#
|
||||
# This definition extracts the O/H/N submechanism from GRI-Mech 3.0
|
||||
|
||||
ideal_gas(name = "gas",
|
||||
elements = "O H N",
|
||||
species = """gri30: all""",
|
||||
transport = 'Mix',
|
||||
reactions = 'gri30: all',
|
||||
options = ['skip_undeclared_elements',
|
||||
'skip_undeclared_species'],
|
||||
initial_state = state(temperature = 300.0, pressure = OneAtm,
|
||||
mole_fractions = 'H2:2, O2:1, N2:3.76')
|
||||
)
|
||||
|
||||
@@ -71,7 +71,7 @@ if __name__ == "__main__":
|
||||
print isentropic.__doc__
|
||||
data = isentropic()
|
||||
try:
|
||||
from matplotlib.matlab import *
|
||||
from pylab import *
|
||||
clf
|
||||
plot(data[:,1], data[:,0])
|
||||
ylabel('Area Ratio')
|
||||
@@ -1,5 +1,5 @@
|
||||
# This example shows how to create 'functors' - objects that evaluate
|
||||
# functions. These are useful for specifying the expansion rate of
|
||||
# functions. These are useful for specifying the expansion rate or
|
||||
# heat flux at a wall.
|
||||
|
||||
from Cantera.Func import *
|
||||
@@ -1,67 +0,0 @@
|
||||
"""
|
||||
|
||||
Viewing a reaction path diagram in a web browser.
|
||||
|
||||
This script uses the public webdot server at webdot.graphviz.org to
|
||||
perform the rendering of the graph. You don't need to get the 'dot'
|
||||
program to use this script, but you do need to be able to put your
|
||||
output file where it can be served by your web server. You can either
|
||||
run a local server, or mount the remote directory where your web files
|
||||
are located. You could also modify this script to write the file
|
||||
locally, and then upload it to your web server.
|
||||
|
||||
"""
|
||||
|
||||
from os.path import join
|
||||
from Cantera import *
|
||||
from Cantera import rxnpath
|
||||
import os
|
||||
|
||||
#------------ site-specific configuration -----------------------------
|
||||
|
||||
# Set 'output_dir' to a directory that is within the document tree of
|
||||
# your web server, and set output_url to the URL that accesses this
|
||||
# directory.
|
||||
|
||||
# output_dir = /var/www/html # linux/apache default
|
||||
|
||||
output_dir = 'c:/cygwin/var/www/htdocs'
|
||||
output_urldir = 'http://blue.caltech.edu'
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# these lines can be replaced by any commands that generate
|
||||
# an object of a class derived from class Kinetics (such as IdealGasMix)
|
||||
# in some state.
|
||||
gas = GRI30()
|
||||
gas.setState_TPX(2500.0, OneAtm, 'CH4:2, O2:1, N2:3.76')
|
||||
gas.equilibrate('TP')
|
||||
x = gas.moleFractions()
|
||||
gas.setMassFractions(x)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
# To control diagram attributes, create an instance of
|
||||
# class rxnpath.PathDiagram and set the properties as desired.
|
||||
# Then pass it as the last argument to rxnpath.write
|
||||
|
||||
d = rxnpath.PathDiagram(title = 'reaction path diagram following N',
|
||||
bold_color = 'orange',
|
||||
threshold = 0.001)
|
||||
|
||||
# element to follow
|
||||
element = 'N'
|
||||
|
||||
output_file = 'rxnpath2.dot'
|
||||
url = output_urldir+'/'+output_file
|
||||
|
||||
# graphics format. Must be one of png, svg, gif, or jpg
|
||||
fmt = 'svg'
|
||||
|
||||
print 'writing dot file',output_file+'...'
|
||||
#rxnpath.write(gas, element, join(output_dir, output_file), d)
|
||||
rxnpath.write(gas, element, output_file, d)
|
||||
#os.system('scp '+output_file+' blue:/var/www/html')
|
||||
#print 'generating browser view...'
|
||||
#rxnpath.view(url, fmt)
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user