|
| 1 | +using OrdinaryDiffEqSSPRK, OrdinaryDiffEqLowStorageRK |
| 2 | +using Trixi |
| 3 | + |
| 4 | +# 1) Dry Air 2) SF_6 |
| 5 | +equations = CompressibleEulerMulticomponentEquations2D(gammas = (1.4, 1.648), |
| 6 | + gas_constants = (0.287, 1.578)) |
| 7 | + |
| 8 | +""" |
| 9 | + initial_condition_shock(coordinates, t, equations::CompressibleEulerEquations2D) |
| 10 | +
|
| 11 | +Shock traveling from left to right where it interacts with a Perturbed interface. |
| 12 | +""" |
| 13 | +@inline function initial_condition_shock(x, t, |
| 14 | + equations::CompressibleEulerMulticomponentEquations2D) |
| 15 | + rho_0 = 1.25 # kg/m^3 |
| 16 | + p_0 = 101325 # Pa |
| 17 | + T_0 = 293 # K |
| 18 | + u_0 = 352 # m/s |
| 19 | + d = 20 |
| 20 | + w = 40 |
| 21 | + |
| 22 | + if x[1] < 25 |
| 23 | + # Shock region. |
| 24 | + v1 = 0.35 |
| 25 | + v2 = 0.0 |
| 26 | + rho1 = 1.72 |
| 27 | + rho2 = 0.03 |
| 28 | + p = 1.57 |
| 29 | + elseif (x[1] <= 30) || (x[1] <= 70 && abs(125 - x[2]) > w / 2) |
| 30 | + # Intermediate region. |
| 31 | + v1 = 0.0 |
| 32 | + v2 = 0.0 |
| 33 | + rho1 = 1.25 |
| 34 | + rho2 = 0.03 |
| 35 | + p = 1.0 |
| 36 | + else |
| 37 | + (x[1] <= 70 + d) |
| 38 | + # SF_6 region. |
| 39 | + v1 = 0.0 |
| 40 | + v2 = 0.0 |
| 41 | + rho1 = 0.03 |
| 42 | + rho2 = 6.03 #SF_6 |
| 43 | + p = 1.0 |
| 44 | + end |
| 45 | + |
| 46 | + return prim2cons(SVector(v1, v2, p, rho1, rho2), equations) |
| 47 | +end |
| 48 | + |
| 49 | +# Define the simulation. |
| 50 | +initial_condition = initial_condition_shock |
| 51 | + |
| 52 | +surface_flux = flux_lax_friedrichs |
| 53 | +volume_flux = flux_ranocha |
| 54 | +basis = LobattoLegendreBasis(3) |
| 55 | + |
| 56 | +limiter_idp = SubcellLimiterIDP(equations, basis; |
| 57 | + positivity_variables_cons = ["rho" * string(i) |
| 58 | + for i in eachcomponent(equations)]) |
| 59 | + |
| 60 | +volume_integral = VolumeIntegralSubcellLimiting(limiter_idp; |
| 61 | + volume_flux_dg = volume_flux, |
| 62 | + volume_flux_fv = surface_flux) |
| 63 | + |
| 64 | +solver = DGSEM(basis, surface_flux, volume_integral) |
| 65 | + |
| 66 | +coordinates_min = (0.0, 0.0) |
| 67 | +coordinates_max = (250.0, 250.0) |
| 68 | +mesh = P4estMesh((32, 32), polydeg = 3, coordinates_min = (0.0, 0.0), |
| 69 | + coordinates_max = (250.0, 250.0), periodicity = (false, true), |
| 70 | + initial_refinement_level = 0) |
| 71 | + |
| 72 | +# Completely free outflow |
| 73 | +function boundary_condition_outflow(u_inner, normal_direction::AbstractVector, |
| 74 | + x, t, |
| 75 | + surface_flux_function, |
| 76 | + equations) |
| 77 | + # Calculate the boundary flux entirely from the internal solution state |
| 78 | + return flux(u_inner, normal_direction, equations) |
| 79 | +end |
| 80 | + |
| 81 | +boundary_conditions = Dict(:x_neg => BoundaryConditionDirichlet(initial_condition), |
| 82 | + :x_pos => boundary_condition_outflow) |
| 83 | + |
| 84 | +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, |
| 85 | + boundary_conditions = boundary_conditions) |
| 86 | + |
| 87 | +############################################################################### |
| 88 | +# ODE solvers, callbacks etc. |
| 89 | + |
| 90 | +tspan = (0.0, 5.0) |
| 91 | +ode = semidiscretize(semi, tspan) |
| 92 | + |
| 93 | +summary_callback = SummaryCallback() |
| 94 | + |
| 95 | +analysis_interval = 10 |
| 96 | +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, |
| 97 | + save_analysis = true) |
| 98 | + |
| 99 | +alive_callback = AliveCallback(analysis_interval = analysis_interval) |
| 100 | + |
| 101 | +save_solution = SaveSolutionCallback(dt = 2.0, |
| 102 | + save_initial_solution = true, |
| 103 | + save_final_solution = true, |
| 104 | + solution_variables = cons2prim) |
| 105 | + |
| 106 | +stepsize_callback = StepsizeCallback(cfl = 0.2) |
| 107 | + |
| 108 | +callbacks = CallbackSet(summary_callback, |
| 109 | + analysis_callback, |
| 110 | + alive_callback, |
| 111 | + save_solution, |
| 112 | + stepsize_callback) |
| 113 | + |
| 114 | +############################################################################### |
| 115 | +# run the simulation |
| 116 | + |
| 117 | +stage_callbacks = (SubcellLimiterIDPCorrection(), |
| 118 | + BoundsCheckCallback(save_errors = false, interval = 100)) |
| 119 | +# `interval` is used when calling this elixir in the tests with `save_errors=true`. |
| 120 | + |
| 121 | +@time begin |
| 122 | + sol = Trixi.solve(ode, Trixi.SimpleSSPRK33(stage_callbacks = stage_callbacks); |
| 123 | + dt = 0.1, # solve needs some value here but it will be overwritten by the stepsize_callback |
| 124 | + ode_default_options()..., callback = callbacks) |
| 125 | +end |
0 commit comments