modified the frac test

This commit is contained in:
Dave Goodwin 2005-08-30 20:28:14 +00:00
parent 80f3968971
commit 1e6e487ce1
4 changed files with 80 additions and 30 deletions

View file

@ -101,6 +101,6 @@ reaction( "H2O => 1.4 H + 0.6 OH + 0.2 O2", [1.0e13, 0.0, 0.0])
# A reaction with fractional reactant stoichiometric
# coefficients.
reaction( "1.4 H + 0.6 OH + 0.2 O2 => H2O", [1.0e13, 0.0, 0.0],
order = "H:0.8 OH:2 O2:1")
reaction( "0.7 H2 + 0.6 OH + 0.2 O2 => H2O", [1.0e13, 0.0, 0.0],
order = "H2:0.8 OH:2 O2:1")

View file

@ -1,44 +1,71 @@
# This script is used to test handling of non-integral product
# stoichiometric coefficients. See file frac.cti for more information.
print 'testing handling of non-integral stoichiometric coefficients...'
from Cantera import *
gas = importPhase('frac.cti')
gas.set(T = 2000, P = OneAtm, X = 'H2O:1.0, OH:0.1, H:0.2, O2:0.3')
gas.set(T = 2000, P = OneAtm, X = 'H2O:1.0, OH:0.1, H:0.2, O2:0.3, H2:0.4')
ih2, ih, io, io2, ioh, ih2o = gas.speciesIndex(['H2','H','O','O2','OH','H2O'])
# forward rates of progress
fwd_rop = gas.fwdRatesOfProgress()
# species creation and destruction rates
cdot = gas.creationRates()
ddot = gas.destructionRates()
nsp = gas.nSpecies()
nr = gas.nReactions()
# print the reaction equations
print 'Reaction Equations:'
for i in range(nr):
print gas.reactionEqn(i)
print
# print the creation rates, and check that the creation rates have the
# correct relationship to the reaction rates of progress
for k in range(nsp):
print 'Creation Rates: '
for k in range(nsp-1):
print '%12s %10.4e %10.4e ' % (gas.speciesName(k),
cdot[k], cdot[k]/fwd_rop[0])
print '%12s %10.4e %10.4e ' % (gas.speciesName(ih2o),
cdot[ih2o], cdot[ih2o]/fwd_rop[1])
# print the destruction rates, and check that the destruction rates have the
# correct relationship to the reaction rates of progress
print '\nDestruction Rates:'
for k in range(nsp-1):
print '%12s %10.4e %10.4e ' % (gas.speciesName(k),
ddot[k], ddot[k]/fwd_rop[1])
print '%12s %10.4e %10.4e ' % (gas.speciesName(ih2o),
ddot[ih2o], ddot[ih2o]/fwd_rop[0])
print
# print the arrays of reactant and product stoichiometric coefficients
x = gas.moleFractions()
c = gas.molarDensity() * x
ih2, ih, io, io2, ioh, ih2o = gas.speciesIndex(['H2','H','O','O2','OH','H2O'])
#rxn 2 orders
order_H = 0.8
# rxn 2 orders from frac.cti
order_H2 = 0.8
order_OH = 2.0
order_O2 = 1.0
kf = gas.fwdRateConstants()
print '\nForward rate constants:'
print kf
cproduct = pow(c[ih],order_H) * pow(c[ioh], order_OH) * pow(c[io2], order_O2)
print fwd_rop[1], cproduct*kf[1]
cproduct = pow(c[ih2],order_H2) * pow(c[ioh], order_OH) * pow(c[io2], order_O2)
print '\nFwd rate of progress, kf*concentration product, difference:'
r1 = fwd_rop[1]
r2 = cproduct*kf[1]
print r1, r2, (r1 - r2)/(r1 + r2)
print
print 'Reactant stoichiometric coefficients:'
print gas.reactantStoichCoeffs()
print 'Product stoichiometric coefficients:'
print gas.productStoichCoeffs()

View file

@ -1,19 +1,42 @@
H2O => 1.3999999999999999 H + 0.20000000000000001 O2 + 0.59999999999999998 OH
testing handling of non-integral stoichiometric coefficients...
Reaction Equations:
H2O => 1.4 H + 0.2 O2 + 0.6 OH
0.7 H2 + 0.2 O2 + 0.6 OH => H2O
Creation Rates:
H2 0.0000e+00 0.0000e+00
H 7.7551e+10 1.4000e+00
H 4.2653e+10 1.4000e+00
O 0.0000e+00 0.0000e+00
O2 1.1079e+10 2.0000e-01
OH 3.3236e+10 6.0000e-01
H2O 0.0000e+00 0.0000e+00
[[ 0.]
[ 0.]
[ 0.]
[ 0.]
[ 0.]
[ 1.]]
[[ 0. ]
[ 1.4]
[ 0. ]
[ 0.2]
[ 0.6]
[ 0. ]]
O2 6.0933e+09 2.0000e-01
OH 1.8280e+10 6.0000e-01
H2O 1.5750e-08 1.0000e+00
Destruction Rates:
H2 1.1025e-08 7.0000e-01
H 0.0000e+00 0.0000e+00
O 0.0000e+00 0.0000e+00
O2 3.1501e-09 2.0000e-01
OH 9.4503e-09 6.0000e-01
H2O 3.0466e+10 1.0000e+00
Forward rate constants:
[ 1.00000000e+13 3.98107200e+04]
Fwd rate of progress, kf*concentration product, difference:
1.57504383393e-08 1.57504383393e-08 0.0
Reactant stoichiometric coefficients:
[[ 0. 0.7]
[ 0. 0. ]
[ 0. 0. ]
[ 0. 0.2]
[ 0. 0.6]
[ 1. 0. ]]
Product stoichiometric coefficients:
[[ 0. 0. ]
[ 1.4 0. ]
[ 0. 0. ]
[ 0.2 0. ]
[ 0.6 0. ]
[ 0. 1. ]]

View file

@ -101,7 +101,7 @@ echo
#################################################################
#
#################################################################
echo "testing handling of fractional product stoichiometric coefficients..."
echo "Testing handling of fractional product stoichiometric coefficients..."
$PYTHON_CMD frac.py > frac_test.out
diff -w frac_test.out frac_blessed.out > diff_test.out
retnStat=$?