1 Introduction

The immense complexity of the earth’s atmospheric and oceanic systems involves a variety of processes, which act on different space and time scales. Modeling such geophysical flows has earned significance in past years due to its applications in areas such as flood control, coastal engineering, or environmental assessment among others. There is a variety of physical situations of environmental attentiveness such as flows in rivers, open channels, mountain passes where the horizontal length scale is large compared to their depth. These natural occurrences may be encountered for instance in the Gulf of Mexico, North Sea and Southern Caspian Sea [19, 39]. These types of phenomena may be modeled by a system of first-order non-linear partial differential equations (PDEs), whose derivation involves the same assumptions as the Saint-Venant equations [15].

Two-phase flows often involve the interaction of fluids of distinct nature such as gas and solid or gas and liquid. See for instance the Baer–Nunziato problem [4]. On the other hand, the interaction of two immiscible liquid fluids of different densities might result in the formation of two layers. Each of these layers can be approximated using the shallow water equations, where they exchange momentum with each other [9]. Compared to other simplified models, the Saint-Venant system has a variety of advantages because of its ability to explain complex topographies. The heavier fluid is located in between the topography and the lighter fluid. The bottom layer acts as a moving bathymetry on the top one while the top layer exchanges momentum with the bottom one due to hydrostatic pressure. Two-layer flows may occur, for instance, in rivers when salty water moves below fresh water, in which case shear flow instabilities may lead to internal waves [3]. See [28] for more details on the two-layer shallow-water equations, which model this type of flow through irregular geometry. This approach is also applicable in a variety of multi-fluid phenomena, including tsunamis produced by underwater landslides [18], and areas such as coastal hydrodynamics to measure the water level and discharge [35] among others. Two-layer shallow water flows can also be used to study interfacial waves in the ocean [14].

There are several theoretical and numerical challenges when we deal with the two-layer shallow water equations. One first issue is related to the hyperbolicity of the system. Recently, many authors have considered two-layer shallow water flows in which the PDE-based model is conditionally hyperbolic. See for instance [6, 11, 12, 23]. The second difficulty is the presence of non-conservative products due to momentum exchange. As it is common in hyperbolic balance laws, shockwaves may form even when the initial data is smooth. The presence of non-conservative products creates both theoretical and numerical difficulties. Using the theory of Dal Maso, LeFloch, and Murat [13], one can derive the generalized Rankine Hugoniot (RH) condition which depends on the family of Lipschitz continuous paths \(\Phi \). Different paths can lead to different jump conditions, hence different weak solutions. See [2] for more details. In addition to theoretical challenges, developing an appropriate numerical scheme is key, and it will be described in the upcoming sections.

In this work, a novel approach has been used by considering the weak compressibility of both layers which makes the system strictly hyperbolic. In order to ensure realistic simulations of flow exchanges through natural narrows, considerations of friction in channels with irregular geometry are taken in this article. In the case of large pressure relaxation and zero atmospheric pressure, a standard two-layer shallow water model is retrieved. We can see that our method is reminiscent of the relaxation approach used in [1], where here we have interpreted the relaxation in the context of the fluid’s weak compressibility.

When numerically approximating solutions of a Saint-Venant system, it is essential to manage the preservation of steady states, or at least those at rest. In [20, 22], a numerical scheme was developed with this well-balanced property. Later on, more schemes have been designed which hold the well-balanced property. See for instance [7, 31, 43] and references therein. In contrast with the regular Saint-Venant equations, non-conservative products arise in the two-layer shallow water model due to the dynamics of the interface between the two layers. The development of efficient numerical schemes for hyperbolic conservation laws has observed a rapid growth in the past decades, but the case of non-conservative systems is still a hot and challenging topic from both theoretical and numerical perspectives. In this context, upwind-based finite-volume schemes [9] and finite-element schemes [34] were devised to simulate such complex flows in the past decades, among others. Furthermore, a well-balanced finite volume scheme of arbitrary order was introduced in [38]. A robust well-balanced positivity preserving central-upwind scheme was developed in [28] for a constant channel width and it was extended for a varying cross-section in [6]. Additionally, a central-upwind scheme for a conditionally hyperbolic two-layer shallow water model with friction and entrainment for general channels was implemented in [23]. A new approach was designed in [40] with the help of a generalized Rankine–Hugoniot jump condition which is known as a path-conservative scheme. However, path conservative schemes have a drawback that they may fail to converge to physically relevant solutions in some cases [2, 40]. Afterward, an entropy stable path consistent scheme was introduced in [10] by using the generalized Rankine–Hugoniot conditions. In the numerical part of this work, we develop a well-balanced path-conservative semi-discrete central-upwind scheme. We use a suitable discretization for the source terms that arise in part due to the bottom topography, which results in a robust well-balanced numerical scheme. We compute exact solutions with the aid of linear Volpert paths, and compare them with our numerical approximations. Although we are not generalizing to all parameter regimes, we show in different numerical tests that our approximated solutions are in good agreement with the exact solutions. It is well known that large numerical errors may arise near contact waves due to the inability of the scheme to preserve the Riemann invariants across those jumps [25]. In that case, we show a moderate improvement of the path-conservative scheme in comparison with a regular central-upwind scheme which is path-independent. Other tests involving general channels and discontinuous topographies are also displayed.

This article is organized in the following manner. In Sect. 2, we formulate the mathematical model and present its hyperbolic properties; the generalized Rankine–Hugoniot jump conditions are introduced with the help of a linear path; and present the corresponding Riemann invariants for shock waves, rarefaction waves, and contact discontinuities. In Sect. 3, a robust well-balanced path-conservative semi-discrete central-upwind scheme is developed and the main aspects of the scheme are discussed. Section 4 is devoted to the numerical results which confirm the robustness of the scheme, including the solution of Riemann problems involving either isolated waves or more than one wave from different families; and two more tests involving simulations with continuous and discontinuous topographies in general channels. Appendix A provides the eigenstructure of the system to show its hyperbolicity. Finally Appendix B provides the Riemann invariants in the case of channels with constant width.

2 The Model and its Properties

A one-dimensional model for two-layer shallow water flows can be found in [9]. Such incompressible version results in a conditionally hyperbolic system. Hyperbolicity can be lost, for instance, when the velocity difference between layers is strong. In order to address the theoretical and numerical challenges that arise in such cases, Abgrall and Karni [1] used a relaxation approach that resulted in an unconditionally hyperbolic system.

Fig. 1
figure 1

Schematic of flow with a Cross-section of the channel, b Profile view of the channel, and c 3D view of the channel

Following the relaxation approach, here we formulate a new model by considering a weak compressibility of both layers as done in [12], extending it to the case of general channels [23]. Here we add two extra equations which brings the compressibility of both the layers in existence. A schematic of the flow can be seen in Fig. 1. The model can be written as

