Skip to content

Explicit per-fluid equation-of-state selector#1664

Closed
fahnab666 wants to merge 1 commit into
MFlowCode:masterfrom
fahnab666:feature/eos-selector
Closed

Explicit per-fluid equation-of-state selector#1664
fahnab666 wants to merge 1 commit into
MFlowCode:masterfrom
fahnab666:feature/eos-selector

Conversation

@fahnab666

@fahnab666 fahnab666 commented Jul 21, 2026

Copy link
Copy Markdown

Description

Second step of the incremental multi-equation-of-state (EOS) interface: an explicit, stable per-fluid EOS selector in place of scattered booleans. Each fluid carries an integer fluid_pp(i)%eos drawn from a five-value enumeration:

Name Value Status
stiffened_gas 1 exposed (default)
ideal_gas_mixture 2 exposed (chemistry)
mie_gruneisen 3 reserved, rejected
jwl 4 reserved, rejected
table 5 reserved, rejected

Only the already-supported backends are exposed: stiffened gas stays the default, and ideal_gas_mixture (Pyrometheus) is used when chemistry = T. The remaining three values are defined for forward compatibility but explicitly rejected at validation, so no unsupported combination can be selected. Case files use readable names, e.g. "fluid_pp(1)%eos": "stiffened_gas"; the integer representation is internal.

No hot-path change: %eos is written as a default and read only in validation, never in a flux / Riemann / pressure / RHS path. The default merge(eos_ideal_gas_mixture, eos_stiffened_gas, chemistry) reproduces prior solver assumptions exactly, so results are unchanged.

Unsupported (eos, feature) combinations are rejected in both layers, correctly placed: the shared Fortran runtime checker (s_check_eos in m_checker_common.fpp) and the Python static validator (check_eos in case_validator.py, with a PHYSICS_DOCS entry). The toolchain auto-generation is preserved, including a compound-key skip in generate_constants_fpp so the fluid_pp(1)%eos key does not emit an invalid Fortran identifier.

Type of change

  • New feature (non-breaking)

Testing

Full golden suite bit-identical across all three targets (pre_process, simulation, post_process) on gfortran; no golden files changed, since %eos never enters a numerical path. Validation behavior: unsupported (eos, feature) pairs are rejected with a clear message, readable names resolve to the enum, and a chemistry case resolves to ideal_gas_mixture.

This PR is independent of #1663 (central thermodynamics interface): the branch sits directly on master, shares no symbols with that PR, and the two touch m_global_parameters_common.fpp only in disjoint regions, so they can be reviewed and merged in either order.

Related

Part of the incremental EOS ladder tracked in #1638. Ladder so far: PR 1 #1663 (central thermodynamics interface), PR 2 #1664 (explicit EOS selector), PR 3 #1665 (generic Mie-Gruneisen core); JWL follows as a Mie-Gruneisen reference curve. The three open PRs are independent and can be reviewed in parallel.

Introduce fluid_pp(:)%eos, a stable five-value enumeration
(stiffened_gas, ideal_gas_mixture, mie_gruneisen, jwl, table)
replacing 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 all
existing goldens stay bit-identical, and no runtime dispatch enters
the hot per-cell path. Case files accept readable names; the integer
representation stays internal. Checkers (Fortran and Python) 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 now skips compound registry keys so the per-fluid
CONSTRAINTS entries drive only readable-name resolution and validation.
Copilot AI review requested due to automatic review settings July 21, 2026 05:15
@fahnab666
fahnab666 requested a review from sbryngelson as a code owner July 21, 2026 05:15

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.

Pull request overview

Introduces an explicit per-fluid equation-of-state (EOS) selector (fluid_pp(i)%eos) to replace scattered boolean selection, while keeping current behavior unchanged by default and rejecting unsupported EOS options in both Python and Fortran validation layers.

Changes:

  • Add fluid_pp(:)%eos to the Fortran physical-parameters type and initialize it consistently across pre_process/simulation/post_process.
  • Extend the Python parameter registry and static validator to accept readable EOS names and reject unsupported (eos, chemistry) combinations with documented guidance.
  • Prevent auto-generation of invalid Fortran enum identifiers for compound keys, and define EOS enum constants centrally in m_constants.fpp.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
toolchain/mfc/params/generators/fortran_gen.py Skips enum-constant emission for compound/indexed keys that can’t form valid Fortran identifiers.
toolchain/mfc/params/descriptions.py Adds a description entry for fluid_pp(i)%eos.
toolchain/mfc/params/definitions.py Registers fluid_pp(i)%eos with name→int mapping and value labels for toolchain parsing/validation.
toolchain/mfc/case_validator.py Adds check_eos plus documentation entry and wires it into common validation.
src/simulation/m_global_parameters.fpp Initializes fluid_pp(i)%eos default based on chemistry.
src/pre_process/m_global_parameters.fpp Initializes fluid_pp(i)%eos default based on chemistry.
src/post_process/m_global_parameters.fpp Initializes fluid_pp(i)%eos default based on chemistry.
src/common/m_global_parameters_common.fpp Re-exports EOS enum constants needed for defaults/checks.
src/common/m_derived_types.fpp Adds eos field to physical_parameters type.
src/common/m_constants.fpp Defines stable EOS enum constants (eos_*).
src/common/m_checker_common.fpp Adds Fortran-side runtime check s_check_eos and calls it from common input checking.
docs/documentation/case.md Documents the new fluid_pp(i)%%eos parameter and current supported options.

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.47%. Comparing base (0857ace) to head (d919207).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1664      +/-   ##
==========================================
+ Coverage   59.46%   59.47%   +0.01%     
==========================================
  Files          83       83              
  Lines       21170    21178       +8     
  Branches     3135     3135              
==========================================
+ Hits        12588    12596       +8     
  Misses       6476     6476              
  Partials     2106     2106              

☔ 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 marked this pull request as draft July 21, 2026 12:32
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