Skip to content

Add convergence-rate CI for WENO5/3/1 and MUSCL2 - #5

Closed
sbryngelson wants to merge 22 commits into
masterfrom
feat/convergence-ci
Closed

sbryngelson wants to merge 22 commits into
masterfrom
feat/convergence-ci

Conversation

@sbryngelson

Copy link
Copy Markdown
Owner

Closes MFlowCode#305

Summary

  • Adds a convergence CI workflow (.github/workflows/convergence.yml) that runs on push to any branch and workflow_dispatch
  • 1D job: single-fluid Euler density sine wave (rho = 1 + 0.2 sin(2πx)), one period advection; per-scheme resolution ranges and pass thresholds:
    • WENO5: N ∈ [128, 512], rate ≥ 4.8 (capped before machine-precision floor at N=1024)
    • WENO3: N ∈ [256, 1024], rate ≥ 1.8 (Jiang-Shu smooth-extremum asymptote = 2, not 3)
    • WENO1: N ∈ [128, 1024], rate ≥ 0.95
    • MUSCL2: N ∈ [128, 1024], rate ≥ 1.9 (unlimited muscl_lim=0 slope; TVD limiters stall at smooth extrema)
  • 2D job: isentropic vortex at eps=0.01 with Gauss-Legendre IC (hcid=283); N ∈ [32, 128]
  • Adds muscl_lim=0 (unlimited central-difference slope) to m_muscl.fpp and parameter definitions
  • Adds examples/1D_euler_convergence/ single-fluid benchmark case

Test plan

  • Convergence CI passes on this branch (triggered by push)
  • WENO5 shows rate ~5, WENO3 ~2 (1D smooth-extremum degradation), WENO1 ~1, MUSCL2 ~2
  • 2D isentropic vortex WENO5 shows rate ~4, WENO3 ~2

