|
| 1 | +using OrdinaryDiffEqSSPRK |
| 2 | +using Trixi |
| 3 | + |
| 4 | +############################################################################### |
| 5 | +# semidiscretization of the ideal MHD equations |
| 6 | +gamma = 2 |
| 7 | +equations = IdealGlmMhdEquations1D(gamma) |
| 8 | + |
| 9 | +""" |
| 10 | + initial_condition_briowu_shock_tube_mod(x, t, equations::IdealGlmMhdEquations1D) |
| 11 | +
|
| 12 | +Compound shock tube test case for one dimensional ideal MHD equations. |
| 13 | +It is basically an MHD extension of the Sod shock tube. |
| 14 | +Taken from Section V of the article with a modified lower right pressure (1e-3 instead of 0.1) |
| 15 | +- Brio and Wu (1988) |
| 16 | + An Upwind Differencing Scheme for the Equations of Ideal Magnetohydrodynamics |
| 17 | + [DOI: 10.1016/0021-9991(88)90120-9](https://doi.org/10.1016/0021-9991(88)90120-9) |
| 18 | +""" |
| 19 | +function initial_condition_briowu_shock_tube_mod(x, t, equations::IdealGlmMhdEquations1D) |
| 20 | + # domain must be set to [0, 1], γ = 2, final time = 0.12 |
| 21 | + RealT = eltype(x) |
| 22 | + rho = x[1] < 0.5f0 ? 1.0f0 : 0.125f0 |
| 23 | + v1 = 0 |
| 24 | + v2 = 0 |
| 25 | + v3 = 0 |
| 26 | + p = x[1] < 0.5f0 ? one(RealT) : RealT(1e-3) # 1e-3 instead of 0.1 |
| 27 | + B1 = 0.75f0 |
| 28 | + B2 = x[1] < 0.5f0 ? 1 : -1 |
| 29 | + B3 = 0 |
| 30 | + return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations) |
| 31 | +end |
| 32 | +initial_condition = initial_condition_briowu_shock_tube_mod |
| 33 | + |
| 34 | +boundary_conditions = BoundaryConditionDirichlet(initial_condition) |
| 35 | + |
| 36 | +surface_flux = flux_hlle |
| 37 | +volume_flux = flux_derigs_etal |
| 38 | +basis = LobattoLegendreBasis(4) |
| 39 | + |
| 40 | +indicator_sc = IndicatorHennemannGassner(equations, basis, |
| 41 | + alpha_max = 0.5, |
| 42 | + alpha_min = 0.001, |
| 43 | + alpha_smooth = true, |
| 44 | + variable = density_pressure) |
| 45 | +volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; |
| 46 | + volume_flux_dg = volume_flux, |
| 47 | + volume_flux_fv = surface_flux) |
| 48 | +solver = DGSEM(basis, surface_flux, volume_integral) |
| 49 | + |
| 50 | +coordinates_min = 0.0 |
| 51 | +coordinates_max = 1.0 |
| 52 | +mesh = TreeMesh(coordinates_min, coordinates_max, |
| 53 | + initial_refinement_level = 4, |
| 54 | + n_cells_max = 10_000, |
| 55 | + periodicity = false) |
| 56 | + |
| 57 | +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, |
| 58 | + boundary_conditions = boundary_conditions) |
| 59 | + |
| 60 | +############################################################################### |
| 61 | +# ODE solvers, callbacks etc. |
| 62 | + |
| 63 | +tspan = (0.0, 0.12) |
| 64 | +ode = semidiscretize(semi, tspan) |
| 65 | + |
| 66 | +summary_callback = SummaryCallback() |
| 67 | + |
| 68 | +analysis_interval = 100 |
| 69 | +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, |
| 70 | + extra_analysis_errors = (:l2_error_primitive, |
| 71 | + :linf_error_primitive)) |
| 72 | + |
| 73 | +alive_callback = AliveCallback(analysis_interval = analysis_interval) |
| 74 | + |
| 75 | +save_restart = SaveRestartCallback(interval = 100, |
| 76 | + save_final_restart = true) |
| 77 | + |
| 78 | +amr_indicator = IndicatorHennemannGassner(semi, |
| 79 | + alpha_max = 0.5, |
| 80 | + alpha_min = 0.001, |
| 81 | + alpha_smooth = true, |
| 82 | + variable = density_pressure) |
| 83 | +amr_controller = ControllerThreeLevel(semi, amr_indicator, |
| 84 | + base_level = 4, |
| 85 | + max_level = 6, max_threshold = 0.01) |
| 86 | +amr_callback = AMRCallback(semi, amr_controller, |
| 87 | + interval = 5, |
| 88 | + adapt_initial_condition = true, |
| 89 | + adapt_initial_condition_only_refine = true) |
| 90 | + |
| 91 | +stepsize_callback = StepsizeCallback(cfl = 1.1) |
| 92 | + |
| 93 | +callbacks = CallbackSet(summary_callback, |
| 94 | + analysis_callback, alive_callback, |
| 95 | + save_restart, |
| 96 | + amr_callback, stepsize_callback) |
| 97 | + |
| 98 | +############################################################################### |
| 99 | +# run the simulation |
| 100 | + |
| 101 | +# crashes without positivity limiter |
| 102 | +stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6,), |
| 103 | + variables = (pressure,)) |
| 104 | + |
| 105 | +sol = solve(ode, SSPRK54(stage_limiter! = stage_limiter!); |
| 106 | + dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback |
| 107 | + ode_default_options()..., callback = callbacks); |
0 commit comments