-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dry air warm bubble test case (#1779)
* add LMARS flux in 2D * add dry air warm bubble test case * get formatting right * remove += * add DOI * cleaned up variables (naming, scope) * reduce run time of test case * Revert "reduce run time of test case" This reverts commit b6e527b. * change output folder * change energy term in LMARS solver to use p_l/r * add lmars consistency checks * switched to kennedy gruber flux * add euler warm bubble elixir to tests * adapt errors due to change flux * add warm bubble test with TreeMesh * fix unit test * fix format * adapt polynomial degree and CFL number * fix format * adapt tests due to changed parameters * Update src/equations/compressible_euler_2d.jl Co-authored-by: Andrew Winters <andrew.ross.winters@liu.se> * Update src/equations/compressible_euler_2d.jl Co-authored-by: Andrew Winters <andrew.ross.winters@liu.se> * Update src/equations/compressible_euler_3d.jl Co-authored-by: Andrew Winters <andrew.ross.winters@liu.se> * Update src/equations/compressible_euler_3d.jl Co-authored-by: Andrew Winters <andrew.ross.winters@liu.se> * correct test result * use callable struct to hold parameters Thanks sloede! * Update examples/structured_2d_dgsem/elixir_euler_warm_bubble.jl Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com> * Update examples/tree_2d_dgsem/elixir_euler_warm_bubble.jl Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com> * year of Wicker paper, comment on tspan [no ci] * add comment on speed of sound --------- Co-authored-by: Andrew Winters <andrew.ross.winters@liu.se> Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
- Loading branch information
1 parent
2463b38
commit 4bb74f8
Showing
8 changed files
with
519 additions
and
33 deletions.
There are no files selected for viewing
146 changes: 146 additions & 0 deletions
146
examples/structured_2d_dgsem/elixir_euler_warm_bubble.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
# Warm bubble test case from | ||
# - Wicker, L. J., and Skamarock, W. C. (1998) | ||
# A time-splitting scheme for the elastic equations incorporating | ||
# second-order Runge–Kutta time differencing | ||
# [DOI: 10.1175/1520-0493(1998)126%3C1992:ATSSFT%3E2.0.CO;2](https://doi.org/10.1175/1520-0493(1998)126%3C1992:ATSSFT%3E2.0.CO;2) | ||
# See also | ||
# - Bryan and Fritsch (2002) | ||
# A Benchmark Simulation for Moist Nonhydrostatic Numerical Models | ||
# [DOI: 10.1175/1520-0493(2002)130<2917:ABSFMN>2.0.CO;2](https://doi.org/10.1175/1520-0493(2002)130<2917:ABSFMN>2.0.CO;2) | ||
# - Carpenter, Droegemeier, Woodward, Hane (1990) | ||
# Application of the Piecewise Parabolic Method (PPM) to | ||
# Meteorological Modeling | ||
# [DOI: 10.1175/1520-0493(1990)118<0586:AOTPPM>2.0.CO;2](https://doi.org/10.1175/1520-0493(1990)118<0586:AOTPPM>2.0.CO;2) | ||
struct WarmBubbleSetup | ||
# Physical constants | ||
g::Float64 # gravity of earth | ||
c_p::Float64 # heat capacity for constant pressure (dry air) | ||
c_v::Float64 # heat capacity for constant volume (dry air) | ||
gamma::Float64 # heat capacity ratio (dry air) | ||
|
||
function WarmBubbleSetup(; g = 9.81, c_p = 1004.0, c_v = 717.0, gamma = c_p / c_v) | ||
new(g, c_p, c_v, gamma) | ||
end | ||
end | ||
|
||
# Initial condition | ||
function (setup::WarmBubbleSetup)(x, t, equations::CompressibleEulerEquations2D) | ||
@unpack g, c_p, c_v = setup | ||
|
||
# center of perturbation | ||
center_x = 10000.0 | ||
center_z = 2000.0 | ||
# radius of perturbation | ||
radius = 2000.0 | ||
# distance of current x to center of perturbation | ||
r = sqrt((x[1] - center_x)^2 + (x[2] - center_z)^2) | ||
|
||
# perturbation in potential temperature | ||
potential_temperature_ref = 300.0 | ||
potential_temperature_perturbation = 0.0 | ||
if r <= radius | ||
potential_temperature_perturbation = 2 * cospi(0.5 * r / radius)^2 | ||
end | ||
potential_temperature = potential_temperature_ref + potential_temperature_perturbation | ||
|
||
# Exner pressure, solves hydrostatic equation for x[2] | ||
exner = 1 - g / (c_p * potential_temperature) * x[2] | ||
|
||
# pressure | ||
p_0 = 100_000.0 # reference pressure | ||
R = c_p - c_v # gas constant (dry air) | ||
p = p_0 * exner^(c_p / R) | ||
|
||
# temperature | ||
T = potential_temperature * exner | ||
|
||
# density | ||
rho = p / (R * T) | ||
|
||
v1 = 20.0 | ||
v2 = 0.0 | ||
E = c_v * T + 0.5 * (v1^2 + v2^2) | ||
return SVector(rho, rho * v1, rho * v2, rho * E) | ||
end | ||
|
||
# Source terms | ||
@inline function (setup::WarmBubbleSetup)(u, x, t, equations::CompressibleEulerEquations2D) | ||
@unpack g = setup | ||
rho, _, rho_v2, _ = u | ||
return SVector(zero(eltype(u)), zero(eltype(u)), -g * rho, -g * rho_v2) | ||
end | ||
|
||
############################################################################### | ||
# semidiscretization of the compressible Euler equations | ||
warm_bubble_setup = WarmBubbleSetup() | ||
|
||
equations = CompressibleEulerEquations2D(warm_bubble_setup.gamma) | ||
|
||
boundary_conditions = (x_neg = boundary_condition_periodic, | ||
x_pos = boundary_condition_periodic, | ||
y_neg = boundary_condition_slip_wall, | ||
y_pos = boundary_condition_slip_wall) | ||
|
||
polydeg = 3 | ||
basis = LobattoLegendreBasis(polydeg) | ||
|
||
# This is a good estimate for the speed of sound in this example. | ||
# Other values between 300 and 400 should work as well. | ||
surface_flux = FluxLMARS(340.0) | ||
|
||
volume_flux = flux_kennedy_gruber | ||
volume_integral = VolumeIntegralFluxDifferencing(volume_flux) | ||
|
||
solver = DGSEM(basis, surface_flux, volume_integral) | ||
|
||
coordinates_min = (0.0, 0.0) | ||
coordinates_max = (20_000.0, 10_000.0) | ||
|
||
cells_per_dimension = (64, 32) | ||
mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max) | ||
|
||
semi = SemidiscretizationHyperbolic(mesh, equations, warm_bubble_setup, solver, | ||
source_terms = warm_bubble_setup, | ||
boundary_conditions = boundary_conditions) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
tspan = (0.0, 1000.0) # 1000 seconds final time | ||
|
||
ode = semidiscretize(semi, tspan) | ||
|
||
summary_callback = SummaryCallback() | ||
|
||
analysis_interval = 1000 | ||
|
||
analysis_callback = AnalysisCallback(semi, interval = analysis_interval, | ||
extra_analysis_errors = (:entropy_conservation_error,)) | ||
|
||
alive_callback = AliveCallback(analysis_interval = analysis_interval) | ||
|
||
save_solution = SaveSolutionCallback(interval = analysis_interval, | ||
save_initial_solution = true, | ||
save_final_solution = true, | ||
output_directory = "out", | ||
solution_variables = cons2prim) | ||
|
||
stepsize_callback = StepsizeCallback(cfl = 1.0) | ||
|
||
callbacks = CallbackSet(summary_callback, | ||
analysis_callback, | ||
alive_callback, | ||
save_solution, | ||
stepsize_callback) | ||
|
||
############################################################################### | ||
# run the simulation | ||
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), | ||
maxiters = 1.0e7, | ||
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback | ||
save_everystep = false, callback = callbacks); | ||
|
||
summary_callback() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
# Warm bubble test case from | ||
# - Wicker, L. J., and Skamarock, W. C. (1998) | ||
# A time-splitting scheme for the elastic equations incorporating | ||
# second-order Runge–Kutta time differencing | ||
# [DOI: 10.1175/1520-0493(1998)126%3C1992:ATSSFT%3E2.0.CO;2](https://doi.org/10.1175/1520-0493(1998)126%3C1992:ATSSFT%3E2.0.CO;2) | ||
# See also | ||
# - Bryan and Fritsch (2002) | ||
# A Benchmark Simulation for Moist Nonhydrostatic Numerical Models | ||
# [DOI: 10.1175/1520-0493(2002)130<2917:ABSFMN>2.0.CO;2](https://doi.org/10.1175/1520-0493(2002)130<2917:ABSFMN>2.0.CO;2) | ||
# - Carpenter, Droegemeier, Woodward, Hane (1990) | ||
# Application of the Piecewise Parabolic Method (PPM) to | ||
# Meteorological Modeling | ||
# [DOI: 10.1175/1520-0493(1990)118<0586:AOTPPM>2.0.CO;2](https://doi.org/10.1175/1520-0493(1990)118<0586:AOTPPM>2.0.CO;2) | ||
struct WarmBubbleSetup | ||
# Physical constants | ||
g::Float64 # gravity of earth | ||
c_p::Float64 # heat capacity for constant pressure (dry air) | ||
c_v::Float64 # heat capacity for constant volume (dry air) | ||
gamma::Float64 # heat capacity ratio (dry air) | ||
|
||
function WarmBubbleSetup(; g = 9.81, c_p = 1004.0, c_v = 717.0, gamma = c_p / c_v) | ||
new(g, c_p, c_v, gamma) | ||
end | ||
end | ||
|
||
# Initial condition | ||
function (setup::WarmBubbleSetup)(x, t, equations::CompressibleEulerEquations2D) | ||
@unpack g, c_p, c_v = setup | ||
|
||
# center of perturbation | ||
center_x = 10000.0 | ||
center_z = 2000.0 | ||
# radius of perturbation | ||
radius = 2000.0 | ||
# distance of current x to center of perturbation | ||
r = sqrt((x[1] - center_x)^2 + (x[2] - center_z)^2) | ||
|
||
# perturbation in potential temperature | ||
potential_temperature_ref = 300.0 | ||
potential_temperature_perturbation = 0.0 | ||
if r <= radius | ||
potential_temperature_perturbation = 2 * cospi(0.5 * r / radius)^2 | ||
end | ||
potential_temperature = potential_temperature_ref + potential_temperature_perturbation | ||
|
||
# Exner pressure, solves hydrostatic equation for x[2] | ||
exner = 1 - g / (c_p * potential_temperature) * x[2] | ||
|
||
# pressure | ||
p_0 = 100_000.0 # reference pressure | ||
R = c_p - c_v # gas constant (dry air) | ||
p = p_0 * exner^(c_p / R) | ||
|
||
# temperature | ||
T = potential_temperature * exner | ||
|
||
# density | ||
rho = p / (R * T) | ||
|
||
v1 = 20.0 | ||
v2 = 0.0 | ||
E = c_v * T + 0.5 * (v1^2 + v2^2) | ||
return SVector(rho, rho * v1, rho * v2, rho * E) | ||
end | ||
|
||
# Source terms | ||
@inline function (setup::WarmBubbleSetup)(u, x, t, equations::CompressibleEulerEquations2D) | ||
@unpack g = setup | ||
rho, _, rho_v2, _ = u | ||
return SVector(zero(eltype(u)), zero(eltype(u)), -g * rho, -g * rho_v2) | ||
end | ||
|
||
############################################################################### | ||
# semidiscretization of the compressible Euler equations | ||
warm_bubble_setup = WarmBubbleSetup() | ||
|
||
equations = CompressibleEulerEquations2D(warm_bubble_setup.gamma) | ||
|
||
boundary_conditions = (x_neg = boundary_condition_periodic, | ||
x_pos = boundary_condition_periodic, | ||
y_neg = boundary_condition_slip_wall, | ||
y_pos = boundary_condition_slip_wall) | ||
|
||
polydeg = 3 | ||
basis = LobattoLegendreBasis(polydeg) | ||
|
||
# This is a good estimate for the speed of sound in this example. | ||
# Other values between 300 and 400 should work as well. | ||
surface_flux = FluxLMARS(340.0) | ||
|
||
volume_flux = flux_kennedy_gruber | ||
volume_integral = VolumeIntegralFluxDifferencing(volume_flux) | ||
|
||
solver = DGSEM(basis, surface_flux, volume_integral) | ||
|
||
coordinates_min = (0.0, 0.0) | ||
coordinates_max = (20_000.0, 10_000.0) | ||
|
||
# Same coordinates as in examples/structured_2d_dgsem/elixir_euler_warm_bubble.jl | ||
# However TreeMesh will generate a 20_000 x 20_000 square domain instead | ||
mesh = TreeMesh(coordinates_min, coordinates_max, | ||
initial_refinement_level = 6, | ||
n_cells_max = 10_000, | ||
periodicity = (true, false)) | ||
|
||
semi = SemidiscretizationHyperbolic(mesh, equations, warm_bubble_setup, solver, | ||
source_terms = warm_bubble_setup, | ||
boundary_conditions = boundary_conditions) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
tspan = (0.0, 1000.0) # 1000 seconds final time | ||
|
||
ode = semidiscretize(semi, tspan) | ||
|
||
summary_callback = SummaryCallback() | ||
|
||
analysis_interval = 1000 | ||
|
||
analysis_callback = AnalysisCallback(semi, interval = analysis_interval, | ||
extra_analysis_errors = (:entropy_conservation_error,)) | ||
|
||
alive_callback = AliveCallback(analysis_interval = analysis_interval) | ||
|
||
save_solution = SaveSolutionCallback(interval = analysis_interval, | ||
save_initial_solution = true, | ||
save_final_solution = true, | ||
output_directory = "out", | ||
solution_variables = cons2prim) | ||
|
||
stepsize_callback = StepsizeCallback(cfl = 1.0) | ||
|
||
callbacks = CallbackSet(summary_callback, | ||
analysis_callback, | ||
alive_callback, | ||
save_solution, | ||
stepsize_callback) | ||
|
||
############################################################################### | ||
# run the simulation | ||
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), | ||
maxiters = 1.0e7, | ||
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback | ||
save_everystep = false, callback = callbacks); | ||
|
||
summary_callback() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.