Skip to content

Commit 14e4076

Browse files
committed
Add RK1/RK2/RK3 temporal order verification; add --time-stepper to 1D case
1 parent 5336315 commit 14e4076

2 files changed

Lines changed: 22 additions & 12 deletions

File tree

examples/1D_euler_convergence/case.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
parser.add_argument("--cfl", type=float, default=0.4, help="CFL number (default: 0.4)")
2626
parser.add_argument("--no-mapped", action="store_true", help="Disable mapped WENO")
2727
parser.add_argument("--muscl-lim", type=int, default=0, help="MUSCL limiter: 0=unlimited 1=minmod ... (default: 0)")
28+
parser.add_argument("--time-stepper", type=int, default=3, help="Time stepper: 1=Euler 2=RK2 3=RK3 (default: 3)")
2829
args = parser.parse_args()
2930

3031
gamma = 1.4
@@ -79,7 +80,7 @@
7980
"num_fluids": 1,
8081
"mpp_lim": "F",
8182
"mixture_err": "F",
82-
"time_stepper": 3,
83+
"time_stepper": args.time_stepper,
8384
"riemann_solver": 2,
8485
"wave_speeds": 1,
8586
"avg_state": 2,

toolchain/mfc/test/run_temporal_order.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
#!/usr/bin/env python3
22
"""
3-
Time-integration order verification for MFC's RK3 time stepper.
3+
Time-integration order verification for MFC's RK1, RK2, and RK3 time steppers.
44
55
Uses the 1D single-fluid Euler advection problem (rho = 1 + 0.2*sin(2*pi*x),
66
u=1, p=1, L=1, T=1) with a fine spatial grid (N=512, WENO5) so the spatial
7-
error (~4e-12) is negligible compared to the RK3 temporal error at the CFLs
8-
tested here.
7+
error (~4e-12) is negligible compared to the temporal error at the CFLs tested.
98
109
L2(rho(T) - rho(0)) measures total accumulated error. By fixing N and varying
1110
CFL (and hence dt), the spatial contribution is constant and the measured rate
1211
reflects the time integration order.
1312
14-
CFL values [0.5, 0.25] keep the temporal error well above the spatial floor:
15-
CFL=0.50 → err ~8.3e-10 (>200x spatial floor)
16-
CFL=0.25 → err ~1.1e-10 (>25x spatial floor)
17-
Pairwise rate ≈ 2.95, threshold ≥ 2.7.
13+
CFL ranges are chosen to be within each stepper's stability region and keep
14+
temporal errors well above the ~4e-12 spatial floor:
15+
RK1 (Euler, 1st order): CFL=[0.10, 0.05] — stable limit ~0.1 with WENO5+LF
16+
(nearly-imaginary eigenvalues constrain Euler more than TVD RK);
17+
error ~2.5e-4 and ~1.2e-4 (rate ≈ 1.0)
18+
RK2 (TVD Heun, 2nd order): CFL=[0.50, 0.25];
19+
error ~1.2e-6 and ~2.9e-7 (rate ≈ 2.0)
20+
RK3 (TVD Shu-Osher, 3rd order): CFL=[0.50, 0.25];
21+
error ~8.3e-10 and ~1.1e-10 (rate ≈ 3.0)
1822
1923
Usage:
2024
python toolchain/mfc/test/run_temporal_order.py
21-
python toolchain/mfc/test/run_temporal_order.py --cfls 0.5 0.25 0.125
25+
python toolchain/mfc/test/run_temporal_order.py --schemes RK3/WENO5 --cfls 0.5 0.25 0.125
2226
"""
2327

2428
import argparse
@@ -37,10 +41,15 @@
3741
MFC = "./mfc.sh"
3842

3943
# (label, extra_args, expected_order, tolerance, cfls)
40-
# All schemes here use RK3 (time_stepper=3 is default in MFC).
4144
# N=512 is fixed; WENO5 keeps spatial error ~4e-12 (negligible at CFL>=0.25).
45+
# RK1/RK2 temporal errors at CFL=0.5 are ~2e-4 and ~2e-7, both >> spatial floor.
4246
SCHEMES = [
43-
("RK3/WENO5", ["--order", "5"], 3, 0.3, [0.5, 0.25]),
47+
# RK1 (Forward Euler): nearly-imaginary WENO5+LF eigenvalues constrain stability
48+
# to CFL < ~0.1; use [0.10, 0.05] which are provably stable and temporal-dominated
49+
("RK1/WENO5", ["--order", "5", "--time-stepper", "1"], 1, 0.1, [0.10, 0.05]),
50+
# RK2/RK3 (TVD): stable to CFL~1; use [0.50, 0.25] for clean temporal dominance
51+
("RK2/WENO5", ["--order", "5", "--time-stepper", "2"], 2, 0.2, [0.50, 0.25]),
52+
("RK3/WENO5", ["--order", "5", "--time-stepper", "3"], 3, 0.3, [0.50, 0.25]),
4453
]
4554

4655
N_SPATIAL = 512 # fixed spatial resolution
@@ -168,7 +177,7 @@ def main():
168177
parser.add_argument(
169178
"--schemes",
170179
nargs="+",
171-
default=["RK3/WENO5"],
180+
default=["RK1/WENO5", "RK2/WENO5", "RK3/WENO5"],
172181
help="Schemes to test (default: all)",
173182
)
174183
parser.add_argument("--num-ranks", type=int, default=1, help="MPI ranks per simulation (default: 1)")

0 commit comments

Comments
 (0)