Skip to content

Fix multicomponent transport for single-species phases, closes #1823 - #2183

Merged
speth merged 2 commits into
Cantera:mainfrom
GiantWizard:multicomponent-single-species
Nov 24, 2026
Merged

speth merged 2 commits into
Cantera:mainfrom
GiantWizard:multicomponent-single-species

Conversation

@GiantWizard

Copy link
Copy Markdown
Contributor

Changes proposed in this pull request

  • Fix MultiTransport for phases with a single species. The diffusion row and column of the L matrix are entirely zero in this case, so thermal_conductivity and thermal_diff_coeffs failed with a singular matrix error. Setting the diagonal entry to 1 decouples that equation without affecting the other unknowns.
  • Return zero from getMultiDiffCoeffs for a single species instead of inverting a zero matrix, consistent with the zero diagonal returned for multi-species phases.
  • Remove the xfail for multicomponent in test_single_species_transport.

Two adjustments to the test were needed for the multicomponent case:

  1. Conductivity tolerance: the pure-species conductivity in a multi-species phase depends on which other species are defined, even at zero mole fraction. For H2O2 at 500 K and 5 atm, and converging smoothly as the second species goes to zero:

    Phase Conductivity
    H2O2 only (this PR) 0.0622671040
    H2O2 + O2 0.0622671040
    H2O2 + OH 0.0622665695
    H2O2 + H2 0.0622657118
    H2O2 + AR 0.0622745679

    The test's reference phase includes H2, so I used rel=1e-4 for multicomponent only.

  2. Self-diffusion check skipped for multicomponent: computing the multicomponent thermal conductivity overwrites the cached self-diffusion coefficient (m_bdiff(k,k) in updateThermal_T), so mix_diff_coeffs changes after thermal_conductivity is called (9.849677e-06 before, 9.850801e-06 after for the single-species phase). This predates this PR and was previously hidden by the crash. I left it out of scope, but am happy to adjust the test or open a separate issue if preferred.

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

Closes #1823

AI Statement (required)

Extensive use of generative AI. I used Claude Opus 5.5 to analyze the cause of the singular matrix and to investigate the two test discrepancies described above; it suggested the fix approach and the test adjustments. I implemented the C++ changes myself, built and ran the test suite locally, and confirmed the multicomponent case fails without the fix.

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

@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.45%. Comparing base (e906c2f) to head (5615b9f).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2183      +/-   ##
==========================================
- Coverage   78.46%   77.45%   -1.01%     
==========================================
  Files         463      470       +7     
  Lines       55849    57189    +1340     
  Branches     9169     9196      +27     
==========================================
+ Hits        43823    44297     +474     
- Misses       8960     9823     +863     
- Partials     3066     3069       +3     

☔ View full report in Codecov by Harness.
📢 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.

@speth speth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @GiantWizard,

Thanks for preparing this PR. I think the actual code changes look good, but had one suggestion regarding the update to the tests.

For what its worth, small changes to the pure species properties are expected as the species set changes, at least for the current implementation -- the polynomial fits to the collision integrals are done on a grid in $T^*$ that depends on the range of temperatures where the thermo data for all the species is considered valid, and on the L-J parameters of each species.

The funny updating of m_bdiff is a separate issue that probably should be fixed, but I don't think we should drag that into the current PR.

Comment thread test/python/test_transport.py Resolved
@bryanwweber

Copy link
Copy Markdown
Member

The funny updating of m_bdiff is a separate issue that probably should be fixed, but I don't think we should drag that into the current PR.

Can we create a new issue to track this error? I think @GiantWizard offered to do that 😄

@GiantWizard

Copy link
Copy Markdown
Contributor Author

Updated test_single_species_transport to restore the mix_diff_coeffs assertion with rel=rtol for all models, and opened #2209 to track the m_bdiff(k, k) overwrite in MultiTransport::updateThermal_T().

@speth speth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, @GiantWizard. This looks good to me.

@speth
speth merged commit 25c494f into Cantera:main Nov 24, 2026
49 of 51 checks passed
@GiantWizard
GiantWizard deleted the multicomponent-single-species branch November 24, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multicomponent transport model fails for single-species phases

4 participants