Skip to content

Commit 189696e

Browse files
Merge branch 'main' into patch-1
2 parents 72875c7 + 1e607d9 commit 189696e

21 files changed

+149
-128
lines changed

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ DispersiveShallowWater.jl follows the interpretation of
55
used in the Julia ecosystem. Notable changes will be documented in this file
66
for human readability.
77

8+
## Changes when updating to v0.8 from v0.7.x
9+
10+
#### Changed
11+
12+
- The initial condition `initial_condition_dingemans` uses equation-specific offsets to account for phase shifts
13+
compared to the experimental data and a slightly different range for the initial wave train ([#237]).
814

915
## Changes in the v0.7 lifecycle
1016

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DispersiveShallowWater"
22
uuid = "4ab875f6-b79a-4e28-9745-4f0293954817"
33
authors = ["Joshua Lampert <joshua.lampert@uni-hamburg.de>"]
4-
version = "0.7.8-DEV"
4+
version = "0.8.1-DEV"
55

66
[deps]
77
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"

benchmark/benchmarks.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ for elixir in elixirs
2222
benchname = joinpath(basename(dirname(elixir)), basename(elixir)) * " - rhs!:"
2323
println("Running $benchname...")
2424
redirect_stdout(devnull) do
25-
trixi_include(@__MODULE__, elixir, tspan = (0.0, 1e-10))
25+
trixi_include(@__MODULE__, elixir, tspan = (0.0, 1e-11))
2626
end
2727
SUITE[benchname] = @benchmarkable DispersiveShallowWater.rhs!($(similar(sol.u[end])),
2828
$(copy(sol.u[end])),

docs/src/basic_example.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ Lastly, we define the physical domain as the interval from -130 to 20 and we cho
7272

7373
## Define numerical solver
7474

75-
In the next step, we build a [`Semidiscretization`](@ref) that bundles all ingredients for the spatial discretization of the model. Especially, we need to define a [`Solver`](@ref).
75+
In the next step, we build a [`Semidiscretization`](@ref) that bundles all ingredients for the spatial discretization of the model. Especially, we need to define a [`Solver`](@ref).
7676

7777
The simplest way to define a solver when working with [`boundary_condition_periodic`](@ref) is to call the constructor by providing the mesh and a desired order of accuracy.
7878

79-
In the following example, we use an accuracy order of 4. The default constructor simply creates periodic first-, second-, and third-derivative central finite difference summation-by-parts (SBP) operators of the provided order of accuracy.
79+
In the following example, we use an accuracy order of 4. The default constructor simply creates periodic first-, second-, and third-derivative central finite difference summation-by-parts (SBP) operators of the provided order of accuracy.
8080

8181
How to use other summation-by-parts operators, is described in the section on [how to customize the solver](@ref customize_solver). Note that for non-periodic boundary conditions, the solver also needs to be created with non-periodic
8282
operators, see, e.g. [examples/bbm\_bbm\_1d/bbm\_bbm\_1d\_basic\_reflecting.jl](https://github.com/NumericalMathematics/DispersiveShallowWater.jl/blob/main/examples/bbm_bbm_1d/bbm_bbm_1d_basic_reflecting.jl).
@@ -127,11 +127,10 @@ nothing # hide
127127

128128
![shoaling solution](shoaling_solution.png)
129129

130-
By default, this will plot the bathymetry, but not the initial (analytical) solution.
130+
By default, this will plot the bathymetry, but not the initial (analytical) solution.
131131

132132
You can adjust this by passing the boolean values `plot_bathymetry` (if `true`, always plot bathymetry in the first subplot) and `plot_initial`. Note that `plot_initial = true` will evaluate and plot the initial condition function at the same time `t` as the numerical solution being displayed (the final time by default). This means if your initial condition function represents an analytical solution, setting `plot_initial = true` will plot the analytical solution at that specific time for comparison.
133133

134-
135134
Plotting an animation over time can, e.g., be done by the following command, which uses `step` to plot the solution at a specific time step. Here `conversion = waterheight_total` makes it so that we only look at the waterheight ``\eta`` and not also the velocity ``v``. More on tutorials for plotting can be found in the chapter [Plotting Simulation Results](@ref plotting).
136135

137136
```@example overview
@@ -150,7 +149,6 @@ It is also possible to plot the solution variables at a fixed spatial point over
150149

151150
More examples sorted by the simulated equations can be found in the [examples/](https://github.com/NumericalMathematics/DispersiveShallowWater.jl/tree/main/examples) subdirectory.
152151

153-
154152
## [Plain program](@id overview-plain-program)
155153

156154
Here follows a version of the program without any comments.

docs/src/callbacks.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# Callbacks
22

33
Callbacks provide additional functionality during simulations, such as monitoring solution properties, analyzing errors, or ensuring conservation of physical quantities.
4-
[DispersiveShallowWater.jl](https://github.com/NumericalMathematics/DispersiveShallowWater.jl implements three main callback types that can be used individually or in combination to enhance simulation analysis and performance monitoring.
4+
[DispersiveShallowWater.jl](https://github.com/NumericalMathematics/DispersiveShallowWater.jl) implements three main callback types that can be used individually or in combination to enhance simulation analysis and performance monitoring.
55

66
When using multiple callbacks simultaneously, combine them using a `CallbackSet`:
77

88
```julia
99
callbacks = CallbackSet(analysis_callback, summary_callback)
1010
sol = solve(ode, Tsit5(), callback = callbacks)
1111
```
12+
1213
More information on the usage of callbacks within the SciML framework can be found [in the documentation](https://docs.sciml.ai/DiffEqDocs/stable/features/callback_functions/).
1314

1415
## Summary Callback
@@ -28,7 +29,7 @@ sol = solve(ode, Tsit5(), callback = summary_callback)
2829

2930
At the end of the simulation, the callback will display output similar to:
3031

31-
```
32+
```julia
3233
───────────────────────────────────────────────────────────────────────────────────────────
3334
DispersiveSWE Time Allocations
3435
─────────────────────── ────────────────────────
@@ -46,7 +47,6 @@ analyze solution 3 13.2ms 3.0% 4.39ms 147KiB 0.
4647
───────────────────────────────────────────────────────────────────────────────────────────
4748
```
4849

49-
5050
## Analysis Callback
5151

5252
The [`AnalysisCallback`](@ref) monitors solution quality and physical properties during the simulation. It computes error norms and tracks conservation of important physical quantities at specified time intervals.
@@ -189,4 +189,4 @@ For additional information on relaxation, how it works, and why and when it is u
189189
[^RanochaSayyariDalcinParsaniKetcheson2020]:
190190
Ranocha, Sayyari, Dalcin, Parsani, Ketcheson (2020):
191191
Relaxation Runge–Kutta Methods: Fully-Discrete Explicit Entropy-Stable Schemes for the Compressible Euler and Navier–Stokes Equations.
192-
[DOI: 10.1137/19M1263480](https://doi.org/10.1137/19M1263480)
192+
[DOI: 10.1137/19M1263480](https://doi.org/10.1137/19M1263480)

docs/src/dingemans.md

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The bathymetry profile consists of:
1010

1111
- A flat section from the wave maker to x = 11.01
1212
- A linearly increasing slope from x = 11.01 to x = 23.04 (maximum height of 0.6)
13-
- A flat plateau from x = 23.04 to x = 27.04
13+
- A flat plateau from x = 23.04 to x = 27.04
1414
- A linearly decreasing slope from x = 27.04 to x = 33.07
1515
- A flat section beyond x = 33.07
1616

@@ -33,17 +33,17 @@ Next, we set up the different equation systems we want to compare:
3333
bbmbbm = BBMBBMEquations1D(bathymetry_type = bathymetry_variable,
3434
gravity = 9.81, eta0 = 0.0)
3535
36-
# Svärd-Kalisch equations with specific parameter set
37-
sk = SvaerdKalischEquations1D(gravity = 9.81, eta0 = 0.8, alpha = 0.0,
38-
beta = 0.27946992481203003, gamma = 0.0521077694235589)
36+
# Svärd-Kalisch equations with specific parameter set (optimized for small wave numbers)
37+
sk = SvaerdKalischEquations1D(gravity = 9.81, eta0 = 0.8, alpha = 0.0004040404040404049,
38+
beta = 0.49292929292929294, gamma = 0.15707070707070708)
3939
40-
# Serre-Green-Naghdi equations with variable bathymetry
40+
# Serre-Green-Naghdi equations with variable bathymetry
4141
sgn = SerreGreenNaghdiEquations1D(bathymetry_type = bathymetry_variable,
42-
gravity = 9.81)
42+
gravity = 9.81, eta0 = 0.8)
4343
4444
# Hyperbolic approximation of Serre-Green-Naghdi equations
4545
hysgn = HyperbolicSerreGreenNaghdiEquations1D(bathymetry_type = bathymetry_mild_slope,
46-
lambda = 100.0, gravity = 9.81)
46+
lambda = 100.0, gravity = 9.81, eta0 = 0.8)
4747
# for actual simulations a higher lambda (~500) is recommended
4848
# it is chosen so low to be able to see the difference between it
4949
# and the SGN equation.
@@ -134,8 +134,7 @@ y_limits = (-0.03, 0.87)
134134
# Model configurations: (semidiscretization, solution, label, conversion_function, linestyle)
135135
models = [
136136
(semi_bbmbbm, sol_bbmbbm, "BBM-BBM", shifted_waterheight, :solid),
137-
# Svärd-Kalisch has a phase shift which need to be adjusted for in the initial condition
138-
# (semi_sk, sol_sk, "Svärd-Kalisch", waterheight_total, :dashdotdot),
137+
(semi_sk, sol_sk, "Svärd-Kalisch", waterheight_total, :dashdotdot),
139138
(semi_sgn, sol_sgn, "Serre-Green-Naghdi", waterheight_total, :dot),
140139
(semi_hysgn, sol_hysgn, "Hyperbolic Serre-Green-Naghdi", waterheight_total, :dashdot)
141140
]
@@ -164,7 +163,7 @@ for time_val in times
164163
push!(snapshot_plots, p)
165164
end
166165
167-
# Create legend plot
166+
# Create legend plot
168167
legend_plot = plot(legend=:top, framestyle=:none, legendfontsize=11)
169168
170169
for (i, (_, _, label, _, linestyle)) in enumerate(models)
@@ -190,7 +189,6 @@ nothing # hide
190189

191190
The results show how different dispersive wave models capture the wave evolution over the trapezoidal bathymetry.
192191

193-
194192
## [Plain program](@id overview-plain-program-dingemans)
195193

196194
Here follows a version of the program without any comments.
@@ -202,17 +200,17 @@ using DispersiveShallowWater, OrdinaryDiffEqTsit5, Plots
202200
bbmbbm = BBMBBMEquations1D(bathymetry_type = bathymetry_variable,
203201
gravity = 9.81, eta0 = 0.0)
204202

205-
# Svärd-Kalisch equations with specific parameter set
206-
sk = SvaerdKalischEquations1D(gravity = 9.81, eta0 = 0.8, alpha = 0.0,
207-
beta = 0.27946992481203003, gamma = 0.0521077694235589)
203+
# Svärd-Kalisch equations with specific parameter set (optimized for small wave numbers)
204+
sk = SvaerdKalischEquations1D(gravity = 9.81, eta0 = 0.8, alpha = 0.0004040404040404049,
205+
beta = 0.49292929292929294, gamma = 0.15707070707070708)
208206

209-
# Serre-Green-Naghdi equations with variable bathymetry
207+
# Serre-Green-Naghdi equations with variable bathymetry
210208
sgn = SerreGreenNaghdiEquations1D(bathymetry_type = bathymetry_variable,
211-
gravity = 9.81)
209+
gravity = 9.81, eta0 = 0.8)
212210

213211
# Hyperbolic approximation of Serre-Green-Naghdi equations
214212
hysgn = HyperbolicSerreGreenNaghdiEquations1D(bathymetry_type = bathymetry_mild_slope,
215-
lambda = 100.0, gravity = 9.81)
213+
lambda = 100.0, gravity = 9.81, eta0 = 0.8)
216214
# for actual simulations a higher lambda (~500) is recommended
217215
# it is chosen so low to be able to see the difference between it
218216
# and the SGN equation.
@@ -262,8 +260,7 @@ y_limits = (-0.03, 0.87)
262260
# Model configurations: (semidiscretization, solution, label, conversion_function, linestyle)
263261
models = [
264262
(semi_bbmbbm, sol_bbmbbm, "BBM-BBM", shifted_waterheight, :solid),
265-
# Svärd-Kalisch has a phase shift which need to be adjusted for in the initial condition
266-
# (semi_sk, sol_sk, "Svärd-Kalisch", waterheight_total, :dashdotdot),
263+
(semi_sk, sol_sk, "Svärd-Kalisch", waterheight_total, :dashdotdot),
267264
(semi_sgn, sol_sgn, "Serre-Green-Naghdi", waterheight_total, :dot),
268265
(semi_hysgn, sol_hysgn, "Hyperbolic Serre-Green-Naghdi", waterheight_total, :dashdot)
269266
]
@@ -292,7 +289,7 @@ for time_val in times
292289
push!(snapshot_plots, p)
293290
end
294291

295-
# Create legend plot
292+
# Create legend plot
296293
legend_plot = plot(legend=:top, framestyle=:none, legendfontsize=11)
297294

298295
for (i, (_, _, label, _, linestyle)) in enumerate(models)
@@ -321,4 +318,4 @@ plot(all_plots...,
321318
[^Dingemans1997]:
322319
Dingemans (1997):
323320
Water Wave Propagation Over Uneven Bottoms (In 2 Parts).
324-
[DOI: 10.1142/1241](https://doi.org/10.1142/1241)
321+
[DOI: 10.1142/1241](https://doi.org/10.1142/1241)

docs/src/dispersion.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ function initial_condition_traveling_wave(x, t, equations, mesh)
8888
omega = frequency(k)
8989
h0 = reference_height()
9090
A = 0.02
91-
h = A * cos(k * x - omega * t)
92-
v = sqrt(equations.gravity / k * tanh(k * h0)) * h / h0
93-
eta = h + equations.eta0
91+
eta_prime = A * cos(k * x - omega * t)
92+
v = sqrt(equations.gravity / k * tanh(k * h0)) * eta_prime / h0
93+
eta = eta_prime + equations.eta0
9494
D = h0
9595
return SVector(eta, v, D)
9696
end

docs/src/overview.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@ The following table provides an overview of all available equation systems and t
2222
![water height and bathymetry](bathymetry.png)
2323

2424
- ``\eta``: Total water height
25-
- ``v``: Velocity in horizontal direction
25+
- ``v``: Velocity in horizontal direction
2626
- ``D``: Still-water depth
2727
- ``w``: Auxiliary variable in hyperbolic approximation (``\approx -h v_x``)
2828
- ``H``: Auxiliary variable in hyperbolic approximation (``\approx h``)
2929

30-
3130
## Abstract Shallow Water Equations Interface
3231

3332
Several equation systems in [DispersiveShallowWater.jl](https://github.com/NumericalMathematics/DispersiveShallowWater.jl) (`BBMBBMEquations1D`, `SvaerdKalischEquations1D`, `SerreGreenNaghdiEquations1D`, and `HyperbolicSerreGreenNaghdiEquations1D`) are subtypes of [`AbstractShallowWaterEquations`](@ref). This design reflects that these systems all contain the classical shallow water equations as a subsystem, extended with additional dispersive terms.

docs/src/plotting.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ nothing # hide
4141

4242
# [Plotting Simulation Results](@id plotting)
4343

44-
[DispersiveShallowWater.jl](https://github.com/NumericalMathematics/DispersiveShallowWater.jl) provides flexible plotting capabilities through [Plots.jl](https://github.com/JuliaPlots/Plots.jl) recipes. The plotting system supports various conversion functions, visualization options, and analysis tools.
44+
[DispersiveShallowWater.jl](https://github.com/NumericalMathematics/DispersiveShallowWater.jl) provides flexible plotting capabilities through [Plots.jl](https://github.com/JuliaPlots/Plots.jl) recipes. The plotting system supports various conversion functions, visualization options, and analysis tools.
4545

4646
[Makie.jl](https://docs.makie.org/stable/) is not supported yet. [Contributions are welcome](https://github.com/NumericalMathematics/DispersiveShallowWater.jl/issues/220).
4747

@@ -59,7 +59,7 @@ using Plots
5959
6060
t = 13.37 # plot solution at (roughly) t = 13.37s
6161
step_idx = argmin(abs.(saveat .- t)) # get the closest point to 13.37
62-
p1 = plot(semi => sol, conversion = prim2prim, plot_bathymetry = false,
62+
p1 = plot(semi => sol, conversion = prim2prim, plot_bathymetry = false,
6363
suptitle = "Primitive Variables", step = step_idx)
6464
p2 = plot(semi => sol, conversion = prim2cons, plot_bathymetry = false,
6565
suptitle = "Conservative Variables", step = step_idx)

docs/src/solvers.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ solver = Solver(D1, D2, D3)
4242
```
4343

4444
where:
45-
- `D1` is always required and must be an `AbstractDerivativeOperator`
45+
46+
- `D1` is always required and must be an `AbstractDerivativeOperator`
4647
- `D2` and `D3` are optional and can be either `AbstractDerivativeOperator`s, `AbstractMatrix`es, or `nothing`
4748

4849
## Reflecting Boundary Conditions
@@ -68,6 +69,7 @@ Other possible choices for sources can be found in the [documentation of Summati
6869
For equations that benefit from upwind discretizations (such as the Serre-Green-Naghdi equations), you can use [upwind SBP Operators](@ref upwind_sbp):
6970

7071
**For periodic boundary conditions:**
72+
7173
```julia
7274
using SummationByPartsOperators: upwind_operators, periodic_derivative_operator
7375

@@ -81,6 +83,7 @@ solver = Solver(D1)
8183
```
8284

8385
**For reflecting boundary conditions:**
86+
8487
```julia
8588
using SummationByPartsOperators: Mattsson2017, upwind_operators
8689

@@ -197,6 +200,7 @@ semi = Semidiscretization(mesh, equations, initial_condition, solver,
197200
```
198201

199202
The solver you choose should be compatible with your boundary conditions:
203+
200204
- Periodic operators (created with `periodic_derivative_operator` or `fourier_derivative_operator`) require `boundary_condition_periodic`
201205
- Non-periodic operators (created with `MattssonNordström2004`, etc.) are needed for `boundary_condition_reflecting`
202206

@@ -205,6 +209,7 @@ The solver you choose should be compatible with your boundary conditions:
205209
### Mismatched Operators and Boundary Conditions
206210

207211
**Problem**: Using periodic operators with reflecting boundary conditions or vice versa.
212+
208213
```julia
209214
# ❌ This will fail
210215
D1 = periodic_derivative_operator(1, 4, mesh.xmin, mesh.xmax, mesh.N)
@@ -214,9 +219,10 @@ semi = Semidiscretization(mesh, equations, initial_condition, solver,
214219
```
215220

216221
**Solution**: Match operator type to boundary conditions:
222+
217223
```julia
218224
# ✅ Correct approach
219-
D1 = derivative_operator(MattssonNordström2004(), derivative_order = 1,
225+
D1 = derivative_operator(MattssonNordström2004(), derivative_order = 1,
220226
accuracy_order = 4, xmin = mesh.xmin, xmax = mesh.xmax, N = mesh.N)
221227
solver = Solver(D1)
222228
semi = Semidiscretization(mesh, equations, initial_condition, solver,
@@ -226,6 +232,7 @@ semi = Semidiscretization(mesh, equations, initial_condition, solver,
226232
### Incorrect Grid Size for DG Methods
227233

228234
**Problem**: Grid size not divisible by polynomial degree + 1 for DG methods.
235+
229236
```julia
230237
# ❌ N = 101, p = 3, but 101 is not divisible by (3+1) = 4
231238
N = 101
@@ -234,6 +241,7 @@ mesh = Mesh1D(coordinates_min, coordinates_max, N) # Error in DG setup!
234241
```
235242

236243
**Solution**: Ensure `N` is divisible by `p + 1`:
244+
237245
```julia
238246
# ✅ Adjust N to be divisible by p + 1
239247
p = 3

0 commit comments

Comments
 (0)