Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BBMEquation1D #150

Merged
merged 39 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
8733df4
add BBMEquation1D
JoshuaLampert Sep 10, 2024
1e3d7cd
format
JoshuaLampert Sep 10, 2024
31a4613
fix
JoshuaLampert Sep 10, 2024
5cbb277
add BBM to docs
JoshuaLampert Sep 10, 2024
c9ee358
adjust docs
JoshuaLampert Sep 10, 2024
4f8a46c
fix names of testsets
JoshuaLampert Sep 10, 2024
8014e72
Merge branch 'main' into bbm-equation
JoshuaLampert Sep 11, 2024
9a7d1de
Merge branch 'main' into bbm-equation
JoshuaLampert Sep 11, 2024
de01822
Apply suggestions from code review
JoshuaLampert Sep 11, 2024
d7f07ea
fix quadratic invariant
JoshuaLampert Sep 11, 2024
e34aa54
fix test values
JoshuaLampert Sep 11, 2024
931072a
a bit more clarifying comments about energy_total_modified
JoshuaLampert Sep 11, 2024
1e01799
fix docstring
JoshuaLampert Sep 11, 2024
30f15ec
Apply suggestions from code review
JoshuaLampert Sep 11, 2024
673a72d
fix entropy_modified
JoshuaLampert Sep 12, 2024
577303c
change to Hamiltonian and implement non-split form semi
JoshuaLampert Sep 15, 2024
5808a59
Apply suggestions from code review
JoshuaLampert Sep 15, 2024
04c5c51
fix docstring
JoshuaLampert Sep 15, 2024
c1995a6
Merge branch 'bbm-equation' of https://github.com/JoshuaLampert/Dispe…
JoshuaLampert Sep 15, 2024
5cca7f4
fix unit test
JoshuaLampert Sep 15, 2024
b9c0e0a
Apply suggestions from code review
JoshuaLampert Sep 15, 2024
c1360b5
add reference in docstring
JoshuaLampert Sep 15, 2024
e5d29d3
fix tests
JoshuaLampert Sep 15, 2024
62a31bd
nicer rendering
JoshuaLampert Sep 15, 2024
05abcc0
Apply suggestions from code review
JoshuaLampert Sep 16, 2024
3adc071
use dimensional equation
JoshuaLampert Sep 17, 2024
8547cd9
fix Hamiltonian in docstring
JoshuaLampert Sep 17, 2024
5fdc0c9
fix typo
JoshuaLampert Sep 17, 2024
56929ab
remove spurious gif
JoshuaLampert Sep 17, 2024
51e54cc
fix typo
JoshuaLampert Sep 17, 2024
df9451e
fix modified entropy
JoshuaLampert Sep 17, 2024
925727e
soften tolerance
JoshuaLampert Sep 17, 2024
4561e8a
fix name of test module
JoshuaLampert Sep 17, 2024
2b0b4db
Apply suggestions from code review
JoshuaLampert Sep 17, 2024
b40b9b4
remove bathymetry type
JoshuaLampert Sep 17, 2024
05d3fbd
adjust comments
JoshuaLampert Sep 17, 2024
24d9222
one half [skip ci]
JoshuaLampert Sep 17, 2024
edb245a
run CI
JoshuaLampert Sep 18, 2024
256eed5
revert
JoshuaLampert Sep 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ used in the Julia ecosystem. Notable changes will be documented in this file
for human readability.


## Changes in the v0.4 lifecycle

