ck2yaml: IndexError on an empty THERMO section in the input file

Open Beginner friendly
#2,204 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
tooling

Research direction

Start by reading parse_nasa7_section in ck2yaml.py around line 952, where the traceback shows the failing access to the empty THERMO section. Reproduce with the provided chem.inp and therm.dat using the documented python -m cantera.ck2yaml command. Done when the empty section is ignored or produces a regular input error instead of an uncaught IndexError.

Written by the indexing model from the issue text.

Description

ck2yaml stops with an uncaught IndexError when the input file has an empty THERMO section (THERMO followed directly by END) and the thermo data is given in a separate --thermo file.

Steps to reproduce

chem.inp:

ELEMENTS
H
END
SPECIES
H H2
END
THERMO
END
REACTIONS
H + H + M = H2 + M   1.0E18 -1.0 0.0
END

therm.dat:

THERMO
   300.000  1000.000  5000.000
H                 SYNTH H   1               G   300.000  5000.000 1000.00      1
 2.50000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00    2
 2.50000000E+04 5.00000000E-01 2.50000000E+00 0.00000000E+00 0.00000000E+00    3
 0.00000000E+00 0.00000000E+00 2.50000000E+04 5.00000000E-01                   4
H2                SYNTH H   2               G   300.000  5000.000 1000.00      1
 3.50000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00    2
-1.00000000E+03-3.00000000E+00 3.50000000E+00 0.00000000E+00 0.00000000E+00    3
 0.00000000E+00 0.00000000E+00-1.00000000E+03-3.00000000E+00                   4
END
python -m cantera.ck2yaml --input=chem.inp --thermo=therm.dat --output=out.yaml

Behavior

  File ".../ck2yaml.py", line 952, in parse_nasa7_section
    TintDefault = float(lines[1, 2].split()[1])
IndexError: list index out of range

parse_nasa7_section reads the second line of the section as the temperature line, but the section has no second line. Expected: the empty section is ignored, or a regular input error is reported.

System information

  • Cantera 3.2.0 (Python 3.13, Linux); also reproduced with ck2yaml.py of main at 25c1ab1 (line 952).
Dominant language
C++
Stars
885
Forks
438
Avg merge
3h 41m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Cantera/cantera

All issues in Cantera/cantera

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.