The hyperbopy
module allows solving 1D non-conservative hyperbolic systems of equations of the form:
where:
-
$\boldsymbol{U} \in \mathbb{R}^{N}$ is a vector of unkown quantities -
$\boldsymbol{F}: \in \mathbb{R}^{N} \to \mathbb{R}^{N}$ is a non-linear flux -
$B(\boldsymbol{U},Z) \in \mathbb{R}^{N \times N}$ is a non-conservative term -
$\boldsymbol{S}(\boldsymbol{U}) \in \mathbb{R}^{N \times N}$ is a source term.
The numerical schemes are:
- spatial: well-balanced central-upwind scheme (path-conservative or not) for the spatial discretization (unless specified otherwise) [1,2]
- temporal: stage-3 order-3 explicit strong stability preserving Runge-Kutta [eSSPRK 3-3] in time [3]
Here, we show how to solve the one-layer shallow water equations already implemented in hyperbopy
. More examples are available in the reference_cases
directory.
import numpy as np
from hyperbopy import Simulation
from hyperbopy.models import SW1LGlobal
# ## Domain size
L = 10 # domain length [m]
# ## Grid parameters
tmax = 2.5 # s max time
Nx = 1000 # spatial grid points number (evenly spaced)
x = np.linspace(0, L, Nx)
dx = L/(Nx - 1)
# ## Initial condition
# Bottom topography
Z = 0*x
# layer
hmin = 1e-10
l0 = 5
h0 = 0.5
#
h = hmin*np.ones_like(x) + np.where(x <= l0, h0, 0) # window
# velocity
q = np.zeros_like(x)
W0 = np.array([h, q, Z])
# ## Boundary conditions
BCs = [['symmetry', 'symmetry'], [0, 0]]
# ## Initialization
model = SW1LGlobal() # model with default parameters
simu = Simulation(model, W0, BCs, dx) # simulation
# %% Run model
U, t = simu.run_simulation(tmax, plot_fig=True, dN_fig=50, x=x, Z=Z)
-
$h$ : layer height -
$u$ : layer velocity -
$q = hu$ : layer discharge -
$Z$ : bottom topography -
$r = \rho_1/\rho_2$ : layer density ratio ($r <=1$ )
with subscripts
-
model = '1L_global'
-
model = '1L_local'
-
model = '1L_non_hydro_global'
where:
are the non-hydrostatic terms, and
Note The spatial discretization scheme is here a well-balanced central upwind scheme. For additional details, please refer to [4].
-
model = '2L_layerwise'
-
model = '2L_layerwise'
To use a custom model, you need to create a class that implements as methods the matrices used by the wanted spatial scheme. The easiest would be to copy an already implemented models in hyperbopy.models
, and modify it with the appropriate fluxes, sources, etc ...
- Clone or download this repository
cd hyperbopy
pip3 install -e ./
(editable mode installation)
-
[1] Kurganov, A., & Petrova, G. (2007). A second-order well-balanced positivity preserving central-upwind scheme for the Saint-Venant system. Communications in Mathematical Sciences, 5(1), 133-160.
-
[2] Diaz, M. J. C., Kurganov, A., & de Luna, T. M. (2019). Path-conservative central-upwind schemes for nonconservative hyperbolic systems. ESAIM: Mathematical Modelling and Numerical Analysis, 53[3], 959-985.
-
[3] Isherwood, L., Grant, Z. J., & Gottlieb, S. (2018). Strong stability preserving integrating factor Runge--Kutta methods. SIAM Journal on Numerical Analysis, 56[6], 3276-3307.
-
[4] Chertock, A., & Kurganov, A. (2020). Central-upwind scheme for a non-hydrostatic Saint-Venant system. Hyperbolic Problems: Theory, Numerics, Applications, 10.
-
implementing a choice for boundary conditions type per variables -
adding apath_conservative=True/False
option for faster solving easier systems -
When 2. is done, adding a new possible source term that does not-depend on derivatives (and thus does not need the path-conservative scheme) -
Adding the draining-time technique for wet/dry fronts
-
Adding the positivity preserving technique (if possible)
-
07/07/02023: version: 0.1.2
- Reworking code, creating new classes for spatial schemes, temporal schemes, plotting, and starting simulation
- Changing name to hyperbopy
- implementing custom boundary conditions
-
04/07/02023: version: 0.1.0
- Reworking all code, separating model definition, spatial scheme and temporal scheme.
-
20/06/02023:
- adding non-hydro globally conservative on-layer model
-
13/06/2023: version: 0.0.1
- changing repo organization to be able to select within system of equations
- adding the locally conservative two-layer model [dam break shows shock solution]
- adding the globally conservative one-layer model [dam break shows Ritter solution]
- adding the locally conservative one-layer model [dam break shows shock solution]
-
09/06/2023: First stable version (two layer globally) with validated reference examples. So far, no shock for dam-break solution, which exhibits the Ritter solution.
-
07/06/2023: First commit