sbryngelson and others added 22 commits April 29, 2026 20:55
…ns (MFlowCode#1382)

Co-authored-by: Daniel J. Vickers <dnlvickers5@gmail.com>
Co-authored-by: Spencer Bryngelson <sbryngelson@gmail.com>
Co-authored-by: Spencer Bryngelson <shb@gatech.edu>
Co-authored-by: Spencer Bryngelson <sbryngelson@gmail.com>
Co-authored-by: Spencer Bryngelson <sbryngelson@gmail.com>
Co-authored-by: Anand <anand@Anands-MacBook-Pro.local>
With eps=5 the prim->cons covariance error O(eps^3 h^2) swamps WENO5's
O(eps^2 h^5) error at all practical resolutions, giving apparent rate 2.
Using eps=0.01 shifts the crossover to h~0.22 so that N=16..64 (h=0.63..0.16)
are firmly in the WENO5-dominated regime and show rate ~5, as in Johnsen &
Colonius (2006) who similarly used a weak vortex.

- hcid=283: vortex strength now read from patch_icpp(patch_id)%epsilon
  (defaults to 5 if not set, preserving backward compatibility)
- case.py: eps_vortex=0.01, c_max updated accordingly
- run_convergence.py: resolutions 16,32,64; WENO5 tolerance 4.0 (rate>=4)
- convergence.yml: updated to 16 32 64
CFL=0.02 eliminates RK3 temporal error so WENO5 shows rate 5.
WENO3 expected rate is 2 (not 3) on smooth-extremum problems per
Henrick et al. 2005 — JS smoothness indicators degrade at f'=0.
The 2D vortex job remains the authority on WENO3 rate 3.
1D runner now uses examples/1D_euler_convergence/case.py (single-fluid,
density sine wave, no non-conservative alpha equation) instead of the
two-fluid advection case.  The five-equation model non-conservative alpha
transport degrades unlimited MUSCL to ~1st order on two-fluid problems
even with identical EOS; the single-fluid Euler case gives clean rates.

Add muscl_lim=0 (unlimited central-difference) to MUSCL reconstruction:
- src/simulation/m_muscl.fpp: central slope = 0.5*(slopeL+slopeR)
- toolchain/mfc/params/definitions.py: add 0 to choices
- toolchain/mfc/case_validator.py: allow muscl_lim in {0..5}

1D and 2D convergence cases default to muscl_lim=0 for smooth problems
where TVD limiters would stall at smooth extrema.  Runner default CFL=0.02
so RK3 temporal error O(h^3) stays negligible for WENO5 rate-5 verification.
N=16 (m=n=15) is below the minimum grid size for WENO5's 5-point stencil
and causes pre_process to abort.  Start all 2D tests at N=32.

WENO3 on the stationary isentropic vortex is pre-asymptotic at N=32-128:
fitted rate ~2.02, local rate 1.83->2.21 (converging toward 3). Lower
threshold from 2.2 to 1.8 (expected=3, tol=1.2).  The rate still clearly
exceeds the 1D result (1.77, Jiang-Shu smooth-extremum degradation), which
is the distinction this test is designed to demonstrate.
…d to 0.95

Default and CI resolutions: 128 256 512 1024.  WENO5 is capped at N=512
per-scheme (hits double-precision floor at N=1024 after 111k steps; error
~2.6e-12 vs 4.2e-12 at N=512, rate collapses to 0.69).  N=128-512 gives
fitted rate 4.99.

WENO1 threshold tightened from 0.6 to 0.95 (tol 0.05): pairwise rates
0.95->0.97->0.99 at N=128-1024, fitted 0.97.

MUSCL2 shows exact rate 2.00 at all doublings N=128-1024.
WENO5 capped at N=512 (machine-precision floor kills rate at N=1024,
error ~2.6e-12, rate collapses to 0.69). WENO3 starts at N=256 to skip
coarse pre-asymptotic points. WENO1 and MUSCL2 use full [128,1024] range.

Thresholds: WENO5>=4.8, WENO3>=1.8, WENO1>=0.95, MUSCL2>=1.9.
Tests are too slow (~30-45 min each job) to run on every PR push.
Manual trigger via workflow_dispatch lets you run them deliberately
when verifying numerics, not on every commit.
@sbryngelson sbryngelson closed this May 6, 2026
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

Claude Code Review

Head SHA: 3a069d2

Files changed:

  • 30
  • .github/workflows/convergence.yml
  • src/common/include/2dHardcodedIC.fpp
  • src/simulation/m_global_parameters.fpp
  • src/simulation/m_muscl.fpp
  • src/simulation/m_pressure_relaxation.fpp
  • src/simulation/m_start_up.fpp
  • toolchain/mfc/case_validator.py
  • toolchain/mfc/test/cases.py
  • toolchain/mfc/test/run_convergence.py
  • toolchain/mfc/test/run_convergence_1d.py

Findings

1. Convergence CI workflow lacks pull_request: trigger — will never run on PRs

.github/workflows/convergence.yml lines 9–11:

on:
  push:
  workflow_dispatch:

The workflow fires on every branch push but not on pull-request events. The plan in docs/superpowers/plans/2026-05-05-convergence-ci.md explicitly included pull_request: as a trigger so that PRs are validated before merge. Without it, convergence failures on a feature branch will not appear as PR checks and cannot block the merge. Add pull_request: under on:.


2. AMD-path array in m_pressure_relaxation.fpp changed from 2 → 3 but remains hardcoded, not num_fluids

src/simulation/m_pressure_relaxation.fpp:

#:if not MFC_CASE_OPTIMIZATION and USING_AMD
    real(wp), dimension(3) :: alpha_rho, alpha  ! changed from dimension(2)
#:else
    real(wp), dimension(num_fluids) :: alpha_rho, alpha
#:endif

The loop immediately below indexes alpha_rho(i) and alpha(i) for i = 1, num_fluids. With dimension(3), any case where num_fluids > 3 on an AMD GPU build will silently read past the end of the array, corrupting mixture properties or causing a crash. The #:else branch already uses the correct dimension(num_fluids). If AMD flang rejects a runtime-sized local in a device routine, the constant should be a named parameter equal to the maximum supported num_fluids, not an ad-hoc value that matches the current test case.


3. Van Albada and Van Leer limiters lose their sum-of-slopes guard — golden files for lim=3/4 tests may be stale

src/simulation/m_muscl.fpp — Van Albada (lim=3) guard changed from four conditions (individual magnitudes, sum, and product) to the single product check slopeL*slopeR > muscl_eps. The product-only guard is mathematically sufficient (when the product is positive both slopes share the same sign, so sL²+sR² > 0 and sL+sR ≠ 0), but it changes the activation threshold for lim=3 and lim=4 relative to the previous hard-coded 1e-6 checks. Existing golden files for tests using muscl_lim=3 or muscl_lim=4 (generated with the old guard logic) should be regenerated to avoid spurious golden-file failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Convergence result in CI

7 participants