Fix 1D solver crash when loglevel > 7 (#2073) - #2162
Open
hazalkoom wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a crash in the 1D solver debug-output path when loglevel > 7 by allowing residual-saving to bypass thermodynamic state evaluation during toArray() serialization.
Changes:
- Adds a
skipThermoparameter toDomain1D::toArray()and propagates it throughFlow1D/Boundary1Dimplementations. - Introduces an internal
Sim1D::save(..., skipThermo)overload and uses it fromsaveResidual()to avoid evaluating thermo on residual vectors. - Adds a Python regression test intended to exercise
loglevel7 vs 8 debug output.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/python/test_onedim.py | Adds a regression test for high loglevels and debug file behavior. |
| src/oneD/Sim1D.cpp | Routes residual saving through toArray(..., skipThermo=true) via an internal save overload. |
| src/oneD/Flow1D.cpp | Skips updateThermo() (and related density/normalization) when skipThermo=true. |
| src/oneD/Boundary1D.cpp | Updates toArray signatures across boundary domains to accept skipThermo. |
| include/cantera/oneD/Sim1D.h | Declares internal save(..., skipThermo) helper. |
| include/cantera/oneD/Flow1D.h | Updates toArray override signature. |
| include/cantera/oneD/Domain1D.h | Extends toArray API contract with skipThermo documentation. |
| include/cantera/oneD/Boundary1D.h | Updates toArray override signatures for boundary domains. |
Suppressed comments (1)
src/oneD/Boundary1D.cpp:767
- The new skipThermo parameter is not used here. When Sim1D::saveResidual() swaps m_state to residuals, this toArray() will still call setCoverages() using non-physical residual values, which can throw and reintroduce the loglevel>7 crash for ReactingSurface1D cases. Handle skipThermo by avoiding any thermo/phase state updates and writing the raw values into the SolutionArray instead.
shared_ptr<SolutionArray> ReactingSurf1D::toArray(bool normalize, bool skipThermo)
{
if (!m_state) {
throw CanteraError("ReactingSurf1D::toArray",
"Domain needs to be installed in a container before calling toArray.");
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
hazalkoom
force-pushed
the
fix-1d-loglevel
branch
from
August 7, 2026 09:35
84ba020 to
e12a85d
Compare
Contributor
Author
|
Addressed review comments and updated the PR:
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2162 +/- ##
==========================================
+ Coverage 78.15% 78.19% +0.04%
==========================================
Files 453 453
Lines 55433 55461 +28
Branches 9115 9123 +8
==========================================
+ Hits 43324 43370 +46
+ Misses 9060 9041 -19
- Partials 3049 3050 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
* Added skipThermo parameter to Domain1D::toArray to avoid evaluating thermodynamic properties when saving solver residuals, which are not valid thermodynamic states. * Updated Flow1D and Boundary1D classes override signatures. * Added a parameterized unit test in test_onedim.py testing loglevel=7 and loglevel=8 to prevent regressions.
hazalkoom
force-pushed
the
fix-1d-loglevel
branch
from
August 7, 2026 10:27
e12a85d to
d138cd2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes proposed in this pull request
This pull request fixes a crash that happens when running the 1D flame solver with a debug log level greater than 7 (for example,
loglevel=8).loglevelis set to 8 or higher, the solver saves the mathematical errors (residuals) todebug_sim1d.yaml. To do this,saveResidual()temporarily copies error values into the main solution vector (m_state). However, when writing the output file,Flow1D::toArray()was callingupdateThermo()onm_state. Because residual values are mathematical errors (not valid thermodynamic state data, and often contain zeros), this caused Cantera to throwtemperature must be positive. T = 0and crash.skipThermoparameter (defaulting tofalse) toDomain1D::toArray()and its derived classes (Flow1D,Boundary1D). WhensaveResidual()outputs residual data,skipThermois set totrue, bypassingupdateThermo()and density evaluations on non-physical residual numbers.test_solve_loglevel_residualtotest/python/test_onedim.pytesting debug output atloglevel7 (solution) and 8 (residual) to prevent regressions.If applicable, fill in the issue number this pull request is fixing
Closes #2073
If applicable, provide an example illustrating new features this pull request is introducing
Not applicable (this is a bug fix).
AI Statement (required)
Significant portions of code and documentation were generated using AI tools, and then reviewed and tested by the contributor. The planning phase was assisted by Claude Opus 4.6, and the execution and coding phase was completed using Gemini pro 3.1.
Checklist
scons build&scons test) and unit tests address code coverage