#### Added
- Add `BBMEquation1D` ([#150]).

## Changes when updating to v0.5 from v0.4.x

#### Changed
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
**DispersiveShallowWater.jl** is a [Julia](https://julialang.org/) package that implements structure-preserving numerical methods for dispersive shallow water models.
To date, it provides provably conservative, entropy-conserving and well-balanced numerical schemes for some dispersive shallow water models:

* the [BBM equation](https://doi.org/10.4208/cicp.OA-2020-0119),
JoshuaLampert marked this conversation as resolved.
Show resolved Hide resolved
* the [BBM-BBM equations with varying bottom topography](https://iopscience.iop.org/article/10.1088/1361-6544/ac3c29),
* the [dispersive shallow water model proposed by Magnus Svärd and Henrik Kalisch](https://arxiv.org/abs/2302.09924),
* the [Serre-Green-Naghdi equations](https://arxiv.org/abs/2408.02665).
Expand Down
1 change: 1 addition & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
[**DispersiveShallowWater.jl**](https://github.com/JoshuaLampert/DispersiveShallowWater.jl) is a [Julia](https://julialang.org/) package that implements structure-preserving numerical methods for dispersive shallow water models.
To date, it provides provably conservative, entropy-conserving and well-balanced numerical schemes for some dispersive shallow water models:

* the [BBM equation](https://doi.org/10.4208/cicp.OA-2020-0119),
JoshuaLampert marked this conversation as resolved.
Show resolved Hide resolved
* the [BBM-BBM equations with varying bottom topography](https://iopscience.iop.org/article/10.1088/1361-6544/ac3c29),
* the [dispersive shallow water model proposed by Magnus Svärd and Henrik Kalisch](https://arxiv.org/abs/2302.09924),
* the [Serre-Green-Naghdi equations](https://arxiv.org/abs/2408.02665).
Expand Down
40 changes: 40 additions & 0 deletions examples/bbm_1d/bbm_1d_basic.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using OrdinaryDiffEq
using DispersiveShallowWater

###############################################################################
# Semidiscretization of the BBM equation

equations = BBMEquation1D()

initial_condition = initial_condition_convergence_test
boundary_conditions = boundary_condition_periodic

# create homogeneous mesh
coordinates_min = -90.0
coordinates_max = 90.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, 1000.0)
ode = semidiscretize(semi, tspan)
summary_callback = SummaryCallback()
analysis_callback = AnalysisCallback(semi; interval = 10,
extra_analysis_errors = (:conservation_error,),
extra_analysis_integrals = (waterheight_total,
entropy_modified,
invariant_cubic))
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)
42 changes: 42 additions & 0 deletions examples/bbm_1d/bbm_1d_fourier.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using OrdinaryDiffEq
using DispersiveShallowWater
using SummationByPartsOperators: fourier_derivative_operator

###############################################################################
# Semidiscretization of the BBM equation

equations = BBMEquation1D()

initial_condition = initial_condition_convergence_test
boundary_conditions = boundary_condition_periodic

# create homogeneous mesh
coordinates_min = -90.0
coordinates_max = 90.0
N = 512
mesh = Mesh1D(coordinates_min, coordinates_max, N)

# create solver with Fourier SBP operators
D1 = fourier_derivative_operator(xmin(mesh), xmax(mesh), nnodes(mesh))
D2 = D1^2
solver = Solver(D1, D2)

# 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, 1000.0)
ode = semidiscretize(semi, tspan)
summary_callback = SummaryCallback()
analysis_callback = AnalysisCallback(semi; interval = 10,
extra_analysis_errors = (:conservation_error,),
extra_analysis_integrals = (waterheight_total,
entropy_modified,
invariant_cubic))
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)
40 changes: 40 additions & 0 deletions examples/bbm_1d/bbm_1d_manufactured.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using OrdinaryDiffEq
using DispersiveShallowWater

###############################################################################
# Semidiscretization of the BBM equation

equations = BBMEquation1D()

initial_condition = initial_condition_manufactured
source_terms = source_terms_manufactured
boundary_conditions = boundary_condition_periodic

# create homogeneous mesh
coordinates_min = -1.0
coordinates_max = 1.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,
source_terms = source_terms)

###############################################################################
# Create `ODEProblem` and run the simulation
tspan = (0.0, 1.0)
ode = semidiscretize(semi, tspan)
summary_callback = SummaryCallback()
analysis_callback = AnalysisCallback(semi; interval = 10,
extra_analysis_errors = (:conservation_error,),
extra_analysis_integrals = (waterheight_total,))
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 examples/bbm_1d/bbm_1d_relaxation.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using OrdinaryDiffEq
using DispersiveShallowWater

###############################################################################
# Semidiscretization of the BBM equation

equations = BBMEquation1D()

initial_condition = initial_condition_convergence_test
boundary_conditions = boundary_condition_periodic

# create homogeneous mesh
coordinates_min = -90.0
coordinates_max = 90.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, 1000.0)
ode = semidiscretize(semi, tspan)
summary_callback = SummaryCallback()
analysis_callback = AnalysisCallback(semi; interval = 10,
extra_analysis_errors = (:conservation_error,),
extra_analysis_integrals = (waterheight_total,
entropy_modified,
invariant_cubic))

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)
5 changes: 3 additions & 2 deletions src/DispersiveShallowWater.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ include("util.jl")
export examples_dir, get_examples, default_example, convergence_test

export AbstractShallowWaterEquations,
BBMBBMEquations1D,
BBMEquation1D, BBMBBMEquations1D,
SvärdKalischEquations1D, SvaerdKalischEquations1D,
SerreGreenNaghdiEquations1D, HyperbolicSerreGreenNaghdiEquations1D

Expand All @@ -71,7 +71,8 @@ export prim2prim, prim2cons, cons2prim, prim2phys,
gravity_constant,
bathymetry, still_water_surface,
energy_total, entropy, lake_at_rest_error,
energy_total_modified, entropy_modified
energy_total_modified, entropy_modified,
invariant_cubic

export Mesh1D, xmin, xmax, nnodes

Expand Down
1 change: 1 addition & 0 deletions src/callbacks_step/analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,4 @@ pretty_form_utf(::typeof(energy_total)) = "∫e_total"
pretty_form_utf(::typeof(entropy_modified)) = "∫U_modified"
pretty_form_utf(::typeof(energy_total_modified)) = "∫e_modified"
pretty_form_utf(::typeof(lake_at_rest_error)) = "∫|η-η₀|"
pretty_form_utf(::typeof(invariant_cubic)) = "∫(η + 1)³"
Loading
Loading