|
| 1 | +#!/usr/bin/env python3 |
| 2 | +""" |
| 3 | +1D single-fluid Euler convergence case. |
| 4 | +
|
| 5 | +Single fluid with a density sine wave: rho = 1 + 0.2*sin(2*pi*x). |
| 6 | +Constant velocity u=1 and pressure p=1. For this IC, the Euler equations |
| 7 | +reduce to pure advection of all variables at speed u=1. After exactly one |
| 8 | +period (T = L/u = 1), the exact solution equals the IC, so |
| 9 | +L2(rho(T) - rho(0)) measures the accumulated scheme spatial truncation error. |
| 10 | +
|
| 11 | +No non-conservative alpha equation — clean benchmark for WENO/MUSCL rates. |
| 12 | +""" |
| 13 | + |
| 14 | +import argparse |
| 15 | +import json |
| 16 | +import math |
| 17 | + |
| 18 | +parser = argparse.ArgumentParser(description="1D Euler convergence case") |
| 19 | +parser.add_argument("--mfc", type=json.loads, default="{}", metavar="DICT") |
| 20 | +parser.add_argument("-N", type=int, default=64, help="Grid points (default: 64)") |
| 21 | +parser.add_argument("--order", type=int, default=5, help="WENO order: 1, 3, or 5") |
| 22 | +parser.add_argument("--muscl", action="store_true", help="Use MUSCL-2 instead of WENO") |
| 23 | +parser.add_argument("--cfl", type=float, default=0.4, help="CFL number (default: 0.4)") |
| 24 | +parser.add_argument("--no-mapped", action="store_true", help="Disable mapped WENO") |
| 25 | +parser.add_argument("--muscl-lim", type=int, default=0, help="MUSCL limiter: 0=unlimited 1=minmod ... (default: 0)") |
| 26 | +args = parser.parse_args() |
| 27 | + |
| 28 | +gamma = 1.4 |
| 29 | +N = args.N |
| 30 | +m = N - 1 |
| 31 | +L = 1.0 |
| 32 | +dx = L / N |
| 33 | + |
| 34 | +# c_sound = sqrt(gamma * p / rho) = sqrt(gamma) for p=1, rho=1 |
| 35 | +c_max = math.sqrt(gamma) + 1.0 # acoustic + convective |
| 36 | +dt = args.cfl * dx / c_max |
| 37 | +T_end = 1.0 |
| 38 | +Nt = max(4, math.ceil(T_end / dt)) |
| 39 | +dt = T_end / Nt |
| 40 | + |
| 41 | +if args.muscl: |
| 42 | + scheme_params = { |
| 43 | + "recon_type": 2, |
| 44 | + "muscl_order": 2, |
| 45 | + "muscl_lim": args.muscl_lim, |
| 46 | + } |
| 47 | +else: |
| 48 | + scheme_params = { |
| 49 | + "recon_type": 1, |
| 50 | + "weno_order": args.order, |
| 51 | + "weno_eps": 1.0e-16, |
| 52 | + "weno_Re_flux": "F", |
| 53 | + "weno_avg": "F", |
| 54 | + "mapped_weno": "F" if (args.order == 1 or args.no_mapped) else "T", |
| 55 | + "null_weights": "F", |
| 56 | + "mp_weno": "F", |
| 57 | + } |
| 58 | + |
| 59 | +print( |
| 60 | + json.dumps( |
| 61 | + { |
| 62 | + "run_time_info": "F", |
| 63 | + "x_domain%beg": 0.0, |
| 64 | + "x_domain%end": L, |
| 65 | + "m": m, |
| 66 | + "n": 0, |
| 67 | + "p": 0, |
| 68 | + "dt": dt, |
| 69 | + "t_step_start": 0, |
| 70 | + "t_step_stop": Nt, |
| 71 | + "t_step_save": Nt, |
| 72 | + "num_patches": 1, |
| 73 | + "model_eqns": 2, |
| 74 | + "alt_soundspeed": "F", |
| 75 | + "num_fluids": 1, |
| 76 | + "mpp_lim": "F", |
| 77 | + "mixture_err": "F", |
| 78 | + "time_stepper": 3, |
| 79 | + "riemann_solver": 2, |
| 80 | + "wave_speeds": 1, |
| 81 | + "avg_state": 2, |
| 82 | + "bc_x%beg": -1, |
| 83 | + "bc_x%end": -1, |
| 84 | + "format": 1, |
| 85 | + "precision": 2, |
| 86 | + "prim_vars_wrt": "T", |
| 87 | + "parallel_io": "F", |
| 88 | + "patch_icpp(1)%geometry": 1, |
| 89 | + "patch_icpp(1)%x_centroid": 0.5, |
| 90 | + "patch_icpp(1)%length_x": L, |
| 91 | + "patch_icpp(1)%vel(1)": 1.0, |
| 92 | + "patch_icpp(1)%pres": 1.0, |
| 93 | + "patch_icpp(1)%alpha_rho(1)": "1.0 + 0.2 * sin(2.0 * pi * x / lx)", |
| 94 | + "patch_icpp(1)%alpha(1)": 1.0, |
| 95 | + "fluid_pp(1)%gamma": 1.0 / (gamma - 1.0), |
| 96 | + "fluid_pp(1)%pi_inf": 0.0, |
| 97 | + **scheme_params, |
| 98 | + } |
| 99 | + ) |
| 100 | +) |
0 commit comments