Path: blob/main/test/test_tree_2d_eulermulti.jl
2055 views
module TestExamples2DEulerMulticomponent12using Test3using Trixi45include("test_trixi.jl")67EXAMPLES_DIR = joinpath(examples_dir(), "tree_2d_dgsem")89@testset "Compressible Euler Multicomponent" begin10@trixi_testset "Testing entropy2cons and cons2entropy" begin11using ForwardDiff12using Trixi: Trixi, CompressibleEulerMulticomponentEquations2D, cons2entropy,13entropy2cons, SVector14gammas = (1.1546412974182538, 1.1171560258914812, 1.097107661471476,151.0587601652669245, 1.6209889683979308, 1.6732209755396386,161.2954303574165822)17gas_constants = (5.969461071171914, 3.6660802003290183, 6.639008614675539,188.116604827140456, 6.190706056680031, 1.6795013743693712,192.197737590916966)20equations = CompressibleEulerMulticomponentEquations2D(gammas = SVector{length(gammas)}(gammas...),21gas_constants = SVector{length(gas_constants)}(gas_constants...))22u = [-1.7433292819144075, 0.8844413258376495, 0.6050737175812364,230.8261998359817043, 1.0801186290896465, 0.505654488367698,240.6364415555805734, 0.851669392285058, 0.31219606420306223,251.0930477805612038]26w = cons2entropy(u, equations)27# test that the entropy variables match the gradients of the total entropy28@test w ≈ ForwardDiff.gradient(u -> Trixi.total_entropy(u, equations), u)29# test that `entropy2cons` is the inverse of `cons2entropy`30@test entropy2cons(w, equations) ≈ u31end3233# NOTE: Some of the L2/Linf errors are comparably large. This is due to the fact that some of the34# simulations are set up with dimensional states. For example, the reference pressure in SI35# units is 101325 Pa, i.e., pressure has values of O(10^5)3637@trixi_testset "elixir_eulermulti_shock_bubble.jl" begin38@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_shock_bubble.jl"),39l2=[4073.78467629094177,410.9174752929795251,4257942.83587826468,430.1828847253029943,440.01112703785092534745],46linf=[47196.81051991521073,487.8456811648529605,49158891.88930113698,500.811379581519794,510.0801197355918791352],53tspan=(0.0, 0.001))54# Ensure that we do not have excessive memory allocations55# (e.g., from type instabilities)56let57t = sol.t[end]58u_ode = sol.u[end]59du_ode = similar(u_ode)60@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 100061end62end6364@trixi_testset "elixir_eulermulti_shock_bubble_shockcapturing_subcell_positivity.jl" begin65rm(joinpath("out", "deviations.txt"), force = true)66@test_trixi_include(joinpath(EXAMPLES_DIR,67"elixir_eulermulti_shock_bubble_shockcapturing_subcell_positivity.jl"),68l2=[6981.52845664909304,702.5455678559421346,7163229.190712645846,720.19929478404550321,730.01106860422844342574],75linf=[76249.21708417382013,7740.33299887640794,78174205.0118831558,790.6881458768113586,800.1127440115817397281],82initial_refinement_level=3,83tspan=(0.0, 0.001),84save_errors=true)85lines = readlines(joinpath("out", "deviations.txt"))86@test lines[1] == "# iter, simu_time, rho1_min, rho2_min"87# Runs 15 time steps.88@test startswith(lines[end], "15")89# Ensure that we do not have excessive memory allocations90# (e.g., from type instabilities)91let92t = sol.t[end]93u_ode = sol.u[end]94du_ode = similar(u_ode)95# Larger values for allowed allocations due to usage of custom96# integrator which are not *recorded* for the methods from97# OrdinaryDiffEq.jl98# Corresponding issue: https://github.com/trixi-framework/Trixi.jl/issues/187799@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 15000100end101end102103@trixi_testset "elixir_eulermulti_shock_bubble_shockcapturing_subcell_minmax.jl" begin104@test_trixi_include(joinpath(EXAMPLES_DIR,105"elixir_eulermulti_shock_bubble_shockcapturing_subcell_minmax.jl"),106l2=[10773.41054363926742,1081.5072038797716156,10957405.58964098063,1100.17877099207437225,1110.010085388785440972112],113linf=[114213.59140793740318,11524.57625853486584,116152498.21319871658,1170.5911106543157919,1180.09936092838440383119],120initial_refinement_level=3,121tspan=(0.0, 0.001))122# Ensure that we do not have excessive memory allocations123# (e.g., from type instabilities)124let125t = sol.t[end]126u_ode = sol.u[end]127du_ode = similar(u_ode)128# Larger values for allowed allocations due to usage of custom129# integrator which are not *recorded* for the methods from130# OrdinaryDiffEq.jl131# Corresponding issue: https://github.com/trixi-framework/Trixi.jl/issues/1877132@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 15000133end134end135136@trixi_testset "elixir_eulermulti_ec.jl" begin137@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_ec.jl"),138l2=[1390.050182236154087095,1400.050189894464434635,1410.2258715597305131,1420.06175171559771687143],144linf=[1450.3108124923284472,1460.3107380389947733,1471.054035804988521,1480.29347582879608936149])150# Ensure that we do not have excessive memory allocations151# (e.g., from type instabilities)152let153t = sol.t[end]154u_ode = sol.u[end]155du_ode = similar(u_ode)156@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000157end158end159160@trixi_testset "elixir_eulermulti_es.jl" begin161@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_es.jl"),162l2=[1630.0496546258404055,1640.04965550099933263,1650.22425206549856372,1660.004087155041747821,1670.008174310083495642,1680.016348620166991283,1690.032697240333982566170],171linf=[1720.2488251110766228,1730.24832493304479406,1740.9310354690058298,1750.017452870465607374,1760.03490574093121475,1770.0698114818624295,1780.139622963724859179])180# Ensure that we do not have excessive memory allocations181# (e.g., from type instabilities)182let183t = sol.t[end]184u_ode = sol.u[end]185du_ode = similar(u_ode)186@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000187end188end189190@trixi_testset "elixir_eulermulti_convergence_ec.jl" begin191@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_ec.jl"),192l2=[1930.00012290225488326508,1940.00012290225488321876,1950.00018867397906337653,1964.8542321753649044e-5,1979.708464350729809e-5198],199linf=[2000.0006722819239133315,2010.0006722819239128874,2020.0012662292789555885,2030.0002843844182700561,2040.0005687688365401122205])206# Ensure that we do not have excessive memory allocations207# (e.g., from type instabilities)208let209t = sol.t[end]210u_ode = sol.u[end]211du_ode = similar(u_ode)212@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000213end214end215216@trixi_testset "elixir_eulermulti_convergence_es.jl" begin217@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"),218l2=[2192.2661773867001696e-6,2202.266177386666318e-6,2216.593514692980009e-6,2228.836308667348217e-7,2231.7672617334696433e-6224],225linf=[2261.4713170997993075e-5,2271.4713170997104896e-5,2285.115618808515521e-5,2295.3639516094383666e-6,2301.0727903218876733e-5231])232# Ensure that we do not have excessive memory allocations233# (e.g., from type instabilities)234let235t = sol.t[end]236u_ode = sol.u[end]237du_ode = similar(u_ode)238@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000239end240end241242@trixi_testset "elixir_eulermulti_convergence_es.jl with flux_chandrashekar" begin243@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"),244l2=[2451.8621737639352465e-6,2461.862173764098385e-6,2475.942585713809631e-6,2486.216263279534722e-7,2491.2432526559069443e-6250],251linf=[2521.6235495582606063e-5,2531.6235495576388814e-5,2545.854523678827661e-5,2555.790274858807898e-6,2561.1580549717615796e-5257],258volume_flux=flux_chandrashekar)259# Ensure that we do not have excessive memory allocations260# (e.g., from type instabilities)261let262t = sol.t[end]263u_ode = sol.u[end]264du_ode = similar(u_ode)265@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000266end267end268end269270end # module271272273