Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Floating point geometry flags cause ck2cti error #446

Closed
bryanwweber opened this issue Apr 4, 2017 · 2 comments
Closed

Floating point geometry flags cause ck2cti error #446

bryanwweber opened this issue Apr 4, 2017 · 2 comments
Labels
bug Input Input parsing and conversion (for example, ck2yaml)

Comments

@bryanwweber
Copy link
Member

bryanwweber commented Apr 4, 2017

Cantera version

2.3.0

Operating System

Linux (but should apply to any)

Python/MATLAB version

Any

Expected Behavior

Parse attached transport data

Actual Behavior

Traceback (most recent call last):
  File "/home/bryan/miniconda3/bin/ck2cti", line 6, in <module>
    sys.exit(cantera.ck2cti.script_entry_point())
  File "/home/bryan/miniconda3/lib/python3.6/site-packages/cantera/ck2cti.py", line 2299, in script_entry_point
    main(sys.argv[1:])
  File "/home/bryan/miniconda3/lib/python3.6/site-packages/cantera/ck2cti.py", line 2272, in main
    permissive=permissive)
  File "/home/bryan/miniconda3/lib/python3.6/site-packages/cantera/ck2cti.py", line 2204, in convertMech
    self.parseTransportData(lines, transportFile, 1)
  File "/home/bryan/miniconda3/lib/python3.6/site-packages/cantera/ck2cti.py", line 1952, in parseTransportData
    self.speciesDict[speciesName].transport = TransportData(*data, comment=comment)
  File "/home/bryan/miniconda3/lib/python3.6/site-packages/cantera/ck2cti.py", line 850, in __init__
    if int(geometry) not in (0,1,2):
ValueError: invalid literal for int() with base 10: '1.00'

Steps to reproduce

  1. ck2cti --input=chem.txt --thermo=therm.txt --transport=tran.txt

The error is because some of the geometry flags are specified as 1.00. In Python, parsing a string to an integer with the int object requires the string to be a representation of an integer, it doesn't cast a floating point string representation to an integer, and instead raises that ValueError. It would be nice if we handled this more gracefully, either by doing the casting ourselves or by raising a helpful error message.

(Reported by Kyle Linevitch at UConn)

@speth
Copy link
Member

speth commented Apr 5, 2017

  • I don't see any non-integer geometry flags in the attached tran.txt file, so how this error is occurring is a bit unclear to me
  • The attached chem.txt is actually the CTI file, not the Chemkin-format mechanism, so I can't test the behavior.

@bryanwweber
Copy link
Member Author

bryanwweber commented Apr 5, 2017

Shoot... my bad. I originally uploaded the modified copies >_< The problem files are on this post.

tran.txt
therm.txt
chem.txt

bryanwweber added a commit to bryanwweber/cantera that referenced this issue Jun 13, 2017
If floating point geometry flags are specified rather than integers, intercept the
ValueError raised by Python and raise a more sensible exception.

Fixes Cantera#446
@bryanwweber bryanwweber added bug Input Input parsing and conversion (for example, ck2yaml) labels Jun 14, 2017
decaluwe pushed a commit to decaluwe/cantera that referenced this issue Jun 29, 2017
If geometry flags are specified rather that can't be cast to integers,
intercept the ValueError raised by Python and raise a more sensible
exception.

Fixes Cantera#446
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Input Input parsing and conversion (for example, ck2yaml)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants