Added an example dir

This commit is contained in:
Harry Moffat 2009-03-24 14:57:15 +00:00
parent 870801a077
commit ca49dd8a11
6 changed files with 213 additions and 0 deletions

View file

@ -0,0 +1,9 @@
Makefile
air.xml
ct2ctml.log
diff_out_0.txt
gri30.xml
h2o2.xml
output_0.txt
runtest
transport_log.xml

View file

@ -0,0 +1,15 @@
#!/bin/sh
PYTHON_CMD = @PYTHON_CMD@
run:
$(PYTHON_CMD) piston.py
test:
./runtest
clean:
rm -f *.log *.csv *.xml
./cleanup
# end of file

View 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 \
catcomb.csv output_0.txt diff*

View file

@ -0,0 +1,41 @@
time [s] T1 [K] T2 [K] V1 [m^3] V2 [m^3] V1+V2 [m^3] X(CO)
Adding reactor (none)
Adding reactor (none)
Initializing reactor network.
Reactor 0: 11 variables.
0 sensitivity params.
Reactor 1: 55 variables.
0 sensitivity params.
Number of equations: 66
Maximum time step: 0.002
0.002 900.0 900.0006 0.5 0.1 0.6 0.2853
0.004 900.0 900.0017 0.5 0.1 0.6 0.2853
0.006 900.0 900.0108 0.5 0.1 0.6 0.2853
0.008 2094.0 1073.0930 0.5423 0.0577 0.6 0.2853
0.010 2232.8 1087.5290 0.5447 0.05533 0.6 0.2853
0.012 2245.4 1089.1486 0.5449 0.05514 0.6 0.2853
0.014 2248.6 1090.1367 0.5449 0.05512 0.6 0.2852
0.016 2249.7 1091.4076 0.5448 0.05515 0.6 0.2851
0.018 2250.1 1093.3914 0.5448 0.05523 0.6 0.2849
0.020 2250.4 1096.5044 0.5446 0.05536 0.6 0.2845
0.022 2250.8 1101.2707 0.5445 0.05555 0.6 0.284
0.024 2251.4 1108.4685 0.5442 0.05584 0.6 0.2833
0.026 2252.3 1119.5415 0.5437 0.0563 0.6 0.2822
0.028 2253.7 1138.1910 0.5429 0.05705 0.6 0.2802
0.030 2257.3 1183.3728 0.5411 0.05886 0.6 0.2755
0.032 2358.9 2820.1201 0.4913 0.1087 0.6 0.03655
0.034 2351.1 2819.4430 0.4911 0.1089 0.6 0.0365
0.036 2350.5 2819.3900 0.491 0.109 0.6 0.03649
0.038 2350.4 2819.3862 0.491 0.109 0.6 0.03649
0.040 2350.4 2819.3859 0.491 0.109 0.6 0.03649
0.042 2350.4 2819.3859 0.491 0.109 0.6 0.03649
0.044 2350.4 2819.3859 0.491 0.109 0.6 0.03649
0.046 2350.4 2819.3859 0.491 0.109 0.6 0.03649
0.048 2350.4 2819.3859 0.491 0.109 0.6 0.03649
0.050 2350.4 2819.3859 0.491 0.109 0.6 0.03649
0.052 2350.4 2819.3859 0.491 0.109 0.6 0.03649
0.054 2350.4 2819.3859 0.491 0.109 0.6 0.03649
0.056 2350.4 2819.3859 0.491 0.109 0.6 0.03649
0.058 2350.4 2819.3859 0.491 0.109 0.6 0.03649
0.060 2350.4 2819.3859 0.491 0.109 0.6 0.03649
To view a plot of these results, run this script with the option -plot

View file

@ -0,0 +1,99 @@
"""
Gas 1: a stoichiometric H2/O2/Ar mixture
Gas 2: a wet CO/O2 mixture
-------------------------------------
| || |
| || |
| gas 1 || gas 2 |
| || |
| || |
-------------------------------------
The two volumes are connected by an adiabatic free piston.
The piston speed is proportional to the pressure difference
between the two chambers.
Note that each side uses a *different* reaction mechanism
"""
from Cantera import *
from Cantera.Reactor import *
import sys
fmt = '%10.3f %10.1f %10.4f %10.4g %10.4g %10.4g %10.4g'
print '%10s %10s %10s %10s %10s %10s %10s' % ('time [s]','T1 [K]','T2 [K]',
'V1 [m^3]', 'V2 [m^3]',
'V1+V2 [m^3]','X(CO)')
gas1 = importPhase('h2o2.cti')
gas1.set(T = 900.0, P = OneAtm, X = 'H2:2, O2:1, AR:20')
gas2 = GRI30()
gas2.set(T = 900.0, P = OneAtm, X = 'CO:2, H2O:0.01, O2:5')
r1 = Reactor(gas1, volume = 0.5)
r2 = Reactor(gas2, volume = 0.1)
w = Wall(left = r1, right = r2, K = 1.0e3)
reactors = ReactorNet([r1, r2])
tim = []
t1 = []
t2 = []
v1 = []
v2 = []
v = []
xco = []
xh2 = []
for n in range(30):
time = (n+1)*0.002
reactors.advance(time)
print fmt % (time, r1.temperature(), r2.temperature(),
r1.volume(), r2.volume(), r1.volume() + r2.volume(),
r2.moleFraction('CO'))
tim.append(time)
t1.append(r1.temperature())
t2.append(r2.temperature())
v1.append(r1.volume())
v2.append(r2.volume())
v.append(r1.volume() + r2.volume())
xco.append(r2.moleFraction('CO'))
xh2.append(r1.moleFraction('H2'))
# plot the results if matplotlib is installed.
# see http://matplotlib.sourceforge.net to get it
args = sys.argv
if len(args) > 1 and (args[1] == '-plot' or
args[1] == '-p' or
args[1] == '--plot'):
try:
from matplotlib.pylab import *
clf
subplot(2,2,1)
plot(tim,t1,'-',tim,t2,'r-')
xlabel('Time (s)');
ylabel('Temperature (K)');
subplot(2,2,2)
plot(tim,v1,'-',tim,v2,'r-',tim,v,'g-')
xlabel('Time (s)');
ylabel('Volume (m3)');
subplot(2,2,3)
plot(tim,xco);
xlabel('Time (s)');
ylabel('CO Mole Fraction (right)');
subplot(2,2,4)
plot(tim,xh2);
xlabel('Time (s)');
ylabel('H2 Mole Fraction (left)');
show()
except:
print """matplotlib required.
http://matplotlib.sourceforge.net"""
else:
print """To view a plot of these results, run this script with the option -plot"""

View file

@ -0,0 +1,44 @@
#!/bin/sh
#
#
temp_success="1"
/bin/rm -f output_0.txt diff_csv.txt diff_out_0.txt
##########################################################################
PYTHON_CMD=@PYTHON_CMD@
prog=piston.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
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=$?
retnTotal=1
if test $retnStat_0 = "0"
then
retnTotal=0
fi
if test $retnTotal = "0"
then
echo "Successful test comparison on "`pwd`
else
echo "Unsuccessful test comparison of csv files on "`pwd` " test"
fi