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

Provide better error message when converting surface mechanism without providing gas phase input #1656

Closed
speth opened this issue Jan 8, 2024 · 0 comments · Fixed by #1669
Labels
Input Input parsing and conversion (for example, ck2yaml)

Comments

@speth
Copy link
Member

speth commented Jan 8, 2024

Problem description

Generally, converting a surface mechanism from Chemkin format, separate input files are needed for both the surface and gas phase. If only the surface input file is provided, it should be relatively easy to suggest that the missing gas phase file is the problem. However, the current error message is somewhat difficult for a human to parse.

Steps to reproduce

From the Cantera source directory, run:

python -m cantera.ck2yaml --thermo=test/data/surface2-thermo.dat --surface=test/data/surface2.inp

Behavior

Resulting output:

Error reading reaction starting on line 6:
"""
 H2 + 2_Pt_  => 2H_Pt                        4.4579E+10  0.5   0.0
					  FORD/_Pt_  1/
"""

ERROR: Unable to parse 'test/data/surface2.inp' near line 6:
Unexpected token "H2+2" in reaction expression "H2+2_Pt_=>2H_Pt
".
Please check https://cantera.org/stable/userguide/ck2yaml-tutorial.html#debugging-common-errors-in-ck-files
for the correct Chemkin syntax.

Traceback (most recent call last):
  File "/Users/speth/src/cantera/build/python/cantera/ck2yaml.py", line 1059, in read_kinetics_entry
    locs[j] = int(token), 'coeff'
              ^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'H2+2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/speth/src/cantera/build/python/cantera/ck2yaml.py", line 1062, in read_kinetics_entry
    locs[j] = float(token), 'coeff'
              ^^^^^^^^^^^^
ValueError: could not convert string to float: 'H2+2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/speth/src/cantera/build/python/cantera/ck2yaml.py", line 2312, in <module>
    main()
  File "/Users/speth/src/cantera/build/python/cantera/ck2yaml.py", line 2195, in main
    parser, surfaces = Parser.convert_mech(input_file, thermo_file,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/speth/src/cantera/build/python/cantera/ck2yaml.py", line 2054, in convert_mech
    parser.load_chemkin_file(surface_file, surface=True)
  File "/Users/speth/src/cantera/build/python/cantera/ck2yaml.py", line 1788, in load_chemkin_file
    reaction, revReaction = self.read_kinetics_entry(kinetics, surface)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/speth/src/cantera/build/python/cantera/ck2yaml.py", line 1064, in read_kinetics_entry
    raise InputError('Unexpected token "{}" in reaction expression "{}".',
InputError: Unexpected token "H2+2" in reaction expression "H2+2_Pt_=>2H_Pt
".
Please check https://cantera.org/stable/userguide/ck2yaml-tutorial.html#debugging-common-errors-in-ck-files
for the correct Chemkin syntax.

From which the user is supposed to infer that the problem is the lack of a definition of the species "H2".

System information

  • Cantera version: main at 811ffbc
  • OS: macOS 14.2.1
  • Python 3.11
@speth speth added the Input Input parsing and conversion (for example, ck2yaml) label Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Input Input parsing and conversion (for example, ck2yaml)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant