Skip to content

Reject chemistry with num_fluids > 1 in case validator#1472

Merged
sbryngelson merged 1 commit into
masterfrom
chem-multifluid-guard
May 31, 2026
Merged

Reject chemistry with num_fluids > 1 in case validator#1472
sbryngelson merged 1 commit into
masterfrom
chem-multifluid-guard

Conversation

@sbryngelson
Copy link
Copy Markdown
Member

Description

Closes #1470.

Chemistry in MFC assumes a single reacting gas phase and is not coupled to the multi-fluid (5-equation) model. When chemistry = T is combined with num_fluids > 1, the simulation silently produces NaN rather than erroring out. Two paths in src/common/m_variables_conversion.fpp are responsible:

  1. The chemistry branch of s_convert_conservative_to_primitive_variables overwrites all partial densities (qK_prim_vf(1:num_fluids)) with the species-summed total density — correct for num_fluids = 1, destructive otherwise.
  2. s_compute_pressure recovers temperature from the total internal energy via Cantera's ideal-gas EOS, ignoring pi_inf. With a second stiffened-gas fluid present (e.g. a water droplet, pi_inf ~ 4e8), the inversion diverges and NaN propagates.

Full multi-fluid + chemistry coupling is a larger, research-level effort. This PR is the short-term fix: a case-validator guard that rejects the unsupported combination with a clear message instead of leaving users to debug NaNs. Both chemistry and num_fluids are known at case-definition time, so the guard lives in Python (case_validator.py); no Fortran-side check is needed.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Scope

  • Adds one prohibit to CaseValidator.check_chemistry, mirroring the existing mhd and num_fluids != 1 guard.

How Has This Been Tested?

Validator unit-checked directly:

  • chemistry='T', num_fluids=2 -> rejected with "chemistry is only supported for single-component flows (num_fluids = 1)"
  • chemistry='T', num_fluids=1 -> passes (no regression for existing chemistry examples, all of which use num_fluids = 1)
  • num_fluids=2 without chemistry -> passes (unaffected)
  • chemistry='T' with num_fluids unset -> passes (deferred to existing model_eqns/num_fluids check)

ruff check and ruff format --check pass on the changed file.

Checklist

  • I have added a concise diagnostic message
  • My change is a single logical commit
  • ruff lint/format pass

Copilot AI review requested due to automatic review settings May 31, 2026 12:44
@sbryngelson sbryngelson added bug Something isn't working or doesn't seem right documentation Improvements or additions to documentation labels May 31, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a case-validator guard to reject unsupported chemistry configurations with more than one fluid, preventing known NaN-producing multi-fluid chemistry runs from reaching the Fortran simulation path.

Changes:

  • Reads num_fluids in CaseValidator.check_chemistry.
  • Prohibits chemistry = T when num_fluids is set to a value other than 1.
  • Adds an explanatory comment tying the guard to the single-reacting-gas chemistry assumption.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.31%. Comparing base (574e53d) to head (797eea9).
⚠️ Report is 12 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1472   +/-   ##
=======================================
  Coverage   61.31%   61.31%           
=======================================
  Files          72       72           
  Lines       19771    19771           
  Branches     2852     2852           
=======================================
  Hits        12123    12123           
  Misses       5699     5699           
  Partials     1949     1949           

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

@sbryngelson sbryngelson merged commit 016c763 into master May 31, 2026
95 checks passed
@sbryngelson sbryngelson deleted the chem-multifluid-guard branch May 31, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working or doesn't seem right documentation Improvements or additions to documentation

Development

Successfully merging this pull request may close these issues.

MFC does not work when multi-fluid and chemistry are set at the same time

2 participants