Skip to content

Conversation

@ischoegl
Copy link
Member

@ischoegl ischoegl commented Oct 12, 2025

Changes proposed in this pull request

Add a missing updateThermo call prior to export as SolutionArray. This ensures consistent thermodynamic states.

  • Fixes Flow1D::toArray
  • Add Domain1D.info to Python API (same as SolutionArray.info)

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

Closes #2007

If applicable, provide an example illustrating new features this pull request is introducing

>>> import cantera as ct
>>> gas = ct.Solution("h2o2.yaml")
>>> gas.set_equivalence_ratio(1., "H2", "O2:0.21,N2:0.79")
>>> stack = ct.FreeFlame(gas)
>>> stack.flame.set_profile("T", [0, 0.3, 0.7, 1], [300, 300, 2000, 2000])
>>> stack.flame.set_profile("velocity", [0, 0.3, 0.7, 1], [.3, .3, .3 * 20/3, .3 * 20/3])
>>> stack.flame.info()
     grid velocity     T         D         H2    H    O        O2   OH  H2O  HO2 H2O2   AR        N2
0   0.000   0.3000   300  0.849553  0.0285116    0    0  0.226269    0    0    0    0    0  0.745220
1   0.020   0.3000   300  0.849553  0.0285116    0    0  0.226269    0    0    0    0    0  0.745220
2   0.040   0.7250   725  0.351539  0.0285116    0    0  0.226269    0    0    0    0    0  0.745220
3   0.060   1.5750  1575  0.161820  0.0285116    0    0  0.226269    0    0    0    0    0  0.745220
4   0.080   2.0000  2000  0.127433  0.0285116    0    0  0.226269    0    0    0    0    0  0.745220
5   0.100   2.0000  2000  0.127433  0.0285116    0    0  0.226269    0    0    0    0    0  0.745220

[6 rows x 14 components; state='TDY']
>>> stack.inlet.info()
      T         D         H2    H    O        O2   OH  H2O  HO2 H2O2   AR        N2
0   300  0.849553  0.0285116    0    0  0.226269    0    0    0    0    0  0.745220

[1 rows x 12 components; state='TDY']

Other thoughts

Inconsistent states are only present prior to the first call to Sim1D.solve; any subsequent output will be consistent as long as states are not overwritten. While SolutionArray with inconsistent states may have been saved in prior versions of Cantera, a re-import to Sim1D / Domain1D will still work correctly, as an inconsistent density D is ignored. The same is not true if an inconsistent SolutionArray is imported directly; in that case, states will be set using Solution.TDY with an incorrect pressure trace.

Checklist

  • The pull request includes a clear description of this code change
  • Commit messages have short titles and reference relevant issues
  • Build passes (scons build & scons test) and unit tests address code coverage
  • Style & formatting of contributed code follows contributing guidelines
  • The pull request is ready for review

@ischoegl ischoegl force-pushed the fix-Domain1D-toArray branch from 83056dc to 6695071 Compare October 12, 2025 22:31
@codecov
Copy link

codecov bot commented Oct 12, 2025

Codecov Report

❌ Patch coverage is 45.45455% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.22%. Comparing base (a6a341e) to head (330ba12).
⚠️ Report is 27 commits behind head on main.

Files with missing lines Patch % Lines
interfaces/cython/cantera/_onedim.pyx 21.42% 11 Missing ⚠️
interfaces/cython/cantera/solutionbase.pyx 71.42% 2 Missing ⚠️
src/oneD/Boundary1D.cpp 71.42% 2 Missing ⚠️
src/oneD/Domain1D.cpp 0.00% 2 Missing ⚠️
include/cantera/oneD/Domain1D.h 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2008      +/-   ##
==========================================
- Coverage   75.24%   75.22%   -0.02%     
==========================================
  Files         454      454              
  Lines       56756    56776      +20     
  Branches     9373     9373              
==========================================
+ Hits        42704    42710       +6     
- Misses      10873    10887      +14     
  Partials     3179     3179              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ischoegl ischoegl marked this pull request as ready for review October 13, 2025 00:40
@ischoegl ischoegl requested a review from a team October 13, 2025 00:40
@ischoegl ischoegl requested a review from speth October 13, 2025 20:06
Copy link
Member

@speth speth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is OK with me, with a couple of minor changes.

@ischoegl
Copy link
Member Author

This is OK with me, with a couple of minor changes.

Thanks, @speth! Change requests are addressed.

@ischoegl ischoegl requested a review from speth October 19, 2025 02:42
@ischoegl ischoegl merged commit 7e21f3e into Cantera:main Oct 19, 2025
47 of 49 checks passed
@ischoegl ischoegl deleted the fix-Domain1D-toArray branch October 19, 2025 04:58
@speth speth mentioned this pull request Oct 24, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Domain1D::toArray may not represent correct thermodynamic states

2 participants