Cantera / cantera

Chemical kinetics, thermodynamics, and transport tool suite
https://cantera.org
Other
581 stars 342 forks source link

Fix minor issues in ck2yaml and test suite #1669

Closed ischoegl closed 4 months ago

ischoegl commented 4 months ago

Fix glitch in test suite / improve exception handling

If applicable, fill in the issue number this pull request is fixing

Closes #1666, closes #1656

Illustration

Using the minimal example from #1656 (issue reporting unhelpful exception handling), the output is now

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

ERROR: Cannot specify a surface mechanism without a gas phase

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/opt/homebrew/Caskroom/miniforge/base/envs/cantera-dev/lib/python3.11/site-packages/cantera/ck2yaml.py", line 2316, in <module>
    main()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/cantera-dev/lib/python3.11/site-packages/cantera/ck2yaml.py", line 2199, in main
    parser, surfaces = Parser.convert_mech(input_file, thermo_file,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/cantera-dev/lib/python3.11/site-packages/cantera/ck2yaml.py", line 2051, in convert_mech
    raise InputError(msg)
InputError: Cannot specify a surface mechanism without a gas phase
Please check https://cantera.org/stable/userguide/ck2yaml-tutorial.html#debugging-common-errors-in-ck-files
for the correct Chemkin syntax.

Checklist