1 Introduction

By the classical dispersion analysis, high order methods are more efficient than low order method for solving wave propagation problems with sufficient smoothness [1, 2]. In many applications, wave propagation can be modeled by hyperbolic partial differential equations satisfying energy conservation or dissipation. For robustness of a numerical method, it is important that the discretization satisfies a corresponding discrete energy estimate. Such methods are often referred to as energy stable. When using finite difference methods to solve initial-boundary-value problems, a summation-by-parts (SBP) property is crucial to prove energy stability of the discretization. The SBP property discretely mimics the integration-by-parts principle, which is used to derive the continuous energy estimate. In [3], Kreiss and Scherer introduced the SBP concept and constructed traditional SBP operators for the first derivative. These traditional SBP operators are based on central finite difference stencils in the interior, and special stencils on a few grid points near boundaries. The simultaneous-approximation-term (SAT) method is often used to weakly impose boundary conditions [4]. The SBP-SAT discretization has been derived and analyzed for a wide range of hyperbolic and parabolic problems, see the reviews [5, 6].

Upwind SBP operators are constructed for the first derivative [7]. These operators are based on biased finite difference stencils in the interior, and come in pairs for a given accuracy. When combining with the SAT method to impose boundary conditions, the upwind SBP-SAT discretization naturally introduces dissipation, which can lead to significantly smaller errors than the traditional SBP-SAT discretization without dissipation. As an example, it was observed in the numerical experiments in [7] that the upwind SBP-SAT method has a higher-than-expected convergence rate when solving the advection equation and a first-order linear hyperbolic system. The first main contribution of this paper is to derive error estimates by the normal mode analysis for a class of upwind SBP-SAT schemes. We prove that, with a particular choice of penalty parameters in the SAT method, the convergence rate is indeed higher than using traditional SBP operators.

For problems with piecewise smooth coefficients modeling discontinuous media, stable and high order multiblock SBP-SAT discretizations have been derived for hyperbolic and parabolic problems [8,9,10,11]. The central idea is to decompose the domain into subdomains such that material discontinuities are aligned with the subdomain interfaces. An SBP finite difference discretization is constructed in each subdomain, and adjacent subdomains are patched together by the SAT method for physical interface conditions. However, if the solution discontinuities move in time, the multiblock strategy cannot be used in a straightforward way. A standard finite difference discretization based on fixed stencils gives numerical solutions with oscillations near discontinuities. One technique to eliminate such spurious oscillations is the weighted essentially nonoscillatory (WENO) method [12, 13]. In a WENO scheme, a nonlinear adaptive procedure automatically selects the smoothest local stencil for avoiding stencils across discontinuities. The WENO schemes have been extensively developed to solve hyperbolic conservation laws. In recent years, a series of work on unequal-sized sub-stencils have been studied, improving the robustness and computational efficiency, as well as smaller residue convergences for steady-state problems [14,15,16]. We note that, however, energy stability can in general not be established for standard WENO schemes.

Efforts have been made to develop schemes that have both the SBP and the WENO property, which is often referred to as energy stable WENO (ESWENO) method. An ESWENO method for the advection equation with periodic boundary conditions was developed in [17, 18]. Based on traditional SBP operators and the SAT method, the ESWENO methodology was further developed to a fourth order accurate discretization for the advection equation with inflow boundary conditions [19]. Motivated by the superior accuracy property of upwind SBP finite difference discretization in [7], we extend the methodology and develop an upwind ESWENO method.

The rest of the paper is organized as follows. In Sect. 2, we introduce the upwind SBP property, and the SAT method for imposing boundary conditions. A discrete energy estimate is derived to ensure stability of the semidiscretization. In Sect. 3, we derive error estimates for the upwind SBP-SAT discretization using the normal mode analysis. In Sect. 4, we derive an ESWENO method based on the upwind SBP operators. Numerical examples are presented in Sect. 5 to verify the error estimates from Sect. 3 and the performance of the upwind ESWENO method from Sect. 4. Finally, we draw conclusion in Sect. 6.

2 Spatial Approximation

2.1 SBP Property

Consider a uniform grid \(\textbf{x}\) in domain [0, 1] with grid points

$$\begin{aligned} x_j:= (j-1)h,\quad j=1,\ldots ,n, \quad h:=\frac{1}{n-1}, \end{aligned}$$
(1)

where n is the number of grid points and h is the grid spacing. Central finite difference stencils can easily be constructed on the grid points away from the boundaries by using Taylor expansion. On the few grid points close to the boundaries, one-sided stencils are used as boundary closure. The boundary closure can be specially constructed so that the finite difference stencils satisfy a SBP property, which is a discrete analogue of the integration-by-parts principle. The SBP concept was first introduced by Kreiss and Scherer [3] on uniform grid (1). We refer to this concept as traditional SBP, and restate its definition below.

Definition 1

(Traditional SBP) The difference operator D is a first derivative SBP operator if it satisfies

$$\begin{aligned} D = H^{-1} \left( Q+\frac{B}{2}\right) , \end{aligned}$$

where H is symmetric positive definite, \(Q=-Q^\top \) and \(B=\text {diag}([-1,0,0,\ldots ,0,0,1])\).

The operator H defines a discrete inner product, thus a discrete norm \(\Vert \cdot \Vert _H\). It is also a quadrature [20]. In a traditional SBP operator, a standard central finite difference stencil is used on the grid points in the interior; on a few grid points close to boundaries, special boundary closures are constructed so that the SBP property is satisfied. With a pth order accurate (p is even) central finite difference stencil in the interior, the boundary closures can at most be (p/2)th order accurate. In [3], the SBP operators are constructed for \(p=2,4,6,8\) with boundary closures on the first p/2 grid points. It is important to note that the number of grid points with the boundary closures is independent of grid spacing h. When using the traditional SBP operator to solve first order hyperbolic problems, the convergence rate is in general \(p/2+1\) [21, 22].

Recently, Mattsson constructed upwind SBP operators [7]. Comparing with the traditional SBP operators, the main difference is that noncentered finite difference stencils are used on the grid points in the interior. Upwind SBP operators with p from 2 to 9 were constructed in [7], and for each p the operators come in pairs, with one operator skewed to the left and the other operator skewed to the right.

Definition 2

(Upwind SBP) The difference operator \(D_m\) and \(D_p\) are a pair of first derivative upwind SBP operators if they can be written as

$$\begin{aligned} D_m = H^{-1} \left( Q_m+\frac{B}{2}\right) ,\quad D_p = H^{-1} \left( Q_p+\frac{B}{2}\right) , \end{aligned}$$

where \(Q_m=-Q_p^\top \), \(Q_m+Q_m^\top \) is symmetric positive semidefinite, and \(B=\text {diag}([-1,0,0,\ldots ,0,0,1])\).

Similar to the traditional SBP operators, the accuracy near boundaries is lower than in the interior. With a pth order accurate interior stencil, the accuracy of the boundary closures is \((p-1)/2\) on the first \((p+1)/2\) grid points for odd p, and p/2 on the first p/2 grid points for even p. The subscripts m and p are abbreviations of minus and plus, corresponding to biased stencils to the left and right directions, respectively.

2.2 An SBP-SAT Discretization

We consider the linear advection equation as our model problem,

$$\begin{aligned} U_t + U_x = 0,\quad x\in [0,1],\ t\in [0,1], \end{aligned}$$
(2)

with inflow boundary condition \(U(0,t) = g(t)\). In this case, the initial profile of U is transported from left to right, and the upwind direction is to the left.

We discretize the equation in space on a uniform grid (1). Let \(\textbf{u}=[u_1, u_2, \ldots , u_n]^T\) be the finite difference solution, where \(u_j\approx U(x_j,t)\). The SBP-SAT discretization of (2) reads

$$\begin{aligned} \textbf{u}_t + D_m \textbf{u} = \tau H^{-1}\mathbf {e_0} (u_1-g(t)), \end{aligned}$$
(3)

where \(\mathbf {e_0}:=[1,0,0,\ldots ,0]^\top \). The term on the right-hand side is a penalty term weakly imposing the boundary condition \(U(0,t) = g(t)\), and the penalty parameter \(\tau \) is determined in the stability analysis so that (3) satisfies a discrete energy estimate.

Lemma 1

The semidiscretization (3) with \(g(t)\equiv 0\) satisfies the energy estimate \(\frac{d}{dt}\Vert \textbf{u}\Vert _H^2\le 0\) if the penalty parameter \(\tau \le -1/2\).

Proof

We multiply (3) by \(\textbf{u}^\top H\) on both sides, and obtain

$$\begin{aligned} \textbf{u}^\top H \textbf{u}_t + \textbf{u}^\top H D_m \textbf{u} = \tau (u_1)^2. \end{aligned}$$

Adding the above equation to its tranpose, we have

$$\begin{aligned} \frac{d}{dt}\Vert u\Vert _H^2&= -\textbf{u}^\top (H D_m+(H D_m)^\top ) \textbf{u} + 2\tau (u_1)^2 \\&=-\textbf{u}^\top (Q_m+Q_m^\top +B) \textbf{u} + 2\tau (u_1)^2\\&=-\textbf{u}^\top (Q_m+Q_m^\top ) \textbf{u} +(2\tau +1) (u_1)^2- (u_n)^2\\&\le 0, \end{aligned}$$

if \(\tau \le -1/2\). We have used \(\textbf{u}^\top (Q_m+Q_m^\top ) \textbf{u} \ge 0\) by Definition 2. \(\square \)

