Skip to content

Commit

Permalink
Fix entropy for quasi-1D compressible Euler (#1974)
Browse files Browse the repository at this point in the history
* Fix `entropy` for quasi-1D compressible Euler 

Fixes https://github.com/trixi-framework/Trixi.jl/pull/1947/files#r1628569760

* Update test_tree_1d_euler.jl

adding a test

* Update src/equations/compressible_euler_quasi_1d.jl

Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>

* Update test/test_tree_1d_euler.jl

Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>

* Update test/test_tree_1d_euler.jl

Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>

* fix formatting

* fix formatting again

---------

Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
  • Loading branch information
jlchan and ranocha authored Jun 10, 2024
1 parent fc15c38 commit 23c70ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/equations/compressible_euler_quasi_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,8 @@ end
# 1D compressible Euler equations scaled by the channel width `a`.
@inline function entropy(u, equations::CompressibleEulerEquationsQuasi1D)
a_rho, a_rho_v1, a_e, a = u
q = a * entropy(SVector(a_rho, a_rho_v1, a_e) / a,
CompressibleEulerEquations1D(equations.gamma))

return SVector(q[1], q[2], q[3], a)
return a * entropy(SVector(a_rho, a_rho_v1, a_e) / a,
CompressibleEulerEquations1D(equations.gamma))
end

# Convert conservative variables to entropy. The entropy variables for the
Expand Down
9 changes: 9 additions & 0 deletions test/test_tree_1d_euler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,14 @@ end
end
end

@trixi_testset "test_quasi_1D_entropy" begin
a = 0.9
u_1D = SVector(1.1, 0.2, 2.1)
u_quasi_1D = SVector(a * 1.1, a * 0.2, a * 2.1, a)
@test entropy(u_quasi_1D, CompressibleEulerEquationsQuasi1D(1.4))
a * entropy(u_1D, CompressibleEulerEquations1D(1.4))
end

@trixi_testset "elixir_euler_quasi_1d_source_terms.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_quasi_1d_source_terms.jl"),
l2=[
Expand All @@ -423,6 +431,7 @@ end
1.821888865105592e-6,
1.1166012159335992e-7,
])

# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
Expand Down

0 comments on commit 23c70ba

Please sign in to comment.