Added tut1 python tutorial to test suite
This commit is contained in:
parent
46e80acd92
commit
977d25da92
6 changed files with 744 additions and 0 deletions
|
|
@ -3,10 +3,12 @@
|
|||
# test target -> make the program and run the test
|
||||
test:
|
||||
./runtest @PYTHON_CMD@
|
||||
@cd tut1; ./runtest @PYTHON_CMD@
|
||||
|
||||
# clean target -> clean up
|
||||
clean:
|
||||
../../bin/rm_cvsignore
|
||||
cd tut1; ./cleanup
|
||||
|
||||
depends:
|
||||
|
||||
|
|
|
|||
5
test_problems/python/tut1/.cvsignore
Normal file
5
test_problems/python/tut1/.cvsignore
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
csvCode.txt
|
||||
ct2ctml.log
|
||||
diff_test.out
|
||||
gri30.xml
|
||||
output.txt
|
||||
2
test_problems/python/tut1/cleanup
Executable file
2
test_problems/python/tut1/cleanup
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
/bin/rm -f csvCode.txt ct2ctml.log diff_test.out output.txt gri30.xml
|
||||
365
test_problems/python/tut1/output_blessed.txt
Normal file
365
test_problems/python/tut1/output_blessed.txt
Normal file
|
|
@ -0,0 +1,365 @@
|
|||
|
||||
|
||||
Tutorial 1: Getting started
|
||||
|
||||
|
||||
|
||||
gri30:
|
||||
|
||||
temperature 300 K
|
||||
pressure 101325 Pa
|
||||
density 0.081889 kg/m^3
|
||||
mean mol. weight 2.01588 amu
|
||||
|
||||
1 kg 1 kmol
|
||||
----------- ------------
|
||||
enthalpy 26470.1 5.336e+04 J
|
||||
internal energy -1.21088e+06 -2.441e+06 J
|
||||
entropy 64914 1.309e+05 J/K
|
||||
Gibbs function -1.94477e+07 -3.92e+07 J
|
||||
heat capacity c_p 14311.8 2.885e+04 J/K
|
||||
heat capacity c_v 10187.3 2.054e+04 J/K
|
||||
|
||||
X Y Chem. Pot. / RT
|
||||
------------- ------------ ------------
|
||||
H2 1 1 -15.7173
|
||||
H 0 0
|
||||
O 0 0
|
||||
O2 0 0
|
||||
OH 0 0
|
||||
H2O 0 0
|
||||
HO2 0 0
|
||||
H2O2 0 0
|
||||
C 0 0
|
||||
CH 0 0
|
||||
CH2 0 0
|
||||
CH2(S) 0 0
|
||||
CH3 0 0
|
||||
CH4 0 0
|
||||
CO 0 0
|
||||
CO2 0 0
|
||||
HCO 0 0
|
||||
CH2O 0 0
|
||||
CH2OH 0 0
|
||||
CH3O 0 0
|
||||
CH3OH 0 0
|
||||
C2H 0 0
|
||||
C2H2 0 0
|
||||
C2H3 0 0
|
||||
C2H4 0 0
|
||||
C2H5 0 0
|
||||
C2H6 0 0
|
||||
HCCO 0 0
|
||||
CH2CO 0 0
|
||||
HCCOH 0 0
|
||||
N 0 0
|
||||
NH 0 0
|
||||
NH2 0 0
|
||||
NH3 0 0
|
||||
NNH 0 0
|
||||
NO 0 0
|
||||
NO2 0 0
|
||||
N2O 0 0
|
||||
HNO 0 0
|
||||
CN 0 0
|
||||
HCN 0 0
|
||||
H2CN 0 0
|
||||
HCNN 0 0
|
||||
HCNO 0 0
|
||||
HOCN 0 0
|
||||
HNCO 0 0
|
||||
NCO 0 0
|
||||
N2 0 0
|
||||
AR 0 0
|
||||
C3H7 0 0
|
||||
C3H8 0 0
|
||||
CH2CHO 0 0
|
||||
CH3CHO 0 0
|
||||
|
||||
gri30:
|
||||
|
||||
temperature 1200 K
|
||||
pressure 405300 Pa
|
||||
density 0.081889 kg/m^3
|
||||
mean mol. weight 2.01588 amu
|
||||
|
||||
1 kg 1 kmol
|
||||
----------- ------------
|
||||
enthalpy 1.32956e+07 2.68e+07 J
|
||||
internal energy 8.3462e+06 1.682e+07 J
|
||||
entropy 79509.9 1.603e+05 J/K
|
||||
Gibbs function -8.21163e+07 -1.655e+08 J
|
||||
heat capacity c_p 15377.9 3.1e+04 J/K
|
||||
heat capacity c_v 11253.5 2.269e+04 J/K
|
||||
|
||||
X Y Chem. Pot. / RT
|
||||
------------- ------------ ------------
|
||||
H2 1 1 -16.5912
|
||||
H 0 0
|
||||
O 0 0
|
||||
O2 0 0
|
||||
OH 0 0
|
||||
H2O 0 0
|
||||
HO2 0 0
|
||||
H2O2 0 0
|
||||
C 0 0
|
||||
CH 0 0
|
||||
CH2 0 0
|
||||
CH2(S) 0 0
|
||||
CH3 0 0
|
||||
CH4 0 0
|
||||
CO 0 0
|
||||
CO2 0 0
|
||||
HCO 0 0
|
||||
CH2O 0 0
|
||||
CH2OH 0 0
|
||||
CH3O 0 0
|
||||
CH3OH 0 0
|
||||
C2H 0 0
|
||||
C2H2 0 0
|
||||
C2H3 0 0
|
||||
C2H4 0 0
|
||||
C2H5 0 0
|
||||
C2H6 0 0
|
||||
HCCO 0 0
|
||||
CH2CO 0 0
|
||||
HCCOH 0 0
|
||||
N 0 0
|
||||
NH 0 0
|
||||
NH2 0 0
|
||||
NH3 0 0
|
||||
NNH 0 0
|
||||
NO 0 0
|
||||
NO2 0 0
|
||||
N2O 0 0
|
||||
HNO 0 0
|
||||
CN 0 0
|
||||
HCN 0 0
|
||||
H2CN 0 0
|
||||
HCNN 0 0
|
||||
HCNO 0 0
|
||||
HOCN 0 0
|
||||
HNCO 0 0
|
||||
NCO 0 0
|
||||
N2 0 0
|
||||
AR 0 0
|
||||
C3H7 0 0
|
||||
C3H8 0 0
|
||||
CH2CHO 0 0
|
||||
CH3CHO 0 0
|
||||
|
||||
gri30:
|
||||
|
||||
temperature 900 K
|
||||
pressure 100000 Pa
|
||||
density 0.369279 kg/m^3
|
||||
mean mol. weight 27.6332 amu
|
||||
|
||||
1 kg 1 kmol
|
||||
----------- ------------
|
||||
enthalpy 455660 1.259e+07 J
|
||||
internal energy 184862 5.108e+06 J
|
||||
entropy 8529.31 2.357e+05 J/K
|
||||
Gibbs function -7.22072e+06 -1.995e+08 J
|
||||
heat capacity c_p 1304.4 3.604e+04 J/K
|
||||
heat capacity c_v 1003.52 2.773e+04 J/K
|
||||
|
||||
X Y Chem. Pot. / RT
|
||||
------------- ------------ ------------
|
||||
H2 0 0
|
||||
H 0 0
|
||||
O 0 0
|
||||
O2 0.190114 0.220149 -27.9596
|
||||
OH 0 0
|
||||
H2O 0 0
|
||||
HO2 0 0
|
||||
H2O2 0 0
|
||||
C 0 0
|
||||
CH 0 0
|
||||
CH2 0 0
|
||||
CH2(S) 0 0
|
||||
CH3 0 0
|
||||
CH4 0.095057 0.0551863 -37.0813
|
||||
CO 0 0
|
||||
CO2 0 0
|
||||
HCO 0 0
|
||||
CH2O 0 0
|
||||
CH2OH 0 0
|
||||
CH3O 0 0
|
||||
CH3OH 0 0
|
||||
C2H 0 0
|
||||
C2H2 0 0
|
||||
C2H3 0 0
|
||||
C2H4 0 0
|
||||
C2H5 0 0
|
||||
C2H6 0 0
|
||||
HCCO 0 0
|
||||
CH2CO 0 0
|
||||
HCCOH 0 0
|
||||
N 0 0
|
||||
NH 0 0
|
||||
NH2 0 0
|
||||
NH3 0 0
|
||||
NNH 0 0
|
||||
NO 0 0
|
||||
NO2 0 0
|
||||
N2O 0 0
|
||||
HNO 0 0
|
||||
CN 0 0
|
||||
HCN 0 0
|
||||
H2CN 0 0
|
||||
HCNN 0 0
|
||||
HCNO 0 0
|
||||
HOCN 0 0
|
||||
HNCO 0 0
|
||||
NCO 0 0
|
||||
N2 0.714829 0.724665 -24.935
|
||||
AR 0 0
|
||||
C3H7 0 0
|
||||
C3H8 0 0
|
||||
CH2CHO 0 0
|
||||
CH3CHO 0 0
|
||||
|
||||
gri30:
|
||||
|
||||
temperature 1235.23 K
|
||||
pressure 193934 Pa
|
||||
density 0.545252 kg/m^3
|
||||
mean mol. weight 28.8752 amu
|
||||
|
||||
1 kg 1 kmol
|
||||
----------- ------------
|
||||
enthalpy 5.56724e+06 1.608e+08 J
|
||||
internal energy 5.21156e+06 1.505e+08 J
|
||||
entropy 10866.6 3.138e+05 J/K
|
||||
Gibbs function -7.85549e+06 -2.268e+08 J
|
||||
heat capacity c_p 2258.12 6.52e+04 J/K
|
||||
heat capacity c_v 1970.18 5.689e+04 J/K
|
||||
|
||||
X Y Chem. Pot. / RT
|
||||
------------- ------------ ------------
|
||||
H2 0.0188679 0.00131724 -21.3768
|
||||
H 0.0188679 0.000658618 2.45072
|
||||
O 0.0188679 0.0104545 -0.130267
|
||||
O2 0.0188679 0.020909 -30.495
|
||||
OH 0.0188679 0.0111131 -23.9578
|
||||
H2O 0.0188679 0.0117717 -52.4329
|
||||
HO2 0.0188679 0.0215676 -32.8359
|
||||
H2O2 0.0188679 0.0222262 -48.7862
|
||||
C 0.0188679 0.00784834 45.7869
|
||||
CH 0.0188679 0.00850696 30.4521
|
||||
CH2 0.0188679 0.00916558 8.43598
|
||||
CH2(S) 0.0188679 0.00916558 12.8299
|
||||
CH3 0.0188679 0.0098242 -16.0065
|
||||
CH4 0.0188679 0.0104828 -36.8745
|
||||
CO 0.0188679 0.0183028 -40.2646
|
||||
CO2 0.0188679 0.0287573 -70.9103
|
||||
HCO 0.0188679 0.0189614 -29.3505
|
||||
CH2O 0.0188679 0.0196201 -43.7869
|
||||
CH2OH 0.0188679 0.0202787 -38.854
|
||||
CH3O 0.0188679 0.0202787 -33.4663
|
||||
CH3OH 0.0188679 0.0209373 -56.6067
|
||||
C2H 0.0188679 0.0163553 22.4849
|
||||
C2H2 0.0188679 0.0170139 -9.62065
|
||||
C2H3 0.0188679 0.0176725 -6.88586
|
||||
C2H4 0.0188679 0.0183312 -29.6415
|
||||
C2H5 0.0188679 0.0189898 -27.3078
|
||||
C2H6 0.0188679 0.0196484 -45.4153
|
||||
HCCO 0.0188679 0.0268098 -20.3438
|
||||
CH2CO 0.0188679 0.0274684 -42.3074
|
||||
HCCOH 0.0188679 0.0274684 -29.6958
|
||||
N 0.0188679 0.00915242 22.608
|
||||
NH 0.0188679 0.00981104 7.2794
|
||||
NH2 0.0188679 0.0104697 -11.0016
|
||||
NH3 0.0188679 0.0111283 -34.4022
|
||||
NNH 0.0188679 0.0189635 -9.19194
|
||||
NO 0.0188679 0.0196069 -22.2473
|
||||
NO2 0.0188679 0.0300614 -32.3728
|
||||
N2O 0.0188679 0.0287593 -25.4986
|
||||
HNO 0.0188679 0.0202655 -22.6121
|
||||
CN 0.0188679 0.0170008 12.6004
|
||||
HCN 0.0188679 0.0176594 -18.1967
|
||||
H2CN 0.0188679 0.018318 -10.0875
|
||||
HCNN 0.0188679 0.0268118 6.88522
|
||||
HCNO 0.0188679 0.0281139 -20.4444
|
||||
HOCN 0.0188679 0.0281139 -37.9279
|
||||
HNCO 0.0188679 0.0281139 -48.2213
|
||||
NCO 0.0188679 0.0274552 -22.1878
|
||||
N2 0.0188679 0.0183048 -28.7463
|
||||
AR 0.0188679 0.0261032 -23.5881
|
||||
C3H7 0.0188679 0.0281554 -36.9365
|
||||
C3H8 0.0188679 0.028814 -55.0607
|
||||
CH2CHO 0.0188679 0.028127 -38.8293
|
||||
CH3CHO 0.0188679 0.0287856 -57.467
|
||||
|
||||
gri30:
|
||||
|
||||
temperature 1235.23 K
|
||||
pressure 368222 Pa
|
||||
density 0.545252 kg/m^3
|
||||
mean mol. weight 15.2079 amu
|
||||
|
||||
1 kg 1 kmol
|
||||
----------- ------------
|
||||
enthalpy 1.26294e+07 1.921e+08 J
|
||||
internal energy 1.19541e+07 1.818e+08 J
|
||||
entropy 15645.4 2.379e+05 J/K
|
||||
Gibbs function -6.69611e+06 -1.018e+08 J
|
||||
heat capacity c_p 2918.61 4.439e+04 J/K
|
||||
heat capacity c_v 2371.89 3.607e+04 J/K
|
||||
|
||||
X Y Chem. Pot. / RT
|
||||
------------- ------------ ------------
|
||||
H2 0.14234 0.0188679 -18.7148
|
||||
H 0.284681 0.0188679 5.8058
|
||||
O 0.0179345 0.0188679 0.460166
|
||||
O2 0.00896725 0.0188679 -30.5977
|
||||
OH 0.0168716 0.0188679 -23.4285
|
||||
H2O 0.0159277 0.0188679 -51.9612
|
||||
HO2 0.00869341 0.0188679 -32.9696
|
||||
H2O2 0.0084358 0.0188679 -48.95
|
||||
C 0.0238899 0.0188679 46.664
|
||||
CH 0.0220403 0.0188679 31.2487
|
||||
CH2 0.0204565 0.0188679 9.15798
|
||||
CH2(S) 0.0204565 0.0188679 13.5519
|
||||
CH3 0.0190851 0.0188679 -15.3539
|
||||
CH4 0.017886 0.0188679 -36.2868
|
||||
CO 0.0102441 0.0188679 -40.2341
|
||||
CO2 0.00651994 0.0188679 -71.3318
|
||||
HCO 0.00988827 0.0188679 -29.3554
|
||||
CH2O 0.00955633 0.0188679 -43.8259
|
||||
CH2OH 0.00924596 0.0188679 -38.9261
|
||||
CH3O 0.00924596 0.0188679 -33.5384
|
||||
CH3OH 0.00895511 0.0188679 -56.7108
|
||||
C2H 0.0114639 0.0188679 22.6278
|
||||
C2H2 0.0110201 0.0188679 -9.51722
|
||||
C2H3 0.0106094 0.0188679 -6.8204
|
||||
C2H4 0.0102283 0.0188679 -29.6127
|
||||
C2H5 0.00987352 0.0188679 -27.3142
|
||||
C2H6 0.00954255 0.0188679 -45.4558
|
||||
HCCO 0.00699356 0.0188679 -20.6951
|
||||
CH2CO 0.00682587 0.0188679 -42.6829
|
||||
HCCOH 0.00682587 0.0188679 -30.0714
|
||||
N 0.0204859 0.0188679 23.3314
|
||||
NH 0.0191107 0.0188679 7.93336
|
||||
NH2 0.0179085 0.0188679 -10.4126
|
||||
NH3 0.0168486 0.0188679 -33.8742
|
||||
NNH 0.00988722 0.0188679 -9.19699
|
||||
NO 0.00956275 0.0188679 -22.2857
|
||||
NO2 0.0062371 0.0188679 -32.8386
|
||||
N2O 0.00651948 0.0188679 -25.9201
|
||||
HNO 0.00925196 0.0188679 -22.6835
|
||||
CN 0.0110287 0.0188679 12.7046
|
||||
HCN 0.0106174 0.0188679 -18.1305
|
||||
H2CN 0.0102356 0.0188679 -10.0579
|
||||
HCNN 0.00699304 0.0188679 6.53384
|
||||
HCNO 0.00666916 0.0188679 -20.8432
|
||||
HOCN 0.00666916 0.0188679 -38.3267
|
||||
HNCO 0.00666916 0.0188679 -48.6201
|
||||
NCO 0.00682915 0.0188679 -22.5629
|
||||
N2 0.010243 0.0188679 -28.716
|
||||
AR 0.00718287 0.0188679 -23.9127
|
||||
C3H7 0.00665933 0.0188679 -37.3368
|
||||
C3H8 0.00650712 0.0188679 -55.4841
|
||||
CH2CHO 0.00666604 0.0188679 -39.2286
|
||||
CH3CHO 0.00651352 0.0188679 -57.8894
|
||||
76
test_problems/python/tut1/runtest
Executable file
76
test_problems/python/tut1/runtest
Executable file
|
|
@ -0,0 +1,76 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
#
|
||||
if test "$#" -ge "2" ; then
|
||||
echo "runtest ERROR: program requires one argument."
|
||||
echo " runtest PYTHON_CMD"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
temp_success="1"
|
||||
/bin/rm -f output.txt diff_test.out csvCode.txt ct2ctml.log \
|
||||
gri30.xml
|
||||
|
||||
testName=tut1
|
||||
#################################################################
|
||||
#
|
||||
#################################################################
|
||||
#
|
||||
# Try to create a default python executable location if no
|
||||
# argument to runtest is supplied.
|
||||
#
|
||||
if test -z "$PYTHON_CMD" ; then
|
||||
if test -z "$PYTHONHOME" ; then
|
||||
PYTHON_CMDA=python
|
||||
else
|
||||
PYTHON_CMDA=$PYTHONHOME/bin/python
|
||||
fi
|
||||
else
|
||||
PYTHON_CMDA=$PYTHON_CMD
|
||||
fi
|
||||
FIRSTARG=$1
|
||||
PYTHON_CMDB=${FIRSTARG:=$PYTHON_CMDA}
|
||||
|
||||
#
|
||||
# Check to see whether the python executable exists in the
|
||||
# current user path
|
||||
#
|
||||
locThere=`which $PYTHON_CMDB 2>&1`
|
||||
isThere=$?
|
||||
if test "$isThere" != "0" ; then
|
||||
echo 'Can not find the python executable: ' $PYTHON_CMDB
|
||||
echo ' '
|
||||
echo $locThere
|
||||
exit 1
|
||||
fi
|
||||
#pVersion=`$PYTHON_CMDB -V 2>&1`
|
||||
|
||||
#################################################################
|
||||
#
|
||||
#################################################################
|
||||
|
||||
echo -n "Testing \"$PYTHON_CMDB tut1\" ... "
|
||||
$PYTHON_CMDB tut1.py > output.txt
|
||||
retnStat=$?
|
||||
if [ $retnStat != "0" ]
|
||||
then
|
||||
temp_success="0"
|
||||
echo "ERROR: tut1.py returned with bad status, $retnStat, check output"
|
||||
fi
|
||||
|
||||
diff -w output.txt output_blessed.txt > diff_test.out
|
||||
retnStat=$?
|
||||
if [ $retnStat = "0" ]
|
||||
then
|
||||
echo "successful diff comparison on $testName test"
|
||||
if [ $temp_success = "1" ]
|
||||
then
|
||||
echo "PASSED" > csvCode.txt
|
||||
fi
|
||||
else
|
||||
echo "unsuccessful diff comparison on $testName test"
|
||||
echo "FAILED" > csvCode.txt
|
||||
temp_success="0"
|
||||
fi
|
||||
echo
|
||||
|
||||
294
test_problems/python/tut1/tut1.py
Executable file
294
test_problems/python/tut1/tut1.py
Executable file
|
|
@ -0,0 +1,294 @@
|
|||
#################################
|
||||
print """
|
||||
|
||||
Tutorial 1: Getting started
|
||||
|
||||
"""
|
||||
##################################
|
||||
|
||||
|
||||
# Put this statement at the top of each Python script to import the
|
||||
# most commonly-used parts of Cantera:
|
||||
|
||||
from Cantera import *
|
||||
|
||||
# The first thing you need is an object representing some phase of
|
||||
# matter. We'll create here a gas mixture:
|
||||
gas1 = GRI30()
|
||||
|
||||
# To view the state of the mixture, just print it:
|
||||
print gas1
|
||||
|
||||
# You should see something like this:
|
||||
#
|
||||
# temperature 300 K
|
||||
# pressure 101325 Pa
|
||||
# density 0.081889 kg/m^3
|
||||
# mean mol. weight 2.01588 amu
|
||||
|
||||
# 1 kg 1 kmol
|
||||
# ----------- ------------
|
||||
# enthalpy 26470.1 5.336e+04 J
|
||||
# internal energy -1.21088e+06 -2.441e+06 J
|
||||
# entropy 64914 1.309e+05 J/K
|
||||
# Gibbs function -1.94477e+07 -3.92e+07 J
|
||||
# heat capacity c_p 14311.8 2.885e+04 J/K
|
||||
# heat capacity c_v 10187.3 2.054e+04 J/K
|
||||
|
||||
# X Y
|
||||
# ------------- ------------
|
||||
# H2 1.000000e+00 1.000000e+00
|
||||
# H 0.000000e+00 0.000000e+00
|
||||
# O 0.000000e+00 0.000000e+00
|
||||
# O2 0.000000e+00 0.000000e+00
|
||||
# OH 0.000000e+00 0.000000e+00
|
||||
# H2O 0.000000e+00 0.000000e+00
|
||||
# HO2 0.000000e+00 0.000000e+00
|
||||
# H2O2 0.000000e+00 0.000000e+00
|
||||
# C 0.000000e+00 0.000000e+00
|
||||
# CH 0.000000e+00 0.000000e+00
|
||||
# CH2 0.000000e+00 0.000000e+00
|
||||
# CH2(S) 0.000000e+00 0.000000e+00
|
||||
# CH3 0.000000e+00 0.000000e+00
|
||||
# CH4 0.000000e+00 0.000000e+00
|
||||
# CO 0.000000e+00 0.000000e+00
|
||||
# CO2 0.000000e+00 0.000000e+00
|
||||
# HCO 0.000000e+00 0.000000e+00
|
||||
# CH2O 0.000000e+00 0.000000e+00
|
||||
# CH2OH 0.000000e+00 0.000000e+00
|
||||
# CH3O 0.000000e+00 0.000000e+00
|
||||
# CH3OH 0.000000e+00 0.000000e+00
|
||||
# C2H 0.000000e+00 0.000000e+00
|
||||
# C2H2 0.000000e+00 0.000000e+00
|
||||
# C2H3 0.000000e+00 0.000000e+00
|
||||
# C2H4 0.000000e+00 0.000000e+00
|
||||
# C2H5 0.000000e+00 0.000000e+00
|
||||
# C2H6 0.000000e+00 0.000000e+00
|
||||
# HCCO 0.000000e+00 0.000000e+00
|
||||
# CH2CO 0.000000e+00 0.000000e+00
|
||||
# HCCOH 0.000000e+00 0.000000e+00
|
||||
# N 0.000000e+00 0.000000e+00
|
||||
# NH 0.000000e+00 0.000000e+00
|
||||
# NH2 0.000000e+00 0.000000e+00
|
||||
# NH3 0.000000e+00 0.000000e+00
|
||||
# NNH 0.000000e+00 0.000000e+00
|
||||
# NO 0.000000e+00 0.000000e+00
|
||||
# NO2 0.000000e+00 0.000000e+00
|
||||
# N2O 0.000000e+00 0.000000e+00
|
||||
# HNO 0.000000e+00 0.000000e+00
|
||||
# CN 0.000000e+00 0.000000e+00
|
||||
# HCN 0.000000e+00 0.000000e+00
|
||||
# H2CN 0.000000e+00 0.000000e+00
|
||||
# HCNN 0.000000e+00 0.000000e+00
|
||||
# HCNO 0.000000e+00 0.000000e+00
|
||||
# HOCN 0.000000e+00 0.000000e+00
|
||||
# HNCO 0.000000e+00 0.000000e+00
|
||||
# NCO 0.000000e+00 0.000000e+00
|
||||
# N2 0.000000e+00 0.000000e+00
|
||||
# AR 0.000000e+00 0.000000e+00
|
||||
# C3H7 0.000000e+00 0.000000e+00
|
||||
# C3H8 0.000000e+00 0.000000e+00
|
||||
# CH2CHO 0.000000e+00 0.000000e+00
|
||||
# CH3CHO 0.000000e+00 0.000000e+00
|
||||
#
|
||||
# What you have just done is to create an object ("gas1") that
|
||||
# implements GRI-Mech 3.0, the 53-species, 325-reaction natural gas
|
||||
# combustion mechanism developed by Gregory P. Smith, David M. Golden,
|
||||
# Michael Frenklach, Nigel W. Moriarty, Boris Eiteneer, Mikhail
|
||||
# Goldenberg, C. Thomas Bowman, Ronald K. Hanson, Soonho Song, William
|
||||
# C. Gardiner, Jr., Vitali V. Lissianski, and Zhiwei Qin. See
|
||||
# http://www.me.berkeley.edu/gri_mech/ for more information.
|
||||
#
|
||||
# The object created by GI30() has properties you would expect for a gas
|
||||
# mixture - it has a temperature, a pressure, species mole and mass
|
||||
# fractions, etc. As we'll soon see, it has many more properties.
|
||||
#
|
||||
# The summary of the state of 'gas1' printed above shows that new
|
||||
# objects created by function GRI30() start out with a temperature of
|
||||
# 300 K, a pressure of 1 atm, and have a composition that consists of
|
||||
# only one species, in this case hydrogen. There is nothing special
|
||||
# about H2 - it just happens to be the first species listed in the
|
||||
# input file defining GRI-Mech 3.0 that the 'GRI30' function reads. In
|
||||
# general, whichever species is listed first will initially have a
|
||||
# mole fraction of 1.0, and all of the others will be zero.
|
||||
|
||||
|
||||
# Setting the state
|
||||
# -----------------
|
||||
|
||||
# The state of the object can easily be changed. For example,
|
||||
|
||||
gas1.setTemperature(1200)
|
||||
|
||||
# sets the temperature to 1200 K. (Cantera always uses SI units.)
|
||||
# After this statement,
|
||||
|
||||
print gas1
|
||||
|
||||
# results in:
|
||||
#
|
||||
# temperature 1200 K
|
||||
# pressure 405300 Pa
|
||||
# density 0.081896 kg/m^3
|
||||
# mean mol. weight 2.01594 amu
|
||||
#
|
||||
# X Y
|
||||
# ------------- ------------
|
||||
# H2 1.000000e+000 1.000000e+000
|
||||
# (other species not shown)
|
||||
#
|
||||
# Notice that the temperature has been changed as requested, but the
|
||||
# pressure has changed too. The density and composition have
|
||||
# not.
|
||||
#
|
||||
# When setting properties individually, some convention needs to be
|
||||
# adopted to specify which other properties are held constant. This is
|
||||
# because thermodynamics requires that *two* properties (not one) in
|
||||
# addition to composition information be specified to fix the
|
||||
# intensive state of a substance (or mixture).
|
||||
#
|
||||
# Cantera adopts the following convention: only one of the set
|
||||
# (temperature, density, mass fractions) is altered by setting any
|
||||
# single property. This means that:
|
||||
#
|
||||
# a) Setting the temperature is done holding density and
|
||||
# composition fixed. (The pressure changes.)
|
||||
|
||||
# b) Setting the pressure is done holding temperature and
|
||||
# composition fixed. (The density changes.)
|
||||
#
|
||||
# c) Setting the composition is done holding temperature
|
||||
# and density fixed. (The pressure changes).
|
||||
#
|
||||
|
||||
# Instead of using a method like 'setTemperature' to set one property,
|
||||
# you can use a single method 'set' to set any property or combination
|
||||
# of properties:
|
||||
|
||||
gas1.set(Temperature = 900.0, Pressure = 1.e5)
|
||||
|
||||
# This statement sets both temperature and pressure at the same
|
||||
# time. Any number of property/value pairs can be specified in a
|
||||
# call to 'set'. For example, the following sets the mole fractions
|
||||
# too:
|
||||
|
||||
gas1.set(Temperature = 900.0, Pressure = 1.e5,
|
||||
MoleFractions = 'CH4:1,O2:2,N2:7.52')
|
||||
|
||||
# The 'set' function also accepts abbreviated property names:
|
||||
|
||||
gas1.set(T = 900.0, P = 1.0e5, X = 'CH4:1,O2:2,N2:7.52')
|
||||
|
||||
# Either version results in:
|
||||
print gas1
|
||||
|
||||
# temperature 900 K
|
||||
# pressure 100000 Pa
|
||||
# density 0.369279 kg/m^3
|
||||
# mean mol. weight 27.6332 amu
|
||||
|
||||
# 1 kg 1 kmol
|
||||
# ----------- ------------
|
||||
# enthalpy 455660 1.259e+07 J
|
||||
# internal energy 184862 5.108e+06 J
|
||||
# entropy 8529.31 2.357e+05 J/K
|
||||
# Gibbs function -7.22072e+06 -1.995e+08 J
|
||||
# heat capacity c_p 1304.4 3.604e+04 J/K
|
||||
# heat capacity c_v 1003.52 2.773e+04 J/K
|
||||
|
||||
# X Y
|
||||
# ------------- ------------
|
||||
# H2 0.000000e+00 0.000000e+00
|
||||
# H 0.000000e+00 0.000000e+00
|
||||
# O 0.000000e+00 0.000000e+00
|
||||
# O2 1.901141e-01 2.201487e-01
|
||||
# OH 0.000000e+00 0.000000e+00
|
||||
# H2O 0.000000e+00 0.000000e+00
|
||||
# HO2 0.000000e+00 0.000000e+00
|
||||
# H2O2 0.000000e+00 0.000000e+00
|
||||
# C 0.000000e+00 0.000000e+00
|
||||
# CH 0.000000e+00 0.000000e+00
|
||||
# CH2 0.000000e+00 0.000000e+00
|
||||
# CH2(S) 0.000000e+00 0.000000e+00
|
||||
# CH3 0.000000e+00 0.000000e+00
|
||||
# CH4 9.505703e-02 5.518632e-02
|
||||
# CO 0.000000e+00 0.000000e+00
|
||||
# CO2 0.000000e+00 0.000000e+00
|
||||
# HCO 0.000000e+00 0.000000e+00
|
||||
# CH2O 0.000000e+00 0.000000e+00
|
||||
# CH2OH 0.000000e+00 0.000000e+00
|
||||
# CH3O 0.000000e+00 0.000000e+00
|
||||
# CH3OH 0.000000e+00 0.000000e+00
|
||||
# C2H 0.000000e+00 0.000000e+00
|
||||
# C2H2 0.000000e+00 0.000000e+00
|
||||
# C2H3 0.000000e+00 0.000000e+00
|
||||
# C2H4 0.000000e+00 0.000000e+00
|
||||
# C2H5 0.000000e+00 0.000000e+00
|
||||
# C2H6 0.000000e+00 0.000000e+00
|
||||
# HCCO 0.000000e+00 0.000000e+00
|
||||
# CH2CO 0.000000e+00 0.000000e+00
|
||||
# HCCOH 0.000000e+00 0.000000e+00
|
||||
# N 0.000000e+00 0.000000e+00
|
||||
# NH 0.000000e+00 0.000000e+00
|
||||
# NH2 0.000000e+00 0.000000e+00
|
||||
# NH3 0.000000e+00 0.000000e+00
|
||||
# NNH 0.000000e+00 0.000000e+00
|
||||
# NO 0.000000e+00 0.000000e+00
|
||||
# NO2 0.000000e+00 0.000000e+00
|
||||
# N2O 0.000000e+00 0.000000e+00
|
||||
# HNO 0.000000e+00 0.000000e+00
|
||||
# CN 0.000000e+00 0.000000e+00
|
||||
# HCN 0.000000e+00 0.000000e+00
|
||||
# H2CN 0.000000e+00 0.000000e+00
|
||||
# HCNN 0.000000e+00 0.000000e+00
|
||||
# HCNO 0.000000e+00 0.000000e+00
|
||||
# HOCN 0.000000e+00 0.000000e+00
|
||||
# HNCO 0.000000e+00 0.000000e+00
|
||||
# NCO 0.000000e+00 0.000000e+00
|
||||
# N2 7.148289e-01 7.246650e-01
|
||||
# AR 0.000000e+00 0.000000e+00
|
||||
# C3H7 0.000000e+00 0.000000e+00
|
||||
# C3H8 0.000000e+00 0.000000e+00
|
||||
# CH2CHO 0.000000e+00 0.000000e+00
|
||||
# CH3CHO 0.000000e+00 0.000000e+00
|
||||
|
||||
|
||||
# Other properties may also be set using 'set', including some that
|
||||
# can only be set in combination with others. The following property
|
||||
# pairs may be set: (Enthalpy, Pressure), (IntEnergy, Volume),
|
||||
# (Entropy, Volume), (Entropy, Pressure). In each case, the values of
|
||||
# the extensive properties must be entered *per unit mass*.
|
||||
|
||||
# Setting the enthalpy and pressure:
|
||||
gas1.set(Enthalpy = 2*gas1.enthalpy_mass(), Pressure = 2*OneAtm)
|
||||
|
||||
# This sets gas1 to a state with P = 2 atm, and a specific enthalpy
|
||||
# twice its previous value.
|
||||
|
||||
# Note that the abbreviations T, P, H, U, S, V can also be used with
|
||||
# the 'set' method.
|
||||
|
||||
# The composition above was specified using a string. The format is a
|
||||
# comma-separated list of <species name>:<relative mole numbers>
|
||||
# pairs. The mole numbers will be normalized to produce the mole
|
||||
# fractions, and therefore they are 'relative' mole numbers. Mass
|
||||
# fractions can be set in this way too by changing 'X' to 'Y' in the
|
||||
# above statement.
|
||||
|
||||
# The composition can also be set using an array, which must have the
|
||||
# same size as the number of species. For example, to set all 53 mole
|
||||
# fractions to the same value, do this:
|
||||
|
||||
x = ones(53,'d'); # NumPy array of 53 ones
|
||||
gas1.set(X = x)
|
||||
print gas1
|
||||
|
||||
# To set the mass fractions to equal values:
|
||||
gas1.set(Y = x)
|
||||
print gas1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Reference in a new issue