|
| 1 | +#!/usr/bin/env python3 |
| 2 | +""" |
| 3 | +2D single-fluid Euler convergence case (smooth diagonal advection). |
| 4 | +
|
| 5 | +Density wave rho = 1 + 0.2*sin(2*pi*(x+y)) with uniform velocity (u, v) = (1, 1) |
| 6 | +on the unit square with periodic BCs. Pressure p = 1 throughout. For this IC |
| 7 | +the Euler equations reduce to pure advection of all variables along the |
| 8 | +diagonal at speed sqrt(2); the wave phase x+y - 2t returns to x+y after |
| 9 | +T = 0.5. L2(rho(T) - rho(0)) measures accumulated scheme spatial truncation |
| 10 | +error. |
| 11 | +
|
| 12 | +The point of this case is to exercise WENO7 / TENO7 in 2D without the |
| 13 | +primitive-to-conserved covariance floor that dominates the 2D isentropic |
| 14 | +vortex (run_convergence.py) at testable resolutions. Here all primitives are |
| 15 | +linear in the conserved variables, so there is no floor. |
| 16 | +""" |
| 17 | + |
| 18 | +import argparse |
| 19 | +import json |
| 20 | +import math |
| 21 | + |
| 22 | +parser = argparse.ArgumentParser(description="2D Euler diagonal-advection convergence case") |
| 23 | +parser.add_argument("--mfc", type=json.loads, default="{}", metavar="DICT") |
| 24 | +parser.add_argument("-N", type=int, default=64, help="Grid points per dim (default: 64)") |
| 25 | +parser.add_argument("--order", type=int, default=5, help="WENO order: 1, 3, 5, or 7") |
| 26 | +parser.add_argument("--muscl", action="store_true", help="Use MUSCL-2 instead of WENO") |
| 27 | +parser.add_argument("--teno", action="store_true", help="Use TENO instead of WENO") |
| 28 | +parser.add_argument("--teno-ct", type=float, default=1e-6, help="TENO CT threshold (default: 1e-6)") |
| 29 | +parser.add_argument("--cfl", type=float, default=0.4, help="CFL number (default: 0.4; use 0.005 for WENO7/TENO7)") |
| 30 | +parser.add_argument("--no-mapped", action="store_true", help="Disable mapped WENO") |
| 31 | +parser.add_argument("--muscl-lim", type=int, default=0, help="MUSCL limiter: 0=unlimited 1=minmod ... (default: 0)") |
| 32 | +parser.add_argument("--time-stepper", type=int, default=3, help="Time stepper: 1=Euler 2=RK2 3=RK3 (default: 3)") |
| 33 | +args = parser.parse_args() |
| 34 | + |
| 35 | +gamma = 1.4 |
| 36 | +N = args.N |
| 37 | +m = N - 1 |
| 38 | +L = 1.0 |
| 39 | +dx = L / N |
| 40 | + |
| 41 | +# Max wave speed: |u| + c with c = sqrt(gamma * p / rho_min). rho_min = 1 - 0.2. |
| 42 | +c_max = math.sqrt(gamma / 0.8) + 1.0 |
| 43 | +dt = args.cfl * dx / c_max |
| 44 | +T_end = 0.5 # one full diagonal period: phase shift = 2*T_end = 1.0 |
| 45 | +Nt = max(4, math.ceil(T_end / dt)) |
| 46 | +dt = T_end / Nt |
| 47 | + |
| 48 | +if args.muscl: |
| 49 | + scheme_params = { |
| 50 | + "recon_type": 2, |
| 51 | + "muscl_order": 2, |
| 52 | + "muscl_lim": args.muscl_lim, |
| 53 | + } |
| 54 | +else: |
| 55 | + scheme_params = { |
| 56 | + "recon_type": 1, |
| 57 | + "weno_order": args.order, |
| 58 | + "weno_eps": 1.0e-40, |
| 59 | + "weno_Re_flux": "F", |
| 60 | + "weno_avg": "F", |
| 61 | + "mapped_weno": "F" if (args.order == 1 or args.no_mapped or args.teno) else "T", |
| 62 | + "null_weights": "F", |
| 63 | + "mp_weno": "F", |
| 64 | + "teno": "T" if args.teno else "F", |
| 65 | + **({"teno_CT": args.teno_ct} if args.teno else {}), |
| 66 | + } |
| 67 | + |
| 68 | +print( |
| 69 | + json.dumps( |
| 70 | + { |
| 71 | + "run_time_info": "F", |
| 72 | + "x_domain%beg": 0.0, |
| 73 | + "x_domain%end": L, |
| 74 | + "y_domain%beg": 0.0, |
| 75 | + "y_domain%end": L, |
| 76 | + "m": m, |
| 77 | + "n": m, |
| 78 | + "p": 0, |
| 79 | + "dt": dt, |
| 80 | + "t_step_start": 0, |
| 81 | + "t_step_stop": Nt, |
| 82 | + "t_step_save": Nt, |
| 83 | + "num_patches": 1, |
| 84 | + "model_eqns": 2, |
| 85 | + "alt_soundspeed": "F", |
| 86 | + "num_fluids": 1, |
| 87 | + "mpp_lim": "F", |
| 88 | + "mixture_err": "F", |
| 89 | + "time_stepper": args.time_stepper, |
| 90 | + "riemann_solver": 2, |
| 91 | + "wave_speeds": 1, |
| 92 | + "avg_state": 2, |
| 93 | + "bc_x%beg": -1, |
| 94 | + "bc_x%end": -1, |
| 95 | + "bc_y%beg": -1, |
| 96 | + "bc_y%end": -1, |
| 97 | + "format": 1, |
| 98 | + "precision": 2, |
| 99 | + "prim_vars_wrt": "T", |
| 100 | + "parallel_io": "F", |
| 101 | + "patch_icpp(1)%geometry": 3, |
| 102 | + "patch_icpp(1)%x_centroid": 0.5, |
| 103 | + "patch_icpp(1)%y_centroid": 0.5, |
| 104 | + "patch_icpp(1)%length_x": L, |
| 105 | + "patch_icpp(1)%length_y": L, |
| 106 | + "patch_icpp(1)%vel(1)": 1.0, |
| 107 | + "patch_icpp(1)%vel(2)": 1.0, |
| 108 | + "patch_icpp(1)%pres": 1.0, |
| 109 | + "patch_icpp(1)%alpha_rho(1)": "1.0 + 0.2 * sin(2.0 * pi * (x / lx + y / ly))", |
| 110 | + "patch_icpp(1)%alpha(1)": 1.0, |
| 111 | + "fluid_pp(1)%gamma": 1.0 / (gamma - 1.0), |
| 112 | + "fluid_pp(1)%pi_inf": 0.0, |
| 113 | + **scheme_params, |
| 114 | + } |
| 115 | + ) |
| 116 | +) |
0 commit comments