Skip to content

Vectorize Redlich-Kwong property calculations#2099

Draft
speth wants to merge 5 commits intoCantera:mainfrom
speth:eigen-RK-v2
Draft

Vectorize Redlich-Kwong property calculations#2099
speth wants to merge 5 commits intoCantera:mainfrom
speth:eigen-RK-v2

Conversation

@speth
Copy link
Member

@speth speth commented Mar 10, 2026

Changes proposed in this pull request

  • Use Eigen to vectorize most property calculations in RedlichKwongMFTP
  • Rename some internal variables in RedlichKwongMFTP to have simpler, more clear names

This should wait until after #2087 is resolved to avoid introducing merge conflicts there -- I'll resolve those conflicts in this PR.

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

Besides simplifying the implementation, this provides a substantial speed benefit to the calculations -- more than I was expecting. Average time for the cases in the non_ideal_shock_tube.py example (using the main branch after merging #2094 as a baseline):

  • Baseline
    • MoleReactor (no preconditioner): 5.525 s
    • IdealGasMoleReactor without preconditioner: 1.988 s
    • IdealGasMoleReactor with preconditioner: 1.004 s
  • Vectorized
    • MoleReactor (no preconditioner): 1.131 s
    • IdealGasMoleReactor without preconditioner: 0.345 s
    • IdealGasMoleReactor with preconditioner: 0.228 s

So this provides another factor of 4 speed up, on top of the performance gains from #2094, and brings the Redlich-Kwong integration time to within about a factor of 2 compared to a calculation using the ideal gas model.

AI Statement (required)

  • Extensive use of generative AI. 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. Prepared with the help of ChatGPT Codex 5.3.

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
  • AI Statement is included
  • The pull request is ready for review

@speth speth added the Thermo label Mar 10, 2026
@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 97.46835% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.57%. Comparing base (d13048d) to head (d7ee85f).

Files with missing lines Patch % Lines
src/thermo/RedlichKwongMFTP.cpp 97.27% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2099      +/-   ##
==========================================
- Coverage   77.63%   77.57%   -0.06%     
==========================================
  Files         451      452       +1     
  Lines       53045    52944     -101     
  Branches     8853     8805      -48     
==========================================
- Hits        41179    41071     -108     
- Misses       8889     8895       +6     
- Partials     2977     2978       +1     

☔ 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.

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.

1 participant