Skip to content

Add a per-fluid equation-of-state selector - #1700

Open
fahnab666 wants to merge 6 commits into
MFlowCode:masterfrom
fahnab666:feature/eos-selector-v2
Open

Add a per-fluid equation-of-state selector#1700
fahnab666 wants to merge 6 commits into
MFlowCode:masterfrom
fahnab666:feature/eos-selector-v2

Conversation

@fahnab666

@fahnab666 fahnab666 commented Jul 31, 2026

Copy link
Copy Markdown

Adds fluid_pp(i)%eos, a stable enumeration for a fluid's equation of state, in place of the implicit backend selection. This is the second step of the incremental EOS interface.

Only the two backends we already support are accepted:

  • stiffened_gas (default)
  • ideal_gas_mixture (chemistry builds, via Pyrometheus)

mie_gruneisen, jwl, and table are reserved in the enum and rejected until their backends exist.

ideal_gas_mixture is the Pyrometheus mixture backend and is only valid in a chemistry build. On a non-chemistry build it is rejected, not silently downgraded. A plain ideal gas without chemistry is already covered by stiffened_gas with pi_inf = 0, which reduces the stiffened-gas law to the ideal-gas law, so it does not need its own enum value.

The default resolves from the compile-time chemistry flag, so existing cases do not change and the golden suite stays bit-identical (616/616, no goldens regenerated). The selector is validated at input time only, so nothing new enters the per-cell hot path. Case files use the readable names while the integer stays internal. The Fortran and Python checkers both reject unsupported values, ideal_gas_mixture on a non-chemistry build, and mixing EOS families within one run.

Introduce fluid_pp(:)%eos, a stable five-value enumeration
(stiffened_gas, ideal_gas_mixture, mie_gruneisen, jwl, table)
in place of implicit backend selection. Only stiffened_gas (default)
and ideal_gas_mixture (chemistry, Pyrometheus) are backed by an
adapter; the remaining values are reserved and rejected explicitly.

The default resolves from the compile-time chemistry flag, so every
existing case is unchanged and all goldens stay bit-identical, and no
runtime dispatch enters the hot per-cell path. Case files accept
readable names while the integer representation stays internal. The
Fortran and Python checkers reject unsupported values, ideal_gas_mixture
without a chemistry build, and intra-cell EOS mixing (every fluid must
share one family).

The five enum constants are hand-written in m_constants.fpp; the
constant generator skips compound registry keys so the per-fluid
CONSTRAINTS entries drive only readable-name resolution and validation.
State plainly that a plain ideal gas without chemistry is stiffened_gas
with pi_inf = 0, and that ideal_gas_mixture is the Pyrometheus mixture
backend valid only in a chemistry build. This keeps users from reaching
for ideal_gas_mixture on a non-chemistry build, where it is rejected.
@fahnab666
fahnab666 force-pushed the feature/eos-selector-v2 branch from 18786a8 to 7ee3cd3 Compare July 31, 2026 15:02
@fahnab666
fahnab666 marked this pull request as ready for review July 31, 2026 15:04
@fahnab666
fahnab666 requested a review from sbryngelson as a code owner July 31, 2026 15:04
Copilot AI review requested due to automatic review settings July 31, 2026 15:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.79%. Comparing base (8dfe8c7) to head (1a7222f).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1700      +/-   ##
==========================================
+ Coverage   60.77%   60.79%   +0.01%     
==========================================
  Files          83       83              
  Lines       20872    20880       +8     
  Branches     3101     3101              
==========================================
+ Hits        12685    12693       +8     
  Misses       6121     6121              
  Partials     2066     2066              

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

@sbryngelson sbryngelson 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 for this. The plumbing checks out — _r(f"{px}eos", INT, ...) registration means the MPI broadcast is auto-generated correctly as MPI_INTEGER for all three targets, the namelist binds fluid_pp as a derived type so fluid_pp(1)%eos resolves, and the compile-time chemistry parameter makes the pre-namelist-read default correct. The Fortran and Python checkers agree.

Four things to address before merge, mostly around the enum having several hand-synced copies. Details inline.

Separately, worth noting for context rather than as a change request: nothing in src/ currently reads %eos, and both checkers leave exactly one legal value per build since it is fully determined by chemistry. That is defensible as step-2 groundwork, but it is the part I would most want justified given the guidance against config knobs with one correct value.

Comment thread src/common/m_constants.fpp Outdated
Comment thread toolchain/mfc/case_validator.py Outdated
Comment thread toolchain/mfc/case_validator.py Outdated
Comment thread toolchain/mfc/params/definitions.py
than hand-sync the eos integer values, and cover the bubbles_euler slot

Records the fluid_pp(:)%eos hand-written constants as a "still manual"
case in common-pitfalls.md and notes it in the m_constants.fpp comment,
since generate_constants_fpp silently skips compound registry keys.

check_eos in case_validator.py now reads its two supported values from
CONSTRAINTS["fluid_pp(1)%eos"]["names"], the same idiom already used
for recon_type, instead of a third hand-synced copy of 1 and 2.

check_eos (Python) and s_check_eos (Fortran) both now cover the extra
fluid property slot that bubbles_euler uses, matching the existing
check_stiffened_eos pattern; previously fluid_pp(num_fluids+1)%eos
went unvalidated when bubbles_euler was set.

Adds eos to the physical_parameters member list comment in
definitions.py, the registry/type drift guard from MFlowCode#1553.
@fahnab666
fahnab666 requested a review from sbryngelson August 2, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants