Repository navigation
Fix 2129 nasa9 reference pressure - #2174
Conversation
NASA 9-coefficient polynomials (McBride et al. 2002, NASA TP-2002-211556) use a standard reference pressure of 1 bar (100,000 Pa). When the reference-pressure field was omitted in YAML files, Cantera defaulted to 1 atm (101,325 Pa), causing a slight offset in standard entropy calculations. - Emit reference-pressure: 1 bar for NASA9 entries in ck2yaml and ctml2yaml - Explicitly specify reference-pressure: 1 bar for species in airNASA9.yaml and test datasets - Add regression tests in test_thermo.py Fixes Cantera#2129
Fixes mypy / stubtest type check error.
There was a problem hiding this comment.
🔵 Needs a closer look
The NASA9 converters may incorrectly apply 1 bar to condensed-phase species instead of preserving their 1 atm reference pressure.
Pull request overview
Fixes NASA9 reference-pressure handling by applying the 1 bar standard and adding regression coverage.
Changes:
- Updates NASA9 YAML data and fixtures with explicit reference pressures.
- Updates CK/CTML conversion metadata and Python typing.
- Adds pressure and entropy regression tests.
File summaries
| File | Reviewed change |
|---|---|
test/python/test_thermo.py |
Adds NASA9 pressure and entropy tests. |
test/data/nasa9-test.yaml |
Updates NASA9 reference-pressure fixtures. |
test/data/nasa9-test-subset.yaml |
Updates subset fixture pressures. |
test/data/nasa9-embedded.yaml |
Updates embedded NASA9 pressures. |
interfaces/cython/cantera/speciesthermo.py |
Extends thermo input typing. |
interfaces/cython/cantera/ctml2yaml.py |
Updates NASA9 reference-pressure conversion. |
interfaces/cython/cantera/ck2yaml.py |
Updates NASA9 reference-pressure conversion. |
data/airNASA9.yaml |
Sets explicit 1 bar references. |
Review details
Suppressed comments (2)
interfaces/cython/cantera/ck2yaml.py:225
- This hard-codes 1 bar for every NASA9 entry, but NASA9 is also used for condensed species:
Nasa9Poly1documents 1 bar for gases and 1 atm for condensed phases (include/cantera/thermo/Nasa9Poly1.h:48-50).ck2yamlhas no phase information here, so converting condensed NASA9 data such as thenasa_condensed.yamlsource will silently change its reference pressure from the current 1 atm default. Please make the emission phase-aware or preserve the condensed-phase default.
out['reference-pressure'] = '1 bar'
interfaces/cython/cantera/ctml2yaml.py:1663
- The fallback has the same phase ambiguity for XML conversion: when
P0/Prefis absent, this changes NASA9 condensed species to 1 bar even though the model documentation specifies 1 atm for condensed phases.SpeciesThermo.NASA9only receives the thermo node, so it cannot safely choose 1 bar without phase context; otherwise this conversion changes the prior default behavior.
thermo_attribs["reference-pressure"] = 1.0e5
- Files reviewed: 8/8 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2174 +/- ##
==========================================
- Coverage 78.46% 77.45% -1.02%
==========================================
Files 463 470 +7
Lines 55849 57184 +1335
Branches 9169 9195 +26
==========================================
+ Hits 43823 44292 +469
- Misses 8960 9823 +863
- Partials 3066 3069 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Only write reference-pressure when P0/Pref is explicitly present in the source XML. This avoids incorrect defaults for condensed-phase species where the standard state pressure is 1 atm, not 1 bar.
…erage - In ck2yaml, inspect column 52 (phase flag) of NASA9 entries. Gas-phase species (flag 0) emit reference-pressure: 1 bar, while condensed-phase species (flag > 0) omit reference-pressure, preserving the 1 atm default. - In ctml2yaml, only check P0 on NASA9 elements to eliminate partial branch. - Add tests in test_convert.py covering both gas and condensed NASA9 conversion in ck2yaml and CTML conversion without P0.
Fixes stubtest consistency check in typing workflow.
Summary of Updates & Fixes Since Initial SubmissionFollowing CI checks and review feedback, here is what was identified and updated:
|
speth
left a comment
There was a problem hiding this comment.
Thanks for putting this together, @hazalkoom, and sorry for the delayed review. I think this all looks good, with one minor suggestion for a comment noted below.
no problem about the delay, updated the comment like you suggested. |
speth
left a comment
There was a problem hiding this comment.
Thanks for the quick update! Looks good to me.
Changes proposed in this pull request
reference-pressure: 1 baron all species indata/airNASA9.yamland test YAML reference files.ck2yaml.pyandctml2yaml.pyto emitreference-pressure: 1 barwhen converting NASA9 polynomials to YAML._SpeciesThermoInputTypedDict inctml2yaml.pyandspeciesthermo.pyto include"reference-pressure".test/python/test_thermo.pyto verify that NASA9 species load with 1 bar reference pressure and evaluate standard entropy matching NIST values.Background:
NASA 9-coefficient polynomials (McBride et al. 2002, NASA TP-2002-211556 / NASA ThermoBuild) use a standard reference pressure of 1 bar (100,000 Pa). When
reference-pressurewas omitted in YAML files, Cantera defaulted to 1 atm (101,325 Pa), causing a ~0.109 J/mol/K offset in standard entropy calculations ($R \ln(101325 / 100000)$).If applicable, fill in the issue number this pull request is fixing
Closes #2129
If applicable, provide an example illustrating new features this pull request is introducing
(Bug fix / standard-state correction only).
AI Statement (required)
Significant portions of code or documentation were generated with AI, including
logic and implementation decisions. All generated code and documentation were
reviewed and understood by the contributor. Examples: Output from agentic coding
tools and/or substantial refactoring by LLMs (web-based or local).
Checklist
scons build&scons test) and unit tests address code coverage