Skip to content

Commit

Permalink
Added test cases for entropy2cons and cons2entropy for compressible m…
Browse files Browse the repository at this point in the history
…ulticomponent euler 1d and 2d
  • Loading branch information
teohyikhaw committed Dec 8, 2023
1 parent 035ad11 commit 74f94fb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/test_tree_1d_eulermulti.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module TestExamples1DEulerMulti

using Test
using Trixi
using ForwardDiff

include("test_trixi.jl")

Expand All @@ -10,6 +11,18 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem")
@testset "Compressible Euler Multicomponent" begin
#! format: noindent

@trixi_testset "Testing entropy2cons and cons2entropy" begin
using ForwardDiff
gammas = (1.3272378792562836, 1.5269959187969864, 1.8362285750521512, 1.0409061360276926, 1.4652015053812224, 1.3626493264184423)
gas_constants = (1.817636851910076, 6.760820475922636, 5.588953939749113, 6.31574782981543, 3.362932038038397, 3.212779569399733)
equations = CompressibleEulerMulticomponentEquations1D(gammas=SVector{length(gammas)}(gammas...),
gas_constants=SVector{length(gas_constants)}(gas_constants...))
u = [-1.4632513788889214, 0.9908786980927811, 0.2909066990257628, 0.6256623915420473, 0.4905882754313441, 0.14481800501749112, 1.0333532872771651, 0.6805599818745411]
w = cons2entropy(u, equations)
@test w ForwardDiff.gradient(u -> total_entropy(u, equations), u)
@test entropy2cons(w, equations) u
end

@trixi_testset "elixir_eulermulti_ec.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_ec.jl"),
l2=[0.15330089521538684, 0.4417674632047301,
Expand Down
12 changes: 12 additions & 0 deletions test/test_tree_2d_eulermulti.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem")
@testset "Compressible Euler Multicomponent" begin
#! format: noindent

@trixi_testset "Testing entropy2cons and cons2entropy" begin
using ForwardDiff
gammas = (1.1546412974182538, 1.1171560258914812, 1.097107661471476, 1.0587601652669245, 1.6209889683979308, 1.6732209755396386, 1.2954303574165822)
gas_constants = (5.969461071171914, 3.6660802003290183, 6.639008614675539, 8.116604827140456, 6.190706056680031, 1.6795013743693712, 2.197737590916966)
equations = CompressibleEulerMulticomponentEquations2D(gammas=SVector{length(gammas)}(gammas...),
gas_constants=SVector{length(gas_constants)}(gas_constants...))
u = [-1.7433292819144075, 0.8844413258376495, 0.6050737175812364, 0.8261998359817043, 1.0801186290896465, 0.505654488367698, 0.6364415555805734, 0.851669392285058, 0.31219606420306223, 1.0930477805612038]
w = cons2entropy(u, equations)
@test w ForwardDiff.gradient(u -> total_entropy(u, equations), u)
@test entropy2cons(w, equations) u
end

# NOTE: Some of the L2/Linf errors are comparably large. This is due to the fact that some of the
# simulations are set up with dimensional states. For example, the reference pressure in SI
# units is 101325 Pa, i.e., pressure has values of O(10^5)
Expand Down

0 comments on commit 74f94fb

Please sign in to comment.