We call such a semidiscretization energy stable. In the above energy analysis, \(-\textbf{u}^\top (Q_m+Q_m^\top ) \textbf{u}\) is an artificial dissipation term. The same analysis carries over to the case with traditional SBP operators but without any artificial dissipation.

The convergence rate in \(L^2\) norm of the traditional SBP-SAT discretization of the advection equation is \(p/2+1\), i.e. one order higher than the order of truncation error of the boundary closure. This phenomenon, often termed as gain in convergence, was theoretically analyzed in [21, 22] using the normal mode analysis. For the upwind SBP-SAT discretization, it is observed in [7] that the gain in convergence is more than one order. In the following section, we prove that for the advection equation, with most of the choices of the penalty parameter \(\tau \le -1/2\) the gain in convergence is one order, i.e. the same as the traditional SBP-SAT discretization; the special choice of \(\tau = -1\) results in a gain in convergence of order 1.5. In addition, we also consider a first order hyperbolic system and prove that the gain in convergence is 1.5 when the penalty parameter and the boundary condition satisfy a specific relation, while all other stable choices give a gain in convergence of one order.

3 Accuracy Analysis for the Linear Schemes

We derive error estimates for the linear schemes for both the scalar advection equation and a first order hyperbolic system. We assume the initial and boundary data are compatible and sufficiently smooth. This compatibility condition allows a decomposition of Eq. (2) in a bounded domain to two half-line problems, in \(x\in (-\infty , 1]\) and \(x\in [0, \infty )\), and the Cauchy problem in \(x\in (-\infty , \infty )\) [23]. We discretize the equation and prove stability in the bounded domain, but analyze the accuracy of discretization for the three decomposed problems.

3.1 Error Estimate for the Linear Scheme for the Advection Equation

Let \(\textbf{v}\) be the exact solution of (2) evaluated on the grid. Then \(\textbf{v}\) satisfies

$$\begin{aligned} \textbf{v}_t + D_m \textbf{v} = \textbf{d}, \end{aligned}$$
(4)

where \(\textbf{d}\) is the truncation error on the grid \(\textbf{x}\). The truncation error has the following structure

$$\begin{aligned} \textbf{d} = [\underbrace{\mathcal {O}(h^b),\ldots , \mathcal {O}(h^b)}_{r}, \mathcal {O}(h^p), \ldots \ldots \ldots , \mathcal {O}(h^p),\underbrace{\mathcal {O}(h^b), \ldots ,\mathcal {O}(h^b)}_{r}]^\top , \end{aligned}$$

where \(b<p\). In the analysis, we decompose the truncation error into three parts \(\textbf{d}:=\mathbf {d^{(\varvec{\varepsilon })}}+\mathbf {d^{(I)}}+\mathbf {d^{(\varvec{\xi })}}\). The first r elements of the left boundary truncation error \(\mathbf {d^{(\varvec{\varepsilon })}}\) are \(\mathcal {O}(h^b)\) and the remaining elements in \(\mathbf {d^{(\varvec{\varepsilon })}}\) are all zeros. Similarly in the right boundary truncation error \(\mathbf {d^{(\varvec{\xi })}}\), the last r elements \(\mathcal {O}(h^b)\) are the only nonzero elements. In \(\mathbf {d^{(I)}}\), the first and last r elements are zero but the elements in the interior are \(\mathcal {O}(h^p)\). It is important to note that r does not depend on h, and the number of grid points with truncation error \(\mathcal {O}(h^p)\) is proportational to \(h^{-1}\).

Let \(\varvec{\zeta }:=\textbf{v}-\textbf{u}\) be the pointwise error. The error equation reads

$$\begin{aligned} \varvec{\zeta }_t + D_m \varvec{\zeta } = -\tau H^{-1}\mathbf {e_0} (\zeta _1)+\textbf{d}. \end{aligned}$$
(5)

The truncation error \(\textbf{d}\) is a forcing term. Applying the energy analysis to the error equation (5), it is straightforward to obtain the estimate \(\Vert \varvec{\zeta }\Vert \le Ch^{\min (p,b+1/2)}\). The half an order gain from the boundary truncation error is due to the fact that r does not depend on h.

Since the scheme is linear, we also decompose the pointwise error \(\varvec{\zeta }:=\varvec{\varepsilon }+\varvec{\zeta }^{\mathbf {(I)}}+\varvec{\xi }\), where the three components \(\varvec{\varepsilon }\), \(\varvec{\zeta }^{\mathbf {(I)}}\) and \(\varvec{\xi }\) correspond to the truncation error \(\mathbf {d^{(\varvec{\varepsilon })}}\), \(\mathbf {d^{(I)}}\) and \(\mathbf {d^{(\varvec{\xi })}}\), respectively. In the following, we analyze the three components of the pointwise error, and then combine them to obtain an error estimate for \(\varvec{\zeta }\).

An estimate for the interior pointwise error \(\varvec{\zeta }^{\mathbf {(I)}}\) can be established by the energy analysis. Following the steps in the proof of Lemma 1, we have

$$\begin{aligned} \frac{d}{dt}\Vert \varvec{\zeta }^{\mathbf {(I)}}\Vert _H^2 \le 2 (\varvec{\zeta }^{\mathbf {(I)}})^\top H \mathbf {d^{(I)}} \le 2 \Vert \varvec{\zeta }^{\mathbf {(I)}}\Vert _H \Vert \mathbf {d^{(I)}}\Vert _H. \end{aligned}$$

Consequently,

$$\begin{aligned} \frac{d}{dt}\Vert \varvec{\zeta }^{\mathbf {(I)}}\Vert _H \le \Vert \mathbf {d^{(I)}}\Vert _H. \end{aligned}$$

An integration in time gives

$$\begin{aligned} \Vert \varvec{\zeta }^{\mathbf {(I)}}\Vert _H \le Ch^p, \end{aligned}$$

where C depends on the exact solution and the final time but not h. In the following, we use C to denote a generic constant that may depend on the continuous problem but not h, and may take different values in different estimates.

The above approach can be used to analyze the boundary pointwise error, leading to the estimates

$$\begin{aligned} \Vert \varvec{\varepsilon }\Vert _H \le Ch^{b+1/2},\quad \Vert \varvec{\xi }\Vert _H \le Ch^{b+1/2}. \end{aligned}$$

However, these results are suboptimal, and sharper error estimates can be obtained by the normal mode analysis based on Laplace transform.

Now consider the error equation for \(\varvec{\varepsilon }\),

$$\begin{aligned} \varvec{\varepsilon }_t + D_m \varvec{\varepsilon } = -\tau H^{-1}\mathbf {e_0} (\varepsilon _1)+\mathbf {d^{(\varvec{\varepsilon })}}. \end{aligned}$$
(6)

After Laplace transforming (6) in time and multiplying with h, we obtain

$$\begin{aligned} \widetilde{s}\widehat{\varvec{\varepsilon }} + hD_m \widehat{\varvec{\varepsilon }} = -\tau hH^{-1}\mathbf {e_0} (\widehat{\varepsilon _1})+h\widehat{\mathbf {d^{(\varvec{\varepsilon })}}}, \end{aligned}$$
(7)

where \(\widetilde{s}:=sh\) with s the dual of time, and \(\widehat{\varvec{\varepsilon }}\) is the Laplace-transformed variable of \(\varvec{\varepsilon }\). The central idea for sharp error estimates is first deriving an error bound for \(\varvec{\varepsilon }\) in the Laplace space, and then use Parseval’s relation to obtain the corresponding estimate in the physical space. To this end, we shall solve the difference equation (7) in the following two steps.

In the interior, the upwind SBP operator \(D_m\) uses a repeated finite difference stencil, and the components on the right-hand side of (7) equal to zero. More precisely, we have

$$\begin{aligned} \widetilde{s}\widehat{\varepsilon }_j + h\sum _{i=j-k_1}^{j+k_2}(D_m)_{ji}\widehat{\varepsilon }_i = 0,\quad j=r+1, r+2, \ldots , \end{aligned}$$
(8)

where \(k_1=(p-1)/2\), \(k_2=(p+1)/2\) for odd p, and \(k_1=(p-2)/2\), \(k_2=(p+2)/2\) for even p. The solution to (8) can be obtained by solving the corresponding characteristic equation.

In the first r equations in (7), the SBP operator \(D_m\) has boundary modified stencils and the truncation error has nonzero components. In this case, a system of r linear equations shall be solved and its solution depends on \(\widetilde{s}\). It is important to analyze the behavior of the solution in the limit \(\widetilde{s}\rightarrow 0\), because the convergence rate corresponds to the asymptotic regime when \(h\rightarrow 0\).

The stencils in \(D_m\) and the SAT for the inflow boundary condition affect the solution to (7). Therefore, to obtain error estimates with \(D_m\) of different order of accuracy, the analysis must be performed for each \(D_m\). In [7], upwind SBP operators \(D_m\) with interior order \(p=2\) to 9 are constructed. We present below the accuracy property of the semidiscretization with \(p=3\) and its proof.

Theorem 2

Consider the stable semidiscretization (3) with a third order accurate interior stencil and first order accurate boundary closure in \(D_m\). The convergence rate is 2.5 if the penalty parameter is \(\tau =-1\), and 2 if \(\tau \ne -1\).

Proof

We start by considering \(\varvec{\varepsilon }\) corresponding to the inflow boundary condition at \(x=0\). The interior error equation in Laplace space reads

$$\begin{aligned} \widetilde{s} \widehat{\varepsilon }_j = -\frac{1}{6}\widehat{\varepsilon }_{j-2}+\widehat{\varepsilon }_{j-1}-\frac{1}{2}\widehat{\varepsilon }_{j}-\frac{1}{3}\widehat{\varepsilon }_{j+1}, \quad j = 3,4,\cdots . \end{aligned}$$

