hkmoffat / cantera

Automatically exported from code.google.com/p/cantera
0 stars 0 forks source link

ck2cti.py handling of duplicate reactions with explicit reverse reactions #139

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The following lines in a chemkin file (from 
http://c3.nuigalway.ie/methylbutanoate.html ):

H2O2+O2<=>HO2+HO2 4.634E+16 -0.35 5.067E+04
REV/ 4.200E+14 0.00 1.198E+04 /
DUP
H2O2+O2<=>HO2+HO2 1.434E+13 -0.35 3.706E+04
REV/ 1.300E+11 0.00 -1.629E+03 /
DUP

Cause the exception:
__main__.InputParseError: Encountered unmarked duplicate reaction H2O2 + O2 <=> 
HO2 + HO2.

I believe the following patch fixes it, but you may have another way.

Index: ck2cti.py
===================================================================
--- ck2cti.py   (revision 1883)
+++ ck2cti.py   (working copy)
@@ -1050,11 +1050,15 @@
        chebyshevCoeffs = []

        # Note that the subsequent lines could be in any order
+        revReaction = None
        for line in lines[1:]:
            tokens = line.split('/')
            if 'dup' in line.lower():
                # Duplicate reaction
                reaction.duplicate = True
+                if revReaction:
+                    revReaction.duplicate = True
+                

            elif 'low' in line.lower():
                # Low-pressure-limit Arrhenius parameters
@@ -1080,6 +1084,8 @@
                    Ea = (float(tokens[2].strip()),"kcal/mol"),
                    T0 = (1,"K"),
                )
+                if reaction.duplicate:
+                    revReaction.duplicate = True

            elif 'ford' in line.lower():
                tokens = tokens[1].split()

Original issue reported on code.google.com by r.h.w...@gmail.com on 17 Jan 2013 at 10:53

GoogleCodeExporter commented 9 years ago
Fixed in r2066 (trunk) / r2073 (2.0 maintenance).

Original comment by yarmond on 22 Jan 2013 at 8:37