First commit of demo dir.
This commit is contained in:
parent
8e356eccdd
commit
8b9a0b743e
7 changed files with 4705 additions and 0 deletions
11
Cantera/python/examples/reactors/combustor_sim/.cvsignore
Normal file
11
Cantera/python/examples/reactors/combustor_sim/.cvsignore
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Makefile
|
||||
air.xml
|
||||
combustor.csv
|
||||
ct2ctml.log
|
||||
diff_csv.txt
|
||||
diff_out_0.txt
|
||||
gri30.xml
|
||||
output_0.txt
|
||||
ptcombust.xml
|
||||
runtest
|
||||
transport_log.xml
|
||||
15
Cantera/python/examples/reactors/combustor_sim/Makefile.in
Normal file
15
Cantera/python/examples/reactors/combustor_sim/Makefile.in
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
|
||||
PYTHON_CMD = @PYTHON_CMD@
|
||||
|
||||
run:
|
||||
$(PYTHON_CMD) combustor.py
|
||||
|
||||
test:
|
||||
./runtest
|
||||
clean:
|
||||
rm -f *.log *.csv *.xml
|
||||
./cleanup
|
||||
|
||||
# end of file
|
||||
|
||||
5
Cantera/python/examples/reactors/combustor_sim/cleanup
Executable file
5
Cantera/python/examples/reactors/combustor_sim/cleanup
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
/bin/rm -rf equilibrate_log*.html
|
||||
/bin/rm -rf .cttmp* ct2ctml.log transport_log.xml vcs_equilibrate_res*.csv \
|
||||
combustor.csv output_0.txt diff*
|
||||
83
Cantera/python/examples/reactors/combustor_sim/combustor.py
Normal file
83
Cantera/python/examples/reactors/combustor_sim/combustor.py
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
""" 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()
|
||||
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,6 @@
|
|||
Adding reactor (none)
|
||||
Initializing reactor network.
|
||||
Reactor 0: 55 variables.
|
||||
0 sensitivity params.
|
||||
Number of equations: 55
|
||||
Maximum time step: 6
|
||||
64
Cantera/python/examples/reactors/combustor_sim/runtest.in
Executable file
64
Cantera/python/examples/reactors/combustor_sim/runtest.in
Executable file
|
|
@ -0,0 +1,64 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
#
|
||||
temp_success="1"
|
||||
/bin/rm -f output_0.txt combustor.csv diff_csv.txt diff_out_0.txt
|
||||
|
||||
##########################################################################
|
||||
PYTHON_CMD=@PYTHON_CMD@
|
||||
prog=combustor.py
|
||||
if test ! -f $prog ; then
|
||||
echo $prog ' does not exist'
|
||||
exit -1
|
||||
fi
|
||||
#################################################################
|
||||
#
|
||||
CANTERA_DATA=${CANTERA_DATA:=../../../data/inputs}; export CANTERA_DATA
|
||||
CANTERA_BIN=${CANTERA_BIN:=../../../bin}
|
||||
|
||||
#################################################################
|
||||
|
||||
$PYTHON_CMD $prog > output_0.txt <<+
|
||||
1.0
|
||||
+
|
||||
retnStat=$?
|
||||
if [ $retnStat != "0" ]
|
||||
then
|
||||
temp_success="0"
|
||||
echo "$prog returned with bad status, $retnStat, check output"
|
||||
fi
|
||||
|
||||
diff -w output_blessed_0.txt output_0.txt > diff_out_0.txt
|
||||
retnStat_0=$?
|
||||
|
||||
csvdiff -a 1.0E-50 combustor_blessed_0.csv combustor.csv > diff_csv.txt
|
||||
retnStat_csv_0=$?
|
||||
|
||||
retnTotal=1
|
||||
if test $retnStat_0 = "0"
|
||||
then
|
||||
retnTotal=0
|
||||
fi
|
||||
|
||||
retnCSVTotal=1
|
||||
if test $retnStat_csv_0 = "1"
|
||||
then
|
||||
retnCSVTotal=0
|
||||
fi
|
||||
|
||||
if test $retnCSVTotal = "0"
|
||||
then
|
||||
echo "Successful test comparison on "`pwd`
|
||||
if test $retnTotal = "1"
|
||||
then
|
||||
echo " But text files show differences. See diff_out_0.txt"
|
||||
fi
|
||||
else
|
||||
echo "Unsuccessful test comparison of csv files on "`pwd` " test"
|
||||
echo " see diff_csv.txt "
|
||||
if test $retnTotal != "0"
|
||||
then
|
||||
echo " ASCII files are different too - see diff_test*.txt"
|
||||
fi
|
||||
fi
|
||||
|
||||
Loading…
Add table
Reference in a new issue