dbirch997 / cantera

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

ck2cti fails to parse mechanisms with no reactions #225

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a mechanism with the reaction section specified but with no reactions 
(see attached test.inp)
2. Process the mechanism with ck2cti from 2.1.1

What is the expected output? What do you see instead?
An error:

ERROR: Unable to parse 'test.inp' near line 19:

is thrown, with the traceback:

Traceback (most recent call last):
  File "/home/bryan/.local/bin/ck2cti", line 1895, in <module>
    main(sys.argv[1:])
  File "/home/bryan/.local/bin/ck2cti", line 1891, in main
    outName, permissive=permissive)
  File "/home/bryan/.local/bin/ck2cti", line 1806, in convertMech
    self.loadChemkinFile(inputFile)
  File "/home/bryan/.local/bin/ck2cti", line 1573, in loadChemkinFile
    if kineticsList[0] == '' and commentsList[-1] == '':
IndexError: list index out of range

The reason seems to be because kineticsList and commentsList are empty, so 
indexing them fails. One solution is to check the lists for "emptyness" by:

if kineticsList and commentsList:

on line 1572 and indent the following if-else structure. I'm not sure if this 
is the best solution though, or if this solution will break other things.

This problem occurs when the reactions section is completely empty, or when its 
only contents are comments.

Original issue reported on code.google.com by bryan.w....@gmail.com on 14 Jul 2014 at 6:30

Attachments:

GoogleCodeExporter commented 9 years ago
Seems OK to me.

I think that kineticsList and commentsList are always the same length, so you 
only need to check one of them.

If you want to avoid the extra indentation level, you can just start the 
if/else structure with:

   if not kineticsList:
       pass
   elif ...

Original comment by yarmond on 14 Jul 2014 at 9:14

GoogleCodeExporter commented 9 years ago
Fixed by r3045

Original comment by bryan.w....@gmail.com on 16 Jul 2014 at 4:18