2005-06-18 16:58:39 +00:00
|
|
|
# This script is used to test handling of non-integral product
|
|
|
|
|
# stoichiometric coefficients. See file frac.cti for more information.
|
|
|
|
|
|
2005-08-30 20:28:14 +00:00
|
|
|
print 'testing handling of non-integral stoichiometric coefficients...'
|
|
|
|
|
|
2005-06-18 16:58:39 +00:00
|
|
|
from Cantera import *
|
|
|
|
|
gas = importPhase('frac.cti')
|
2005-08-30 20:28:14 +00:00
|
|
|
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
|
2005-06-18 16:58:39 +00:00
|
|
|
fwd_rop = gas.fwdRatesOfProgress()
|
|
|
|
|
|
2005-08-30 20:28:14 +00:00
|
|
|
# species creation and destruction rates
|
2005-06-18 16:58:39 +00:00
|
|
|
cdot = gas.creationRates()
|
2005-08-30 20:28:14 +00:00
|
|
|
ddot = gas.destructionRates()
|
2005-06-18 16:58:39 +00:00
|
|
|
|
|
|
|
|
nsp = gas.nSpecies()
|
|
|
|
|
nr = gas.nReactions()
|
|
|
|
|
|
|
|
|
|
# print the reaction equations
|
2005-08-30 20:28:14 +00:00
|
|
|
print 'Reaction Equations:'
|
2005-06-18 16:58:39 +00:00
|
|
|
for i in range(nr):
|
|
|
|
|
print gas.reactionEqn(i)
|
2005-08-30 20:28:14 +00:00
|
|
|
print
|
2005-06-18 16:58:39 +00:00
|
|
|
|
|
|
|
|
# print the creation rates, and check that the creation rates have the
|
|
|
|
|
# correct relationship to the reaction rates of progress
|
2005-08-30 20:28:14 +00:00
|
|
|
print 'Creation Rates: '
|
|
|
|
|
for k in range(nsp-1):
|
2005-06-18 16:58:39 +00:00
|
|
|
print '%12s %10.4e %10.4e ' % (gas.speciesName(k),
|
|
|
|
|
cdot[k], cdot[k]/fwd_rop[0])
|
2005-08-30 20:28:14 +00:00
|
|
|
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
|
2005-06-18 16:58:39 +00:00
|
|
|
|
|
|
|
|
# print the arrays of reactant and product stoichiometric coefficients
|
2005-07-25 03:55:32 +00:00
|
|
|
|
|
|
|
|
x = gas.moleFractions()
|
|
|
|
|
c = gas.molarDensity() * x
|
|
|
|
|
|
2005-08-30 20:28:14 +00:00
|
|
|
# rxn 2 orders from frac.cti
|
|
|
|
|
order_H2 = 0.8
|
2005-07-25 03:55:32 +00:00
|
|
|
order_OH = 2.0
|
|
|
|
|
order_O2 = 1.0
|
|
|
|
|
|
|
|
|
|
kf = gas.fwdRateConstants()
|
2005-08-30 20:28:14 +00:00
|
|
|
print '\nForward rate constants:'
|
|
|
|
|
print kf
|
2005-07-25 03:55:32 +00:00
|
|
|
|
2005-08-30 20:28:14 +00:00
|
|
|
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]
|
2006-03-03 16:37:39 +00:00
|
|
|
diff12 = (r1 - r2)/(r1 + r2)
|
|
|
|
|
if (abs(diff12) < 1.0E-10) :
|
|
|
|
|
diff12 = 0.0
|
|
|
|
|
print r1, r2, diff12
|
2005-08-30 20:28:14 +00:00
|
|
|
print
|
|
|
|
|
print 'Reactant stoichiometric coefficients:'
|
2005-06-18 16:58:39 +00:00
|
|
|
print gas.reactantStoichCoeffs()
|
2005-08-30 20:28:14 +00:00
|
|
|
print 'Product stoichiometric coefficients:'
|
2005-06-18 16:58:39 +00:00
|
|
|
print gas.productStoichCoeffs()
|
|
|
|
|
|