-
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.
Allow Fourier and periodic rational derivative operators for `BBMBBME…
…quations1D` and `SvaerdKalischEquations1D` (#154) * allow Fourier and periodic rational derivative operators * format * adjust tolerances * avoid clutter * fix * add test for PeriodicRationalDerivativeOperator for BBMEquation1D
- Loading branch information
1 parent
2f11fb1
commit a80b640
Showing
13 changed files
with
216 additions
and
21 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
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
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 BBM-BBM equation | ||
|
||
# or bathymetry_variable instead of bathymetry_flat | ||
equations = BBMBBMEquations1D(bathymetry_type = bathymetry_flat, 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 = -35.0 | ||
coordinates_max = 35.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, 30.0) | ||
ode = semidiscretize(semi, tspan) | ||
summary_callback = SummaryCallback() | ||
analysis_callback = AnalysisCallback(semi; interval = 10, | ||
extra_analysis_errors = (:conservation_error,), | ||
extra_analysis_integrals = (waterheight_total, | ||
velocity, entropy)) | ||
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/svaerd_kalisch_1d/svaerd_kalisch_1d_dingemans_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,43 @@ | ||
using OrdinaryDiffEq | ||
using DispersiveShallowWater | ||
using SummationByPartsOperators: fourier_derivative_operator | ||
|
||
############################################################################### | ||
# Semidiscretization of the Svärd-Kalisch equations | ||
|
||
equations = SvaerdKalischEquations1D(gravity_constant = 9.81, eta0 = 0.8, alpha = 0.0, | ||
beta = 0.27946992481203003, gamma = 0.0521077694235589) | ||
|
||
initial_condition = initial_condition_dingemans | ||
boundary_conditions = boundary_condition_periodic | ||
|
||
# create homogeneous mesh | ||
coordinates_min = -138.0 | ||
coordinates_max = 46.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, 70.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, | ||
entropy_modified)) | ||
callbacks = CallbackSet(analysis_callback, summary_callback) | ||
|
||
saveat = range(tspan..., length = 500) | ||
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
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.