Skip to content

Commit

Permalink
[ck2cti] Add support for MWON and MWOFF keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
speth committed Jul 28, 2016
1 parent 1e5eb8c commit fd9d60f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
39 changes: 30 additions & 9 deletions interfaces/cython/cantera/ck2cti.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,15 @@ def __init__(self, *args, **kwargs):
Arrhenius.__init__(self, *args, **kwargs)
self.coverages = []
self.is_sticking = False
self.motz_wise = None

def rateStr(self):
if self.is_sticking:
return ' stick({0})'.format(Arrhenius.rateStr(self)[1:-1])
if self.motz_wise is None:
return ' stick({0})'.format(Arrhenius.rateStr(self)[1:-1])
else:
return ' stick({0}, motz_wise={1})'.format(
Arrhenius.rateStr(self)[1:-1], self.motz_wise)
elif not self.coverages:
return ' ' + Arrhenius.rateStr(self)

Expand Down Expand Up @@ -931,6 +936,7 @@ def __init__(self):
self.output_energy_units = 'cal/mol' # for the output file
self.quantity_units = 'mol' # for the current REACTIONS section
self.output_quantity_units = 'mol' # for the output file
self.motz_wise = None
self.warning_as_error = True

self.elements = []
Expand Down Expand Up @@ -1314,6 +1320,12 @@ def parseExpression(expression, dest):
if 'stick' in line.lower():
arrhenius.is_sticking = True

if 'mwon' in line.lower():
arrhenius.motz_wise = True

if 'mwoff' in line.lower():
arrhenius.motz_wise = False

if 'dup' in line.lower():
# Duplicate reaction
reaction.duplicate = True
Expand Down Expand Up @@ -1759,17 +1771,21 @@ def readline():
# Reactions section
inHeader = False
for token in tokens[1:]:
units = token.upper()
if units in ENERGY_UNITS:
self.energy_units =ENERGY_UNITS[units]
token = token.upper()
if token in ENERGY_UNITS:
self.energy_units =ENERGY_UNITS[token]
if not self.processed_units:
self.output_energy_units = ENERGY_UNITS[units]
elif units in QUANTITY_UNITS:
self.quantity_units = QUANTITY_UNITS[units]
self.output_energy_units = ENERGY_UNITS[token]
elif token in QUANTITY_UNITS:
self.quantity_units = QUANTITY_UNITS[token]
if not self.processed_units:
self.output_quantity_units = QUANTITY_UNITS[units]
self.output_quantity_units = QUANTITY_UNITS[token]
elif token == 'MWON':
self.motz_wise = True
elif token == 'MWOFF':
self.motz_wise = False
else:
raise InputParseError("Unrecognized energy or quantity unit, {0!r}".format(units))
raise InputParseError("Unrecognized token on REACTIONS line, {0!r}".format(token))

self.processed_units = True

Expand Down Expand Up @@ -2060,6 +2076,11 @@ def writeCTI(self, header=None, name='gas', transportModel='Mix',
lines.append('# Reaction data')
lines.append(delimiterLine)

if self.motz_wise is True:
lines.append('enable_motz_wise()')
elif self.motz_wise is False:
lines.append('disable_motz_wise()')

for i,r in enumerate(self.reactions):
lines.extend('# '+c for c in r.comment.split('\n') if c)
lines.append('\n# Reaction {0}'.format(i+1))
Expand Down
3 changes: 3 additions & 0 deletions interfaces/cython/cantera/test/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,11 @@ def test_surface_mech(self):
# Sticking coefficients
self.assertFalse(surf.reaction(1).is_sticking_coefficient)
self.assertTrue(surf.reaction(2).is_sticking_coefficient)
self.assertTrue(surf.reaction(2).use_motz_wise_correction)
self.assertTrue(surf.reaction(4).is_sticking_coefficient)
self.assertFalse(surf.reaction(4).use_motz_wise_correction)
self.assertTrue(surf.reaction(4).duplicate)
self.assertTrue(surf.reaction(6).use_motz_wise_correction)

# Coverage dependencies
covdeps = surf.reaction(1).coverage_deps
Expand Down
5 changes: 3 additions & 2 deletions test/data/surface1.inp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ _Pt_ PT 1 S 300.0 3000.0 1000.0 1
0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 4
END

REACTIONS JOULES/MOLE
REACTIONS JOULES/MOLE MWON
H2 + 2_Pt_ => 2H_Pt 4.4579E+10 0.5 0.0
FORD/_Pt_ 1/
2H_Pt => H2 + 2_Pt_ 3.70E+21 0.00 67400.0
Expand All @@ -36,11 +36,12 @@ END
O2 + 2_Pt_ => 2O_Pt 1.80E+21 -0.5 0.0
DUPLICATE
O2 + 2_Pt_ => 2O_Pt 0.023 0.00 0.00
DUPLICATE STICK
DUPLICATE STICK MWOFF
2O_Pt => O2 + 2_Pt_ 3.70E+21 0.00 213200.0
COV/O_Pt 0.0 0.0 -60000.0/
O + _Pt_ => O_Pt 1.00 0.0 0.0
STICK
MWON
H2O + _Pt_ => H2O_Pt 0.75 0.0 0.0
STICK
H2O_Pt => H2O + _Pt_ 1.0E+13 0.00 40300.0
Expand Down

0 comments on commit fd9d60f

Please sign in to comment.