The corresponding characteristic equation is

$$\begin{aligned} -\frac{1}{6}+\kappa -\left( \frac{1}{2}+\widetilde{s}\right) \kappa ^2-\frac{1}{3}\kappa ^3=0\quad j = 3,4,\cdots . \end{aligned}$$

At \(\widetilde{s}=0\), the characteristic equation has three solutions

$$\begin{aligned} 1,\quad \frac{-5+\sqrt{33}}{4}\approx 0.1861,\quad \frac{-5-\sqrt{33}}{4}\approx -2.6861. \end{aligned}$$

By a perturbation analysis, the admissible solutions satisfying \(|\kappa |<1\) are

$$\begin{aligned} \kappa _1=1-\widetilde{s},\quad \kappa _2=\frac{-5+\sqrt{33}}{4}+\mathcal {O}(\widetilde{s})\approx 0.1861+\mathcal {O}(\widetilde{s}). \end{aligned}$$

We note that \(\kappa _1\) is a slowly decaying solution and \(\kappa _2\) is a fast decaying solution. The general solution to the interior error equation can be written as

$$\begin{aligned} \widehat{\varepsilon }_j = \sigma _1\kappa _1^{j-1}+\sigma _2\kappa _2^{j-1},\quad j=1,2,\ldots , \end{aligned}$$
(9)

where the coefficients \(\sigma _1\) and \(\sigma _2\) will be determined by the error equation near the boundary.

On the first two grid points, the error equation (7) with \(j=1,2\) is

$$\begin{aligned} \widetilde{s} \widehat{\varepsilon }_1 - \widehat{\varepsilon }_1+\widehat{\varepsilon }_2-\frac{12}{5}\tau \widehat{\varepsilon }_1&= \frac{1}{2}h^2\widehat{v}_{xx}(x_1), \\ \widetilde{s} \widehat{\varepsilon }_2 - \frac{9}{13}\widehat{\varepsilon }_1+\frac{5}{13}\widehat{\varepsilon }_2+\frac{4}{13}\widehat{\varepsilon }_3&= -\frac{5}{26}h^2\widehat{v}_{xx}(x_1), \end{aligned}$$

Using the general solution (9), we obtain the boundary system \(C_3\varvec{\Sigma }=\mathbf {d_3}\), where

$$\begin{aligned}{} & {} C_3=\begin{bmatrix} \widetilde{s}-1-\frac{12}{5}\tau +\kappa _1 &{} \widetilde{s}-1-\frac{12}{5}\tau +\kappa _2 \\ -\frac{9}{13}+\widetilde{s}\kappa _1+\frac{5}{13}\kappa _1+\frac{4}{13}\kappa _1^2 &{} -\frac{9}{13}+\widetilde{s}\kappa _2+\frac{5}{13}\kappa _2+\frac{4}{13}\kappa _2^2 \end{bmatrix},\\{} & {} \varvec{\Sigma }=\begin{bmatrix} \sigma _1\\ \sigma _2 \end{bmatrix},\quad \mathbf {d_3}=\begin{bmatrix} \frac{1}{2}\\ -\frac{5}{26} \end{bmatrix}h^2\widehat{v}_{xx}(x_1). \end{aligned}$$

At \(\widetilde{s}=0\), we compute the determinant of the boundary system \(\det (C_3)= 3\tau (3+5\sqrt{33})/65\), which is nonzero for all \(\tau \le -1/2\) required by stability. Thus, the determinant condition is satisfied. The solution to the boundary system is

$$\begin{aligned} \begin{bmatrix} \sigma _1\\ \sigma _2 \end{bmatrix}=\begin{bmatrix} -\frac{10(1+\tau )}{(3+5\sqrt{33})\tau }\\ \frac{10}{(3+5\sqrt{33})} \end{bmatrix}h^2\widehat{v}_{xx}(x_1). \end{aligned}$$
(10)

The choice \(\tau =-1\) gives \(\sigma _1=0\). This is significant, because \(\sigma _1\) is multiplied with the slowly decaying solution \(\kappa _1\) in (9). In this case, substituting (10) to (9), we obtain

$$\begin{aligned} \Vert \varvec{\widehat{\varepsilon }}\Vert _h = \sqrt{h\sum _{j=1}^\infty |\sigma _2\kappa _2^{j-1}|^2} = \sqrt{h\sigma _2^2 \frac{1}{1-|\kappa _2^2|}} \le Ch^{2.5} |\widehat{v}_{xx}(x_1)|\quad \text {when } \tau =-1. \end{aligned}$$
(11)

Even though the truncation error at the inflow boundary condition is \(\mathcal {O}(h)\), the corresponding error converges to zero with rate 2.5 when \(\tau =-1\).

When \(\tau \ne -1\), the convergence rate is lower. To see this, we compute

$$\begin{aligned} \Vert \varvec{\widehat{\varepsilon }}\Vert _h&= \sqrt{h\sum _{j=1}^\infty |\sigma _1\kappa _1^{j-1}+\sigma _2\kappa _2^{j-1}|^2} \le \sqrt{h\sum _{j=1}^\infty |\sigma _1\kappa _1^{j-1}|^2}+\sqrt{h\sum _{j=1}^\infty \sigma _2|\kappa _2^{j-1}|^2} \end{aligned}$$
(12)
$$\begin{aligned}&\le \sqrt{h|\sigma _1|^2 \frac{1}{1-|\kappa _1^2|}}+\sqrt{h|\sigma _2|^2 \frac{1}{1-|\kappa _2^2|}} \end{aligned}$$
(13)

For a bound on the first term of (13), we need to use Lemma 2 in [24]. For completeness, we restate the lemma below. \(\square \)

Lemma 3

(Lemma 2 in [24]) Consider \(Re(\widetilde{s}):= \eta h > 0\), where \(\eta \) is a constant independent of h. Then \(\kappa _1=1-\widetilde{s} +\mathcal {O}({\widetilde{s}}^2)\) satisfies

$$\begin{aligned} \frac{1}{1-|\kappa _1^2|}\le \frac{1}{2\eta h} \end{aligned}$$

to the leading order.

Combining (12)–(13) and Lemma 3, we have

$$\begin{aligned} \Vert \widehat{\varvec{\varepsilon }}\Vert _h \le C h^2 + C h^{2.5} \le C h^2|\widehat{v}_{xx}(x_1)|\quad \text {when } \tau \ne -1. \end{aligned}$$

Therefore, the error in converges to zero with rate 2 when \(\tau \ne -1\), which is half an order lower than when \(\tau =-1\).

The above estimates in Laplace space can be transformed to the corresponding error estimates in physical space by Parseval’s relation. For the case with \(\tau =-1\), we have

$$\begin{aligned} \int _0^\infty e^{-2\eta t}\Vert \varvec{\varepsilon }\Vert _h^2 dt&= \frac{1}{2\pi }\int _{-\infty }^ {\infty } \Vert \widehat{\varvec{\varepsilon }}(\eta +iy)\Vert _h^2 dy \\&\le \frac{ C h^5}{2\pi } \int _{-\infty }^ {\infty } |\widehat{v}_{xx}(x_1,\eta +iy)|^2 dy \\&= C h^5 \int _{0}^ {\infty } e^{-2\eta t} |v_{xx}(x_1,t)|^2 dt. \end{aligned}$$

By the standard argument of future cannot affect past [23, pp. 294], the integration domain \([0,\infty )\) can be changed to any finite final time \(t_f\), resulting

$$\begin{aligned} \Vert \varvec{\varepsilon }\Vert _{h,t}:=\sqrt{\int _0^{t_f}\Vert \varvec{\varepsilon }\Vert _h^2 dt} \le C h^{2.5}\sqrt{ \int _{0}^ {t_f} e^{2\eta t_f} |v_{xx}(x_1,t)|^2 dt}. \end{aligned}$$

The estimate in physical space for the case with \(\tau \ne -1\) can be obtained analogously.

We now consider the outflow boundary \(x=1\). Here, no boundary condition is specified and there is no corresponding SAT in the semidiscretization. However, on the last two grid points the stencils in \(D_m\) are also modified. The characteristic equation is

$$\begin{aligned} \frac{1}{3}+\left( \frac{1}{2}+\widetilde{s}\right) \kappa -\kappa ^2+\frac{1}{6}\kappa ^3=0, \end{aligned}$$

and the only admissible root satisfying \(|\kappa |<1\) for \(Re(\widetilde{s})>0\) is

$$\begin{aligned} \kappa _3 = \frac{5-\sqrt{33}}{2}+\mathcal {O}(\widetilde{s}), \end{aligned}$$

which is a fast decaying component. Let the error \(\varvec{\xi }:=[\ldots , \xi _2, \xi _1]^\top \), then the error equation on the last two grid points are

$$\begin{aligned} \widetilde{s} \widehat{\xi }_2 + \frac{2}{13}\widehat{\xi }_4-\frac{12}{13}\widehat{\xi }_3+\frac{5}{13}\widehat{\xi }_2+\frac{5}{13}\widehat{\xi }_1&= -\frac{1}{26}h^2\widehat{v}_{xx}(x_n), \\ \widetilde{s} \widehat{\xi }_1 + \frac{2}{5}\widehat{\xi }_3-\frac{9}{5}\widehat{\xi }_2+\frac{7}{5}\widehat{\xi }_1&= \frac{1}{10}h^2\widehat{v}_{xx}(x_n), \end{aligned}$$

