[ck2cti] Always write surface reactions to CTI file

Surface reactions were not being written to the CTI file if there were no
gas-phase reactions present.

Also update the count of reactions printed in the output summary to include
surface reactions.
This commit is contained in:
Ray Speth 2018-01-19 10:23:10 -05:00
parent 831b92dac4
commit 552ba97a2b
3 changed files with 55 additions and 2 deletions

View file

@ -2093,7 +2093,7 @@ class Parser(object):
for s in surf.speciesList:
lines.append(s.to_cti())
if self.reactions:
if self.reactions or any(surf.reactions for surf in self.surfaces):
# Write the reactions
lines.append(delimiterLine)
lines.append('# Reaction data')
@ -2233,8 +2233,9 @@ duplicate transport data) to be ignored.
# Write output file
surface_names = self.writeCTI(name=phaseName, outName=outName)
if not quiet:
nReactions = len(self.reactions) + sum(len(surf.reactions) for surf in self.surfaces)
print('Wrote CTI mechanism file to {0!r}.'.format(outName))
print('Mechanism contains {0} species and {1} reactions.'.format(len(self.speciesList), len(self.reactions)))
print('Mechanism contains {0} species and {1} reactions.'.format(len(self.speciesList), nReactions))
return surface_names

View file

@ -444,6 +444,17 @@ class chemkinConverterTest(utilities.CanteraTest):
self.assertEqual(covdeps['OH_Pt'][1], 1.0)
self.assertNear(covdeps['H_Pt'][2], -6e6) # 6000 J/gmol = 6e6 J/kmol
def test_surface_mech2(self):
convertMech(pjoin(self.test_data_dir, 'surface1-gas-noreac.inp'),
surfaceFile=pjoin(self.test_data_dir, 'surface1.inp'),
outName=pjoin(self.test_work_dir, 'surface1-nogasreac.cti'), quiet=True)
gas = ct.Solution('surface1-nogasreac.cti', 'gas')
surf = ct.Interface('surface1-nogasreac.cti', 'PT_SURFACE', [gas])
self.assertEqual(gas.n_reactions, 0)
self.assertEqual(surf.n_reactions, 15)
class CtmlConverterTest(utilities.CanteraTest):
def test_sofc(self):

View file

@ -0,0 +1,41 @@
ELEMENTS H O PT END
SPECIES
H H2 H2O H2O2 HO2 O O2 OH
END
THERMO
300.0 1000.0 3500.0
H 120186H 1 G 0300.00 5000.00 1000.00 1
0.02500000E+02 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 2
0.02547162E+06-0.04601176E+01 0.02500000E+02 0.00000000E+00 0.00000000E+00 3
0.00000000E+00 0.00000000E+00 0.02547162E+06-0.04601176E+01 4
H2 121286H 2 G 0300.00 5000.00 1000.00 1
0.02991423E+02 0.07000644E-02-0.05633828E-06-0.09231578E-10 0.15827519E-14 2
-0.08350340E+04-0.13551101E+01 0.03298124E+02 0.08249441E-02-0.08143015E-05 3
-0.09475434E-09 0.04134872E-11-0.10125209E+04-0.03294094E+02 4
H2O 20387H 2O 1 G 0300.00 5000.00 1000.00 1
0.02672145E+02 0.03056293E-01-0.08730260E-05 0.12009964E-09-0.06391618E-13 2
-0.02989921E+06 0.06862817E+02 0.03386842E+02 0.03474982E-01-0.06354696E-04 3
0.06968581E-07-0.02506588E-10-0.03020811E+06 0.02590232E+02 4
H2O2 120186H 2O 2 G 0300.00 5000.00 1000.00 1
0.04573167E+02 0.04336136E-01-0.14746888E-05 0.02348903E-08-0.14316536E-13 2
-0.01800696E+06 0.05011369E+01 0.03388753E+02 0.06569226E-01-0.14850125E-06 3
-0.04625805E-07 0.02471514E-10-0.01766314E+06 0.06785363E+02 4
HO2 20387H 1O 2 G 0300.00 5000.00 1000.00 1
0.04072191E+02 0.02131296E-01-0.05308145E-05 0.06112269E-09-0.02841164E-13 2
-0.15797270E+03 0.03476029E+02 0.02979963E+02 0.04996697E-01-0.03790997E-04 3
0.02354192E-07-0.08089024E-11 0.01762273E+04 0.09222724E+02 4
O 120186O 1 G 0300.00 5000.00 1000.00 1
0.02542059E+02-0.02755061E-03-0.03102803E-07 0.04551067E-10-0.04368051E-14 2
0.02923080E+06 0.04920308E+02 0.02946428E+02-0.16381665E-02 0.02421031E-04 3
-0.16028431E-08 0.03890696E-11 0.02914764E+06 0.02963995E+02 4
O2 121386O 2 G 0300.00 5000.00 1000.00 1
0.03697578E+02 0.06135197E-02-0.12588420E-06 0.01775281E-09-0.11364354E-14 2
-0.12339301E+04 0.03189165E+02 0.03212936E+02 0.11274864E-02-0.05756150E-05 3
0.13138773E-08-0.08768554E-11-0.10052490E+04 0.06034737E+02 4
OH 121286O 1H 1 G 0300.00 5000.00 1000.00 1
0.02882730E+02 0.10139743E-02-0.02276877E-05 0.02174683E-09-0.05126305E-14 2
0.03886888E+05 0.05595712E+02 0.03637266E+02 0.01850910E-02-0.16761646E-05 3
0.02387202E-07-0.08431442E-11 0.03606781E+05 0.13588605E+01 4
END