Skip to content

Tags: MFlowCode/MFC

Tags

v5.3.2

Toggle v5.3.2's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
fix: inline Fortran constant defaults in _fc() to prevent Homebrew sy…

…nc failures (#1419)

* fix: inline Fortran constant defaults in _fc() to prevent Homebrew sync failures

Previously, _fc() raised if a constant was absent from _FALLBACK_CONSTANTS,
a separate dict that could silently drift from definitions.py. This caused
the v5.3.1 Homebrew build to fail: NIB = _fc('num_ib_patches_max') was added
to definitions.py but _FALLBACK_CONSTANTS was never updated, so every Homebrew
install hit a RuntimeError on startup.

Fix: _fc(name, default) now requires an inline default — the default lives
alongside the call, so they can't get out of sync. Remove _FALLBACK_CONSTANTS
and simplify get_fortran_constants() to return {} when src/ is unavailable.

* fix: restore drift detection in _fc() — raise when src/ is present but key is missing

v5.3.1

Toggle v5.3.1's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
feat: FP stability CI (Verrou) + reduced-energy scheme + HLLC xi-fact…

…or fix (#1403)

* feat: add fp-stability command for Verrou-based FP instability testing

Adds ./mfc.sh fp-stability — a persistent floating-point stability test
suite using Verrou's random IEEE-754 rounding mode.

For each registered test case the runner:
  1. Generates initial conditions via pre_process
  2. Runs simulation once with --rounding-mode=nearest (reference)
  3. Runs simulation N times with --rounding-mode=random
  4. Reports max L-inf deviation vs threshold (PASS/FAIL)

Two cases probe known ill-conditioning in MFC:
  - sod_strong: 1-D Sod p_L/p_R=100,000 — HLLC xi-factor cancellation
    (s_L - vel_L)/(s_L - s_S) near sonic contact
  - water_stiffened: 1-D water shock pi_inf=4046 — pressure recovery
    p=(E-pi_inf)/gamma loses ~4 decimal digits on low-pressure side

Requires a Verrou-enabled Valgrind at $VERROU_HOME/bin/valgrind
(default: $HOME/.local/verrou). Silently skips if not found.
Binaries are auto-discovered from build/install/ or passed explicitly.

* ci: add weekly FP stability workflow using Verrou

* ci: trigger fp-stability on every push

* ci: remove concurrency group from fp-stability

* style: collapse multi-line raise ValueError to satisfy CI ruff formatter

* feat: add sod_standard baseline, enlarge cases, run dd_sym on failure

- Add sod_standard (p_L/p_R=10, well-conditioned, threshold=1e-13) as a
  canary that should always pass under any FP rounding
- Enlarge sod_strong and water_stiffened from 25→50 cells and 5→10 steps
  to give Verrou more arithmetic to perturb and raise sensitivity
- Run verrou_dd_sym automatically on any failing case: generates dd_run.sh
  and dd_cmp.py per case, sets PYTHONPATH for verrou Python libs, saves
  rddmin_summary and full logs to fp-stability-logs/ (uploaded as CI artifact)
- Add python3-numpy to CI apt-get and upload-artifact step (if: always())

* feat: add float proxy, VPREC sweep, dd_line, air_water_interface case

- Add four new test cases total: sod_standard, sod_strong, water_stiffened,
  air_water_interface (two-fluid isobaric contact, stiffened EOS)
- Feature B: float-proxy run (--rounding-mode=float) measures single-precision
  sensitivity without recompiling; skippable with --no-float-proxy
- Feature C: VPREC mantissa sweep at [52,23,16,10] bits shows precision floor
  curve for each case; skippable with --no-vprec
- Feature D: verrou_dd_sym symbol-level delta-debug on failure; --no-dd-sym
- Feature E: verrou_dd_line source-line delta-debug on failure; --no-dd-line
- Add --no-float-proxy/--no-vprec/--no-dd-sym/--no-dd-line CLI flags
- Remove dead _max_diff() function (superseded by _max_diff_np())
- Update FP_STABILITY_COMMAND description to document all 4 cases and features

* fix: add missing air_water_interface case input files

* fix: add alpha(2) for both patches in air_water_interface pre_process.inp

* fix: add reduced-energy (E-tilde) scheme for model_eqns=2 FP stability

Store Ẽ = E - pi_inf_mix (reduced energy) in the conserved energy slot
for the Allaire 5-equation model (model_eqns=2). This eliminates
catastrophic cancellation when recovering pressure via
p = (Ẽ - KE - qv)/gamma vs the old p = (E - pi_inf - KE - qv)/gamma
where pi_inf >> p (e.g. water: pi_inf=4046 >> p=1).

Key changes:
- m_variables_conversion.fpp: scope Ẽ storage to model_eqns=2 only;
  add explicit model_eqns=1/3 branch (physical E) to avoid fallthrough
  to Tait EOS for model_eqns=3 (Saurel 6-equation)
- m_riemann_solvers.fpp: HLL and LF non-MHD blocks use Ẽ as states
  with pi_inf added back for enthalpy H; HLLC Block 1 (model_eqns=3)
  and Block 4 (model_eqns=2) retain their existing correct handling;
  xi-factor denominators protected with sgm_eps (Fix 1)
- m_rhs.fpp: add non-conservative Ẽ source S_Ẽ = -sum_i(pi_inf_i *
  rhs(alpha_i)) for x/y/z directions, gated on model_eqns==2 and
  .not.(bubbles_euler .or. mhd)
- m_sim_helpers.fpp: igr branch drops pi_inf from pressure recovery
  (Ẽ stored) and restores it for physical H
- m_cbc.fpp: energy flux drops dpi_inf_dt term (Ẽ not pi_inf in flux)

* ci: increase fp-stability case step counts to 50 for better sweep coverage

* revert: remove reduced-energy (E-tilde) scheme — moving to separate PR

* fix: protect HLLC xi-factor denominators from division by zero with sgm_eps

* ci: loosen water_stiffened threshold to 1e-8 until Etilde scheme merges

The stiffened-EOS pressure recovery p=(E-pi_inf)/gamma suffers
catastrophic cancellation (~2.5e-9 max_dev under random rounding vs
the previous 1e-10 gate). The algorithmic fix (reduced-energy / Etilde
storage scheme) lives on feat/reduced-energy. Until that PR merges,
raise the gate to 1e-8 so CI is green while still catching regressions.

* ci: GitHub step summary, file annotations, and float-proxy metric in fp-stability

On every run, fp_stability.py now writes to GITHUB_STEP_SUMMARY a
markdown table with pass/fail, max_dev, float proxy, and the full
VPREC precision sweep showing which bit levels (52/23/16/10) fail.

On failure, dd_line source locations are emitted as ::warning::
annotations so the responsible Fortran lines appear highlighted
directly in the PR diff view.

Both are no-ops outside GitHub Actions (env var guards).

* ci: remove pass/fail markers from VPREC sweep table

The VPREC sweep is a sensitivity curve, not a pass/fail test.
Comparing reduced-precision runs against the double-precision threshold
marks every case as failing at 23b/16b/10b, which is noise.
Show raw dev numbers only; the main table has the actual pass/fail.

* fix: move cons.unindent into finally block; use MFC_ROOT_DIR in _find_binary

- cons.unindent()/cons.print() were after the try/finally, so any
  MFCException raised inside _run_case would leave the console
  permanently over-indented for all subsequent case output.
- _find_binary used os.getcwd() which breaks if fp-stability is
  invoked from a subdirectory; MFC_ROOT_DIR is always correct.

* ci: always run dd_line to surface FP hotspots on every run

Previously dd_sym/dd_line only ran on test failure, so passing runs
gave no source-level instability info.

Now dd_sym and dd_line always run, using a sensitivity threshold of
max_dev/10 rather than the pass/fail threshold. This isolates the
source lines responsible for the dominant FP variation even when the
case passes. Results are capped at top 10 locations per case.

The GitHub step summary now always shows a 'Top FP hotspots (dd_line)'
section, and ::warning:: annotations are emitted for all cases
(labelled 'hotspot' on pass, 'FAIL' on failure) so the sensitive
Fortran lines are visible in the PR diff regardless of CI outcome.

* ci: add bubble_rp and low_mach FP cases; fix dd threshold to use median

* fix: bubble_rp pre_process.inp (remove bubble_model); loosen low_mach threshold to 1e-7

* fix: loosen bubble_rp threshold to 1e-8 (RP ODE cancellation observed ~2e-9)

* ci: use float-mode dd bisection (deterministic, nruns=1) instead of random

* fix: dd_run.sh must honour VERROU_ROUNDING_MODE=nearest for reference run

verrou_dd_sym sets VERROU_ROUNDING_MODE=nearest when producing its reference
run, then leaves it unset for test runs.  Hardcoding --rounding-mode=float as
a CLI arg overrides that env var (CLI takes precedence in Valgrind), so both
reference AND full-perturbation test end up in float mode, give identical
output, deviation=0, and dd exits 42.

Fix: use ${VERROU_ROUNDING_MODE:-float} in dd_run.sh so verrou_dd_sym's
nearest-rounding reference is preserved, while test steps still default to
float mode (deterministic, --nruns=1 sufficient).

* feat: add cancellation detection, MCA sig-bits, and float-max checks to fp-stability

Three new Verrou analysis passes, each enabled by default with --no-X to skip:

F. --check-cancellation=yes (--no-cancellation): uses --cc-gen-file for structured
   per-line output of catastrophic cancellation sites in MFC source.

G. --backend=mcaquad MCA runs (--no-mca): N samples with Monte Carlo Arithmetic;
   reports max deviation and a significant-bits lower bound: s = -log2(dev/scale).

H. --check-max-float=yes (--no-float-max): detects double→float conversions that
   would overflow to ±Inf; reports source locations from Valgrind error log.

Results added to GitHub step summary (cancellation sites table, float-max sites
table, MCA sig-bits column in the main results table).

* fix: emit up to 3 dd_line + 3 cancellation annotations per case

Previously only dd_line locations were annotated (minimal delta-debug
set, often just 1 line).  Now also emit the top 3 cancellation sites
per case as ::notice:: so the PR diff shows a richer set of FP hotspots.

* fix: source context in summary, branch filter on workflow, reviewer feedback

- Add _get_source_context() to embed 5-line annotated snippets in the
  GitHub step summary for each dd_line hotspot and cancellation site
- Fix workflow on: push: to only fire on master and fp-stability branches,
  plus add weekly cron schedule (Monday 03:00 UTC)
- Fix log_dir to use MFC_ROOT_DIR instead of os.getcwd()
- Remove unreachable 'or 5' fallback on ARG('samples') (default=5 in CLI)

* fix: eliminate xi_L/R - 1 cancellation in 5-eq HLLC solver

In the 5-equation HLLC block, xi_L ≈ 1 near the sonic contact point, so
computing (xi_L - 1) by post-hoc subtraction from 1 loses significant bits.

Add xi_L_m1 = (s_S - vel_L)/(s_L - s_S), computed directly instead of as
xi_L - 1, and use it throughout the mass, momentum, energy, volume-fraction,
color-function, and species flux loops.

The momentum flux also uses the algebraic identity
  xi*(dir_flg*s_S + (1-dir_flg)*u_i) - u_i = (dir_flg*s_L + (1-dir_flg)*u_i)*xi_m1
which avoids both the xi - 1 and the xi*s_S - u (normal direction) forms.

For the energy flux the star-state term xi_L*(E + expr) - E is rewritten as
E*xi_L_m1 + xi_L*expr, removing the E*(xi_L - 1) cancellation.

All 162 1D regression tests pass; all 6 FP-stability suite cases pass.

* Update fp-stability.yml

* fix: loosen low_mach FP-stability threshold to 2e-7

The low_mach test exercises HLLC's low-Mach correction at near-zero
Mach, where (u_R - u_L) is fundamentally small. Verrou MCA sampling
variance puts the max_dev distribution typically around 5e-8 with a
tail occasionally hitting ~1e-7, making the previous 1e-7 threshold
flaky. Loosen to 2e-7 to absorb sampling noise.

After #1408 (WENO5 sum-of-squares beta) merges, the WENO contribution
to the cancellation chain disappears on uniform grids and the threshold
can be tightened back.

* fix: extend xi_L_m1/xi_R_m1 cancellation fix to all four HLLC blocks

Blocks 1 (model_eqns==3), 2 (model_eqns==4), and 3 (model_eqns==2 with
bubbles_euler) still computed xi_L/R - 1 by subtraction, losing bits near
a sonic contact where xi_L/R approx 1.

Add xi_L_m1/xi_R_m1 = (s_S - u_L/R)/(s_L/R - s_S) to all three blocks and
replace xi_L - 1 in mass, advection, bubble, and vel_src flux loops.

* refactor(fp-stability): replace committed .inp files with Python dicts in fp_stability.py

* refactor(fp-stability): unify CASES + params into one list, add _merge helper

v5.3.0

Toggle v5.3.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
refactor: unify equation/range indices into sys_idx; clean BC globals (

…#1365)

v5.2.2

Toggle v5.2.2's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Modify CLAUDE code review workflow for PR handling (#1354)

v5.2.1

Toggle v5.2.1's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Fix Homebrew install crash: namelist parser gracefully handles missin…

…g Fortran sources (#1154)

The namelist parser (added post-v5.2.0) reads src/*/m_start_up.fpp at runtime
to determine valid parameters per target. Homebrew installs don't include these
Fortran source files, causing a FileNotFoundError crash. When sources are
unavailable, fall back to a built-in copy of the parsed parameter sets (generated
from the same Fortran namelists). This maintains correct per-target filtering
while working without the source tree.

Co-authored-by: Claude Opus 4.6 <[email protected]>

v5.2.0

Toggle v5.2.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
MHD Hyperbolic Divergence Cleaning (#1086)

Co-authored-by: Daniel J. Vickers <[email protected]>
Co-authored-by: Spencer Bryngelson <[email protected]>

v5.1.5

Toggle v5.1.5's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
update python in docker files (#1097)

v5.1.4

Toggle v5.1.4's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Refactor subgrid bubble models (#1085)

Co-authored-by: qodo-code-review[bot] <151058649+qodo-code-review[bot]@users.noreply.github.com>
Co-authored-by: Hyeoksu Lee <[email protected]>

v5.1.3

Toggle v5.1.3's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Update cantera and pyrometheus dependencies (#1053)

v5.1.2

Toggle v5.1.2's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
CI test (#1054)

Co-authored-by: anandrdbz <[email protected]>
Co-authored-by: Anand <[email protected]>
Co-authored-by: Anand Radhakrishnan <[email protected]>