with two unknown variables \(\widehat{\xi }_1\) and \(\widehat{\xi }_2\). Note that \(\xi _j = \xi _2\kappa _3^{j-2}\) for \(j=3,4,\cdots \). At \(\widetilde{s}=0\), these two equations have a unique solution, i.e. the determinant condition is satisfied. Therefore, we have

$$\begin{aligned} \Vert \widehat{\varvec{\xi }}\Vert _h = \sqrt{h|\widehat{\xi }_1|^2+h\sum _{j=2}^\infty |\widehat{\xi }_j|^2}=\sqrt{h|\widehat{\xi }_1|^2+h|\widehat{\xi }_2|^2\frac{1}{1-|\kappa _3|^2}}\le Ch^{2.5}|\widehat{v}_{xx}(x_n)|. \end{aligned}$$

The error \(\Vert \widehat{\varvec{\xi }}\Vert _h\) converges to zero with rate 2.5, even though the truncation error on the last two grid points is \(\mathcal {O}(h)\). By using Parseval’s relation, we have

$$\begin{aligned} \Vert {\varvec{\xi }}\Vert _{h,t} \le Ch^{2.5}\sqrt{ \int _{0}^ {t_f} e^{2\eta t_f} |v_{xx}(x_n,t)|^2 dt}. \end{aligned}$$

Combining the estimates for the two boundary truncation error \(\varvec{\varepsilon }\) and \(\varvec{\xi }\), the error estimate for \(\varvec{\zeta }\) follows. This concludes the proof. \(\square \)

When using a finite difference method to solve an initial boundary value problem, it is common that the truncation error is larger near boundaries than in the interior. The general results in [21, 22] state that for first order hyperbolic problems, the convergence rate can be one order higher than the boundary truncation error, i.e. there is a gain in convergence of one order. In Theorem 2, we have proved that for most choices \(\tau \le -1/2\), \(\tau \ne -1\), the gain in convergence is indeed one order, resulting in an overall convergence rate of order 2. With the particular choice \(\tau =-1\), a higher convergence rate of order 2.5 is obtained, corresponding to a gain in convergence of order 1.5. Hence, the penalty parameter \(\tau =-1\) shall be used in practical computation.

3.2 Error Estimate for the Linear Scheme for a First Order Hyperbolic System

Consider the first order hyperbolic system

$$\begin{aligned} \textbf{U}_t + A\textbf{U}_x = 0,\quad x\in [0,1],\ t\in [0,1], \end{aligned}$$
(14)

where the \(2\times 2\) coefficient matrix is

$$\begin{aligned} A = \begin{bmatrix} 0 &{} 1\\ 1 &{} 0 \end{bmatrix}, \end{aligned}$$
(15)

and the unknown \(\textbf{U}(x,t):=[U(x,t), V(x,t)]^\top \) has two components. There are several boundary conditions that lead to a wellposed problem. Here, we consider

$$\begin{aligned} U(0,t)+\alpha _0 V(0,t)=g_1(t),\quad U(1,t)+\alpha _1 V(1,t)=g_n(t). \end{aligned}$$
(16)

Theorem 4

The first order hyperbolic system (14)–(15) with boundary condition (16) satisfies an energy estimate if \(\alpha _0\ge 0\) and \(\alpha _1\le 0\).

Proof

We multiply (14) by \(\textbf{U}^\top \), and obtain

$$\begin{aligned} \frac{d}{dt}\int _0^1 U^2+V^2dx = -2UV|_0^1 = -2\alpha _0 V^2(0,t) + 2\alpha _1 V^2(1,t) \end{aligned}$$

with homogeneous boundary condition \(g_1=g_n=0\). Therefore, we have the energy estimate \(\frac{d}{dt}\int _0^1 U^2+V^2dx \le 0\) when \(\alpha _0\ge 0\) and \(\alpha _1\le 0\). \(\square \)

We discretize the equation in space on a uniform grid \(\textbf{x}\) defined in (1). Let \(\textbf{w}:=[\textbf{u},\textbf{v}]^\top \) be the finite difference solution such that \(u_j\approx U(x_j,t)\) and \(v_j\approx V(x_j,t)\). To derive a stable finite difference scheme, we perform a flux splitting

$$\begin{aligned} A:= A_m+A_p:= \frac{1}{2}\begin{bmatrix} 1 &{} 1\\ 1 &{} 1 \end{bmatrix}+\frac{1}{2}\begin{bmatrix} -1 &{} 1\\ 1 &{} -1 \end{bmatrix}, \end{aligned}$$

where \(A_m\) corresponds to the wave going from left to right, and \(A_p\) corresponds to the wave going from right to left. We write the semidiscretization as

$$\begin{aligned}&\textbf{w}_t + (A_p \otimes D_p) \textbf{w}+ (A_m \otimes D_m)\textbf{w}\nonumber \\&\quad =\begin{bmatrix} \tau _1 H^{-1} \textbf{e}_1(u_1+\alpha _0 v_1-g_1) \\ \tau _2 H^{-1} \textbf{e}_1(u_1+\alpha _0 v_1-g_1) \end{bmatrix}+\begin{bmatrix} \tau _3 H^{-1} \textbf{e}_n(u_n+\alpha _1 v_n-g_n) \\ \tau _4 H^{-1} \textbf{e}_n(u_n+\alpha _1 v_n-g_n) \end{bmatrix}. \end{aligned}$$
(17)

The last two terms on the left-hand side of (17) approximate \(A\textbf{U}_x\) using the pair of upwind SBP operators, while the right-hand side imposes weakly the boundary conditions. The four penalty parameters \(\tau _1\), \(\tau _2\), \(\tau _3\), \(\tau _4\) are determined by the following stability analysis.

Lemma 5

The semidiscretization (17) satisfies the energy estimate \(\frac{d}{dt}\Vert \textbf{w}\Vert _H\le 0\) if

$$\begin{aligned} (\alpha _0\tau _1-\tau _2-1)^2+4\alpha _0\tau _1\le 0,\quad (\alpha _1\tau _3-\tau _4+1)^2-4\alpha _1\tau _3\le 0. \end{aligned}$$
(18)

Proof

The proof by the energy analysis follows the same principle as the proof for Lemma 1, see also Lemma 3.1 in [7]. More precisely, for homogeneous boundary data the energy change rate is

$$\begin{aligned} \frac{d}{dt}\Vert \textbf{w}\Vert _H^2 \le&\textbf{w}^\top (I \otimes (Q_p+Q_p^\top ))\textbf{w}\\&+2u_1v_1 + 2\tau _1u_1(u_1+\alpha _0 v_1) + 2\tau _2 v_1(u_1+\alpha _0 v_1) \\&-2u_nv_n+2\tau _3 u_n(u_n+\alpha _1 v_n) + 2\tau _4 v_n(u_n+\alpha _1 v_n). \end{aligned}$$

On the right-hand side, the first term is nonpositive because of the SBP property. The second line corresponds to the boundary terms at \(x=0\) and the third line corresponds to the boundary terms at \(x=1\), and they can be analyzed separately.

Consider the boundary terms at \(x=0\), i.e., \(BT_0:=2u_1v_1 + 2\tau _1 u_1 (u_1+\alpha _0 v_1) + 2\tau _2 v_1(u_1+\alpha _0 v_1)\). If \(\tau _1=0\), then we must choose \(\tau _2=-1\) so that \(BT_0=-2\alpha _0 v_1^2\le 0\). If \(\tau _1\ne 0\), then we have

$$\begin{aligned} BT_0=2\tau _1 \left[ \left( u_1+\left( \frac{\alpha _0}{2}+\frac{\tau _2+1}{2\tau _1}\right) v_1\right) ^2 - \left( \frac{\alpha _0}{2}+\frac{\tau _2+1}{2\tau _1}\right) ^2v_1^2+\frac{\tau _2\alpha _0}{\tau _1}v_1^2 \right] . \end{aligned}$$

We can guarantee \(BT_0\le 0\) if \(\tau _1<0\) and

$$\begin{aligned} - \left( \frac{\alpha _0}{2}+\frac{\tau _2+1}{2\tau _1}\right) ^2+\frac{\tau _2\alpha _0}{\tau _1}\ge 0 \Rightarrow (\alpha _0\tau _1-\tau _2-1)^2+4\alpha _0\tau _1\le 0. \end{aligned}$$

The boundary terms at \(x=1\) can be analyzed in a similar way, yielding the stability condition \((\alpha _1\tau _3-\tau _4+1)^2-4\alpha _1\tau _3\le 0\). \(\square \)

To derive error estimates, we follow the main steps of the accuracy analysis for the advection equation by the normal mode analysis. First, we need to use the change of variables to the error equation of the hyperbolic system. We then split the error component into an interior part and a boundary part. The interior part can be estimated by the energy method in the same way as for the advection equation in Sec. 3.1. It is the error due to the boundary closure that dominates the overall convergence rate. We have the following theorem for the error estimate.

Theorem 6

Consider the stable semidiscretization (17) with a third order accurate interior stencil and first order accurate boundary closure in the pair \(D_m\) and \(D_p\). The convergence rate is 2.5 if

$$\begin{aligned} \alpha _0 \tau _1 +\tau _2+1=0,\quad \alpha _1 \tau _3 +\tau _4-1=0. \end{aligned}$$
(19)

Otherwise, the convergence rate is 2.

Proof

We start by considering the error component \(\varvec{\varepsilon }:=[\varvec{\gamma },\varvec{\delta }]^\top \) that is due to the truncation error near the left boundary \(x=0\) when using the upwind operators with third order accurate interior stencil.

