-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement Serre-Green-Naghdi equations for flat bathymetry (#127)
* implement Serre-Green-Naghdi equations for flat bathymetry * fix typos * format * update SummationByPartsOperators compat in tests * run tests in CI * fix stuff gone wrong when formatting * Apply suggestions from code review Co-authored-by: Joshua Lampert <[email protected]> * Apply suggestions from code review Co-authored-by: Joshua Lampert <[email protected]> * format Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * use Fourier and add comments * add upwind version * unit tests * fix typo * AbstractShallowWaterEquations * add relaxation example * docstring for energy_total_modified for SGN * remove obsolete specializations * format * fix docstrings * allow nothing for D2 * store bathymetry in q * document bathymetry * fix unit tests * unit tests for energy_total_modified * fix type instability of allocate_coefficients * another unit test for energy_total_modified * Apply suggestions from code review Co-authored-by: Joshua Lampert <[email protected]> * consistency adaptations for SvaerdKalischEquations1D * additional tests for type stability * format * fix * more unit tests * Apply suggestions from code review Co-authored-by: Joshua Lampert <[email protected]> * dispatch RHS on bathymetry * stricter test tolerance * make allocs tests stricter * fix docstring --------- Co-authored-by: Joshua Lampert <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
6577a58
commit fba188f
Showing
19 changed files
with
989 additions
and
105 deletions.
There are no files selected for viewing
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
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
40 changes: 40 additions & 0 deletions
40
examples/serre_green_naghdi_1d/serre_green_naghdi_soliton.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,40 @@ | ||
using OrdinaryDiffEq | ||
using DispersiveShallowWater | ||
|
||
############################################################################### | ||
# Semidiscretization of the Serre-Green-Naghdi equations | ||
|
||
equations = SerreGreenNaghdiEquations1D(gravity_constant = 9.81) | ||
|
||
# initial_condition_convergence_test needs periodic boundary conditions | ||
initial_condition = initial_condition_convergence_test | ||
boundary_conditions = boundary_condition_periodic | ||
|
||
# create homogeneous mesh | ||
coordinates_min = -50.0 | ||
coordinates_max = 50.0 | ||
N = 512 | ||
mesh = Mesh1D(coordinates_min, coordinates_max, N) | ||
|
||
# create solver with periodic SBP operators of accuracy order 4 | ||
accuracy_order = 4 | ||
solver = Solver(mesh, accuracy_order) | ||
|
||
# semidiscretization holds all the necessary data structures for the spatial discretization | ||
semi = Semidiscretization(mesh, equations, initial_condition, solver, | ||
boundary_conditions = boundary_conditions) | ||
|
||
############################################################################### | ||
# Create `ODEProblem` and run the simulation | ||
tspan = (0.0, (xmax(mesh) - xmin(mesh)) / sqrt(1.2 * equations.gravity)) # one period | ||
ode = semidiscretize(semi, tspan) | ||
summary_callback = SummaryCallback() | ||
analysis_callback = AnalysisCallback(semi; interval = 100, | ||
extra_analysis_errors = (:conservation_error,), | ||
extra_analysis_integrals = (waterheight_total, | ||
entropy_modified)) | ||
callbacks = CallbackSet(analysis_callback, summary_callback) | ||
|
||
saveat = range(tspan..., length = 100) | ||
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7, | ||
save_everystep = false, callback = callbacks, saveat = saveat) |
41 changes: 41 additions & 0 deletions
41
examples/serre_green_naghdi_1d/serre_green_naghdi_soliton_fourier.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,41 @@ | ||
using OrdinaryDiffEq | ||
using DispersiveShallowWater | ||
using SummationByPartsOperators: fourier_derivative_operator | ||
|
||
############################################################################### | ||
# Semidiscretization of the Serre-Green-Naghdi equations | ||
|
||
equations = SerreGreenNaghdiEquations1D(gravity_constant = 9.81) | ||
|
||
# initial_condition_convergence_test needs periodic boundary conditions | ||
initial_condition = initial_condition_convergence_test | ||
boundary_conditions = boundary_condition_periodic | ||
|
||
# create homogeneous mesh | ||
coordinates_min = -50.0 | ||
coordinates_max = 50.0 | ||
N = 128 | ||
mesh = Mesh1D(coordinates_min, coordinates_max, N) | ||
|
||
# create solver with Fourier pseudospectral collocation method | ||
D1 = fourier_derivative_operator(xmin(mesh), xmax(mesh), nnodes(mesh)) | ||
solver = Solver(D1, nothing) | ||
|
||
# semidiscretization holds all the necessary data structures for the spatial discretization | ||
semi = Semidiscretization(mesh, equations, initial_condition, solver, | ||
boundary_conditions = boundary_conditions) | ||
|
||
############################################################################### | ||
# Create `ODEProblem` and run the simulation | ||
tspan = (0.0, (xmax(mesh) - xmin(mesh)) / sqrt(1.2 * equations.gravity)) # one period | ||
ode = semidiscretize(semi, tspan) | ||
summary_callback = SummaryCallback() | ||
analysis_callback = AnalysisCallback(semi; interval = 100, | ||
extra_analysis_errors = (:conservation_error,), | ||
extra_analysis_integrals = (waterheight_total, | ||
entropy_modified)) | ||
callbacks = CallbackSet(analysis_callback, summary_callback) | ||
|
||
saveat = range(tspan..., length = 100) | ||
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7, | ||
save_everystep = false, callback = callbacks, saveat = saveat) |
43 changes: 43 additions & 0 deletions
43
examples/serre_green_naghdi_1d/serre_green_naghdi_soliton_relaxation.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,43 @@ | ||
using OrdinaryDiffEq | ||
using DispersiveShallowWater | ||
using SummationByPartsOperators: fourier_derivative_operator | ||
|
||
############################################################################### | ||
# Semidiscretization of the Serre-Green-Naghdi equations | ||
|
||
equations = SerreGreenNaghdiEquations1D(gravity_constant = 9.81) | ||
|
||
# initial_condition_convergence_test needs periodic boundary conditions | ||
initial_condition = initial_condition_convergence_test | ||
boundary_conditions = boundary_condition_periodic | ||
|
||
# create homogeneous mesh | ||
coordinates_min = -50.0 | ||
coordinates_max = 50.0 | ||
N = 128 | ||
mesh = Mesh1D(coordinates_min, coordinates_max, N) | ||
|
||
# create solver with Fourier pseudospectral collocation method | ||
D1 = fourier_derivative_operator(xmin(mesh), xmax(mesh), nnodes(mesh)) | ||
solver = Solver(D1, nothing) | ||
|
||
# semidiscretization holds all the necessary data structures for the spatial discretization | ||
semi = Semidiscretization(mesh, equations, initial_condition, solver, | ||
boundary_conditions = boundary_conditions) | ||
|
||
############################################################################### | ||
# Create `ODEProblem` and run the simulation | ||
tspan = (0.0, (xmax(mesh) - xmin(mesh)) / sqrt(1.2 * equations.gravity)) # one period | ||
ode = semidiscretize(semi, tspan) | ||
summary_callback = SummaryCallback() | ||
analysis_callback = AnalysisCallback(semi; interval = 100, | ||
extra_analysis_errors = (:conservation_error,), | ||
extra_analysis_integrals = (waterheight_total, | ||
entropy_modified)) | ||
relaxation_callback = RelaxationCallback(invariant = entropy_modified) | ||
# Always put relaxation_callback before analysis_callback to guarantee conservation of the invariant | ||
callbacks = CallbackSet(relaxation_callback, analysis_callback, summary_callback) | ||
|
||
saveat = range(tspan..., length = 100) | ||
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7, | ||
save_everystep = false, callback = callbacks, saveat = saveat) |
48 changes: 48 additions & 0 deletions
48
examples/serre_green_naghdi_1d/serre_green_naghdi_soliton_upwind.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,48 @@ | ||
using OrdinaryDiffEq | ||
using DispersiveShallowWater | ||
using SummationByPartsOperators: upwind_operators, periodic_derivative_operator | ||
using SparseArrays: sparse | ||
|
||
############################################################################### | ||
# Semidiscretization of the Serre-Green-Naghdi equations | ||
|
||
equations = SerreGreenNaghdiEquations1D(gravity_constant = 9.81) | ||
|
||
# initial_condition_convergence_test needs periodic boundary conditions | ||
initial_condition = initial_condition_convergence_test | ||
boundary_conditions = boundary_condition_periodic | ||
|
||
# create homogeneous mesh | ||
coordinates_min = -50.0 | ||
coordinates_max = 50.0 | ||
N = 512 | ||
mesh = Mesh1D(coordinates_min, coordinates_max, N) | ||
|
||
# create solver with periodic upwind SBP operators of accuracy order 4 | ||
# (note that only central-type with even order are used) | ||
accuracy_order = 4 | ||
D1 = upwind_operators(periodic_derivative_operator; | ||
derivative_order = 1, | ||
accuracy_order = accuracy_order - 1, | ||
xmin = xmin(mesh), xmax = xmax(mesh), | ||
N = nnodes(mesh)) | ||
solver = Solver(D1, nothing) | ||
|
||
# semidiscretization holds all the necessary data structures for the spatial discretization | ||
semi = Semidiscretization(mesh, equations, initial_condition, solver, | ||
boundary_conditions = boundary_conditions) | ||
|
||
############################################################################### | ||
# Create `ODEProblem` and run the simulation | ||
tspan = (0.0, (xmax(mesh) - xmin(mesh)) / sqrt(1.2 * equations.gravity)) # one period | ||
ode = semidiscretize(semi, tspan) | ||
summary_callback = SummaryCallback() | ||
analysis_callback = AnalysisCallback(semi; interval = 100, | ||
extra_analysis_errors = (:conservation_error,), | ||
extra_analysis_integrals = (waterheight_total, | ||
entropy_modified)) | ||
callbacks = CallbackSet(analysis_callback, summary_callback) | ||
|
||
saveat = range(tspan..., length = 100) | ||
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7, | ||
save_everystep = false, callback = callbacks, saveat = saveat) |
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
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
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
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.