From d1fc24fa8e5ca081727ec0637cef9bca28498a07 Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Sat, 25 Jun 2005 13:16:06 +0000 Subject: [PATCH] reorganized --- Cantera/python/examples/flame1.py | 88 ------------- Cantera/python/examples/flame2.py | 97 --------------- .../python/examples/{ => flames}/npflame1.py | 0 Cantera/python/examples/flames/ohn.cti | 14 --- .../examples/{ => gasdynamics}/isentropic.py | 2 +- .../{ => liquid_vapor}/critProperties.py | 0 .../examples/{ => liquid_vapor}/rankine.py | 0 .../python/examples/{ => misc}/rxnpath1.py | 0 .../examples/{ => reactors}/function1.py | 2 +- .../python/examples/{ => reactors}/mix1.py | 0 .../python/examples/{ => reactors}/mix2.py | 0 .../examples/{ => reactors}/reactor1.py | 0 .../examples/{ => reactors}/reactor2.py | 0 Cantera/python/examples/rxnpath2.py | 67 ---------- Cantera/python/examples/stflame1.py | 117 ------------------ .../{ => surface_chemistry}/catcomb.py | 0 .../{ => surface_chemistry}/diamond.py | 0 .../examples/{ => transport}/dustygas.py | 0 18 files changed, 2 insertions(+), 385 deletions(-) delete mode 100755 Cantera/python/examples/flame1.py delete mode 100755 Cantera/python/examples/flame2.py rename Cantera/python/examples/{ => flames}/npflame1.py (100%) delete mode 100644 Cantera/python/examples/flames/ohn.cti rename Cantera/python/examples/{ => gasdynamics}/isentropic.py (98%) rename Cantera/python/examples/{ => liquid_vapor}/critProperties.py (100%) rename Cantera/python/examples/{ => liquid_vapor}/rankine.py (100%) rename Cantera/python/examples/{ => misc}/rxnpath1.py (100%) rename Cantera/python/examples/{ => reactors}/function1.py (99%) rename Cantera/python/examples/{ => reactors}/mix1.py (100%) rename Cantera/python/examples/{ => reactors}/mix2.py (100%) rename Cantera/python/examples/{ => reactors}/reactor1.py (100%) rename Cantera/python/examples/{ => reactors}/reactor2.py (100%) delete mode 100755 Cantera/python/examples/rxnpath2.py delete mode 100644 Cantera/python/examples/stflame1.py rename Cantera/python/examples/{ => surface_chemistry}/catcomb.py (100%) rename Cantera/python/examples/{ => surface_chemistry}/diamond.py (100%) rename Cantera/python/examples/{ => transport}/dustygas.py (100%) diff --git a/Cantera/python/examples/flame1.py b/Cantera/python/examples/flame1.py deleted file mode 100755 index 084ab061b..000000000 --- a/Cantera/python/examples/flame1.py +++ /dev/null @@ -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() - diff --git a/Cantera/python/examples/flame2.py b/Cantera/python/examples/flame2.py deleted file mode 100755 index a3bf9ebf1..000000000 --- a/Cantera/python/examples/flame2.py +++ /dev/null @@ -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() - - - - - diff --git a/Cantera/python/examples/npflame1.py b/Cantera/python/examples/flames/npflame1.py similarity index 100% rename from Cantera/python/examples/npflame1.py rename to Cantera/python/examples/flames/npflame1.py diff --git a/Cantera/python/examples/flames/ohn.cti b/Cantera/python/examples/flames/ohn.cti deleted file mode 100644 index ace7666b9..000000000 --- a/Cantera/python/examples/flames/ohn.cti +++ /dev/null @@ -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') - ) - diff --git a/Cantera/python/examples/isentropic.py b/Cantera/python/examples/gasdynamics/isentropic.py similarity index 98% rename from Cantera/python/examples/isentropic.py rename to Cantera/python/examples/gasdynamics/isentropic.py index 18aa4da58..6ae9b6722 100755 --- a/Cantera/python/examples/isentropic.py +++ b/Cantera/python/examples/gasdynamics/isentropic.py @@ -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') diff --git a/Cantera/python/examples/critProperties.py b/Cantera/python/examples/liquid_vapor/critProperties.py similarity index 100% rename from Cantera/python/examples/critProperties.py rename to Cantera/python/examples/liquid_vapor/critProperties.py diff --git a/Cantera/python/examples/rankine.py b/Cantera/python/examples/liquid_vapor/rankine.py similarity index 100% rename from Cantera/python/examples/rankine.py rename to Cantera/python/examples/liquid_vapor/rankine.py diff --git a/Cantera/python/examples/rxnpath1.py b/Cantera/python/examples/misc/rxnpath1.py similarity index 100% rename from Cantera/python/examples/rxnpath1.py rename to Cantera/python/examples/misc/rxnpath1.py diff --git a/Cantera/python/examples/function1.py b/Cantera/python/examples/reactors/function1.py similarity index 99% rename from Cantera/python/examples/function1.py rename to Cantera/python/examples/reactors/function1.py index f999e261b..c3c08f3a4 100644 --- a/Cantera/python/examples/function1.py +++ b/Cantera/python/examples/reactors/function1.py @@ -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 * diff --git a/Cantera/python/examples/mix1.py b/Cantera/python/examples/reactors/mix1.py similarity index 100% rename from Cantera/python/examples/mix1.py rename to Cantera/python/examples/reactors/mix1.py diff --git a/Cantera/python/examples/mix2.py b/Cantera/python/examples/reactors/mix2.py similarity index 100% rename from Cantera/python/examples/mix2.py rename to Cantera/python/examples/reactors/mix2.py diff --git a/Cantera/python/examples/reactor1.py b/Cantera/python/examples/reactors/reactor1.py similarity index 100% rename from Cantera/python/examples/reactor1.py rename to Cantera/python/examples/reactors/reactor1.py diff --git a/Cantera/python/examples/reactor2.py b/Cantera/python/examples/reactors/reactor2.py similarity index 100% rename from Cantera/python/examples/reactor2.py rename to Cantera/python/examples/reactors/reactor2.py diff --git a/Cantera/python/examples/rxnpath2.py b/Cantera/python/examples/rxnpath2.py deleted file mode 100755 index ae5132b8f..000000000 --- a/Cantera/python/examples/rxnpath2.py +++ /dev/null @@ -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) - - diff --git a/Cantera/python/examples/stflame1.py b/Cantera/python/examples/stflame1.py deleted file mode 100644 index 88bd4fee2..000000000 --- a/Cantera/python/examples/stflame1.py +++ /dev/null @@ -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() - diff --git a/Cantera/python/examples/catcomb.py b/Cantera/python/examples/surface_chemistry/catcomb.py similarity index 100% rename from Cantera/python/examples/catcomb.py rename to Cantera/python/examples/surface_chemistry/catcomb.py diff --git a/Cantera/python/examples/diamond.py b/Cantera/python/examples/surface_chemistry/diamond.py similarity index 100% rename from Cantera/python/examples/diamond.py rename to Cantera/python/examples/surface_chemistry/diamond.py diff --git a/Cantera/python/examples/dustygas.py b/Cantera/python/examples/transport/dustygas.py similarity index 100% rename from Cantera/python/examples/dustygas.py rename to Cantera/python/examples/transport/dustygas.py