In the interior, we have the error equation in Laplace space

$$\begin{aligned} \widetilde{s} \widehat{\gamma }_j&= -\frac{1}{12}\widehat{\gamma }_{j-2}+\frac{1}{3}\widehat{\gamma }_{j-1}-\frac{1}{2}\widehat{\gamma }_{j}+\frac{1}{3}\widehat{\gamma }_{j+1}-\frac{1}{12}\widehat{\gamma }_{j+2}-\frac{1}{12}\widehat{\delta }_{j-2}+\frac{2}{3}\widehat{\delta }_{j-1}-\frac{2}{3}\widehat{\delta }_{j+1}+\frac{1}{12}\widehat{\delta }_{j+2},\end{aligned}$$
(20)
$$\begin{aligned} \widetilde{s} \widehat{\delta }_j&= -\frac{1}{12}\widehat{\gamma }_{j-2}+\frac{2}{3}\widehat{\gamma }_{j-1}-\frac{2}{3}\widehat{\gamma }_{j+1}+\frac{1}{12}\widehat{\gamma }_{j+2} -\frac{1}{12}\widehat{\delta }_{j-2}+\frac{1}{3}\widehat{\delta }_{j-1}-\frac{1}{2}\widehat{\delta }_{j}+\frac{1}{3}\widehat{\delta }_{j+1}-\frac{1}{12}\widehat{\delta }_{j+2}. \end{aligned}$$
(21)

Next, we compute the addition (20) + (21) and subtraction (20) − (21),

$$\begin{aligned} \widetilde{s} (\widehat{\gamma }_j+\widehat{\delta }_j)&= -\frac{1}{6}(\widehat{\gamma }_{j-2}+\widehat{\delta }_{j-2})+(\widehat{\gamma }_{j-1}+\widehat{\delta }_{j-1})-\frac{1}{2}(\widehat{\gamma }_{j}+\widehat{\delta }_{j})-\frac{1}{3}(\widehat{\gamma }_{j+1}+\widehat{\delta }_{j+1}), \end{aligned}$$
(22)
$$\begin{aligned} \widetilde{s} (\widehat{\gamma }_j-\widehat{\delta }_j)&= -\frac{1}{3}(\widehat{\gamma }_{j-1}-\widehat{\delta }_{j-1})-\frac{1}{2}(\widehat{\gamma }_{j}-\widehat{\delta }_{j})+(\widehat{\gamma }_{j+1}-\widehat{\delta }_{j+1})-\frac{1}{6}(\widehat{\gamma }_{j+2}-\widehat{\delta }_{j+2}). \end{aligned}$$
(23)

which can be considered as relations for \(\varvec{\gamma }+\varvec{\delta }\) and \(\varvec{\gamma }-\varvec{\delta }\), respectively. The characteristic equation corresponding to (22) is

$$\begin{aligned} \widetilde{s} \kappa ^2 = -\frac{1}{6} + \kappa - \frac{1}{2}\kappa ^2 -\frac{1}{3}\kappa ^3, \end{aligned}$$

which has two admissible roots \(\kappa _1 = 0.1861+\mathcal {O}(\widetilde{s})\) and \(\kappa _2 = 1-\widetilde{s}+\mathcal {O}(\widetilde{s}^2)\). Similarly, the characteristic equation corresponding to (23) is

$$\begin{aligned} \widetilde{s} \theta = -\frac{1}{3}-\frac{1}{2}\theta + \theta ^2 -\frac{1}{6}\theta ^3, \end{aligned}$$

and has one admissible root \(\theta = -0.3723+\mathcal {O}(\widetilde{s})\). The general solutions to the error equations (22) and (23) are

$$\begin{aligned} \widehat{\gamma }_{j}+\widehat{\delta }_{j}&= \sigma _1 \kappa _1^{j-1}+\sigma _2 \kappa _2^{j-1},\quad j = 1, 2,\ldots ,\\ \widehat{\gamma }_{j}-\widehat{\delta }_{j}&= \sigma _0 \theta ^{j-2},\quad j = 2,3,\cdots . \end{aligned}$$

We then have

$$\begin{aligned} \widehat{\gamma }_{j}&=\frac{1}{2} (\sigma _0 \theta ^{j-2}+\sigma _1 \kappa _1^{j-1}+\sigma _2 \kappa _2^{j-1}),\quad j = 2,3,\ldots , \end{aligned}$$
(24)
$$\begin{aligned} \widehat{\delta }_{j}&= \frac{1}{2} (-\sigma _0 \theta ^{j-2}+\sigma _1 \kappa _1^{j-1}+\sigma _2 \kappa _2^{j-1}),\quad j = 2,3,\ldots , \end{aligned}$$
(25)
$$\begin{aligned} \widehat{\delta }_{1}&= -\widehat{\gamma }_{1}+ \sigma _1 +\sigma _2. \end{aligned}$$
(26)

The four unknowns \(\sigma _0\), \(\sigma _1\), \(\sigma _2\), and \(\widehat{\gamma }_{1}\) shall be determined by the boundary closure. To this end, we consider the error equation on the first two grid points

$$\begin{aligned} \widetilde{s} \widehat{\gamma }_{1}&= -\frac{1}{5}\widehat{\gamma }_{1} + \frac{2}{5}\widehat{\gamma }_{2}-\frac{1}{5}\widehat{\gamma }_{3}+\frac{6}{5}\widehat{\delta }_{1}-\frac{7}{5}\widehat{\delta }_{2}+\frac{1}{5}\widehat{\delta }_{3}+\frac{12}{5}\tau _1(\widehat{\gamma }_{1}+\alpha _0\widehat{\delta }_{1}),\\ \widetilde{s} \widehat{\gamma }_{2}&= \frac{2}{13}\widehat{\gamma }_{1} - \frac{5}{13}\widehat{\gamma }_{2}+\frac{4}{13}\widehat{\gamma }_{3}-\frac{1}{13}\widehat{\gamma }_{4}+\frac{7}{13}\widehat{\delta }_{1}-\frac{8}{13}\widehat{\delta }_{3}+\frac{1}{13}\widehat{\delta }_{4},\\ \widetilde{s} \widehat{\delta }_{1}&= \frac{6}{5}\widehat{\gamma }_{1}-\frac{7}{5}\widehat{\gamma }_{2}+\frac{1}{5}\widehat{\gamma }_{3}-\frac{1}{5}\widehat{\delta }_{1}+\frac{2}{5}\widehat{\delta }_{2}-\frac{1}{5}\widehat{\delta }_{3}+\frac{12}{5}\tau _2(\widehat{\gamma }_{1}+\alpha _0\widehat{\delta }_{1}),\\ \widetilde{s} \widehat{\delta }_{2}&= \frac{7}{13}\widehat{\gamma }_{1}-\frac{8}{13}\widehat{\gamma }_{3}+\frac{1}{13}\widehat{\gamma }_{4}+\frac{2}{13}\widehat{\delta }_{1}-\frac{5}{13}\widehat{\delta }_{2}+\frac{4}{13}\widehat{\delta }_{3}-\frac{1}{13}\widehat{\delta }_{4}. \end{aligned}$$

Using (24)–(26), we rewrite the above equations as a \(4\times 4\) linear system

$$\begin{aligned} C_{s}(\widetilde{s})\varvec{\Sigma _s} = \mathbf {d_s}, \end{aligned}$$
(27)

where \(\varvec{\Sigma _s}=[\sigma _0, \sigma _1, \sigma _2, \widehat{\gamma }_{1}]^\top \) is the unknown vector, and the right-hand side

$$\begin{aligned} \mathbf {d_s}=h^2&\left[ -\frac{1}{10}(3\widehat{v}_{xx}(x_1)+2\widehat{u}_{xx}(x_1)),\right. \\&\frac{1}{26}(3\widehat{v}_{xx}(x_1)+2\widehat{u}_{xx}(x_1)),\\&-\frac{1}{10}(3\widehat{u}_{xx}(x_1)+2\widehat{v}_{xx}(x_1)),\\&\left. \frac{1}{26}(3\widehat{u}_{xx}(x_1)+2\widehat{v}_{xx}(x_1))\right] \end{aligned}$$

is the truncation error vector.

At \(\widetilde{s}=0\), the boundary system matrix \(C_s\) takes the form

$$\begin{aligned} C_s(0) = \begin{bmatrix} \frac{\sqrt{33}+4}{10}, &{} \frac{96\alpha _0\tau _1-5\sqrt{33}+73}{40}, &{} \frac{24\alpha _0\tau _1+7}{10}, &{} -\frac{12\tau _1(\alpha _0-1)+7}{5} \\ -\frac{\sqrt{33}+4}{26}, &{} \frac{5\sqrt{33}+23}{104}, &{} \frac{5}{26}, &{} -\frac{5}{13} \\ -\frac{\sqrt{33}+4}{10}, &{} \frac{96\alpha _0\tau _2-5\sqrt{33}+17}{40}, &{} \frac{24\alpha _0\tau _2-7}{10}, &{} \frac{7-12\tau _2(\alpha _0-1)}{5}\\ \frac{\sqrt{33}+4}{26}, &{}\frac{5\sqrt{33}-17}{104}, &{} -\frac{5}{26}, &{}\frac{5}{13} \end{bmatrix}, \end{aligned}$$

which depends on the parameter \(\alpha _0\) from the boundary condition, and the penalty parameters \(\tau _1,\tau _2\). We solve Eq. (27) at \(\tilde{s}=0\) and focus on the third component of the solution, \(\sigma _2\), that is multiplied with the slowly decaying \(\theta _2=1-\mathcal {O}(\widetilde{s})\) in the general solution. We have

