Skip to content

Commit c4b57ee

Browse files
Add 2D Compressible Euler with Gravity (#119)
* first commit: gravity waves * add first test * add type tests * include tests in runtest.jl * remove some fluxes with orientation * fix tests * fix atol * reach full coverage * fix typo * fix test * Apply suggestions from code review Co-authored-by: Hendrik Ranocha <[email protected]> * add description for Souza non-conservative term * modify comment for Souza flux * fix typo * rename equation and add comment to gravity waves example * fix spell typo error in the comment * small change in a comment --------- Co-authored-by: Hendrik Ranocha <[email protected]>
1 parent 9d6bbf5 commit c4b57ee

File tree

7 files changed

+866
-2
lines changed

7 files changed

+866
-2
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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::CompressibleEulerEnergyEquationsWithGravity2D)
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 = CompressibleEulerEnergyEquationsWithGravity2D(c_p = 1004,
62+
c_v = 717,
63+
gravity = 9.81)
64+
65+
# We have an isothermal background state with T0 = 250 K.
66+
# The reference speed of sound can be computed as:
67+
# cs = sqrt(gamma * R * T0)
68+
cs = sqrt(equations.gamma * equations.R * 250)
69+
surface_flux = (FluxLMARS(cs), flux_zero)
70+
volume_flux = (flux_ranocha, flux_nonconservative_waruzewski_etal)
71+
polydeg = 3
72+
solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux,
73+
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))
74+
75+
boundary_conditions = (x_neg = boundary_condition_periodic,
76+
x_pos = boundary_condition_periodic,
77+
y_neg = boundary_condition_slip_wall,
78+
y_pos = boundary_condition_slip_wall)
79+
80+
coordinates_min = (0.0, 0.0)
81+
coordinates_max = (300_000.0, 10_000.0)
82+
cells_per_dimension = (60, 8)
83+
mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max,
84+
periodicity = (true, false))
85+
source_terms = nothing
86+
initial_condition = initial_condition_gravity_waves
87+
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
88+
source_terms = source_terms,
89+
boundary_conditions = boundary_conditions)
90+
tspan = (0.0, 1800.0)
91+
ode = semidiscretize(semi, tspan)
92+
93+
summary_callback = SummaryCallback()
94+
95+
analysis_interval = 10000
96+
analysis_callback = AnalysisCallback(semi, interval = analysis_interval,
97+
extra_analysis_integrals = (entropy,))
98+
99+
alive_callback = AliveCallback(analysis_interval = analysis_interval)
100+
101+
stepsize_callback = StepsizeCallback(cfl = 1.0)
102+
103+
callbacks = CallbackSet(summary_callback,
104+
analysis_callback,
105+
alive_callback,
106+
stepsize_callback)
107+
108+
sol = solve(ode,
109+
SSPRK43(thread = Trixi.True());
110+
maxiters = 1.0e7,
111+
dt = 1e-1, # solve needs some value here but it will be overwritten by the stepsize_callback
112+
save_everystep = false, callback = callbacks, adaptive = false)

src/TrixiAtmo.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ using HDF5: HDF5, h5open, attributes, create_dataset, datatype, dataspace
3030
energy_kinetic, energy_internal, energy_total, entropy, pressure,
3131
flux, flux_ec, flux_chandrashekar, flux_wintermeyer_etal,
3232
flux_fjordholm_etal, flux_nonconservative_wintermeyer_etal,
33-
flux_nonconservative_fjordholm_etal, FluxLMARS
33+
flux_nonconservative_fjordholm_etal, FluxLMARS, flux_shima_etal,
34+
flux_ranocha, flux_kennedy_gruber
3435

3536
using Trixi: ln_mean, stolarsky_mean, inv_ln_mean
3637

@@ -49,7 +50,8 @@ export CompressibleMoistEulerEquations2D, ShallowWaterEquations3D,
4950
CompressibleEulerPotentialTemperatureEquations3D,
5051
CompressibleEulerPotentialTemperatureEquationsWithGravity1D,
5152
CompressibleEulerPotentialTemperatureEquationsWithGravity2D,
52-
CompressibleEulerPotentialTemperatureEquationsWithGravity3D
53+
CompressibleEulerPotentialTemperatureEquationsWithGravity3D,
54+
CompressibleEulerEnergyEquationsWithGravity2D
5355

5456
export GlobalCartesianCoordinates, GlobalSphericalCoordinates
5557

0 commit comments

Comments
 (0)