Skip to content

Commit 06a8485

Browse files
Add 2D compressible Euler with internal energy as prognostic variable (#172)
* add internal energy equations * add file * add tests * fmt * change test values * add type tests * update test values and fix fluxes * fix test values * increase coverage * fix tests * Update src/equations/compressible_euler_internal_energy_with_gravity_2d.jl Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com> * change name and fix docs * fix exports * fix exports * fix sentence * Apply suggestions from code review Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com> * remove naive wave speed function * Update test/test_type.jl * Update src/equations/compressible_euler_internal_energy_with_gravity_2d.jl --------- Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
1 parent fa8e2d5 commit 06a8485

File tree

7 files changed

+526
-4
lines changed

7 files changed

+526
-4
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# This test case is used to compute convergence rates via a linearized solution.
2+
# The setup follows the approach commonly adopted in benchmark studies; therefore,
3+
# a fixed CFL number is employed.
4+
#
5+
# References:
6+
# - Michael Baldauf and Slavko Brdar (2013):
7+
# "An analytic solution for linear gravity waves in a channel as a test
8+
# for numerical models using the non-hydrostatic, compressible Euler equations"
9+
# Q. J. R. Meteorol. Soc., DOI: 10.1002/qj.2105
10+
# https://doi.org/10.1002/qj.2105
11+
#
12+
# - Maciej Waruszewski, Jeremy E. Kozdon, Lucas C. Wilcox, Thomas H. Gibson,
13+
# and Francis X. Giraldo (2022):
14+
# "Entropy stable discontinuous Galerkin methods for balance laws
15+
# in non-conservative form: Applications to the Euler equations with gravity"
16+
# JCP, DOI: 10.1016/j.jcp.2022.111507
17+
# https://doi.org/10.1016/j.jcp.2022.111507
18+
#
19+
# - Marco Artiano, Oswald Knoth, Peter Spichtinger, Hendrik Ranocha (2025):
20+
# "Structure-Preserving High-Order Methods for the Compressible Euler Equations
21+
# in Potential Temperature Formulation for Atmospheric Flows"
22+
# https://arxiv.org/abs/2509.10311
23+
24+
using OrdinaryDiffEqSSPRK
25+
using Trixi, TrixiAtmo
26+
27+
"""
28+
initial_condition_gravity_waves(x, t,
29+
equations::CompressibleEulerEnergyEquationsWithGravity2D)
30+
31+
Test cases for linearized analytical solution by
32+
- Baldauf, Michael and Brdar, Slavko (2013)
33+
An analytic solution for linear gravity waves in a channel as a test
34+
for numerical models using the non-hydrostatic, compressible {E}uler equations
35+
[DOI: 10.1002/qj.2105] (https://doi.org/10.1002/qj.2105)
36+
"""
37+
function initial_condition_gravity_waves(x, t,
38+
equations::CompressibleEulerInternalEnergyEquationsWithGravity2D)
39+
g = equations.g
40+
c_p = equations.c_p
41+
c_v = equations.c_v
42+
# center of perturbation
43+
x_c = 100_000.0
44+
a = 5_000
45+
H = 10_000
46+
R = c_p - c_v # gas constant (dry air)
47+
T0 = 250
48+
delta = g / (R * T0)
49+
DeltaT = 0.001
50+
Tb = DeltaT * sinpi(x[2] / H) * exp(-(x[1] - x_c)^2 / a^2)
51+
ps = 100_000 # reference pressure
52+
rhos = ps / (T0 * R)
53+
rho_b = rhos * (-Tb / T0)
54+
p = ps * exp(-delta * x[2])
55+
rho = rhos * exp(-delta * x[2]) + rho_b * exp(-0.5 * delta * x[2])
56+
v1 = 20
57+
v2 = 0
58+
return prim2cons(SVector(rho, v1, v2, p, g * x[2]), equations)
59+
end
60+
61+
equations = CompressibleEulerInternalEnergyEquationsWithGravity2D(c_p = 1004,
62+
c_v = 717,
63+
gravity = 9.81)
64+
65+
surface_flux = (flux_conservative_es, flux_nonconservative_es)
66+
volume_flux = (flux_conservative_etec, flux_nonconservative_etec)
67+
polydeg = 3
68+
solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux,
69+
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))
70+
71+
boundary_conditions = (;
72+
y_neg = boundary_condition_slip_wall,
73+
y_pos = boundary_condition_slip_wall)
74+
75+
coordinates_min = (0.0, 0.0)
76+
coordinates_max = (300_000.0, 10_000.0)
77+
trees_per_dimension = (60, 8)
78+
79+
mesh = P4estMesh(trees_per_dimension, polydeg = polydeg,
80+
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
81+
periodicity = (true, false))
82+
83+
initial_condition = initial_condition_gravity_waves
84+
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
85+
boundary_conditions = boundary_conditions)
86+
tspan = (0.0, 1800.0)
87+
ode = semidiscretize(semi, tspan)
88+
89+
summary_callback = SummaryCallback()
90+
91+
analysis_interval = 10000
92+
analysis_callback = AnalysisCallback(semi, interval = analysis_interval,
93+
extra_analysis_integrals = (entropy,))
94+
95+
alive_callback = AliveCallback(analysis_interval = analysis_interval)
96+
97+
stepsize_callback = StepsizeCallback(cfl = 1.0)
98+
99+
callbacks = CallbackSet(summary_callback,
100+
analysis_callback,
101+
alive_callback,
102+
stepsize_callback)
103+
104+
sol = solve(ode,
105+
SSPRK43(thread = Trixi.True());
106+
maxiters = 1.0e7,
107+
dt = 1e-1, # solve needs some value here but it will be overwritten by the stepsize_callback
108+
save_everystep = false, callback = callbacks, adaptive = false)

src/TrixiAtmo.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ export CompressibleMoistEulerEquations2D,
5858
CompressibleEulerPotentialTemperatureEquationsWithGravity2D,
5959
CompressibleEulerPotentialTemperatureEquationsWithGravity3D,
6060
CompressibleEulerEnergyEquationsWithGravity2D,
61-
CompressibleEulerEnergyEquationsWithGravity3D
61+
CompressibleEulerEnergyEquationsWithGravity3D,
62+
CompressibleEulerInternalEnergyEquationsWithGravity2D
6263

6364
export GlobalCartesianCoordinates, GlobalSphericalCoordinates
6465

@@ -72,7 +73,8 @@ export flux_nonconservative_zeros, flux_nonconservative_ec,
7273
flux_tec, flux_etec, flux_nonconservative_souza_etal,
7374
flux_nonconservative_artiano_etal,
7475
flux_nonconservative_waruszewski_etal, flux_zero,
75-
flux_ec_rain, flux_LMARS
76+
flux_ec_rain, flux_LMARS, flux_nonconservative_es, flux_conservative_es,
77+
flux_conservative_etec, flux_nonconservative_etec
7678

7779
export source_terms_lagrange_multiplier, clean_solution_lagrange_multiplier!
7880

0 commit comments

Comments
 (0)