$$\begin{aligned} \sigma _2 = -\frac{(25\sqrt{33}-15)(\alpha _0\tau _1+\tau _2+1)}{204(\tau _1+\tau _2)(\alpha _0+1)}, \end{aligned}$$

which is well-defined because \(\alpha _0\ge 0\) so that \(\alpha _0+1\ne 0\), and \(\tau _1+\tau _2=0\) violates the stability condition (18).

It is important to note that \(\sigma _2=0\) when \(\alpha _0\tau _1+\tau _2+1=0\), regardless of the relation between \(\widehat{v}_{xx}(x_1)\) and \(\widehat{u}_{xx}(x_1)\) in the truncation error vector \(\mathbf {d_s}\). This is important, because \(\sigma _2\) is multiplied with the slowly decaying component \(\theta _2=1-\mathcal {O}(\widetilde{s})\). Componentwise, we can estimate \(\varvec{\Sigma _s}\) as

$$\begin{aligned} |\sigma _0|&\le C h^2 (|\widehat{u}_{xx}(x_1)|+|\widehat{v}_{xx}(x_1)|), \\ |\sigma _1|&\le C h^2 (|\widehat{u}_{xx}(x_1)|+|\widehat{v}_{xx}(x_1)|), \\ \sigma _2&=0,\\ \widehat{\gamma }_{1}&\le C h^2 (|\widehat{u}_{xx}(x_1)|+|\widehat{v}_{xx}(x_1)|). \end{aligned}$$

The error \(\varvec{\varepsilon }\) in Laplace space can be estimated as

$$\begin{aligned} \Vert \widehat{\varvec{\varepsilon }}\Vert _h&= \sqrt{h \sum _{j=1}^\infty |\widehat{\gamma }_j|^2+h \sum _{j=1}^\infty |\widehat{\delta }_j|^2} \\&=h^{0.5}\sqrt{|\widehat{\gamma }_1|^2+\frac{1}{4}\sum _{j=2}^\infty |\sigma _0\kappa ^{j-2}+\sigma _1\theta _1^{j-1}|^2+|\widehat{\delta }_1|^2+\frac{1}{4}\sum _{j=2}^\infty |\sigma _0\kappa ^{j-2}-\sigma _1\theta _1^{j-1}|^2 }\\&\le h^{0.5} \sqrt{|\widehat{\gamma }_1|^2+|\widehat{\delta }_1|^2+ \frac{1}{2}\frac{|\sigma _0|^2}{1-|\kappa |^2} +\frac{1}{2}\frac{|\sigma _1|^2}{1-|\theta _1|^2}}\\&\le Ch^{2.5} (|\widehat{u}_{xx}(x_1)|+|\widehat{v}_{xx}(x_1)|). \end{aligned}$$

The other case for the right boundary \(x=1\) can be analyzed in the same way. We can thus conclude that the overall convergence rate is 2.5 when (19) is satisfied. In this case, the convergence rate is 1.5 orders higher than the boundary truncation error of the upwind SBP operators.

If (19) is not satisfied, then all components of \(\varvec{\Sigma _s}\) are of the same order as the truncation error, and a convergence rate of 2 follows, which is one order higher than the boundary truncation error of the upwind SBP operator. \(\square \)

In the numerical experiments in Sect. 5, we also verify that the same gain in convergence follows for higher order accurate schemes with \(p=4, 5, 6, 7, 8\). The procedure of deriving the corresponding error estimates is the same as above for \(p=3\).

4 An Upwind SBP-SAT Discretization with the WENO Property

In this section, we construct SBP-SAT discretizations with the WENO property for the model problem (2).

To effectively compute weak solutions, which may contain discontinuities, we would use conservative difference to approximate the derivative \(u_x\) at the grid point \(x_j\). To this end, we complement the grid \(\textbf{x}\) in (1) by \(\bar{\textbf{x}}:=[{\bar{x}}_0, {\bar{x}}_1,\ldots ,{\bar{x}}_n]\), which contains \(n+1\) flux points with \({\bar{h}}_i = {\bar{x}}_i-\bar{x}_{i-1}\). In particular, the first and last flux points coincide with the domain boundaries, i.e., \({\bar{x}}_0 = x_1\) and \({\bar{x}}_n = x_n\). In the interior, the flux point \({\bar{x}}_i\) is the midpoint of \(x_i\) and \(x_{i+1}\). However, a few flux points close to the boundaries are shifted, resulting in a nonuniform grid of \(\bar{\textbf{x}}\). The exact location of those flux points will be specified in the derivation of the scheme. Next, we write the discretization matrix in the conservative form,

$$\begin{aligned} D_{m}\textbf{u}|_i= \frac{{\hat{u}}_i-{\hat{u}}_{i-1}}{{\bar{h}}_i}, \quad i=1, \ldots , n, \end{aligned}$$
(28)

where the hat variable \({\hat{u}}_i\) is the numerical flux, which typically is a Lipschitz continuous function of several neighboring values \(u_i\).

The essence of WENO is to use a nonlinear convex combination of numerical fluxes from all the candidate small stencils, such that the scheme can achieve arbitrarily high order accuracy in smooth regions and resolve shocks or other discontinuities sharply and in an essentially non-oscillatory fashion.

In the following, we consider the cases \(p=3\) and \(p=4\) in Sects. 4.1 and  4.2, respectively, followed by the stabilization technique in Sect. 4.3.

4.1 Interior Order \(p=3\)

In the interior, the upwind SBP operator \(D_m\) with third order accuracy has a four-point stencil that is biased to the left,

$$\begin{aligned} D_m \textbf{u}|_i = \frac{1}{h}\left( \frac{1}{6}u_{i-2}-u_{i-1}+\frac{1}{2}u_i+\frac{1}{3}u_{i+1}\right) , \quad i = 3,4,\ldots , n-2. \end{aligned}$$
(29)

The boundary closures are

$$\begin{aligned}&D_m \textbf{u}|_1 = \frac{1}{h}(-u_{1}+u_{2}),\quad D_m \textbf{u}|_2 = \frac{1}{h}\left( -\frac{9}{13}u_{1}+\frac{5}{13}u_{2}+\frac{4}{13}u_{2}\right) , \\&D_m \textbf{u}|_{n-1} = \frac{1}{h}\left( \frac{2}{13}u_{n-3}-\frac{12}{13}u_{n-2}+\frac{5}{13}u_{n-1}+\frac{5}{13}u_{n}\right) ,\\&D_m \textbf{u}|_{n} = \frac{1}{h}\left( \frac{2}{5}u_{n-2}-\frac{9}{5}u_{n-1}+\frac{7}{5}u_{n}\right) . \end{aligned}$$

These boundary closures are designed so that the SBP property is satisfied, but are only first order accurate. The weights of the SBP norm on the first two grid points are \(\frac{5}{12}\) and \(\frac{13}{12}\). As a consequence [19], we have

$$\begin{aligned}&{\bar{x}}_1 ={\bar{x}}_0+ \frac{5}{12}h,\;\;\; {\bar{x}}_{n-1} ={\bar{x}}_n- \frac{5}{12}h, \\&{\bar{x}}_i=\frac{1}{2}(x_i+x_{i+1}),\quad i = 2,3,\ldots , n-2. \end{aligned}$$

Next, we rewrite the difference stencils in \(D_m\) in the form of numerical fluxes (28). For each interior flux point \(2\le i\le n-2\), numerical fluxes (29) can be represented in the form

$$\begin{aligned} {\hat{u}}_i =&-\frac{1}{3} u_{i-1} +\frac{7}{6}u_{i} + \frac{1}{6} u_{i+1} =\frac{1}{3} \left( \frac{1}{2}u_i+\frac{1}{2}u_{i+1}\right) +\frac{2}{3} \left( -\frac{1}{2}u_{i-1}+\frac{3}{2}u_{i}\right) \\ :=&d_i^{(1)} {\hat{u}}_i^{(1)}+d_i^{(2)} {\hat{u}}_i^{(2)} \end{aligned}$$

Here, \({\hat{u}}_i^{(1)}\) and \({\hat{u}}_i^{(2)}\) are numerical fluxes on the two candidate stencils \(\{x_{i}, x_{i+1}\}\) and \(\{x_{i-1}, x_{i}\}\), respectively. These two linear weights \(d_i^{(1)}\) and \(d_i^{(2)}\) will be turned into nonlinear weights when adding the WENO property.

On the first flux point \({\bar{x}}_0\), we take the numerical flux to be \({\hat{u}}_0 = u_1\). By using the same requirement (28) and the boundary stencil of \(D_m\) with \(i=1\) and 2, we obtain the numerical flux \({\hat{u}}_1 = \frac{7}{12}u_1+\frac{5}{12}u_2\). Note that the numerical fluxes on the first two flux points have fixed stencils. On the right boundary, we again take \({\hat{u}}_n=u_n\). For the numerical flux on \(i = n-1\), we make the ansatz

$$\begin{aligned} {\hat{u}}_{n-1}= d_{n-1}^{(1)} \left( -\frac{7}{12}u_{n-2}+\frac{19}{12}u_{n-1}\right) +d_{n-1}^{(2)} \left( \frac{5}{12}u_{n-1}+\frac{7}{12}u_{n}\right) . \end{aligned}$$

By requiring (28) with \(i=n-1\), we obtain \(d_{n-1}^{(1)}=\frac{2}{7}\) and \(d_{n-1}^{(2)}=\frac{5}{7}\), which will also be changed to nonlinear weights in the SBP-WENO scheme.