$$\begin{aligned} \frac{\partial A_1}{\partial t} + u_1 \frac{\partial A_1}{\partial x} = \frac{\mu \left( A_1(p_1- p_0) -g \rho _1 \int _B^{w_1} (w_1+r h_2-z) \sigma (x,z)dz \right) }{\rho _1 c_1 ^2}, \end{aligned}$$
(1a)
$$\begin{aligned} \frac{\partial (\rho _1 A_1)}{\partial t} + \frac{\partial (\rho _1 Q_1)}{\partial x} = 0, \end{aligned}$$
(1b)
$$\begin{aligned} \frac{\partial (\rho _1 Q_1)}{\partial t} + \frac{\partial }{\partial x} \left( \rho _1 A_1u_1^2 + A_1 p_1 \right)&= \left( p_0 + {c_1}_0^2(\rho _1 - \rho _1^{(0)}) + g \rho _2 h_2 \right) \frac{\partial A_1}{\partial x} \nonumber \\&\quad +g \rho _1 \left( I_{1} - h_1 \sigma _B B'\right) + \rho _1 S_{f,1} , \end{aligned}$$
(1c)
$$\begin{aligned} \frac{\partial A_2}{\partial t} + u_2 \frac{\partial A_2}{\partial x} = \frac{\mu \left( A_2(p_2- p_0) - g \rho _2 \int _{w_1}^{w_2} (w_2-z) \sigma (x,z) dz\right) }{\rho _2 c_2 ^2}, \end{aligned}$$
(1d)
$$\begin{aligned} \frac{\partial (\rho _2 A_2)}{\partial t} + \frac{\partial (\rho _2 Q_2)}{\partial x} = 0, \end{aligned}$$
(1e)
$$\begin{aligned} \frac{\partial (\rho _2 Q_2)}{\partial t} + \frac{\partial }{\partial x} \left( \rho _2 A_2u_2^2 + A_2 p_2 \right)&= \left( p_0 + {c_2}_0^2(\rho _2 - \rho _2^{(0)})\right) \frac{\partial A_2}{\partial x}\nonumber \\&\quad +g \rho _2 \left( I_{2} - h_2 \sigma _1 \frac{\partial w_1}{\partial x} \right) + \rho _2 S_{f,2}. \end{aligned}$$
(1f)

Here, x and t are the space and time variables, \(h_1, h_2, u_1, u_2, \rho _1, \rho _2\) denote the heights of internal and external layers, cross-sectional (averaged) velocities of fluids, and densities of both fluids, respectively; \(A_1 = \int _{B}^{w_1} \sigma (x,z) \, dz\) and \(A_2 = \int _{w_1}^{w_2} \sigma (x,z) \, dz\) are the wetted cross-sectional areas of lower and upper layers, respectively; with \(\sigma (x,z)\) describing channel’s breadth at axial position x and height z; \(w_1 = B+h_1\) and \(w_2 = w_1+h_2\) represent the total elevation of internal and external layers, respectively. The bottom topography of the channel is described by the function B(x); g is the acceleration due to gravity; \(Q_i = A_i u_i\) (\(i =1,2\)) are the discharges which measure the flow rate of fluid passing through a cross section; r is the ratio of densities given by \(r = \rho _2/\rho _1 \le 1\). Moreover, \(\sigma _B = \sigma (x,B(x))\) represents the width of the channel at the bottom topography, while \(\sigma _1 = \sigma (x, w_1(x, t))\) and \(\sigma _2 = \sigma (x, w_2(x, t))\) represent the channel’s width at the internal and external layers, respectively. It is important to highlight that both \(\sigma _1\) and \(\sigma _2\) vary both in space and time, as they are computed at the internal and external layers’ heights respectively. The extra Eqs. (1a) and (1d) represent the transport of wetted cross-section, which have been added to the system in [23] to formulate the weak compressibility in this work. Moreover, in the case of large pressure relaxation \((\mu \longrightarrow \infty )\) and zero atmospheric pressure \((p_0 = 0)\), the right hand side of Eqs. (1a) and (1d) becomes zero which shows in view of equations that density is constant. Consequently we retrieve a classical shallow water model in general channels as in [23]. Additionally, the averaged hydrostatic pressures of both layers are given by \(p_1, p_2\), where

$$\begin{aligned} p_1&= p_0 + {c_1}_0^2(\rho _1 - \rho _1^{(0)}) + g \frac{\rho _1}{A_1} \int _{B}^{w_1} (w_1 + r h_2 - z) \, \sigma (x,z) dz, \quad \text {and} \end{aligned}$$
(2)
$$\begin{aligned} p_2&=p_0 + {c_2}_0^2(\rho _2 - \rho _2^{(0)}) + g \frac{\rho _2}{A_2} \int _{w_1}^{w_2} (w_2 -z) \, \sigma (x,z) dz. \end{aligned}$$
(3)

Here, \(p_0\) represents the atmospheric pressure and it is assumed to be constant for simplicity; the parameters \({c_1}_0\) and \({c_2}_0\) are constant and have units of velocity. The last term in the above expressions for \(p_1\) and \(p_2\) arise due to the hydrostatic pressure assumptions. The hydrostatic pressure, which is a function of height for the upper layer with constant density (in height), is given by \(g \rho _2 (w_2-z)\). This term is then vertically integrated to appear as in Eq. (3). The extra term \(rh_2\) in the lower layer is due to the pressure contribution from the upper layer on the lower one. See [23] for more details. Now, the first two terms in both Eqs. (2) and (3) arise due to the weak compressibility assumptions and represent the thermodynamic pressure contributions using the barotropic equations of state [12]. The reference densities \(\rho _1^{(0)},\rho _2^{(0)}\) correspond to steady states of rest and are also taken to be constant. The source terms \(I_1\) and \(I_2\) arise during the averaging process (see [23] for more details) and can be interpreted as vertically integrated pressure terms due to width variations

$$\begin{aligned} I_1 = \int _{B}^{w_1} (w_1 -z) \sigma _x(x,z) \, dz, \quad I_2 = \int _{w_1}^{w_2} (w_2 -z) \sigma _x(x,z) \,dz. \end{aligned}$$
(4)

The friction terms for internal and external layers, respectively, are given as in [26]

$$\begin{aligned} S_{f,1}&= -gr \frac{n_i^2 \left| \frac{Q_1 A_1 + Q_2 A_2}{A_1 +A_2}\right| }{\mathcal {R}^{4/3}} (u_1 - u_2) - g \frac{n_b^2 \left| \frac{Q_1 A_1 + Q_2 A_2}{A_1 +A_2}\right| }{\mathcal {R}^{4/3}} u_1, \nonumber \\ S_{f,2}&= -g \frac{n_i^2 \left| \frac{Q_1 A_1 + Q_2 A_2}{A_1 +A_2}\right| }{\mathcal {R}^{4/3}} (u_2 - u_1), \end{aligned}$$
(5)

where \(n_i,\,\,n_b\) are Manning roughness coefficients for interface and bottom, respectively. The ratio between the wet area and its perimeter is the hydraulic radius \(\mathcal {R}\), which is given by

$$\begin{aligned} \mathcal {R} = \frac{A_1 + A_2}{\sigma _B + \int _{B}^{w_2} \sqrt{4 + (\partial _z \sigma (x,z))^2}dz}. \end{aligned}$$
(6)

Equations (1b) and (1e) correspond to mass conservation, while Eqs. (1c) and (1f) dictate a balance of momentum for both layers. The parameter \(\mu \) is known as the pressure relaxation parameter which is related to the layers’ heights and fluid’s sound speeds. In Chiapolino et al. [12], this parameter is taken as \(\mu = \frac{1}{\tau }\), with \(\tau \) the relaxation time which may be on the order of \(\frac{1}{100}\) seconds. As a result, the parameter \(\mu \) could be a large value as compared to the characteristic scales of the system. When the parameter \(\mu \) tends towards infinity, the values of \(\rho _1\) and \(\rho _2\) become equal to their respective reference values, \(\rho _1^{(0)}\) and \(\rho _2^{(0)}\). As a result, the system mentioned above simplifies to a fully incompressible flow of shallow water with two layers, as described in [23]. Specifically, in the scenario of a constant channel and no friction term, the model (1) reduces to the one introduced by Chiapolino et al. in their work [12].

There are other ways to add the effect of friction in open channels. For instance, in [16], a section-averaged shallow water model is derived with a generalized friction term that does not rely on local uniformity assumptions. The friction terms can be computed directly from three dimensional-turbulence models using dynamic boundary conditions. In [36], friction is incorporated in the model using Chézy coefficients. That would change the source terms in Eq. (5). The source friction term in Eq. (5) showed to provide good numerical results when we compare with experiments in vertical channels [26]. See also [24] for more comparisons with experimental data. However, our choice does not affect the analysis of weak solutions or the hyperbolic properties of the model, and other friction source terms could be easily incorporated.

In above system (1), \(c_1\) and \(c_2\) represent the speed of sound for the lower and upper layers, respectively. Since the external layer is moving freely with the inner layer acting as a topography, the speed of sound for the upper layer is similar to the one-layer case

$$\begin{aligned} c_2 = \sqrt{\frac{gA_2}{\sigma _2}}. \end{aligned}$$
(7)

On the other hand, the speed of sound for bottom layer has contributions form both layers, giving

$$\begin{aligned} c_1 = \sqrt{g\left( r\frac{A_1}{\sigma _2} + (1-r)\frac{A_1}{\sigma _1} \right) }. \end{aligned}$$
(8)

Steady States at Rest. The monodimensional system under investigation admits non-trivial steady states characterized by a delicate balance between flux gradients and source terms. This balance arises when the time derivatives in system (1) are removed in a solution independent of time. Among them, those at rest occur when the velocity vanishes in an incompressible fluid. Specifically, steady states at rest satisfy

$$\begin{aligned} p_0, w_1 \text { and } w_2\;\text {are constant,}\;u_1 = u_2 = 0, \rho _1 = \rho _1^{(0)},\;\text {and}\;\rho _2 = \rho _2^{(0)}. \end{aligned}$$
(9)

In the classical two-layer shallow water flows, steady state solutions are characterized by quantities that remain constant in space and time, such as discharge or energy. Here, the situation is more complicated due to the weak compressibility and the solution variables are characterized by ordinary differential equations rather than algebraic expressions. Something more specific can be said for the special case of a steady state with rigid lid assumptions. Namely, here we consider the case where \(u_2 = 0\), \(\rho _2 = \rho _2^{(0)}\), and \(w_2\) is constant in space and time, so that the external layer is at rest while the fluid in the internal layer is non trivial. In the absence of friction source terms \(S_{f,1} = S_{f,2} = 0\), the above conditions guarantee that Eqs. (1d), (1e) and (1f) are satisfied. Equation (1b) implies that \(\rho _1Q_1\) is constant. Combining Eqs. (1a) and (1c), we get at

Proposition 1

Assume that \(S_{f,1} = S_{f,2} = 0\) and \(\mu >0\). Suppose that \(u_1\) and \(w_1\) satisfy the following closed system of ordinary differential equations

$$\begin{aligned} \partial _x u_1&= \left[ \left( c_{1,0}^2 A_1+ g\int _{B}^{w_1} (w_1-z) \sigma (x,z) dz \right) \frac{\rho _1}{u_1} - \mathcal {R} \right] ^{-1} \nonumber \\&\quad \times \left\{ g A_1 (\rho _1-\rho _2) \left[ \frac{\mu c_{1,0}^2 (\rho _1-\rho _1^{(0)})A_1}{\rho _1 u_1 c_1^2 \sigma _1} - \frac{1}{\sigma _1} \int _B^{w_1} \sigma _x(x,z)dz + \frac{\sigma _B}{\sigma _1} B'(x) \right] \right. \nonumber \\&\quad \left. - \left[ c_{1,0}^2 A_1 + g \int _B^{w_1} (w_1-z) \sigma (x,z)dz \right] \frac{\mu c_{1,0}^2 (\rho _1-\rho _1^{(0)})}{u_1 c_1^2} \right\} \nonumber \\ \partial _x w_1&= \frac{\mu c_{1,0}^2 (\rho _1-\rho _1^{(0)})A_1}{\rho _1 u_1 c_1^2 \sigma _1}- \frac{1}{\sigma _1} \int _B^{w_1} \sigma _x(x,z) dz + \frac{\sigma _B}{\sigma _1} B'(x), \end{aligned}$$
(10)

where \(\rho _1 = \frac{\mathcal {R}}{A_1 u_1}\), and \(\mathcal {R}\) is a constant. If we take \(u_2 = 0, \rho _2 = \rho _2^{(0)}\) and if \(w_2\) is constant, then the resulting vector function is a steady state solution of system (1).

We note that system (10) is closed as everything involved depends only on \(u_1\) and \(w_1\). We also show that in the limit when \(\mu \rightarrow \infty \), \(\rho _1 = \rho _1^{(0)}\) and if we have no upper layer (ignoring \(\rho _2\) from the equations), we recover the standard steady state solutions where the discharge \(Q_1\) and the energy \(\frac{1}{2} u_1^2+g w_1\) are constant.

2.1 The Quasilinear Form and Hyperbolicity

In terms of the conserved variables \({\textbf{W}} = (A_1, \rho _1 A_1, \rho _1 A_1 u_1, A_2, \rho _2 A_2, \rho _2 A_2 u_2)\), system (1) can be written in quasilinear form as

$$\begin{aligned} {\textbf{W}}_t + M({\textbf{W}}; \sigma , B) {\textbf{W}}_x = \mathbf{{S} }_{M} ({\textbf{W}}; \sigma , B), \end{aligned}$$
(11)

where the matrix M is given by

$$\begin{aligned} M = \begin{pmatrix} u_1 &{} 0 &{}0 &{} 0 &{} 0 &{} 0\\ 0 &{} 0 &{} 1 &{} 0 &{} 0 &{} 0 \\ M_{31} &{} \frac{p_1 - p_0 + \rho _1^{(0)}{c_1}_{0}^2 }{\rho _1} - u_1^2 &{} 2u_1 &{} \frac{g \rho _2 A_1}{\sigma _2} &{}0 &{}0\\ 0 &{} 0 &{}0 &{} u_2 &{} 0 &{} 0\\ 0 &{} 0 &{} 0 &{} 0 &{} 0 &{} 1 \\ \rho _2 c_2^2 &{} 0 &{} 0 &{} M_{64} &{} \frac{p_2 - p_0 + \rho _2^{(0)} {c_2}_0^2}{\rho _2} - u_2^2 &{} 2u_2 \end{pmatrix}, \end{aligned}$$
(12)

\(M_{31} = \rho _1 c_1^2 - p_1 + p_0 - \rho _1^{(0)}{c_1}_{0}^2, \,\, M_{64} = \rho _2 c_2^2 - p_2 + p_0 - \rho _2^{(0)} {c_2}_0^2 \), and the vector of the source terms is given by

$$\begin{aligned} { \mathbf{{S} }_{M} ({\textbf{W}}; \sigma , B) }= \begin{pmatrix} \frac{\mu \left( A_1(p_1- p_0) -g \rho _1 \int _B^{w_1} (w_1+r h_2-z) \sigma (x,z)dz \right) }{\rho _1 c_1 ^2} \\ 0\\ \rho _1 c_1^2 \left( I_3-\sigma _B B' \right) + g\frac{\rho _2 A_1}{\sigma _2} \int _{w_1}^{w_2}\sigma _x(x,z) dz + \rho _1 S_{f,1} \\ \frac{\mu \left( A_2( p_2- p_0) - g \rho _2 \int _{w_1}^{w_2} (w_2-z) \sigma (x,z) dz\right) }{\rho _2 c_2 ^2} \\ 0\\ \rho _2 c_2^2 \left( I_4-\sigma _B B' \right) + \rho _2 S_{f,2} \end{pmatrix}. \end{aligned}$$
(13)

The terms \(I_3\) and \(I_4\) in the above vector are defined as

$$\begin{aligned} I_3 = \int _{B}^{w_1} \sigma _x(x,z) \, dz, \quad I_4 = \int _{w_1}^{w_2}\sigma _x(x,z) \, dz. \end{aligned}$$

2.2 Generalized Rankine–Hugoniot Conditions for the Non-conservative System

Dal Maso et al. [13] provided a definition of weak solutions for non-conservative hyperbolic systems which depends on a path \(\Phi \), connecting the left and right states (\({\textbf{W}}_L\),\({\textbf{W}}_R\)) across the discontinuity. Consider a \(C^1\) function \(\Phi : [0,1] \times \Omega \times \Omega \longrightarrow \Omega \) that connects both states, assuming that it is a Lipschitz function on the first parameter (\(\theta \in [0,1]\)) and that it satisfies the following conditions

$$\begin{aligned}&\text {(a)}\quad \forall \,\, {\textbf{W}}_L, {\textbf{W}}_R \in \Omega , \;\Phi (0; {\textbf{W}}_L, {\textbf{W}}_R) = {\textbf{W}}_L \;\text{ and }\;\Phi (1; {\textbf{W}}_L, {\textbf{W}}_R) = {\textbf{W}}_R,\\&\text {(b)} \quad \exists k> 0, \, \forall \,\, {\textbf{W}}_L, {\textbf{W}}_R \in \Omega , \; \left| \frac{\partial \Phi ((\theta ; {\textbf{W}}_L, {\textbf{W}}_R))}{\partial \theta }\right| \le k|{\textbf{W}}_L - {\textbf{W}}_R|,\\&\text {(c)} \quad \exists k > 0, \, \forall \,\, {\textbf{W}}_L, {\textbf{W}}_R, {\textbf{V}}_L, {\textbf{V}}_R \in \Omega , \left| \frac{\partial \Phi ((\theta ; {\textbf{W}}_L, {\textbf{W}}_R))}{\partial \theta } - \frac{\partial \Phi ((\theta ; {\textbf{V}}_L, {\textbf{V}}_R))}{\partial \theta }\right| \\&\quad \le k(|{\textbf{W}}_L - {\textbf{V}}_L| + |{\textbf{W}}_R - {\textbf{V}}_R|). \end{aligned}$$

Using the path \(\Phi \), a generalized Rankine–Hugoniot (RH) jump relation is given by

$$\begin{aligned} \Pi ({\textbf{W}}_R - {\textbf{W}}_L) = \int _{0}^{1} M(\Phi (\theta ; {\textbf{W}}_L, {\textbf{W}}_R)) \frac{\partial \Phi }{\partial \theta }(\theta ; {\textbf{W}}_L, {\textbf{W}}_R) d\theta , \end{aligned}$$
(14)

where \(\Pi \) represents the shock speed. In the case where M is a Jacobian matrix, i.e., \(M = \nabla \mathbf{{G} }\) for some flux \(\mathbf{{G} }\), system (11) reduces to a conservative system. Consequently, the generalized RH condition (14) does not depend on the path (only on the left and right states) and it takes the form of standard RH condition

$$\begin{aligned} \Pi ({\textbf{W}}_R - {\textbf{W}}_L) = \mathbf{{G} }({\textbf{W}}_R) - \mathbf{{G} }({\textbf{W}}_L). \end{aligned}$$
(15)

We are interested in implementing the above generalized Rankine–Hugoniot conditions to compute exact solutions to Riemann problems. Appendix B shows the Riemann invariants across all waves for the Riemann problems in the case of channels with constant width and no source terms in system (1). We direct the interested reader to review that appendix for details.

3 Numerical Scheme

3.1 Path-Conservative Central-Upwind Scheme

We rewrite the non-conservative system (1) as

$$\begin{aligned} \frac{\partial {\textbf{W}}}{\partial t} + \frac{\partial }{\partial x} {\textbf{F}} ({\textbf{W}}, \sigma , B) - \mathcal {C}\frac{\partial {\textbf{W}}}{\partial x} = {\textbf{S}}({\textbf{W}}; \sigma , B), \end{aligned}$$
(16)

with

$$\begin{aligned} {\textbf{W}}&= \begin{pmatrix} A_1\\ \rho _1 A_1\\ \rho _1 Q_1\\ A_2\\ \rho _2 A_2\\ \rho _2 Q_2 \end{pmatrix}, \nonumber \\ {\textbf{F}}({\textbf{W}}, \sigma , B)&= \begin{pmatrix} A_1 u_1\\ \rho _1 Q_1\\ \frac{\rho _1 Q_1^2}{A_1} + g \rho _1 \widehat{w_2} A_1 + A_1 \left( p_0 + {c_1}_0^2 (\rho _1 - \rho _1^{(0)}) \right) \\ A_2 u_2\\ \rho _2 Q_2\\ \frac{\rho _2 Q_2^2}{A_2} + g \rho _2 w_2 A_2 + A_2 \left( p_0 + {c_2}_0^2 (\rho _2 - \rho _2^{(0)}) \right) \end{pmatrix}, \end{aligned}$$
(17)
$$\begin{aligned} \mathcal {C}&= \begin{pmatrix} 0 &{} \frac{-u_1}{\rho _1} &{} \frac{1}{\rho _1} &{} 0 &{} 0 &{} 0\\ 0 &{} 0 &{} 0 &{} 0 &{} 0 &{} 0 \\ p_1 &{} \frac{g}{A_1}\int _{B}^{w_1} z \sigma (x,z) dz &{} 0 &{} 0 &{} 0 &{} 0 \\ 0 &{} 0 &{} 0 &{} 0 &{} \frac{-u_2}{\rho _2} &{} \frac{1}{\rho _2} \\ 0 &{} 0 &{} 0 &{} 0 &{} 0 &{} 0 \\ 0 &{} 0 &{} 0 &{} p_2 &{} \frac{g}{A_2}\int _{w_1}^{w_2} z \sigma (x,z) dz &{} 0 \end{pmatrix},\quad \text {and} \nonumber \\ {\textbf{S}} ({\textbf{W}}, \sigma , B)&=\begin{pmatrix} \frac{\mu \left( A_1(p_1- p_0) -g \rho _1 \int _B^{w_1} (w_1+r h_2-z) \sigma (x,z)dz \right) }{\rho _1 c_1 ^2} \\ 0\\ \rho _1 {S_f}_{,1} \\ \frac{\mu \left( A_2(p_2- p_0) - g \rho _2 \int _{w_1}^{w_2} (w_2-z) \sigma (x,z) dz\right) }{\rho _2 c_2 ^2} \\ 0\\ \rho _2 {S_f}_{,2} \end{pmatrix}. \end{aligned}$$
(18)

Here, the term \(\widehat{w_2}\) is given by \(\widehat{w_2}=w_1 + rh_2.\) In order to numerically solve system (16), we use a well-balanced path-conservative central-upwind scheme as described in [17, 40], which is applied to this more complex but strictly hyperbolic system. We divide the solution domain into grid cells \(\mathcal {I}_i = [x_{i-\frac{1}{2}}, x_{i+\frac{1}{2}}]\), where \(\bigtriangleup x\) is the cell’s length, and \(x_{i\pm \frac{1}{2}} = x_i\pm \frac{\bigtriangleup x}{2}\) denote the location of the grid cell’s interfaces with center at \(x_i\). A central-upwind semi-discrete formulation of Eq. (16) over each cell \(\mathcal {I}_i\) is written as

$$\begin{aligned}&\frac{d}{dt} \overline{{\textbf{W}}}_i(t) + \frac{1}{\bigtriangleup x} \left( {\textbf{F}}\left( {\textbf{W}}\left( x_{i+\frac{1}{2}},t\right) \right) - {\textbf{F}}\left( {\textbf{W}}\left( x_{i-\frac{1}{2}},t\right) \right) \right) \nonumber \\&\quad - \frac{1}{\bigtriangleup x} \int _{x_{i-\frac{1}{2}}}^{x_{i+\frac{1}{2}}} \mathcal {C}(\mathbf{{W} }(x,t),x) \frac{\partial \mathbf{{W} }}{\partial x} dx = \frac{1}{\bigtriangleup x} \int _{x_{i-\frac{1}{2}}}^{x_{i+\frac{1}{2}}} {\textbf{S}}({\textbf{W}}(x,t),x) dx, \end{aligned}$$
(19)

where \( \overline{{\textbf{W}}}_i(t)\) is the cell averaged solution over the cell \(\mathcal {I}_i\)

$$\begin{aligned} \overline{{\textbf{W}}}_i(t) = \frac{1}{\bigtriangleup x}\int _{x_{i-\frac{1}{2}}}^{x_{i+\frac{1}{2}}} {\textbf{W}}(x,t) dx. \end{aligned}$$
(20)

Central-upwind schemes add a numerical vanishing viscosity by approximating Eq. (19) by

$$\begin{aligned} \frac{d}{dt} \overline{{\textbf{W}}}_i(t)&\approx -\frac{{\textbf{H}}_{i+\frac{1}{2}} - {\textbf{H}}_{i-\frac{1}{2}}}{\bigtriangleup x} + \frac{1}{\bigtriangleup x} \int _{x_{i-\frac{1}{2}}}^{x_{i+\frac{1}{2}}} \mathcal {C}(\mathbf{{W} }(x,t),x) \frac{\partial \mathbf{{W} }}{\partial x} dx \nonumber \\&\quad + \frac{1}{\bigtriangleup x} \int _{x_{i-\frac{1}{2}}}^{x_{i+\frac{1}{2}}} {\textbf{S}}({\textbf{W}}(x,t),x) dx, \end{aligned}$$
(21)

where the flux \( {\textbf{F}}({\textbf{W}}(x_{i\pm \frac{1}{2}},t))\) has been approximated by the numerical flux \({\textbf{H}}_{i\pm \frac{1}{2}}(t)\) [30]

$$\begin{aligned} {\textbf{H}}_{i\pm \frac{1}{2}}(t)&= \frac{a_{i\pm \frac{1}{2}}^+ {\textbf{F}}\left( {\textbf{W}}_{i\pm \frac{1}{2}}^- (t)\right) - a_{i\pm \frac{1}{2}}^- {\textbf{F}}\left( {\textbf{W}}_{i\pm \frac{1}{2}}^+ (t)\right) }{a_{i\pm \frac{1}{2}}^+ - a_{i\pm \frac{1}{2}}^-} \nonumber \\&\quad + \frac{a_{i\pm \frac{1}{2}}^+ a_{i\pm \frac{1}{2}}^-}{a_{i\pm \frac{1}{2}}^+ - a_{i\pm \frac{1}{2}}^-}\left( {\textbf{W}}_{i\pm \frac{1}{2}}^+ (t)-{\textbf{W}}_{i\pm \frac{1}{2}}^- (t)\right) . \end{aligned}$$
(22)

Here, \({\textbf{W}}_{i\pm \frac{1}{2}}^- (t)\) and \({\textbf{W}}_{i\pm \frac{1}{2}}^+ (t)\) are, respectively, left and right sided values of the non-oscillatory piecewise linear reconstruction

$$\begin{aligned} {\textbf{W}}_{i+\frac{1}{2}}^- = \overline{\mathbf{{W} }}_i + \frac{\Delta x}{2} \mathbf{{W} }_i' \quad \text{ and } \quad {\textbf{W}}_{i+\frac{1}{2}}^+ = \overline{\mathbf{{W} }}_{i+1} - \frac{\Delta x}{2} \mathbf{{W} }_{i+1}', \end{aligned}$$
(23)

and \(\mathbf{{W} }_i'\) are limited slopes. It is well known that non-oscillatory properties of the central-upwind schemes rely in part on the non-oscillatory property of the polynomial reconstruction. For that end, a variety of slope limiters used in the interface reconstructions are available in the literature [29, 32, 33, 37, 41, 42]. However, we are interested in a generalized minmod limiter [5, 41] for our numerical experiments. In particular, we take

$$\begin{aligned} {\textbf{W}}_i' = \text{ minmod }\left( \theta \bigtriangleup _-\overline{{\textbf{W}}}_i, \bigtriangleup _0\overline{{\textbf{W}}}_i, \theta \bigtriangleup _+\overline{{\textbf{W}}}_i \right) , \quad \text{ with } \quad \theta \in [1,2), \end{aligned}$$
(24)

where \(\bigtriangleup _-\overline{{\textbf{W}}}_i = (\overline{{\textbf{W}}}_i - \overline{{\textbf{W}}}_{i-1})/\bigtriangleup x,\, \bigtriangleup _0\overline{{\textbf{W}}}_i = {(\overline{{\textbf{W}}}_{i+1} - \overline{{\textbf{W}}}_{i-1})/(2\bigtriangleup x)},\) \(\bigtriangleup _+\overline{{\textbf{W}}}_i = (\overline{{\textbf{W}}}_{i+1}- \overline{{\textbf{W}}}_{i})/\bigtriangleup x,\) and the minmod function is defined as

$$\begin{aligned} \text{ minmod }(x_1, x_2, \ldots ) = {\left\{ \begin{array}{ll} \min _i\lbrace x_i \rbrace , &{}\text{ if }\; x_i >0 \quad \forall i, \\ \max _i\lbrace x_i \rbrace , &{} \text{ if }\; x_i <0 \quad \forall i, \\ 0, &{} \text{ otherwise }. \end{array}\right. } \end{aligned}$$
(25)

The parameter \(\theta \) which manages numerical viscosity has been chosen as \(\theta = 1.5\) to avoid spurious oscillations as a larger value of \(\theta \) can lead to more oscillatory reconstructions [28]. Nevertheless, it is convenient to reconstruct first the layers’ heights \(w_1 = B + h_1\) and \(w_2 = w_1 + h_2\) as a first step to guarantee the well-balance properties, as it has been documented in [27]. The above reconstruction gives

$$\begin{aligned} h_{1,i\pm \frac{1}{2}}^\mp = w_{1,i\pm \frac{1}{2}}^\mp - {B_{i\pm \frac{1}{2}}},\quad \text{ and } \quad h_{2,i\pm \frac{1}{2}}^\mp = w_{2,i\pm \frac{1}{2}}^\mp - {w_{1,i\pm \frac{1}{2}}^\mp }, \end{aligned}$$
(26)

and the point values of the total cross sections \(A_{1, i\pm \frac{1}{2}}^\mp \) and \(A_{2, i\pm \frac{1}{2}}^\mp \) are reformulated from these by integrating the interface width

$$\begin{aligned} A_{1, i\pm \frac{1}{2}}^\mp = \int _{B_{i\pm \frac{1}{2}}}^{w_{1,i\pm \frac{1}{2}}^\mp } \sigma \left( x_{i\pm \frac{1}{2}},z \right) dz \quad \text{ and } \quad A_{2, i\pm \frac{1}{2}}^\mp = \int _{w_{1,i\pm \frac{1}{2}}^\mp }^{w_{2,i\pm \frac{1}{2}}^\mp } \sigma \left( x_{i\pm \frac{1}{2}},z \right) dz. \end{aligned}$$
(27)

The density \(\rho \) and the discharge Q are reconstructed directly from Eq. (24) and the velocity is recovered via

$$\begin{aligned} u_{l, i\pm \frac{1}{2}}^\pm = Q_{l, i\pm \frac{1}{2}}^\pm /A_{l, i\pm \frac{1}{2}}^\pm ,\quad l = 1,2. \end{aligned}$$
(28)

In summary, we present the following:

Reconstruction Algorithm:

  1. Step 1:

    Reconstruct \(\rho _{l,i\pm \frac{1}{2}}^\mp ,w_{l,i\pm \frac{1}{2}}^\mp \) and \(Q_{l,i\pm \frac{1}{2}}^\mp \) (\(l = 1,2\)) according to the linear reconstruction given by Eq. (23).

  2. Step 2:

    Compute \(h_{l,i\pm \frac{1}{2}}^\mp \) and integrate \(A_{l, i\pm \frac{1}{2}}^\mp \) according to Eqs. (26) and (27) respectively.

  3. Step 3:

    Compute the velocity \(u_{l, i\pm \frac{1}{2}}^\pm \) according to Eq. (28).

  4. Step 4:

    Compute the vector of conserved variables as \(W_{1,i\pm \frac{1}{2}}^\mp = A_{1,i\pm \frac{1}{2}}^\mp , W_{2,i\pm \frac{1}{2}}^\mp = \rho _{1,i\pm \frac{1}{2}}^\mp A_{1,i\pm \frac{1}{2}}^\mp , W_{3,i\pm \frac{1}{2}}^\mp = \rho _{1,i\pm \frac{1}{2}}^\mp Q_{1,i\pm \frac{1}{2}}^\mp , W_{4,i\pm \frac{1}{2}}^\mp = A_{2,i\pm \frac{1}{2}}^\mp , W_{5,i\pm \frac{1}{2}}^\mp = \rho _{2,i\pm \frac{1}{2}}^\mp A_{2,i\pm \frac{1}{2}}^\mp \), and \(W_{6,i\pm \frac{1}{2}}^\mp = \rho _{2,i\pm \frac{1}{2}}^\mp Q_{2,i\pm \frac{1}{2}}^\mp \).

Moreover, \(a_{i+\frac{1}{2}}^\pm \) in (22) are the one sided local speeds of propagation which are estimated by maximum and minimum wave speeds, i.e.,

$$\begin{aligned} a_{i\pm \frac{1}{2}}^+&= \max \left\{ \max _{k = 1:6}\left( \lambda _k\left( M\left( {\textbf{W}}_{i\pm \frac{1}{2}}^-\right) \right) , \max _{k = 1:6} \lambda _k\left( M\left( {\textbf{W}}_{i\pm \frac{1}{2}}^+\right) \right) , 0 \right) \right\} , \nonumber \\ a_{i\pm \frac{1}{2}}^-&= \min \left\{ \min _{k=1:6}\left( \lambda _k\left( M\left( {\textbf{W}}_{i\pm \frac{1}{2}}^-\right) \right) , \min _{k=1:6} \lambda _k\left( M\left( {\textbf{W}}_{i\pm \frac{1}{2}}^+\right) \right) , 0\right) \right\} , \end{aligned}$$
(29)

where the eigenvalues are computed in Appendix B, Eq. (61). Equation (29) implies that \(a_{i\pm \frac{1}{2}}^+ - a_{i\pm \frac{1}{2}}^-\) is always greater than zero except for the case of “no fluid motion”, i.e., collapsing of all variables \({\textbf{W}}_{i\pm \frac{1}{2}}^\pm \) in a dry state.

Considering the reformulated path-conservative central-upwind scheme described in Castro et al. [17] for the smooth path \(\Phi _{j + \frac{1}{2}} = \Phi (s; \mathbf{{W} }_{j+\frac{1}{2}}^{-}, \mathbf{{W} }_{j+\frac{1}{2}}^{+})\) connecting the state \(\mathbf{{W} }_{j+\frac{1}{2}}^{-}\) and \(\mathbf{{W} }_{j+\frac{1}{2}}^{+}\), we express the path conservative central-upwind scheme as follows

$$\begin{aligned} \frac{d}{dt} \overline{{\textbf{W}}}_i(t)&\approx - \frac{1}{\bigtriangleup x} \left( {\textbf{H}}_{i+\frac{1}{2}} - {\textbf{H}}_{i-\frac{1}{2}} -\mathcal {C}_i - \frac{a_{i-\frac{1}{2}}^+ }{a_{i-\frac{1}{2}}^+ - a_{i-\frac{1}{2}}^-}\mathcal {C}_{\Phi , i-\frac{1}{2}} \right. \nonumber \\&\left. \quad + \frac{a_{i+\frac{1}{2}}^- }{a_{i+\frac{1}{2}}^+ - a_{i+\frac{1}{2}}^-}\mathcal {C}_{\Phi , i+\frac{1}{2}} \right) + \frac{1}{\bigtriangleup x} \int _{x_{i-\frac{1}{2}}}^{x_{i+\frac{1}{2}}} {\textbf{S}}({\textbf{W}}(x,t),x) dx, \end{aligned}$$
(30)

where

$$\begin{aligned} \mathcal {C}_{\Phi , i+\frac{1}{2}} = \int _0^1 \mathcal {C}\left( \Phi _{i+\frac{1}{2}}(s)\right) \frac{d \Phi _{i+\frac{1}{2}}}{ds} ds, \;\mathcal {C}_i = \int _{x_{i-\frac{1}{2}}}^{x_{i+\frac{1}{2}}} \mathcal {C}(\mathcal {P}_i(x))\frac{d\mathcal {P}_i(x)}{dx}dx. \end{aligned}$$
(31)

In the above integrals, one may need certain quantities to be evaluated at the cell’s interior. In such situation, one needs to compute them in terms of the linearly reconstructed variables \(\rho _1, \rho _2, w_1, w_2, Q_1\) and \(Q_2\). For instance, the cross-sectional areas are given by

$$\begin{aligned} A_{1,j}(x) = \int _{B_{j}+\left( x-x_{j+\frac{1}{2}}\right) B_j'}^{{\bar{w}}_1+ \left( x-x_{j+\frac{1}{2}}\right) w_1'} \sigma (x, z) dz, A_{2,j}(x) = \int _{\bar{w}_{1,j}+\left( x-x_{j+\frac{1}{2}}\right) w_{1,j}'}^{{\bar{w}}_{2,j}+\left( x-x_{j+\frac{1}{2}}\right) w_{2,j}'} \sigma (x, z) dz, \end{aligned}$$

for any \(x \in [x_{i-\frac{1}{2}},x_{i+\frac{1}{2}}]\). It is very important to preserve those relations in order to achieve desired properties such as well balance.

In [27], positivity preserving central-upwind schemes for shallow water flows were introduced. Special corrections in the non-oscillatory reconstructions are necessary as a first step towards preservation of positivity. In this work, we have not theoretically showed that the numerical scheme preserves positivity. However, the same corrections and velocity regularizations are employed in this work. See also [23] for more details on the implementation of this technique to two-layer systems.

3.2 Discretization of Bottom Topography and Channel’s Breadth

In the context of the system under consideration, a balance between flux gradients and source terms is necessary for non-trivial steady-state solutions to arise. Well-balanced numerical scheme are those that can preserve such states (or at least those at rest). Kurganov et al. [8, 27] explained that well balancedness can be achieved by applying a special reconstruction of the data at the interfaces and appropriate discretizations of the source terms.

In order to achieve a high-resolution well-balanced scheme, we need a consistent discretization of the channel’s geometry and topography. We start by sampling the channel’s width and bottom topography at the points \(x_{i+\frac{1}{2}}\), and compute the values at the center by the corresponding averages

$$\begin{aligned} \overline{B}_i = \frac{B_{i+\frac{1}{2}} + B_{i-\frac{1}{2}}}{2}, {\overline{\sigma }}_i(z) = \frac{\sigma \left( x_{i+\frac{1}{2}},z\right) + \sigma \left( x_{i-\frac{1}{2}},z\right) }{2}. \end{aligned}$$
(32)

At each cell interface \(x_{i+\frac{1}{2}}\), we construct a piecewise trapezoidal approximation of the channel cross-section, using known values at different heights \(\{ z_k\}\)

$$\begin{aligned} \sigma (x_{i\pm \frac{1}{2}},z)&= {\tilde{\sigma }}_{i\pm \frac{1}{2}}(z) = {\overline{\sigma }}_{i\pm \frac{1}{2}}(z_k) \nonumber \\&\quad + \frac{{\overline{\sigma }}_{i\pm \frac{1}{2}}(z_{k+1}) - {\overline{\sigma }}_{i+\frac{1}{2}}(z_k)}{\bigtriangleup z}(z-z_k) \quad \text{ for } \quad z_k \le z \le z_{k+1}, \end{aligned}$$
(33)

where \(\bigtriangleup z\) is a fixed spatial scale in the vertical direction. This piecewise linear approximation applies to general channels and may be unnecessary in cases where explicit expressions of \(\sigma \) are available.

3.3 Well-balancing

We are interested in developing a numerical scheme that can preserve steady states at rest given by conditions in Eq. (9). This can be done with the interface reconstruction implemented above plus suitable discretizations of the source terms. In our setting, all the source terms in Eq. (18) vanish, and it must not affect the well balance property of the numerical scheme (30) if we discretize it in a consistent way. The proof of the following theorem will focus on showing a balance between flux gradients and non-conservative products. The vector of source terms \(\mathbf{{S} }(\mathbf{{W} }, \sigma , B)\) in Eq. (18) is then discretized as

$$\begin{aligned} \frac{1}{\bigtriangleup x} \int _{x_{j-\frac{1}{2}}^+}^{x_{j+\frac{1}{2}}^-} S_1 dx&= \frac{{\bar{A}}_{1,j} c_{1,0}^2 ({\bar{\rho }}_{1,j}-\rho _{1,0})}{\bar{\rho }_{1,j} c_{1,j}^2}, \nonumber \\ \frac{1}{\bigtriangleup x} \int _{x_{j-\frac{1}{2}}^+}^{x_{j+\frac{1}{2}}^-} S_3 dx&= - g {\overline{\rho }}_{2,j} \frac{n_i^2 \left| \frac{\overline{Q}_{1,j} \overline{A}_{1,j} + \overline{Q}_{2,j} \overline{A}_{2,j}}{\overline{A}_{1,j} +\overline{A}_{2,j}}\right| }{\mathcal {\overline{R}}_j^{4/3}} (\overline{u}_{1,j} - \overline{u}_{2,j}) \nonumber \\&\quad - g \frac{n_b^2 \left| \frac{\overline{Q}_{1,j} \overline{A}_{1,j} + \overline{Q}_{2,j} \overline{A}_{2,j}}{\overline{A}_{1,j} +\overline{A}_{2,j}}\right| }{\mathcal {\overline{R}}_j^{4/3}}\overline{u}_{1,j},\nonumber \\ \frac{1}{\bigtriangleup x} \int _{x_{j-\frac{1}{2}}^+}^{x_{j+\frac{1}{2}}^-} S_4 dx&= \frac{\mu {\bar{A}}_{2,j} c_{2,0}^2 (\bar{\rho }_{2,j}-\rho _2^{(0)})}{{\bar{\rho }}_{2,j} c_{2,j}^2}, \nonumber \\ \frac{1}{\bigtriangleup x} \int _{x_{j-\frac{1}{2}}^+}^{x_{j+\frac{1}{2}}^-} S_6 dx&= - g {\overline{\rho }}_{2,j} \frac{n_i^2 \left| \frac{\overline{Q}_{1,j} \overline{A}_{1,j} + \overline{Q}_{2,j} \overline{A}_{2,j}}{\overline{A}_{1,j} +\overline{A}_{2,j}}\right| }{\mathcal {\overline{R}}_j^{4/3}} (\overline{u}_{2,j}-\overline{u}_{1,j}), \end{aligned}$$
(34)

where

$$\begin{aligned} c_{1,j}&= \sqrt{g \left( \frac{{\bar{\rho }}_{2,j}}{{\bar{\rho }}_{1,j}} \frac{{\bar{A}}_{1,j}}{\sigma _{2,j}}+\left( 1- \frac{\bar{\rho }_{2,j}}{{\bar{\rho }}_{1,j}}\right) \frac{\bar{A}_{1,j}}{\sigma _{1,j}}\right) }, c_{2,j} = \sqrt{\frac{g \bar{A}_{2,j}}{\sigma _{2,j}}}, \nonumber \\ {\bar{R}}_j&= \frac{{\bar{A}}_{1,j}+\bar{A}_{2,j}}{\sigma _{B,j}+\int _{B_j}^{{\bar{w}}_{2,j}} \sqrt{4+(\partial _z \sigma (x_j,z))^2} dz}. \end{aligned}$$
(35)

Theorem 1

Under the linear polynomial reconstruction (23) and (24) for the variables \(\rho _1, \rho _2, w_1, w_2, Q_1\) and \(Q_2\), and the discretization of the source terms given by Eqs. (34) and (35), the resulting path-conservative central-upwind scheme described in Sect. 3.1 is well balanced.

Proof

Under steady state conditions at rest, \(w_1, w_2\) are constants, \(u_1 = 0 = u_2, \rho _1 = \rho _1^{(0)}\) and \(\rho _2 = \rho _2^{(0)}\). Consequently, the terms \( {S_f}_{,1}, {S_f}_{,2}, \rho _1 - \rho _1^{(0)}\) and \(\rho _2 - \rho _2^{(0)}\) in the source of (30) vanish. The left state \(\mathbf{{W} }_{i+\frac{1}{2}}^{-}\) and right state \(\mathbf{{W} }_{i+\frac{1}{2}}^{+}\) of variable vector \(\mathbf{{W} }_{i+\frac{1}{2}}\) are connected (as a function of \(s \in [0,1]\)) with a linear Volpert path defined as \(\mathbf{{W} }_{i+\frac{1}{2}}(s) = \mathbf{{W} }_{i+\frac{1}{2}}^{-}+s(\mathbf{{W} }_{i+\frac{1}{2}}^{+}-\mathbf{{W} }_{i+\frac{1}{2}}^{-})\). Such paths are applied to the variables \(\rho _1, \rho _2, w_1, w_2, Q_1\) and \(Q_2\) and any other variable is obtained in terms of them.

The fourth and fifth terms in the right-hand side of Eq. (30) cancels each other as described below

$$\begin{aligned}{} & {} \frac{d \mathbf{{W_3} }_{i-\frac{1}{2}}(s)}{ds} = 0, \,\,\, \frac{d \mathbf{{W_3} }_{i+\frac{1}{2}}(s)}{ds} = 0, \;(\text{ as } \; u_1=0),\\{} & {} \frac{d \mathbf{{W_6} }_{i-\frac{1}{2}}(s)}{ds} =0, \,\,\, \frac{d \mathbf{{W_6} }_{i+\frac{1}{2}}(s)}{ds} = 0 \;(\text{ as }\; u_2=0), \\{} & {} \int _{0}^{1} {p_1}_{i-\frac{1}{2}} \frac{d \mathbf{{W_1} }_{i-\frac{1}{2}}(s)}{ds}+\int _{0}^{1} \frac{g}{{A_1}_{i-\frac{1}{2}}}\left( \int _{B}^{{w_1}_{i-\frac{1}{2}}} z \sigma (x,z) dz \right) \frac{d \mathbf{{W_2} }_{i-\frac{1}{2}}(s)}{ds} ds\\{} & {} \quad = \left( p_0 + g \rho _1^{(0)}(w_1 + r h_2)\right) \left( {A_1}_{i-\frac{1}{2}}^+ - {A_1}_{i-\frac{1}{2}}^-\right) ,\\{} & {} \int _{0}^{1} {p_1}_{i+\frac{1}{2}} \frac{d \mathbf{{W_1} }_{i+\frac{1}{2}}(s)}{ds}+\int _{0}^{1} \frac{g}{{A_1}_{i+\frac{1}{2}}}\left( \int _{B}^{{w_2}_{i+\frac{1}{2}}} z \sigma (x,z) dz \right) \frac{d \mathbf{{W_2} }_{i+\frac{1}{2}}(s)}{ds} ds\\{} & {} \quad = \left( p_0 + g \rho _1^{(0)}(w_1 + r h_2)\right) \left( {A_1}_{i+\frac{1}{2}}^+ - {A_1}_{i+\frac{1}{2}}^-\right) ,\\{} & {} \int _{0}^{1} {p_2}_{i-\frac{1}{2}} \frac{d \mathbf{{W_4} }_{i-\frac{1}{2}}(s)}{ds}+\int _{0}^{1} \frac{g}{{A_2}_{i-\frac{1}{2}}}\left( \int _{{w_1}_{i-\frac{1}{2}}}^{{w_2}_{i-\frac{1}{2}}} z \sigma (x,z) dz \right) \frac{d \mathbf{{W_5} }_{i-\frac{1}{2}}(s)}{ds} ds\\{} & {} \quad = \left( p_0 + g \rho _2^{(0)} w_2 \right) \left( {A_2}_{i-\frac{1}{2}}^+ - {A_2}_{i-\frac{1}{2}}^-\right) , \\{} & {} \int _{0}^{1} {p_2}_{i+\frac{1}{2}} \frac{d \mathbf{{W_4} }_{i+\frac{1}{2}}(s)}{ds}+\int _{0}^{1} \frac{g}{{A_2}_{i+\frac{1}{2}}}\left( \int _{{w_1}_{i+\frac{1}{2}}}^{{w_2}_{i+\frac{1}{2}}} z \sigma (x,z) dz \right) \frac{d \mathbf{{W_5} }_{i+\frac{1}{2}}(s)}{ds} ds\\{} & {} \quad = \left( p_0 + g \rho _2^{(0)} w_2\right) \left( {A_2}_{i+\frac{1}{2}}^+ - {A_2}_{i+\frac{1}{2}}^-\right) . \end{aligned}$$

In the above relations, it was very important that the coefficients in front of derivatives in the integrands were constant, so we could simply apply the fundamental theorem of calculus. In steady states of rest we have \({A_1}_{i-\frac{1}{2}}^+ = {A_1}_{i-\frac{1}{2}}^-, \,\, {A_1}_{i+\frac{1}{2}}^+ = {A_1}_{i+\frac{1}{2}}^-,\,\, {A_2}_{i-\frac{1}{2}}^+ = {A_2}_{i-\frac{1}{2}}^-\), and \({A_2}_{i+\frac{1}{2}}^+ = {A_2}_{i+\frac{1}{2}}^-\). In view of the above equations, the fourth and fifth terms at the right-hand side of (30) cancel each other.

Given averaged quantities \(\overline{{\mathbf{{W} }}_i}\), one also needs to implement polynomial reconstructions to obtain interface data \(\mathbf{{W} }_{i\pm \frac{1}{2}}^\pm \). For that end, we have also used a linear path to connect \(\mathbf{{W} }_{i-\frac{1}{2}}^{+}\) with \(\mathbf{{W} }_{i+\frac{1}{2}}^{-}\) (as a function of \(x' = x-x_i \in [-\Delta x/2, \Delta x/2])\). In the polynomial integration, we are using a linear reconstruction for \(\rho _1, \rho _2, w_1, w_2, Q_1\) and \(Q_2\) and any other variables are obtained in terms of them. Although B(x) and \(\sigma (x,z)\) are independent of time, we also reconstruct them using the same linear function. The numerical flux will be balanced by \(\mathcal {C}_i\), the polynomial reconstruction of non-conservative terms which we are defining at the inter-cell region of each grid cells in the following manner

$$\begin{aligned} A_1&= \int _{B(x_i+x')}^{w_1(x_i+x')} \sigma (x_i+x', z) dz, \quad A_2 = \int _{w_1(x_i+x')}^{w_2(x_i+x')} \sigma (x_i+x', z) dz, \\ \partial _{x'} \mathbf{{W} }_1&= \partial _{x'} A_1 \\&= \int _{B(x_i+x')}^{w_1(x_i+x')} \sigma _{x'}(x_i+x', z)dz - \sigma (x_i+x', z)|_{z = B(x_i+x')} \partial _{x'}B(x_i+x') \\&\quad + \sigma (x_i+x', z)|_{z = w_1(x_i+x')} \partial _{x'}w_1(x_i+x'),\\ \partial _{x'} \mathbf{{W} }_2&= \partial _{x'} (\rho _1 A_1) = \rho _1 \partial _{x'} A_1 + A_1 \partial _{x'} \rho _1, \\ \partial _{x'} \mathbf{{W} }_3&= \partial _{x'} (\rho _1 Q_1) = \rho _1 \partial _{x'} Q_1 + Q_1 \partial _{x'}\rho _1, \\ \partial _{x'} \mathbf{{W} }_4&= \partial _{x'} A_2 \\&= \int _{w_1(x_i+x')}^{w_2(x_i+x')} \sigma _{x'}(x_i+x', z)dz - \sigma (x_i+x', z)|_{z = w_1(x_i+x')} \partial _{x'}w_1(x_i+x') \\&\quad + \sigma (x_i+x', z)|_{z = w_2(x_i+x')} \partial _{x'}w_2(x_i+x'),\\ \partial _{x'} \mathbf{{W} }_5&= \partial _{x'} (\rho _2 A_2) = \rho _2 \partial _{x'} A_2 + A_2 \partial _{x'} \rho _2, \\ \partial _{x'} \mathbf{{W} }_6&= \partial _{x'} (\rho _2 Q_2) = \rho _2 \partial _{x'} Q_2 + Q_2 \partial _{x'} \rho _2. \end{aligned}$$

As we note, in the scheme it was also very important to linearly reconstruct the appropriate variables and obtain the rest of the variables in terms of them. The first, second, fourth and fifth components of non-conservative polynomial integration vanish because \(u_1=0=u_2\) when the state is at rest. The integration of third term writes

$$\begin{aligned} \mathcal {C}_{3_i}&= \frac{1}{\Delta x}\int _{-\Delta x/2}^{\Delta x/2} \left( \left( p_0 + \frac{g\rho _1}{A_1(x_i+x')}\int _{B(x_i+x')}^{w_1}(w_1 + r h_2 - z)\sigma (x_i + x',z)dz \right) \right. \nonumber \\&\quad \left. \times \frac{d A_1(x_i+x')}{dx'}+ \left( \frac{g\rho _1}{A_1(x_i+x')}\int _{B(x_i+x')}^{w_1} z\sigma (x_i + x',z)dz \right) \frac{d A_1(x_i+x')}{dx'} \right) dx' \nonumber \\ \mathcal {C}_{3_i}&= \frac{1}{\Delta x}\int _{-\Delta x/2}^{\Delta x/2} (p_0 + g\rho _1(w_1 + r h_2))\frac{d A_1(x_i+x')}{dx'} dx' \nonumber \\&= \frac{1}{\Delta x} (p_0 + g\rho _1(w_1 + r h_2))\left( A_{1_{i+\frac{1}{2}}}^- - A_{1_{i-\frac{1}{2}}}^+ \right) . \end{aligned}$$
(36)

Since \({\textbf{W}}_{3_{i\pm \frac{1}{2}}}^- = {\textbf{W}}_{3_{i+\frac{1}{2}}}^+\), \(\mathcal {C}_{3_i}\) has to balance with third component of the numerical flux, which is

$$\begin{aligned} {\textbf{H}}_{3_{i+\frac{1}{2}}}&= \frac{a_{i+\frac{1}{2}}^+ {\textbf{F}}_{3_{i+\frac{1}{2}}}^- - a_{i+\frac{1}{2}}^- {\textbf{F}}_{3_{i+\frac{1}{2}}}^+ }{a_{i+\frac{1}{2}}^+ - a_{i+\frac{1}{2}}^-} + \frac{a_{i+\frac{1}{2}}^+ a_{i+\frac{1}{2}}^-}{a_{i+\frac{1}{2}}^+ - a_{i+\frac{1}{2}}^-}\left( {\textbf{W}}_{3_{i+\frac{1}{2}}}^+ -{\textbf{W}}_{3_{i+\frac{1}{2}}}^-\right) \\&= {\textbf{F}}_{3_{i+\frac{1}{2}}}^+ = {\textbf{F}}_{3_{i+\frac{1}{2}}}^-. \end{aligned}$$

Consequently,

$$\begin{aligned} \frac{1}{\Delta x}({\textbf{H}}_{3_{i+\frac{1}{2}}}-{\textbf{H}}_{3_{i-\frac{1}{2}}})&= \frac{1}{\Delta x}({\textbf{F}}_{3_{i+\frac{1}{2}}}-{\textbf{F}}_{3_{i-\frac{1}{2}}})\nonumber \\&= (p_0 + g\rho _1(w_1 + r h_2)) \frac{\left( A_{1_{i+\frac{1}{2}}}^- - A_{1_{i-\frac{1}{2}}}^+ \right) }{\Delta x}. \end{aligned}$$
(37)

The above equation is exactly the same as (36) and hence there is a balance. In the same way one can see that the sixth component of non-conservative polynomial integration is balanced by the numerical flux. As described above, the vector of source terms in Eq. (18) vanish with the consistent discretization of the source terms (34) and (35). This shows the well-balance property for one Euler step. Since the Runge–Kutta method (41) can be written as a convex combination of Euler steps, the proof is concluded. \(\square \)

3.4 Evolution in Time

The ordinary differential equation system (30) is integrated in time using the second order Strong Stability Preserving Runge–Kutta scheme [21]

$$\begin{aligned}&{\mathbf{{W} }}^{(1)}=\overline{{\mathbf{{W} }}}(t) + \bigtriangleup t {\mathbf{{N} }}[\overline{{\mathbf{{W} }}}(t)], \end{aligned}$$
(38a)
$$\begin{aligned}&{\mathbf{{W} }}^{(2)}= \frac{1}{2}\overline{{\mathbf{{W} }}}(t) + \frac{1}{2}\left( {\mathbf{{W} }}^{(1)} + \bigtriangleup t {\mathbf{{N} }}[{\mathbf{{W} }}^{(1)}] \right) , \end{aligned}$$
(38b)
$$\begin{aligned}&\overline{{\mathbf{{W} }}}(t + \bigtriangleup t) := {\mathbf{{W} }}^{(2)}, \end{aligned}$$
(38c)

with the Runge–Kutta fluxes

$$\begin{aligned} {\mathbf{{N} }}[\overline{{\mathbf{{W} }}}(t)]_i&= - \frac{1}{\bigtriangleup x} \bigg ({\textbf{H}}_{i+\frac{1}{2}} - {\textbf{H}}_{i-\frac{1}{2}} -\mathcal {C}_i - \frac{a_{i-\frac{1}{2}}^+ }{a_{i-\frac{1}{2}}^+ - a_{i-\frac{1}{2}}^-}\mathcal {C}_{\Phi , i-\frac{1}{2}} \nonumber \\&\quad + \frac{a_{i+\frac{1}{2}}^- }{a_{i+\frac{1}{2}}^+ - a_{i+\frac{1}{2}}^-}\mathcal {C}_{\Phi , i+\frac{1}{2}} \bigg )+ \overline{ {\textbf{S}}}_i(t). \end{aligned}$$
(39)

Here, \(\overline{ {\textbf{S}}}_i(t)\) is defined by (18), and its discretization is presented in Eq. (34). The time step \( \bigtriangleup t\) is selected to fulfill the CFL criterion

$$\begin{aligned} \bigtriangleup t \max \left[ \frac{a}{\bigtriangleup x}\max _{k=1,2,i=1:N} \frac{(\rho _k A_k)^-_{i+\frac{1}{2}}+(\rho _k A_k)^+_{i-\frac{1}{2}}}{2(\overline{\rho _k A_k})_i}, 5 \mho _f \right] \le \frac{1}{2}, \end{aligned}$$
(40)

where \(k =1,2\) represents the corresponding quantities for the lower and upper layer respectively. The term \(\mho _f\) is defined by

$$\begin{aligned} \mho _f = g \max (n_i^2, n_b^2)\max _{j=1:N} \frac{\overline{\rho _{2,j}}}{\overline{\rho _{1,j}}} \frac{\left| \frac{\overline{Q}_{1,j}\overline{A}_{1,j} +\overline{Q}_{2,j}\overline{A}_{2,j}}{(\overline{A}_{1,j}+\overline{A}_{2,j})^2} \right| }{\overline{R}_{j}^{4/3}}. \end{aligned}$$

As it was shown in [23], a CFL condition like the one in Eq. (40) would ensure the preservation of positivity in the incompressible case. Here, we have not proved preservation of positivity but we use the same condition, which has shown to be helpful in our numerical tests. The term \(\mho _f\), which is in units of frequency, is present in Eq. (40) in order to guarantee that we resolve the time scale associated with the friction term.

4 Numerical Results

This section describes several numerical tests aimed at showing the merits of the model and the corresponding numerical algorithm. In the following numerical examples, the initial data is described in terms of the primitive variables \(\mathbf{{W} }_{nc} = (h_1,h_2,\rho _1,\rho _2,u_1,u_2)\). Unless otherwise noted, throughout the paper the value of acceleration due to gravity is taken as \(g=9.81\); the reference densities are taken as \(\rho _1^{(0)}=0.1\) and \(\rho _2^{(0)}=0.1\).

One important numerical test here involves the Riemann problem. Often numerical algorithms are tested by comparing numerical solutions with approximated ones on refined grids. Exact weak solutions in this context are not easy to compute and require the use of the generalized Rankine–Hugoniot conditions with the specified paths in Sect. 2.2. Even in the case of channels with constant width and flat topography, non-conservative products are still present. Here we compare with exact weak solutions in order to investigate how close the approximations given by the path-conservative central-upwind scheme are to the solutions given by the generalized Rankine–Hugoniot conditions. Although we do not attempt to generalize, we find a good agreement in the parameter regimes considered here. Simulations in general channels are also presented.

4.1 Riemann Problems

For the Riemann problems in this subsection, we consider channels with constant width and a flat bathymetry. We compare the exact and approximated solutions to different Riemann problems. The exact solution is “cooked up” by starting from the left state and obtaining the intermediate and right states by using the corresponding Riemann invariants.

The approximated solution uses a second order path-conservative well-balanced central-upwind scheme as described above. The CFL number here is taken to be 0.45. In this section, we impose zero Neumann boundary conditions. We also take no pressure relaxation (\(\mu = 0\)) and no friction (\(n_i = n_b = 0\)).

Shock wave in the first family. Consider the Riemann problem with initial conditions

$$\begin{aligned} \mathbf{{W} }_{nc} (x,t=0) = \left\{ \begin{array}{ll} \mathbf{{W} }_{nc,L} &{}\quad \text {if}\; 0 \le x \le 0.5, \\ \mathbf{{W} }_{nc,R} &{}\quad \text {if}\; 0.5 < x \le 1. \end{array} \right. \end{aligned}$$

The left (\(\mathbf{{W} }_{nc,L}\)) and right (\(\mathbf{{W} }_{nc,R}\)) states are given by

$$\begin{aligned} \mathbf{{W} }_{nc,L} = \left( 0.5,0.8,2.8,0.5,1.4071,0.9\right) ,\quad \text {and}\quad \mathbf{{W} }_{nc,L} = \left( 0.5, 0.8,3,0.5,1.1,0.9 \right) .\nonumber \\ \end{aligned}$$
(41)

We note that those two states are connected by a shockwave in the first family, as dictated by Eqs. (63) and (66) in Appendix B.

Fig. 2
figure 2

Perturbation evolution of a shockwave in the first family. The numerical solution has been computed at \(t=0.1\) using 1600 grid points (only 320 gridpoints were plotted to distinguish the symbols). The initial conditions are given by the left and right states in (41), followed by a description of the model’s parameters. a \(h_1\) and \(h_2\). b \(u_1\) and \(u_2\). c \(\rho _1\) and \(\rho _2\). The exact solution is plotted in a solid line while the bottom and top layers are described with circles and squares

The results are shown in Fig. 2, computed in the domain [0, 1] with final time \(t=0.1\). In the context of path conservative schemes, the Lax–Wendroff theorem is only conjectured. Although the plots in Fig. 2 show only 320 gridpoints, here we computed the solution using a fine grid of 1600 points to verify convergence to the exact solution. The parameter values needed to compute the solutions are \({c_1}_0=4,{c_2}_0=2,\,p_0 = 0.01\) for this numerical test. As mentioned above, the exact solution is computed with the help of the Riemann invariants under the non-conservative formulation and the generalized Rankine–Hugoniot conditions. In Fig. 2, the layers’ depths are shown in panel (a). The velocities are displayed in panel (b) and the densities in panel (c). The quantities associated with the bottom layer can be identified with the circles while those for the top layer are described with squares. In all cases, the exact solution is plotted in solid lines. One can observe an excellent agreement for this shockwave in the first family. Due to the well balance property inherited in the present numerical scheme, the Riemann invariants \(h_1, h_2, \rho _2\) and \(u_2\) are well approximated. This is because such Riemann invariants here correspond to quantities that remain constant in time and space. The well-balance property coincidently ensures that those quantities remain constant at later times if they are initially independent of x. This shock wave induces jump discontinuities only in \(u_1\) and \(\rho _1\), leaving the top layer unchanged. This shockwave in the first family is associated with the bottom layer only. The excellent agreement in this numerical test suggests that the path-conservative central-upwind scheme converges to the exact weak solution associated to the chosen linear path.

Contact wave in the second family. For a given left state \(\mathbf{{W} }_{nc,L}\), one can find a one-parameter family of right states which are connected by a 2-contact wave. This way, we cook up exact solutions to be compared with the approximated ones. The Riemann invariants for this computation have been derived using the eigenvalues (61) of the coefficient matrix (60) in Appendix B. This matrix describes the quasi-linear formulation of the generalized Rankine–Hugoniot formulation. The parameter values in this numerical test are \({c_1}_0={c_2}_0=4,\,p_0 = 0.1\). The domain contains 1600 grid cells and the final time is \(t=0.1\). The cooked up solutions have left and right states given by

$$\begin{aligned} \mathbf{{W} }_{nc,L}&= \left( 0.5,0.8,0.5,0.15,1.5,2\right) ,\quad \text {and} \nonumber \\ \mathbf{{W} }_{nc,R}&= \left( 0.8,0.8,0.4349,0.1291,1.5,2.081\right) . \end{aligned}$$
(42)
Fig. 3
figure 3

Perturbation evolution of a contact wave in the second family. The numerical solution has been computed at \(t=0.1\), using 1600 grid points (only 800 gridpoints were plotted to distinguish the symbols). The initial conditions are given by (42), which follows the description of the model’s parameters. Here we use the same symbols and structure as in Fig. 2

The results are shown in Fig. 3. One can see that the analytical and approximated solutions across the contact jump are in excellent agreement here as well. The velocity of the lower layer is constant along a contact wave in the second family, while all other variables vary across the shockwave. This indicates that the contact wave links both layers. State of the art numerical schemes can drastically fail in accurately computing solutions near contact waves, specially in cases where the jump’s amplitude is large. This is in part due to the inability of the path-conservative scheme to preserve the Riemann invariants across those waves, introducing large numerical errors that contaminate the rest of the solution. In Karni et al. [25], a hybrid formulation in the numerical scheme is used, involving a change of variables near the contact waves to preserve the corresponding Riemann invariants. The same issue could happen here if we increase the jump’s amplitude. Although a similar technique could improve the results, this is not our goal in this paper.

Fig. 4
figure 4

Riemann problem with a rarefaction wave (first family), contact wave (second family) and rarefaction wave (third family). The initial conditions are given by Eq. (43), followed by a description of the model’s parameters. The solution is computed at \(t=0.1\), using 1600 grid points. The bottom/top panels display the bottom/top layers. The layers’ depths are plotted in the left panels, the velocities in the middle panels and the densities in the right panels

Riemann problem with three waves: 1-Rarefaction, 2-Contact and 3-Rarefaction. The present Riemann problem consists of a rarefaction in the first family, a contact wave in the second family and a rarefaction wave in the third family. In the following, the left state \(\mathbf{{W} }_{nc,L}\) is connected to the middle left state \(\mathbf{{W} }_{nc,L}^*\) by a rarefaction wave in the first family, which in turn is connected to the middle right state \(\mathbf{{W} }_{nc,R}^*\) by a contact wave, connected to \(\mathbf{{W} }_{nc,R}\) by a rarefaction wave. Such states are

$$\begin{aligned} \mathbf{{W} }_{nc,L}&= \left( 0.5,0.8,0.6,0.15,0.6724,2\right) , \mathbf{{W} }_{nc,L}^* = \left( 0.5,0.8,0.5,0.15,1.5,2\right) , \nonumber \\ \mathbf{{W} }_{nc,R}^*&= \left( 0.8,0.8,0.4349,0.1291,1.5,2.0810\right) , \nonumber \\ \mathbf{{W} }_{nc,R}&= \left( 0.8,0.8,0.5849,0.1291,2.888,2.0810\right) . \end{aligned}$$
(43)

The parameter values are \({c_1}_0={c_2}_0=4,\,p_0 = 0.1\). The results are shown in Fig. 4 using 1600 grid points and a final time \(t=0.1\). The path-dependent non-conservative formulation that determines the weak solution is in excellent agreement with the numerical approximation. The numerical scheme works well even in this Riemann problem that involves the interaction of several distinct waves.

Fig. 5
figure 5

Riemann problem with a solution consisting of a rarefaction in the first family, followed by a contact wave in the second family and a shockwave in the third family. The solution has been computed at \(t=0.1\), using 1600 grid points. The initial conditions are given by Eq. (44), followed by a description of the model’s parameters

Riemann problem with three waves: 1-Rarefaction, 2-Contact and 3-Shock. In contrasts to the previous Riemann problem, this numerical test involves a shockwave instead of a rarefaction wave, representing a more challenging problem due to the jump discontinuity and its interaction with the other waves in the numerical approximations. In the following, we start by choosing a left state \(\mathbf{{W} }_{nc,L}\). We cook up the rest of the solution by finding a middle left state \(\mathbf{{W} }_{nc,L}^*\) that is connected to the left state by a rarefaction wave in the first family. Then, the middle left state is connected to the middle right state \(\mathbf{{W} }_{nc,R}^*\) by a contact wave in the second family. Finally, the middle right state is connected to the right state \(\mathbf{{W} }_{nc,R} \) by a shockwave in the third family. The parameter values are \({c_1}_0= 4, {c_2}_0=0.4,\,p_0 = 0.1\). The initial conditions are given by

$$\begin{aligned} \mathbf{{W} }_{nc,L}&= \left( 0.3,0.5,0.45,0.1,-0.8871,0.8\right) , \nonumber \\ \mathbf{{W} }_{nc,L}^*&= \left( 0.3,0.5,0.35,0.1,0.2,0.8\right) ,\nonumber \\ \mathbf{{W} }_{nc,R}^*&= \left( 0.45,0.5,0.3233,0.0398,0.2,1.7089\right) ,\nonumber \\ \mathbf{{W} }_{nc,R}&= \left( 0.45,0.5,0.1433,0.0398,-3.4545,1.7089\right) . \end{aligned}$$
(44)

The results are shown in Fig. 5, depicted using 1600 grid cells computed at the final time \(t=0.1\). It is noticeable in this case that the value of \({c_2}_0\) is 0.4 which is 10 times smaller than the value of \({c_2}_0\) used for all above cases. This is consistent with situations where the two body fluids consist of materials with very different properties and it can serve as a sensitivity analysis. As we can see, the numerical solution is in excellent agreement with the exact solution. We only observe small oscillations near the discontinuities and in places where waves in other families (4, 5 or 6) could have appeared (here with zero amplitude). On the other hand, we report numerical issues in high values of \({c_2}_0\). However, we also found that such numerical issues are alleviated if we reduce the density of the upper layer. This type of condition could be applicable, for instance, when the fluid in the upper layer is much lighter than that of the lower layer.

Fig. 6
figure 6

Riemann problem with a contact wave in the second family (68), followed by a description of the model’s parameters

Strong jump in contact wave: comparison with classical central-upwind scheme. It is well known that state of the art numerical scheme may drastically fail when computing the solutions near contact waves. As mentioned above, this is due to the inability of the scheme to recognize the corresponding Riemann invariants. In order to accurately compute the solution, a hybrid strategy was proposed in [25] that uses the Riemann invariant formulation near the contact wave and the conservative formulation away from it. It is not our goal in this work to present a hybrid strategy but we would like to compare the path-conservative scheme with the classical central-upwind scheme. For that end, the following left and states that are connected by a contact wave with strong amplitude:

$$\begin{aligned} \mathbf{{W} }_{nc,L}&= \left( 0.5,0.8,0.5,0.15,1.5,2\right) ,\quad \text {and} \nonumber \\ \mathbf{{W} }_{nc,R}&= \left( 1.3,0.8,0.4349,0.1291,1.5,2.081\right) . \end{aligned}$$
(45)

The results are presented in Fig. 6. As expected and explained above, one observes large numerical errors in both numerical schemes as the numerical solutions show oscillations near the contact discontinuity. Nevertheless, one observes a moderate improvement of the path-conservative central-upwind scheme in comparison with its classical counterpart. Such improvement is identified near the discontinuity. Furthermore, the numerical errors in the velocity \(u_1\), which is a Riemann invariant, is smaller in the path-conservative numerical scheme.

Fig. 7
figure 7

Log-log plot of \(L^1\) error versus \(\bigtriangleup x\) measured inside the rarefaction in \(x \in [-0.7,0.7].\)

Accuracy test. In this numerical example, we aim to demonstrate the accuracy of the numerical scheme employed over a successively refined grid. The \(L^1\) relative error for the quantity \(\mathfrak {m}\) is defined as

$$\begin{aligned} \textsf{E}_{\mathfrak {m}}(t) = \frac{1}{\mathscr {L}}\int _{x_0}^{x_1}\left| \frac{\mathfrak {m}(x,t) -\mathfrak {m}_{\text {ref}}(x,t)}{\mathfrak {m}_{\text {ref}}(x,t)} \right| dx, \end{aligned}$$
(46)

in the interval \([x_0,x_1],\) with \(\mathscr {L}\) being the length of the interval. Here, \(\mathfrak {m}_{\text {ref}}(x,t)\) is a reference solution that could be the exact one (when available) or an approximation computed on a refined grid. Computing the exact solutions requires approximating \(\rho _1\) as a solution to an algebraic equation, which could represent a source of uncertainty. Instead, here we have used an approximated solution computed on a grid with 25,600 grid points.

According to the existing theory of monotone schemes, the central upwind scheme exhibits second-order accuracy in smooth regions, while the slope limiter make it first order near discontinuities. In order to ensure the absence of discontinuities, we use a rarefaction solution as initial conditions with left and right states given by \((h_{1,L},\rho _{1,L},u_{1,L},h_{2,L},\rho _{2,L},u_{2,L}) = (0.5,0.6,0.67,0.8,0.15,2)\) and \((h_{1,R},\rho _{1,R},u_{1,R},h_{2,R},\rho _{2,R},u_{2,R}) = (0.5,0.5,1.5,0.8,0.15,2)\). We take this solution at time \(t = 2.1\) with a jump at \(x_{\text {shock}} = 7.25\) as the initial condition. Other model parameters are \(\mu = 0,p_0 = 0.1, c_{1_0} = c_{2_0} = 4, \rho _{1}^{(0)} = 0.4, \rho _{2}^{(0)} = 0.1\). We then simulate for a short duration, concluding at \(t = 2.101\). The log-log plot of the total \(L^1\) relative error \(\textsf{E}= \textsf{E}_{h_1}+\textsf{E}_{h_2}+\textsf{E}_{u_1}+\textsf{E}_{u_2}+\textsf{E}_{\rho _1}+\textsf{E}_{\rho _2}\) and \(\bigtriangleup x\) is shown in Fig. 7, where x lies in the interval \([-0.7,0.7]\), which lies inside the rarefaction smooth region. In Fig. 7 the steeper solid line indicates second-order accuracy, whereas the other dashed line denotes first-order accuracy. We observe that the asterisk symbols closely align with the solid line of slope 2 in smooth regions, indicating that the scheme is second order accurate.

4.2 Numerical Solutions with Topography Variation and General Channels

In this subsection, we first consider a simulation of a perturbation to a steady state at rest in a general channel with both continuous and discontinuous topographies. We note that the limit for large pressure relaxation (\(\mu \rightarrow \infty \)) corresponds to the incompressible two-layer shallow water system. Or, equivalently, when the timescale associated with the weak compressibility relaxation \(\mu ^{-1}\rightarrow 0\) goes to zero. The value of \(\mu \) for this case is 100. Due to the strong relaxation here, we are considering a smaller time step by setting CFL = 0.4. Furthermore, in this section we consider friction with Manning coefficients given by \(n_i=n_b=9\times 10^{-3} \).

Fig. 8
figure 8

Steady solutions at rest. The approximated solution uses 200 grid points with final time \(t=0.1\). Top panels: topography and depths (left), velocities (middle) and densities (right) are shown. Bottom panels: the corresponding errors for depths (left), velocities (middle) and densities (right)

Steady solutions at rest. In this numerical tests, we would like to verify the well-balance property shown in Theorem 1. Before then, let us define the geometry and topography. We choose the following smooth topography

$$\begin{aligned} B(x) = {\left\{ \begin{array}{ll} 0.25 \left( \cos (\pi (x-0.4)/0.25) + 1\right) &{}\text{ if }\; x \in [0.15,0.65],\\ 0 &{} \text{ if }\; x \in [0,1]{\setminus } [0.15,0.65]. \end{array}\right. } \end{aligned}$$

This topography consists of a bump centered at \(x= 0.4\). The channel’s wall is described by the width at each axial position x, and height z. The channel’s width is given by

$$\begin{aligned} \sigma (x,z) = 1+\frac{x}{2}+z. \end{aligned}$$
(47)

The parameter values are \({c_1}_0 = 4\), \({c_2}_0 = 2\), and \(p_0 = 0.01\). The initial conditions, associated with a steady state solution at rest, are given by

$$\begin{aligned} \rho _1(x,0)&= \rho _1^{(0)} = \rho _2(x,0) = \rho _2^{(0)} = 0.1, \quad u_1(x,0) = u_2(x,0) = 0,\nonumber \\ w_1(x,0)&= 0.7,\quad w_2(x,0)=1.2. \end{aligned}$$
(48)

Figure 8 shows the numerical solution at time \(t=0.1\), displaying depths (top left), velocities (top middle) and densities (top right). The corresponding errors, comparing them with the exact solution, are shown in the bottom panels. We point out that we have used the explicit expression for \(\sigma \), which is linear in z. And so, there is no need for piecewise linear reconstructions in this case. As we can see, the solutions were computed to machine precision, indicating that we have achieved the well-balance property.

Fig. 9
figure 9

Three dimensional view of the topography. The layers’ depths correspond to the solution at time \(t= 0.1\) described the initial conditions given by Eq. (50), which follows the description of the model’s parameters

Fig. 10
figure 10

Time evolution of a perturbation to steady state of rest. Top panels: Depth and bottom at times \(t= 0, 0.03, 0.08, 2\). Middle panels: Velocities of both layers. Bottom panels: Densities of both layers at the same times. The initial conditions are given by (50), which follows a description of the model’s parameters. The approximated solution uses 200 grid points

Perturbation from a steady state with continuous bottom topography. This numerical test considers a perturbation to the steady state of rest, with the model’s parameters remaining the same as in the previous test. However, we are considering a more complicated channel here, which is given by

$$\begin{aligned} \sigma (x,z) = {\left\{ \begin{array}{ll} \frac{1}{2}\left( 1 + \sqrt{z} - \frac{1}{4}\sqrt{z} \left( 1-\frac{1}{4} (1+\cos (\pi (x-0.5)/0.2))\right) \right) \\ &{}\text{ if }\; x \in [0.4,0.8),\\ \frac{1}{2}(1+\sqrt{z}) &{}\text{ if }\; x \in [-1,1]{\setminus } [0.4,0.8]. \end{array}\right. } \end{aligned}$$
(49)

The bottom topography is defined as

$$\begin{aligned} B(x) = {\left\{ \begin{array}{ll} 0.25 \left( \cos (\pi (x-0.4)/0.25) + 1\right) &{}\text{ if }\; x \in [0.15,0.65],\\ 0 &{}\text{ if }\; x \in [-1,1]{\setminus } [0.15,0.65]. \end{array}\right. } \end{aligned}$$

The initial conditions are given by

$$\begin{aligned} \rho _1(x,0)&= \rho _1^{(0)} = \rho _2(x,0) = \rho _2^{(0)} = 0.1, \quad u_1(x,0) = u_2(x,0) = 0,\nonumber \\ w_1(x,0)&=0.7,\quad w_2(x,0) = \left\{ \begin{array}{ll} 1.2+ 0.2 &{}\quad \text {if}\; 0.1 \le x \le 0.2, \\ 1.2 &{}\quad \text {otherwise}. \end{array} \right. \end{aligned}$$
(50)

The 3D view of the channel is shown in Fig. 9. The solutions profiles are shown in Fig. 10 at time \(t=0,0.03,0.08,2\) from left to right. The top panels display the topography (B, black thick line), the interface (\(w_1\), thin solid line) and the total height (\(w_2\) dashed line). The middle panels show the velocities for the internal (solid line) and external (dashed line) layers. The bottom panels are devoted to the densities. As one can see, the perturbation in the top layer breakes and travels throughout the domain. Initially, the densities and velocities are the same in both layers, behaving like in the standard (single layer) system. At intermediate times (\(t= 0.3, 0.08\)), one observes that the two densities deviate from each other due to the weak compressibility. At the final time \(t=2\), the two densities converge to the initial value while the velocities are weak. The top layer is constant, indicating that the solution is converging towards the rigid-lid approximation.

Fig. 11
figure 11

Three dimensional view of the channel described by the topography and geometry in (51) and (49), and initial conditions given by (52), at time \(t=0.1\)

Perturbation from a steady state with discontinuous bottom topography. In this numerical test, we consider the following discontinuous topography

$$\begin{aligned} B(x) = {\left\{ \begin{array}{ll} 0&{}\text{ if }\; x \in [-1,0.15],\\ 0.25 \left( \cos (\pi (x-0.4)/0.25) + 1\right) &{} \text{ if }\; x \in [0.15,0.65],\\ 0.25 &{}\text{ if }\; x \in [0.65,1], \end{array}\right. } \end{aligned}$$
(51)

while the wall’s breadth is the same as the previous numerical test, and it is given by Eq. (49).

A 3D view of the channel can be found in Fig. 11. The model’s parameter values are \({c_1}_0 = 4\), \({c_2}_0 = 2\), and \(p_0 = 0.01\). Using a perturbation of \(\epsilon = 0.1\) in \(w_2\), the initial conditions are given by

$$\begin{aligned} \rho _1(x,0)&= \rho _1^{(0)} = \rho _2(x,0) = \rho _2^{(0)} = 0.1, u_1(x,0) = u_2(x,0) = 0,\nonumber \\ w_1(x,0)&=0.7,\quad w_2(x,0) = \left\{ \begin{array}{ll} 1.2+ \epsilon &{}\quad \text {if}\; 0.1 \le x \le 0.2, \\ 1.2 &{}\quad \text {otherwise} \end{array} \right. \end{aligned}$$
(52)
Fig. 12
figure 12

Time evolution of a perturbation to steady state at rest. A resolution of 200 grid points is used. Top panels: Layers’ depths and topography at times \(t= 0, 0.03, 0.07, 2\). Middle panels: Velocities of both layers. Bottom panels: Densities of both layers at the same times. The initial conditions are given by (52), followed by a description of the model’s parameters

The results are shown in Fig. 12. The top panels show the depths of the internal and external layers at times \(t= 0, 0.03, 0.07, 2\), using 200 grid points. The velocities are shown in the middle panels. One observes that the velocities of both layers are close to each other, initially having the same density (bottom panels). This indicates that the flow behaves like a regular (single layer) system. Due to the weak incompressibility of the fluid, both densities start to deviate from each other at intermediate times. Furthermore, at the final time the constant density is recovered again, the velocities are small and the total height \(w_2 = w_1+h_2\) is constant. The interface is not constant, indicating that the solution is converging towards the rigid-lid approximation. The high accuracy in converging to this steady state is due to the well-balance property of the presented numerical scheme, and it works well even in discontinuous topographies.

Positivity preserving property. In this numerical example, we aim to demonstrate the positivity preserving property of the numerical scheme, for which the topography and an explicit form of width are defined as

$$\begin{aligned} B(x) = \frac{3}{10} \max \left( \frac{1}{2}-2\left( x-\frac{3}{4} \right) ^2, 0\right) , \quad \sigma (x,z) = 1+ \frac{x}{2}+z. \end{aligned}$$
(53)

The Manning coefficients for both the interface and the bottom are considered to be the same as those defined at the beginning of this subsection. To perform this test, we made slight modifications to the model’s other parameters compared to the previous test. The relaxation parameter \(\mu \) was set to 10, while the values of other parameters are as follows: \({c_1}_0 = 4\), \({c_2}_0 = 2, \rho _1^{(0)}=0.15, \rho _2^{(0)}=0.1\), and \(p_0 = 0.01\). Initially, both layers are at rest, meaning \(u_1(x,0) = 0 = u_2(x,0)\). The external layer remains at a fixed height at the initial time, while the internal layer experiences a change and is defined by

$$\begin{aligned} w_1(x,0)&= {\left\{ \begin{array}{ll} B(x)+ 0.02 &{} \text{ if }\; x \le 0.75,\\ 1.48 &{} \text{ otherwise }, \end{array}\right. }\quad \text {and}\quad w_2(x,0) = 1.5,\nonumber \\ \rho _1(x,0)&= \rho _1^{(0)},\quad \rho _2(x,0) = \rho _2^{(0)}, \end{aligned}$$
(54)

The modified Neumann boundary conditions in this case, both at the inflow and outflow, are the same values as those defined for the initial conditions. The 3D channel view depicted in Fig. 13 illustrates a complex geometry and the evolution of the fluid over time. The flow variables at time \(t=0\) are shown in the top panel of Fig. 14, and at time \(t=0.2\) they are displayed in the bottom panel. In this initial-boundary value problem, the heavier and lighter fluid move in opposite directions.

Fig. 13
figure 13

Three dimensional view of the channel described by the topography and geometry in (53) for positivity numerical test. The initial conditions are given by (54)

Fig. 14
figure 14

Positivity preserving numerical test with initial conditions given by (54). Upper panels display topography and depths (left), velocities (middle), and densities (right) at time \(t=0\) sec. Lower panels illustrate topography and depths (left), velocities (middle), and densities (right) at time \(t=2\) sec

Convergence to steady states. In this last numerical example, we test the convergence of the numerical scheme towards steady states where the internal layer is not at rest, while the free surface remains stationary. Due to the complexity of the modeled equations, an analytical steady-state solution is unavailable. However, we approximate it using a rigid lid approximation and employing this exact steady state plus a perturbation as initial data. For this numerical test, we set the friction terms to zero, while the relaxation parameter, channel geometry and topography are used to be the same as those defined in the positivity test.

Fig. 15
figure 15

Three dimensional view of the channel described by the topography and geometry in (53) for convergence test. The initial conditions given by (55) are displayed here

Fig. 16
figure 16

Internal waves captured under the initial condition specified by Eq. (55). Left panel shows the topography and depths, middle panel shows the velocities, and right panel shows the densities. In the left panel, the initial condition for \(w_1\) is also plotted in a dotted/dashed line

The initial conditions are computed as follows. The top layer is at rest: \(w_2(x,0)= 1.5\) with zero velocity \(u_2(x,0) =0\) and constant density \(\rho _2(x,0) = 0.1\). The bottom layer, if unperturbed, would have a height and velocity \(w_{1,\text {up}}(x,0)\), \(u_1(x,0)\) satisfying Eq. (10) in Proposition 1, with \(\rho _1(x,0)\) given so that \(\rho _1(x,0) A_{1,\text {up}} (x,0) u_1(x,0) = 0.0587\) is constant with \(A_{1,\text {up}}(x,0) = \int _B^{w_{1,\text {up}}(x,0)}\sigma (x,z)dz\). Using a perturbation of \(\epsilon = 0.2\), \(w_1\) is the modified to be

$$\begin{aligned} w_1(x,0) = {\left\{ \begin{array}{ll} w_{1,\text {up}}(x,0) + \epsilon &{} \text{ if }\; 0.1<x \le 0.2,\\ w_{1,\text {up}}(x,0) &{} \text{ otherwise }, \end{array}\right. } \end{aligned}$$
(55)

A 3D view of the channel, with the topography, internal and external heights can be seen in Fig. 15. Figure 16 shows the different profiles. The left panel displays the topography, the perturbed initial layer’s height (solid line), its time evolution at time \(t=20\) (dotted/dashed line) and the top layer’s height (dashed line). At \(t=20\), the top layer’s height is constant and the bottom one is close to the unperturbed solution. The velocities and the densities in the middle and right panels at time \(t=20\) corroborate that we recover the steady state solution, showing convergence. We can observe that the model in [23] is conditionally hyperbolic and loses this property when the external layer is at rest and the internal layer is in motion. A similar (discontinuous) steady state solution with rigid lid conditions had regions where hyperbolicity was lost in that work [23]. This indicates that the model is not valid anymore in such cases. However, in our model, the consideration of weak compressibility overcomes this situation, resulting in the model outperforming here.

5 Conclusions

In this work, we formulated a weakly compressible two-layer shallow water system with varying cross-sections. In the case of infinite pressure relaxation (\(\mu \rightarrow \infty \)) and zero atmospheric pressure (\(p_0 = 0\)), the original system reduces to the classical two-layer shallow water system with varying width. We obtained the generalized Rankine–Hugoniot relation with the help of a linear Volpert path for the case of a channel with constant width and no source terms, which let us derive exact solutions of Riemann problems for the proposed non-conservative system. In order to validate the exact solutions which depend on a linear path, we use a well-balanced path-conservative central-upwind numerical scheme. Writing the system as a balance law with the matrix of non-conservative products allowed us to implement the numerical scheme. Although we do not attempt to make general statements, we found that the numerical approximations are in excellent agreement with exact weak solutions given by the generalized Rankine–Hugoniot conditions for different Riemann problems. We also simulated perturbations to steady states of rest in general channels and tested the well balance property of the scheme.