Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed cons2entropy files and implemented entropy2cons for CompressibleEulerMulticomponent1D and CompressibleEulerMulticomponent2D #1767

Merged
merged 14 commits into from
Dec 14, 2023
Merged
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]
jlchan marked this conversation as resolved.
Show resolved Hide resolved
w = cons2entropy(u, equations)
@test w ≈ ForwardDiff.gradient(u -> total_entropy(u, equations), u)
@test entropy2cons(w, equations) ≈ u
teohyikhaw marked this conversation as resolved.
Show resolved Hide resolved
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
teohyikhaw marked this conversation as resolved.
Show resolved Hide resolved
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
Loading