There exist many nonlinear weights with different properties. For example, in [18] the following nonlinear weights are derived, \(i=2,3,\ldots ,n-1\), which follows the idea of WENOZ,

$$\begin{aligned}&\tau _i = (u_{i+1}-2u_i+u_{i-1})^2,\\&\beta _i^{(1)} = (u_i-u_{i-1})^2,\quad \beta _i^{(2)} = (u_{i+1}-u_{i})^2,\\&w_i^{(j)} = \frac{\alpha _i^{(j)}}{\alpha _i^{(1)}+\alpha _i^{(2)}}, \quad \alpha _i^{(j)} = d_i^{(j)}\left( 1+\frac{\tau _i}{\varepsilon +\beta _i^{(j)}}\right) ,\ j=1,2. \end{aligned}$$

Here, the small constant \(\varepsilon \) avoids division by zero. Replacing the linear weights by the above nonlinear weights in the corresponding numerical fluxes, we obtain the difference operator

$$\begin{aligned} D_{mw}\textbf{u}|_i= \frac{{\hat{u}}^w_i-{\hat{u}}^w_{i-1}}{{\bar{h}}_i}, \end{aligned}$$
(30)

with the nonlinear numerical fluxes

$$\begin{aligned} \hat{u}^{w}_{i} =\omega _i^{(1)}\hat{u}_i^{(1)} + \omega _i^{(2)}\hat{u}_i^{(2)}. \end{aligned}$$

The resulting difference operator \(D_{mw}\) has the desired WENO property, however, the SBP property is lost. As a consequence, energy stability cannot be proved.

4.2 Interior Order \(p=4\)

In the interior, the upwind SBP operator \(D_m\) with fourth order accuracy has a five-point stencil that is biased to the left,

$$\begin{aligned} D_m \textbf{u}|_i = \frac{1}{h}\left( -\frac{1}{12}u_{i-3}+\frac{1}{2} u_{i-2} - \frac{3}{2}u_{i-1}+\frac{5}{6}u_i+\frac{1}{4}u_{i+1}\right) , \quad i = 5,6,\ldots , n-4, \end{aligned}$$
(31)

which can be rewritten in the conservative form with numerical fluxes,

$$\begin{aligned} \hat{u}_{i} =&\frac{1}{12}u_{i-2}-\frac{5}{12} u_{i-1} + \frac{13}{12}u_{i}+\frac{1}{4}u_{i+1} := d_i^{(1)} {\hat{u}}_i^{(1)}+d_i^{(2)} {\hat{u}}_i^{(2)} +d_i^{(2)} {\hat{u}}_i^{(2)}. \end{aligned}$$

Here, the linear weights are

$$\begin{aligned} d_i^{(1)} = \frac{1}{2}, \quad d_i^{(2)}=\frac{1}{4}, \quad d_i^{(3)}=\frac{1}{4}, \end{aligned}$$
(32)

and the numerical fluxes on substencils are

$$\begin{aligned} \hat{u}_i^{(1)}= \frac{1}{2}u_i+\frac{1}{2}u_{i+1}, \quad \hat{u}_i^{(2)}=-\frac{1}{2}u_{i-1}+\frac{3}{2}u_{i},\quad \hat{u}_i^{(3)}=\frac{1}{3}u_{i-2}-\frac{7}{6}u_{i-1}+\frac{11}{6}u_{i}. \end{aligned}$$

The flux points are \({\bar{x}}_i=\frac{1}{2}(x_i+x_{i+1})\) in the interior \(i = 4,5,\ldots , n-4\), and are shifted near the boundaries,

$$\begin{aligned}&\bar{x}_0 = x_1, \quad {\bar{x}}_1 ={\bar{x}}_0+ \frac{49}{144}h, \quad {\bar{x}}_2 = {\bar{x}}_1 + \frac{61}{48}h, \quad {\bar{x}}_3 ={\bar{x}}_2 + \frac{41}{48}h, \\&{\bar{x}}_n = x_n, \quad {\bar{x}}_{n-1} ={\bar{x}}_n- \frac{5}{12}h, \quad {\bar{x}}_{n-2} = \bar{x}_{n-1} -\frac{61}{48}h, \quad \bar{x}_{n-3} = {\bar{x}}_{n-2}-\frac{41}{48} h. \end{aligned}$$

The numerical fluxes on each point \({\bar{x}}_i\) are constructed such that \(D_m \textbf{u}|_i=\frac{\hat{u}_i - \hat{u}_{i-1}}{{\bar{h}}_i}\). WENO methodology can be applied by replacing the linear weights (32) by nonlinear weights. More precisely, we have designed the following nonlinear weights with the help of smoothness indicator. In the interior, we have

$$\begin{aligned}&\tau _i = (u_{i+1}-3u_i+3u_{i-1}-u_{i-2})^2,\\&\beta _i^{(1)} = (u_{i+1}-u_{i})^2,\qquad \beta _i^{(2)} = (u_{i}-u_{i-1})^2,\\&\beta _i^{(3)} = \frac{13}{12}(u_i-2u_{i-1}+u_{i-2})^2 + \frac{1}{4}(5u_i-8u_{i-1}+3u_{i-2})^2, \\&w_i^{(j)} = \frac{\alpha _i^{(j)}}{\alpha _i^{(1)}+\alpha _i^{(2)}+\alpha _i^{(3)}}, \quad \alpha _i^{(j)} = d_i^{(j)}\left( 1+\frac{\tau _i}{\varepsilon +\beta _i^{(j)}}\right) ,\ j=1,2,3. \end{aligned}$$

Note that when u is smooth in \(\{x_{i-2},\ldots , x_{i+1}\}\), we have

