From 11c9d9fd4874b33ba4db05bd7c7f4389dfdbb5f7 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Tue, 24 Mar 2009 14:02:49 +0000 Subject: [PATCH] Incremental update to add dirs --- Cantera/python/examples/reactors/Makefile.in | 23 ++++- Cantera/python/examples/reactors/combustor.py | 83 ------------------- .../reactors/combustor_sim/Makefile.in | 3 + Cantera/python/examples/reactors/function1.py | 19 ----- .../reactors/functors_sim/Makefile.in | 2 + 5 files changed, 24 insertions(+), 106 deletions(-) delete mode 100644 Cantera/python/examples/reactors/combustor.py delete mode 100644 Cantera/python/examples/reactors/function1.py diff --git a/Cantera/python/examples/reactors/Makefile.in b/Cantera/python/examples/reactors/Makefile.in index 016295c6e..095a8e11d 100644 --- a/Cantera/python/examples/reactors/Makefile.in +++ b/Cantera/python/examples/reactors/Makefile.in @@ -1,16 +1,31 @@ #!/bin/sh -PY_DEMOS = combustor.py function1.py mix1.py mix2.py piston.py reactor1.py \ - reactor2.py sensitivity1.py -PYTHON_CMD = @PYTHON_CMD@ +PY_DEMOS = combustor_sim functors_sim mix1_sim mix2_sim piston_sim reactor1_sim \ + reactor2_sim sensitivity_sim surf_prf_sim + +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 "testing $${py}..."; \ + (cd "$${py}"; @MAKE@ test ) ; \ done) clean: + @(for py in $(PY_DEMOS) ; do \ + echo "testing $${py}..."; \ + (cd "$${py}"; @MAKE@ clean ) ; \ + done) rm -f *.log *.csv *.xml # end of file diff --git a/Cantera/python/examples/reactors/combustor.py b/Cantera/python/examples/reactors/combustor.py deleted file mode 100644 index 752aaac1c..000000000 --- a/Cantera/python/examples/reactors/combustor.py +++ /dev/null @@ -1,83 +0,0 @@ -""" A combustor. Two separate stream - one pure methane and the other - air, both at 300 K and 1 atm flow into an adiabatic combustor where - they mix. We are interested in the steady-state burning - solution. Since at 300 K no reaction will occur between methane and - air, we need to use an 'igniter' to initiate the chemistry. A simple - igniter is a pulsed flow of atomic hydrogen. After the igniter is - turned off, the system approaches the steady burning solution.""" - -from Cantera import * -from Cantera.Reactor import * -from Cantera.Func import * - -# use reaction mechanism GRI-Mech 3.0 -gas = GRI30() - -# create a reservoir for the fuel inlet, and set to pure methane. -gas.set(T = 300.0, P = OneAtm, X = 'CH4:1.0') -fuel_in = Reservoir(gas) -fuel_mw = gas.meanMolarMass() - -# use predefined function Air() for the air inlet -air = Air() -air_in = Reservoir(air) -air_mw = air.meanMolarMass() - -# to ignite the fuel/air mixture, we'll introduce a pulse of radicals. -# The steady-state behavior is independent of how we do this, so we'll -# just use a stream of pure atomic hydrogen. -gas.set(T = 300.0, P = OneAtm, X = 'H:1.0') -igniter = Reservoir(gas) - - -# create the combustor, and fill it in initially with N2 -gas.set(T = 300.0, P = OneAtm, X = 'N2:1.0') -combustor = Reactor(contents = gas, volume = 1.0) - -# create a reservoir for the exhaust -exhaust = Reservoir(gas) - -# lean combustion, phi = 0.5 -equiv_ratio = 0.5 - -# compute fuel and air mass flow rates -factor = 0.1 -air_mdot = factor*9.52*air_mw -fuel_mdot = factor*equiv_ratio*fuel_mw - -# create and install the mass flow controllers. Controllers -# m1 and m2 provide constant mass flow rates, and m3 provides -# a short Gaussian pulse only to ignite the mixture -m1 = MassFlowController(upstream = fuel_in, - downstream = combustor, mdot = fuel_mdot) - -# note that this connects two reactors with different reaction -# mechanisms and different numbers of species. Downstream and upstream -# species are matched by name. -m2 = MassFlowController(upstream = air_in, - downstream = combustor, mdot = air_mdot) - -# The igniter will use a Guassiam 'functor' object to specify the -# time-dependent igniter mass flow rate. -igniter_mdot = Gaussian(t0 = 1.0, FWHM = 0.2, A = 0.1) -m3 = MassFlowController(upstream = igniter, - downstream = combustor, mdot = igniter_mdot) - -# put a valve on the exhaust line to regulate the pressure -v = Valve(upstream = combustor, downstream = exhaust, Kv = 1.0) - -# the simulation only contains one reactor -sim = ReactorNet([combustor]) - -# take single steps to 6 s, writing the results to a CSV file -# for later plotting. -tfinal = 6.0 -tnow = 0.0 -f = open('combustor.csv','w') -while tnow < tfinal: - tnow = sim.step(tfinal) - tres = combustor.mass()/v.massFlowRate() - writeCSV(f, [tnow, combustor.temperature(), tres] - +list(combustor.moleFractions())) -f.close() - diff --git a/Cantera/python/examples/reactors/combustor_sim/Makefile.in b/Cantera/python/examples/reactors/combustor_sim/Makefile.in index d0576b682..bcabcd285 100644 --- a/Cantera/python/examples/reactors/combustor_sim/Makefile.in +++ b/Cantera/python/examples/reactors/combustor_sim/Makefile.in @@ -2,11 +2,14 @@ PYTHON_CMD = @PYTHON_CMD@ +all: + run: $(PYTHON_CMD) combustor.py test: ./runtest + clean: rm -f *.log *.csv *.xml ./cleanup diff --git a/Cantera/python/examples/reactors/function1.py b/Cantera/python/examples/reactors/function1.py deleted file mode 100644 index c3c08f3a4..000000000 --- a/Cantera/python/examples/reactors/function1.py +++ /dev/null @@ -1,19 +0,0 @@ -# This example shows how to create 'functors' - objects that evaluate -# functions. These are useful for specifying the expansion rate or -# heat flux at a wall. - -from Cantera.Func import * - -# create f1(t) = 4 + 6t + 8t^2 + t^3 -f1 = Polynomial([4.0, 6.0, 8.0, 1.0]) - -# create sin(t) -f2 = Fourier(1.0, [(0.0, 0.0), (0.0, 1.0)]) - -# functors can be combined by +,*,or / to create new functors -f3 = f2*f2 - -xpts = 0.1*array(range(100)) - -for x in xpts: - print x, f1(x), f2(x), f3(x) diff --git a/Cantera/python/examples/reactors/functors_sim/Makefile.in b/Cantera/python/examples/reactors/functors_sim/Makefile.in index d464af79a..d538d070a 100644 --- a/Cantera/python/examples/reactors/functors_sim/Makefile.in +++ b/Cantera/python/examples/reactors/functors_sim/Makefile.in @@ -2,6 +2,8 @@ PYTHON_CMD = @PYTHON_CMD@ +all: + run: $(PYTHON_CMD) functors.py