matthewd139 / cantera

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

ck2cti.py not recognizing some floats like "2." for stoichiometric coefficients #220

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The regular expression used to find floating point stoichiometric coefficients 
in ck2cti.py (reFloat, on line 43) seems to miss values without any digits 
after the decimal point, such as "2.".

For example, the reaction line
IC4H7+IC4H8=>.5C7H8+.5XYLENE+.5CH3+.5H+2.H2  .2000E+12    .000  18000.0
gives the error
Traceback (most recent call last):
  File "/Users/kyleniemeyer/Desktop/ck2cti.py", line 1904, in <module>
    main(sys.argv[1:])
  File "/Users/kyleniemeyer/Desktop/ck2cti.py", line 1900, in main
    outName, permissive=permissive)
  File "/Users/kyleniemeyer/Desktop/ck2cti.py", line 1816, in convertMech
    self.loadChemkinFile(inputFile)
  File "/Users/kyleniemeyer/Desktop/ck2cti.py", line 1607, in loadChemkinFile
    reaction,revReaction = self.readKineticsEntry(kinetics)
  File "/Users/kyleniemeyer/Desktop/ck2cti.py", line 1095, in readKineticsEntry
    raise InputParseError('Unexpected token "{0}" in reaction expression "{1}".'.format(token, reaction))
__main__.InputParseError: Unexpected token "+2." in reaction expression "
".

I've seen a number of values in CK-format mechanisms that look like this, so I 
think changing the regex to something like 
reFloat = re.compile(r'\+?((\d*\.?\d+)|(\d+\.?\d*))([eEdD][-+]?\d+)?$')
should fix the problem.

Original issue reported on code.google.com by kyle.nie...@gmail.com on 6 May 2014 at 9:17

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r2936.

Original comment by yarmond on 7 May 2014 at 9:57