$$\begin{aligned}&\beta _1 = (u'_i)^2 h^2 + u'_i u''_i h^3 + \left( \frac{1}{4} (u''_i)^2 + \frac{1}{3}u'_i u^{(3)}_i\right) h^4 + \mathcal {O}(h^5),\\&\beta _2 = (u'_i)^2 h^2 - u'_i u''_i h^3 + \left( \frac{1}{4} (u''_i)^2 + \frac{1}{3}u'_i u^{(3)}_i\right) h^4 + \mathcal {O}(h^5),\\&\beta _3 = (u'_i)^2 h^2 + 2u'_i u''_i h^3 + \left( \frac{25}{12} (u''_i)^2 - \frac{32}{12}u'_i u^{(3)}_i\right) h^4 + \mathcal {O}(h^5),\\&\tau = (u^{(3)}_i)^2 h^6 + \mathcal {O}(h^7). \end{aligned}$$

Suppose \(\varepsilon =0\), the above equations lead to

$$\begin{aligned} \alpha ^{(j)}_i = d^{(j)}_i \left( 1 + \mathcal {O}(h^4)\right) , \;\; j=1, 2, 3. \end{aligned}$$

Furthermore, \(w_i^{(j)}=d_i^{(j)}(1+\mathcal {O}(h^4))\). Consequently,

$$\begin{aligned} \sum _{j=1}^{3} \left( w_i^{(j)} {\hat{u}}_i^{(j)} - d_i^{(j)} {\hat{u}}_i^{(j)} \right) = \mathcal {O}(h^4). \end{aligned}$$

This indicates that the WENO methodology does not destroy the fourth order accuracy in the interior. Moreover, to reduce the impact of \(\epsilon \), we take \(\epsilon =h^2\) in our numerical simulation. Thus, \(\epsilon \) has the same order of magnitude as those smoothness indicators in smooth cases and the above analysis is still valid.

In the Appendix, we present the formulas of the WENO schemes near the boundaries. It is noticed that the number and size of small stencils vary with the location \(\bar{x}_i\). Essentially, we choose the small stencil to meet the conditions that numerical flux on each substencil attains low order accuracy and all linear weights are positive.

4.3 Stabilization

As discussed, the \(D_{mw}\) does not have the SBP property. To derive an SBP-WENO scheme, we add a stabilization term to \(D_{mw}\) such that the resulting operator, \(D_{mws}\), has both the SBP and WENO property. We follow the main steps from [17,18,19], and decompose \(D_{mw}\) to \(D_{mw}=H^{-1}(Q_{mw}+R_{mw})\), where the skew-symmetric part is \(Q_{mw}=\frac{1}{2}(HD_{mw}-(HD_{mw})^\top +B)\) and the symmetric part is \(R_{mw}=\frac{1}{2}(HD_{mw}+(HD_{mw})^\top -B)\). Because of the dependence of \(R_{mw}\) on the nonlinear weights, the matrix \(R_{mw}\) is not guaranteed to be positive semidefinite. To this end, we make the ansatz \(D_{mws}:=H^{-1}(Q_{mw}+R_{mw}+R_s)\), where the stabilization term \(R_s\) leads to a positive semidefinite matrix \(R_{mw}+R_s\) so that \(D_{mws}\) is an SBP operator with the desired accuracy property.

To construct \(R_s\), we decompose \(R_{mw}\). As an example of \(p=4\), we have

$$\begin{aligned} R_{mw}=\Delta \Delta ^\top \Delta \Lambda _3\Delta ^\top \Delta \Delta ^\top +\Delta \Delta ^\top \Lambda _2\Delta \Delta ^\top +\Delta \Lambda _1\Delta ^\top , \end{aligned}$$

where \(\Delta \) is an n-by-\(n+1\) matrix with only nonzero elements \(\Delta _{i,i}=-1\) and \(\Delta _{i,i+1}=1\) for \(i=1,2,\ldots ,n\). The diagonal matrices \(\Lambda _1\), \(\Lambda _2\) and \(\Lambda _3\) are in general not positive semidefinite. Using them, we construct new diagonal matrices \(\Lambda _{1s}\), \(\Lambda _{2\,s}\) and \(\Lambda _{3\,s}\) with diagonal elements \((\Lambda _{1s})_{ii}=\frac{1}{2}\left( \sqrt{((\Lambda _{1})_{ii})^2+(\delta _1)^2}-(\Lambda _{1})_{ii}\right) \), \((\Lambda _{2s})_{ii}=\frac{1}{2}\left( \sqrt{((\Lambda _{2})_{ii})^2+(\delta _2)^2}-(\Lambda _{2})_{ii}\right) \) and \((\Lambda _{3s})_{ii}=\frac{1}{2}\left( \sqrt{((\Lambda _{3})_{ii})^2+(\delta _3)^2}-(\Lambda _{3})_{ii}\right) \) for some constant \(\delta _1\), \(\delta _2\), and \(\delta _3\) that depend on h. In particular, for the inner point \(i=5,6,\ldots ,n-4\),

$$\begin{aligned} \begin{aligned} (\Lambda _{1})_{ii}=&\frac{1}{4}w^{(2)}_{i-1} +\frac{1}{4}w^{(3)}_{i-1} -\frac{1}{4}w^{(2)}_{i} -\frac{5}{12}w^{(3)}_{i} +\frac{1}{6}w^{(3)}_{i+1},\\ (\Lambda _{2})_{ii}=&\frac{1}{4}w^{(2)}_{i} +\frac{1}{12}w^{(3)}_{i} - \frac{1}{3}w^{(3)}_{i+1},\\ (\Lambda _{3})_{ii}=&\frac{1}{6}w^{(3)}_{i}. \end{aligned} \end{aligned}$$

It is observed that \((\Lambda _{3})_{ii}\) is always non-negative and we can set \(\Lambda _{3,s}=\Lambda _{3}\) directly, but modification on \((\Lambda _{1})_{ii}\) and \((\Lambda _{2})_{ii}\) is necessary. Moreover, for smooth cases, \((\Lambda _{1})_{ii}=\mathcal {O}(h^4)\) and \((\Lambda _{2})_{ii}=\mathcal {O}(h^4)\). Therefore, we can take \(\delta _1=\delta _2\) to be \(h^4\) to avoid affecting accuracy. Finally, let \(R_{s}=\Delta \Delta ^\top \Delta \Lambda _{3s}\Delta ^\top \Delta \Delta ^\top +\Delta \Delta ^\top \Lambda _{2s}\Delta \Delta ^\top +\Delta \Lambda _{1s}\Delta ^\top \), which leads to the positive semidefiniteness of \(R_{mw}+R_s\).

The case with \(p=3\) is very similar to the case \(p=4\), with \(\Lambda _3\) being a zero matrix. To avoid repetition, details are not described in this article.

5 Numerical Experiments

In this section, we present numerical examples to verify the theoretical analysis. We start with convergence studies for problems with smooth solutions, and consider the linear SBP-SAT discretization in Sect. 5.1, and the WENO scheme in Sect. 5.2. In addition, we also use the SBP-WENO method to solve a problem with nonsmooth solutions.

5.1 Convergence Rate for the Linear Schemes

We consider the advection Eq. (2) with a manufactured smooth solution \(U(x,t) = \sin (2\pi (x-t)+1)\). We discretize in space by the upwind operators with interior accuracy \(q=3\), 4, 5, 6, 7, and 8. We choose a stepsize in the Runge–Kutta time integrator small enough so that the error is dominated by the spatial discretization.

The discretization is stable for any penalty parameter \(\tau \le -1/2\). According to the accuracy analysis in Sect. 3.1 for \(p=3\), the convergence rate is 2.5 when \(\tau =-1\), and is 2 when \(\tau \ne -1\). That is, the convergence rate is 1.5 orders higher than the boundary truncation error when \(\tau =-1\), and one order higher for other choices of \(\tau \). This is clearly observed in the first error plot in Fig. 1. In addition, we also observe the same phenomena for higher order discretizations \(q=4\), 5, 6, 7 and 8, see Fig. 1. This indicates that \(\tau =-1\) is a good choice even for higher order accurate discretizations.

Fig. 1
figure 1

\(L^2\) error for solving the advection Eq. (2) with different values of p and \(\tau \)

Next, we consider the first order hyperbolic system (14) with a manufactured smooth solution

$$\begin{aligned} U = \begin{bmatrix} -\sin (2\pi (x+t))+\cos (2\pi (x-t))\\ \sin (2\pi (x+t))+\cos (2\pi (x-t)) \end{bmatrix}, \end{aligned}$$

and final time \(T=1\). In the boundary condition (16), we choose \(\alpha _0=1/2\) and \(\alpha _1=0\). We choose the penalty parameters \(\tau _2=-1/3\), \(\tau _3=0\), \(\tau _4=1\), and vary \(\tau _1\). According to the error estimate in Theorem 6, the convergence rate is 2.5 if \(\alpha _0\tau _1+\tau _2+1=0\), i.e. \(\tau _1=-4/3\), while other stable choices of \(\tau _1\) lead to a convergence rate of 2. This is clearly observed in the left panel of Fig. 2. In addition, we have also used upwind SBP operators with \(p=4\), 5, 6, 7 and 8. When \(\alpha _0\tau _1+\tau _2+1=0\), i.e. \(\tau _1=-4/3\), the convergence rate is 1.5 orders higher than the boundary truncation error; other choices of \(\tau _1\) gives a convergence rate that is one order higher than the boundary truncation error. This is consistent with the accuracy analysis for \(p=3\).

Fig. 2
figure 2

\(L^2\) error solving the hyperbolic system (14) with different values of p and \(\tau _1\) for the hyperbolic system

5.2 SBP-WENO

We now consider the SBP-WENO method developed in Sect. 4. In all experiments, we choose the parameters \(\epsilon = h^2\) and \(\delta =h^4\).

First, we consider the same smooth problem as in Sect. 5.1 for the advection equation. The error is plotted in Fig. 3. Clearly, the WENO stencils and the stabilization terms do not destroy the accuracy property of the original SBP discretization.

Fig. 3
figure 3

\(L^2\) error of the SBP-WENO scheme for \(p=3\) (left) and 4 (right) with different values of \(\tau \) for the advection equation

Next, we consider the advection equation in domain \([-1,1]\) with nonsmooth solution. We choose the initial condition to be zero, and the inflow boundary condition

$$\begin{aligned} u(-1, t) = {\left\{ \begin{array}{ll} \left[ e^{-\beta (-1-t-z_{-})^2} + e^{-\beta (-1-t-z_{+}))^2} + 4e^{-\beta (-1-t-z)^2}\right] /6, &{} 0\le t\le 0.4,\\ 1, &{} 0.6\le t\le 0.8, \\ 1 - |10(-1-t+2.1)|, &{} 1\le t\le 1.2, \\ \Bigg [\sqrt{ \max (0, 1-\alpha _{-}^2(-1-t+2.5)^2)} + \Bigg .\\ \sqrt{ \max (0, 1-\alpha _{+}^2(-1-t+2.5)^2)} + \\ \Bigg .4\sqrt{ \max (0, 1-\alpha ^2(-1-t+2.5)^2)}\Bigg ]/6, &{} 1.4\le t\le 1.6, \\ 0, &{} \text {elsewhere}, \end{array}\right. } \end{aligned}$$

where \(\delta _z = 0.005\), \(z=-1.2\), \(z_{-} = z-\delta _z\), \(z_{+} = z+\delta _z\), \(\alpha =10\), \(\alpha _{-}=\alpha -\delta _z\), \(\alpha _{+}=\alpha +\delta _z\), \(\beta = \log (2)/(36\delta _z^2)\). The numerical solution and exact solution at time \(t=1.9\) is plotted in Fig. 4. We observe that the numerical solution agrees very well with the exact solution for the SBP-WENO discretization with \(p=3\) and 4. On the other hand, the result without the WENO scheme has oscillations near the nonsmooth region.

Fig. 4
figure 4

Solutions computed with 401 grid points. Left: SBP-WENO scheme with \(p=3\) and 4. Right: SBP scheme without WENO

6 Conclusion

In an SBP-SAT finite difference discretization, the truncation error is often larger on a few grid points near the boundaries than in the interior. It is well-known that for first order hyperbolic PDEs, the overall convergence rate is one order higher than the order of truncation error near the boundaries [22]. However, with an upwind SBP-SAT method, it was reported that the convergence rate is higher than expected [7]. Using the normal mode analysis, we prove that the convergence rate in an upwind SBP-SAT method is indeed higher than the results in [22]. More precisely, we have considered a scheme with third order truncation error in the interior and first order truncation error on a few grid points near boundaries. With a particular choice of the penalty parameters, the convergence rate is 1.5 orders higher than the boundary truncation error, and all other stable choices of the penalty parameters lead to a convergence rate that is one order higher than the boundary truncation error. Both first order hyperbolic equation and hyperbolic systems are considered. We have carried out numerical experiments with higher order discretizations and observed that the penalty parameters play the same role in convergence rate.

When using an SBP-SAT finite difference method to solve PDEs with nonsmooth data, the numerical solution contains oscillations near the region where the solution is not sufficiently smooth. Using the WENO methodology, we derive an SBP-SAT discretization that can resolve nonsmooth solutions very well, and converges to optimal order for smooth solutions. In addition, the discretization remains energy stable.