1 Introduction

This paper is concerned with the construction of several conservative compact schemes for the following generalized nonlinear Schrödinger equation (NLSE) with wave operator:

$$\begin{aligned} &u_{tt} - u_{xx} + \mathrm{i}\alpha u_{t} + \beta (x) f \bigl(\vert u \vert ^{2}\bigr) u = 0,\quad x \in (0,L), t \in (0,T), \end{aligned}$$
(1.1)
$$\begin{aligned} &u(x,0) = \phi_{0}(x),\qquad u_{t}(x,0) = \phi_{1}(x),\quad x\in [0,L], \end{aligned}$$
(1.2)
$$\begin{aligned} &u(0, t) = u(L,t) = 0,\quad t\in [0,T], \end{aligned}$$
(1.3)

where \(u(x,t)\) is a complex function, α is a real constant, β and f are given real functions, and \(\mathrm{i}^{2} = -1\). NLSE is one of the most important mathematical models with many applications in different fields such as plasma physics [1], nonlinear optics [25], and bimolecular dynamics [68]. One remarkable feature of the model is its conservation law having the form of

$$\begin{aligned} &E(t) = \Vert u_{t}\Vert _{L_{2}}^{2} + \Vert u_{x}\Vert _{L_{2}}^{2} + \int_{0}^{L} \beta (x)F\bigl(\vert u\vert ^{2}\bigr)\,dx = E(0), \end{aligned}$$
(1.4)

where \(F(s) = \int_{0}^{s} f(z)\,dz\).

In the past several years, much attention has been paid to developing effective numerical methods to solve the NLSE. For example, Bao and Cai [9] established uniform error estimates of finite difference methods for NLSEs with wave operator. Sun and Wang [10] investigated linearized finite difference methods for solving the NLSE. Chang et al. [11] presented several linearized finite difference schemes by applying an extrapolation technique to the real coefficient of the nonlinear term. Goubet and Hamraoui [12] presented both numerical and theoretical invariability of energy and mass with finite time for two-dimensional cubic nonlinear Schrödinger equations with a radial defect. Generally speaking, the computational cost can be reduced by applying the linearized numerical methods. As a result, the linearized methods have been extensively investigated for many different nonlinear differential equations, e.g., [1321]. However, the nonconservative linearized schemes may give blow-up solutions [22].

Recently, many numerical methods have been developed based on the conservation laws of (1.1). For example, Brugnano et al. [23] considered a class of energy-conserving Hamiltonian boundary value methods for the equations. In [24], Zhang and Chang proposed a four-level explicit and conservative scheme. Wang and Zhang [25] developed some different conservative schemes based on some special techniques on the nonlinear terms. Hu and Chan [26] further considered a conservative difference scheme for two-dimensional NLSE. In [24, 26], the proposed methods have second order accuracy in spatial direction. In order to improve accuracy in spatial direction, Guo et al. [27] and Cao et al. [28] introduced the energy conserving LDG methods and obtained optimal convergence or superconvergence of the method. Li et al. [29, 30] introduced the compact finite difference methods and investigated fully discrete numerical schemes for cubic NLSE with wave operator (i.e., \(f(s)=s\)). As far as we know, there are few results on construction of conservative compact finite difference methods for the generalized NLSE with wave operator (1.1).

In this study, several compact finite difference schemes are developed for solving the generalized NLSE with wave operator (1.1). It is shown that the fully discrete numerical methods conserve the discrete energy. Then, the boundedness of numerical solutions and the stability of numerical methods are obtained. It is also proved that the numerical methods can attain a convergence rate of \(\mathcal{O}(\tau^{2} + h ^{4})\) in the maximum norm. Here and below, τ and h are respectively the temporal and spatial stepsizes. Besides, by applying the Richardson extrapolation algorithm, the proposed methods have a convergence rate of \(\mathcal{O}(\tau^{4} + h^{4})\) in the maximum norm. Finally, several numerical experiments are proposed to illustrate all the theoretical results.

The rest of the paper is organized as follows. In Sect. 2, a compact difference scheme is given. In Sect. 3, the discrete conservation law of the compact scheme is obtained. In Sect. 4, the boundedness of numerical solutions is obtained. In Sect. 5, stability and convergence are proved. In Sect. 6, several conservative compact schemes are constructed for the nonlinear Schrödinger equation with wave operator. Moreover, the Richardson extrapolation technique is used. In the last section, numerical experiments are presented to support theoretical results.

Throughout the paper, we set C as a general positive constant independent of mesh sizes, which may be changed under different circumstances.

2 Finite difference scheme

Let \(\tau =\frac{T}{N}\) and \(h =\frac{L}{J}\) be the temporal and spatial stepsizes, respectively, where J and N are given positive integers. Denote \(t_{n}=n\tau \) (\(0\leq n \leq N \)), \(x_{j}=jh\) (\(0 \leq j \leq J\)), \(\Omega_{\tau }= \{t_{n}\vert 0\leq n \leq N \}\), and \(\Omega_{h}= \{x_{j}\vert 0\leq j \leq J \}\). Let \(\mathcal{W}_{h}^{0}=\{w _{j}^{n}\vert w_{0}^{n}=w^{n}_{J}=0, j=1,2,\ldots,J-1, n= 1,\ldots,N-1 \}\) be a grid function space defined on \(\Omega_{h}\times \Omega_{ \tau }\). Define

$$\begin{aligned} \begin{aligned}&\delta_{x}w_{j}^{n}=\frac{w_{j+1}^{n}-w_{j}^{n}}{h},\qquad \delta_{\bar{x}}w_{j}^{n}=\frac{w_{j}^{n}-w_{j-1}^{n}}{h}, \\ &\delta_{x}^{2}w_{j}^{n}= \delta_{x} \delta_{\bar{x}} w_{j}^{n} = \frac{1}{h ^{2}}\bigl(w_{j+1}^{n} - 2w_{j}^{n} + w_{j-1}^{n}\bigr), \\ &\delta_{\hat{t}}w_{j}^{n}=\frac{w_{j}^{n+1}-w_{j}^{n-1}}{2\tau },\qquad \delta_{\bar{t}}w_{j}^{n}=\frac{w_{j}^{n}-w_{j}^{n-1}}{\tau }, \\ &\delta_{t}w_{j}^{n}=\frac{w_{j}^{n+1}-w_{j}^{n}}{\tau }, \\ &\delta_{t}^{2}w_{j}^{n} = \delta_{t}\delta_{\bar{t}}w_{j}^{n} = \frac{1}{\tau^{2}}\bigl(w_{j}^{n+1} - 2w_{j}^{n} + w_{j}^{n-1}\bigr), \\ & A _{h}w_{j}^{n} = \frac{1}{12}\bigl(w_{j-1}^{n} + 10w_{j}^{n} + w _{j+1}^{n}\bigr), \\ &\bigl(\mathbf{w}^{n},\mathbf{v}^{n}\bigr) = h\sum _{j=1}^{J-1}w_{j}^{n}\bar{v} _{j}^{n},\qquad \bigl\Vert \mathbf{w}^{n}\bigr\Vert =\sqrt{h\sum_{j=1}^{J-1}\bigl\vert w_{j}^{n}\bigr\vert ^{2}}, \\ &\bigl\Vert \delta_{x}\mathbf{w}^{n}\bigr\Vert =\sqrt {h\sum_{j=0}^{J-1}\bigl\vert \delta_{x} w_{j}^{n}\bigr\vert ^{2}},\qquad \bigl\Vert \mathbf{w}^{n}\bigr\Vert _{\infty }=\max _{1\leq j \leq J-1}\bigl\vert w_{j}^{n}\bigr\vert , \end{aligned} \end{aligned}$$
(2.1)

where \(\mathbf{w}^{n} = (w_{1}^{n},\ldots,w^{n}_{J-1})^{T}\), \(\mathbf{v}^{n} = (v_{1}^{n},\ldots,v^{n}_{J-1})^{T}\).

At the grid point \((x_{j},t_{n})\), we define \({U_{j}^{n}}\) as the exact solution and \({u_{j}^{n}}\) as the numerical solution. We also assume that the exact solution of problem (1.1)–(1.3) satisfies

$$\begin{aligned} \max {\bigl\{ \bigl\Vert \mathbf{U}^{n}\bigr\Vert , \bigl\Vert \delta_{x} \mathbf{U}^{n}\bigr\Vert , \bigl\Vert \mathbf{U}^{n}\bigr\Vert _{\infty }\bigr\} } \leq C . \end{aligned}$$

Now, we present a compact difference scheme for problem (1.1)–(1.3) as follows:

$$\begin{aligned} &A_{h}\delta_{t}^{2}u_{j}^{n} - \delta_{x}^{2} u_{j}^{n} + \mathrm{i}\alpha A_{h}\delta_{\hat{t}}u_{j}^{n} + A_{h} \biggl[ \beta (x_{j}) \frac{F(\vert u_{j}^{n+1}\vert ^{2}) - F(\vert u_{j}^{n-1}\vert ^{2})}{\vert u_{j}^{n+1}\vert ^{2} - \vert u_{j}^{n-1}\vert ^{2}} \frac{u _{j}^{n+1} + u_{j}^{n-1}}{2} \biggr] = 0, \\ &\quad 1\leq j\leq J-1, 1\leq n \leq N-1, \end{aligned}$$
(2.2)
$$\begin{aligned} &u_{j}^{0} = \phi_{0}(x_{j}),\qquad \delta_{\hat{t}}u(x_{j},0) = \phi_{1}(x_{j}),\quad 0\leq j\leq J, \end{aligned}$$
(2.3)
$$\begin{aligned} &u_{0}^{n} = u_{J}^{n} = 0,\quad 0 \leq n \leq N. \end{aligned}$$
(2.4)

Denote

$$\begin{aligned} &\mathbf{u}^{n} = \bigl(u_{1}^{n}, \ldots, u_{J-1}^{n}\bigr)^{T}, \\ &G\bigl( \bigl\vert \mathbf{u}^{n}\bigr\vert ^{2} \bigr) = \operatorname{diag}\biggl( \beta (x_{1}) \frac{F(\vert u_{1}^{n+1} \vert ^{2}) - F(\vert u_{1}^{n-1} \vert ^{2})}{ \vert u_{1}^{n+1} \vert ^{2} - \vert u_{1}^{n-1} \vert ^{2}}, \ldots, \beta ( x_{J-1} ) \frac{F(\vert u_{J-1}^{n+1} \vert ^{2}) - F(\vert u_{J-1}^{n-1} \vert ^{2})}{\vert u_{J-1}^{n+1}\vert ^{2} - \vert u_{J-1}^{n-1}\vert ^{2}} \biggr) ^{T} , \\ &\mathbf{S} = { \begin{pmatrix} 0& 1& 0&\ldots & 0 & 0 \\ 1 & 0& 1 & \ldots & 0 & 0 \\ \vdots &\vdots & \vdots & &\vdots &\vdots \\ 0& 0& 0& \ldots &0 & 1 \\ 0 & 0& 0 &\ldots & 1 & 0 \end{pmatrix} }_{ (J - 1) \times (J - 1)}, \end{aligned}$$
(2.5)
$$\begin{aligned} &\mathbf{M} = \frac{1}{12}(10\mathbf{I} + \mathbf{S}), \qquad \mathbf{A} = \frac{1}{h^{2}}(-2\mathbf{I} + \mathbf{S}), \end{aligned}$$
(2.6)

where I is an identity matrix.

Since M is a symmetric positive definite matrix, there exists a real symmetric positive definite matrix H such that \(\mathbf{H} = \mathbf{M}^{-1}\). Then scheme (2.2)–(2.4) can be written in the following vector form:

$$\begin{aligned} &\delta_{t}^{2} \mathbf{u}^{n} - \mathbf{H} \mathbf{A}\mathbf{u} ^{n} + \mathrm{i}\alpha \delta_{\hat{t}} \mathbf{u}^{n}+ G\bigl(\bigl\vert \mathbf{u}^{n}\bigr\vert ^{2}\bigr)\frac{\mathbf{u}^{n+1} + \mathbf{u}^{n-1} }{2} = 0,\quad 1\leq n \leq N-1, \end{aligned}$$
(2.7)
$$\begin{aligned} &u_{j}^{0} = \phi_{0}(x_{j}),\qquad \delta_{\hat{t}}u_{j}^{0} = \phi_{1}(x_{j}),\quad 0\leq j \leq J, \end{aligned}$$
(2.8)
$$\begin{aligned} &u_{0}^{n} = u_{J}^{n} = 0,\quad 0\leq n \leq N. \end{aligned}$$
(2.9)

3 Discrete conservation law

In this section, we will show that the numerical scheme owns the discrete conservation law. First of all, we introduce some lemmas, which will assist a lot in the proof of the main result.

Lemma 3.1

(cf. [31])

The eigenvalues \(\lambda_{S}^{j}\) of matrix S are \(2\cos (\frac{j\pi }{J})\) (\(j = 1,2,\ldots,J-1\)). Then the eigenvalues of matrices H, A, and HA are \(\frac{12}{10+\lambda_{S}^{j}}\), \(\frac{-2 + \lambda _{S}^{j}}{h^{2}}\), \(\frac{12(-2 + \lambda_{S}^{j})}{h^{2} (10+\lambda _{S}^{j})}\) (\(j = 1,2,\ldots,J-1\)), respectively.

Lemma 3.2

For any mesh function \(\mathbf{u} \in \mathcal{W}_{h}^{0}\) and real symmetric positive definite matrices H and A, we obtain thatHA is a symmetric positive definite matrix and

$$\begin{aligned} - (\mathbf{HA}\mathbf{u}, \mathbf{u})= \Vert \mathbf{R} \mathbf{u}\Vert ^{2}, \end{aligned}$$
(3.1)

where R is obtained by Cholesky decomposition forHA, denoted as \(\mathbf{R} = \operatorname{Chol}(-\mathbf{HA})\).

Proof

It follows from \(\mathbf{M} = \frac{1}{12}(10\mathbf{I} + \mathbf{S})\) and \(\mathbf{A} = \frac{1}{h^{2}}(-2\mathbf{I} + \mathbf{S})\) that

$$\begin{aligned} \mathbf{M}\mathbf{A} &= \frac{1}{12h^{2}}(10\mathbf{I} + \mathbf{S}) (-2 \mathbf{I} + \mathbf{S}) = \frac{1}{12h^{2}}\bigl(-20\mathbf{I} + 8 \mathbf{S} + \mathbf{S}^{2}\bigr)= \mathbf{A}\mathbf{M}. \end{aligned}$$

Therefore, \(\mathbf{AH} = \mathbf{HA}\), which implies that \((- \mathbf{AH})^{T} = -\mathbf{AH}\).

In virtue of Lemma 3.1, we can obtain

$$\begin{aligned} 0 \leq \lambda_{-HA}^{j} = -\frac{12(-2 + \lambda_{S}^{j})}{h^{2} (10+ \lambda_{S}^{j})} \leq \frac{6}{h^{2}}\quad (j = 1,2,\ldots,J-1). \end{aligned}$$

Hence, −HA is a symmetric positive definite matrix. The proof is completed. □

Define

$$\begin{aligned} E^{n} = {}&\bigl\Vert \delta_{t}\mathbf{u}^{n} \bigr\Vert ^{2} + \frac{1}{2}\bigl(\bigl\Vert \mathbf{R} \mathbf{u}^{n}\bigr\Vert ^{2} + \bigl\Vert \mathbf{R} \mathbf{u}^{n+1}\bigr\Vert ^{2}\bigr) -\frac{\tau ^{2}}{2}\bigl\Vert \mathbf{R}\delta_{t}\mathbf{u}^{n}\bigr\Vert ^{2} \\ &{}+ \frac{h}{2}\sum_{j=1}^{J-1} \beta_{j} \bigl[ F\bigl(\bigl\vert u_{j}^{n} \bigr\vert ^{2}\bigr) + F\bigl(\bigl\vert u_{j}^{n+1} \bigr\vert ^{2}\bigr) \bigr] . \end{aligned}$$
(3.2)

Then we get the following energy preserving property for the fully discrete numerical scheme (2.7)–(2.9).

Theorem 3.3

The numerical solutions obtained by the fully discrete numerical scheme (2.7)(2.9) admit: for all \(n\geq 0\), \(E^{n} = E ^{0}\).

Proof

Taking the inner product on both sides of (2.7) with \(\mathbf{u}^{n+1} - \mathbf{u}^{n-1}\) and considering the real part, we arrive at

$$\begin{aligned} &\operatorname{Re}\bigl(\delta_{t}^{2} \mathbf{u}^{n}, \mathbf{u}^{n+1} - \mathbf{u}^{n-1}\bigr) = \bigl\Vert \delta_{t}\mathbf{u}^{n}\bigr\Vert ^{2} - \bigl\Vert \delta_{t}\mathbf{u}^{n-1}\bigr\Vert ^{2} , \end{aligned}$$
(3.3)
$$\begin{aligned} &\operatorname{Re}\bigl(\mathbf{HA}\mathbf{u}^{n}, \mathbf{u}^{n+1} - \mathbf{u}^{n-1} \bigr) \\ &\quad = - \frac{1}{2} \bigl( \bigl\Vert \mathbf{R}\mathbf{u}^{n+1} \bigr\Vert ^{2} - \bigl\Vert \mathbf{R}\mathbf{u}^{n-1}\bigr\Vert ^{2} \bigr) + \frac{\tau^{2}}{2} \bigl( \bigl\Vert \mathbf{R} \delta_{t}\mathbf{u}^{n}\bigr\Vert ^{2} - \bigl\Vert \mathbf{R}\delta_{t}\mathbf{u}^{n-1}\bigr\Vert ^{2} \bigr), \end{aligned}$$
(3.4)
$$\begin{aligned} &\operatorname{Re}\bigl(\mathrm{i}\alpha \delta_{\hat{t}}\mathbf{u}^{n}, \mathbf{u} ^{n+1} - \mathbf{u}^{n-1} \bigr) = 0, \end{aligned}$$
(3.5)
$$\begin{aligned} &\operatorname{Re}\biggl(G\bigl( \bigl\vert \mathbf{u}^{n}\bigr\vert ^{2} \bigr)\frac{\mathbf{u}^{n+1} + \mathbf{u}^{n-1}}{2}, \mathbf{u}^{n+1} - \mathbf{u}^{n-1} \biggr) \\ &\quad = \frac{h}{2}\sum _{j=1}^{J-1}\beta_{j} \bigl[ F\bigl(\bigl\vert u_{j}^{n + 1}\bigr\vert ^{2}\bigr) - F\bigl( \bigl\vert u_{j}^{n - 1}\bigr\vert ^{2}\bigr) \bigr] . \end{aligned}$$
(3.6)

From (3.3)–(3.6), we have

$$\begin{aligned}& \bigl\Vert \delta_{t}\mathbf{u}^{n}\bigr\Vert ^{2} - \bigl\Vert \delta_{t}\mathbf{u}^{n-1}\bigr\Vert ^{2} + \frac{1}{2} \bigl( \bigl\Vert \mathbf{R} \mathbf{u}^{n+1}\bigr\Vert ^{2} - \bigl\Vert \mathbf{R} \mathbf{u}^{n-1}\bigr\Vert ^{2} \bigr) \\& \quad {}-\frac{\tau^{2}}{2} \bigl( \bigl\Vert \mathbf{R}\delta_{t} \mathbf{u}^{n}\bigr\Vert ^{2} - \bigl\Vert \mathbf{R} \delta_{t}\mathbf{u}^{n-1}\bigr\Vert ^{2} \bigr) \\& \quad {} + \frac{h}{2}\sum_{j=1}^{J-1} \beta_{j} \bigl[ F\bigl(\bigl\vert u_{j}^{n+1} \bigr\vert ^{2}\bigr) - F\bigl(\bigl\vert u_{j}^{n-1} \bigr\vert ^{2}\bigr) \bigr] = 0, \end{aligned}$$

which further implies that, for \(n\geq 1\),

$$E^{n}= E^{n-1}. $$

Therefore, the conclusion holds. □

4 Boundedness of numerical solutions

In this section, we present the boundedness of numerical solutions.

Lemma 4.1

(see [32])

For any mesh function \(\mathbf{u}, \mathbf{v}\in \mathcal{W}_{h}^{0}\), there is the identity

$$\begin{aligned} -h\sum_{j=1}^{J-1}\bigl(\delta_{x}^{2}u_{j} \bigr)\bar{v}_{j} = h\sum_{j=0}^{J-1}( \delta_{x} u_{j}) (\delta_{x} \bar{v}_{j}), \end{aligned}$$

which implies that \(-(\mathbf{A}\mathbf{u}, \mathbf{u}) = \Vert \delta_{x}\mathbf{u}\Vert ^{2}\).

Lemma 4.2

(cf. [33])

For any symmetric matrix N, the property of Rayleigh–Ritz ratio is

$$ \min[\lambda_{N}] \leq \frac{(\mathbf{N}\mathbf{x},\mathbf{x})}{(\mathbf{x},\mathbf{x})} \leq \max[\lambda_{N}], $$

where \((\mathbf{x},\mathbf{y})\) indicates the inner product of x and y, \(\min [\lambda_{N}]\) and \(\max [\lambda _{N}]\) denote the smallest and largest eigenvalue of matrix N, respectively.

Lemma 4.3

For any mesh function \(\mathbf{u} \in \mathcal{W}_{h}^{0}\), it holds that \(-(\mathbf{A}\mathbf{u}, \mathbf{u}) \leq -(\mathbf{HA} \mathbf{u}, \mathbf{u})\). That is, \(\Vert \delta_{x}\mathbf{u}\Vert \leq \Vert \mathbf{R}\mathbf{u}\Vert \).

Proof

It follows from \(\mathbf{HA}= \mathbf{AH}\) and \(\mathbf{A}^{T} = \mathbf{A}\) that \(\mathbf{A} - \mathbf{AH}\) is a symmetric matrix. According to \(\mathbf{S}x = \lambda_{S}^{j} x\), we obtain

$$\begin{aligned} \mathbf{H}x = \frac{12}{10 + \lambda_{S}^{j}}x,\qquad \mathbf{A}x = \frac{1}{h^{2}}\bigl(-2 + \lambda_{S}^{j}\bigr)x. \end{aligned}$$
(4.1)

Therefore,

$$\begin{aligned} (\mathbf{I} - \mathbf{H})x = \biggl( 1 - \frac{12}{10 + \lambda_{j}^{s}} \biggr) x = \frac{1}{h^{2}} \biggl( 1 - \frac{12}{10 + \lambda_{S}^{j}} \biggr) \bigl( -2 + \lambda_{S}^{j} \bigr) \mathbf{A}^{-1}x. \end{aligned}$$
(4.2)

Then the eigenvalues of \(\mathbf{A} - \mathbf{AH}\) are given by \(\frac{ ( -2 + \lambda_{S}^{j} ) ^{2}}{h^{2} ( 10 + \lambda _{S}^{j} ) }\). As a result, \(\mathbf{A} - \mathbf{AH}\) is a symmetric and positive definite matrix.

Further, for \(\mathbf{u} \in \mathcal{W}_{h}^{0}\), we get \(\mathbf{u} ^{T}(\mathbf{A} - \mathbf{AH})\mathbf{u} \geq 0\), which completes the proof. □

Lemma 4.4

(cf. [24])

For any mesh function \(\mathbf{u}^{n} \in \mathcal{W}_{h}^{0}\), there is

$$\begin{aligned} \bigl\Vert \mathbf{u}^{n+1}\bigr\Vert ^{2} - \bigl\Vert \mathbf{u}^{n}\bigr\Vert ^{2} \leq \tau \biggl[\bigl\Vert \delta_{t}\mathbf{u}^{n}\bigr\Vert ^{2} + \frac{1}{2}\bigl(\bigl\Vert \mathbf{u}^{n}\bigr\Vert ^{2} + \bigl\Vert \mathbf{u}^{n+1}\bigr\Vert ^{2} \bigr)\biggr]. \end{aligned}$$

Lemma 4.5

(Discrete Sobolev’s inequality [34])

Suppose that \(\{u_{j}\}\) is mesh functions. Given \(\epsilon > 0\), there exists a constant C dependent on ϵ such that

$$\begin{aligned} \Vert \mathbf{u} \Vert _{\infty } \leq \epsilon \Vert \delta_{x}\mathbf{u}\Vert + C \Vert \mathbf{u}\Vert . \end{aligned}$$

Lemma 4.6

Suppose that \(\phi_{0} \in H_{0}^{1}\), \(\phi_{1} \in L_{2}\), \(\beta (x) \geq 0\), \(F(s) \geq 0\), \(s \in [0,+\infty)\), \(\beta, f' \in C^{1}( \mathbb{R})\), and \(\frac{\tau^{2}}{h^{2}} < \frac{1}{3}\). Then the following estimates hold:

$$\begin{aligned} \bigl\Vert \mathbf{u}^{n} \bigr\Vert \leq C,\qquad \bigl\Vert \delta_{x} \mathbf{u}^{n} \bigr\Vert \leq C,\qquad \bigl\Vert \mathbf{u}^{n} \bigr\Vert _{\infty } \leq C. \end{aligned}$$
(4.3)

Proof

It follows from Theorem 3.3 that there exists a constant C such that

$$\begin{aligned} E^{n} = &\bigl\Vert \delta_{t} \mathbf{u}^{n}\bigr\Vert ^{2} + \frac{1}{2} \bigl( \bigl\Vert \mathbf{R}\mathbf{u}^{n}\bigr\Vert ^{2} + \bigl\Vert \mathbf{R}\mathbf{u}^{n+1}\bigr\Vert ^{2}\bigr) - \frac{ \tau^{2}}{2}\bigl\Vert \mathbf{R}\delta_{t} \mathbf{u}^{n}\bigr\Vert ^{2} \\ &+\frac{h}{2}\sum_{j=1}^{J-1} \beta_{j} \bigl( F\bigl(\bigl\vert u_{j}^{n} \bigr\vert ^{2}\bigr) + F\bigl(\bigl\vert u_{j}^{n+1} \bigr\vert ^{2}\bigr) \bigr) = C. \end{aligned}$$
(4.4)

Applying Lemma 3.1 and Lemma 4.2, we can deduce that

$$\begin{aligned} - \frac{\tau^{2}}{2}\bigl\Vert \mathbf{R}\delta_{t} \mathbf{u}^{n}\bigr\Vert ^{2} & \geq - \frac{3\tau^{2}}{h^{2}} \bigl\Vert \delta_{t}\mathbf{u}^{n}\bigr\Vert ^{2}. \end{aligned}$$
(4.5)

Substituting (4.5) into (4.4), we obtain that

$$\begin{aligned} \bigl\Vert \delta_{t}\mathbf{u}^{n}\bigr\Vert ^{2} + \frac{1}{2} \bigl( \bigl\Vert \mathbf{R} \mathbf{u}^{n+1}\bigr\Vert ^{2} + \bigl\Vert \mathbf{R} \mathbf{u}^{n}\bigr\Vert ^{2} \bigr) - \frac{3 \tau^{2}}{h^{2}} \bigl\Vert \delta_{t}\mathbf{u}^{n}\bigr\Vert ^{2} \leq C. \end{aligned}$$
(4.6)

Furthermore, inequality (4.6) can be rewritten as

$$\begin{aligned} \biggl( 1- \frac{3\tau^{2}}{h^{2}} \biggr) \bigl\Vert \delta_{t} \mathbf{u}^{n}\bigr\Vert ^{2} + \frac{1}{2} \bigl( \bigl\Vert \mathbf{R}\mathbf{u}^{n+1}\bigr\Vert ^{2} + \bigl\Vert \mathbf{R}\mathbf{u}^{n}\bigr\Vert ^{2} \bigr) \leq C. \end{aligned}$$
(4.7)

Noting that \(( 1- \frac{3\tau^{2}}{h^{2}} ) > 0\), we have

$$\begin{aligned} \bigl\Vert \delta_{t}\mathbf{u}^{n}\bigr\Vert \leq C ,\qquad \bigl\Vert \mathbf{R} \mathbf{u}^{n} \bigr\Vert \leq C . \end{aligned}$$

Applying Lemma 4.4 to \(\Vert \delta_{t}\mathbf{u}^{n}\Vert \leq C \), we obtain \(\Vert \mathbf{u}^{n}\Vert \leq C \). Using Lemma 4.3, we have \(\Vert \delta_{x}\mathbf{u}^{n} \Vert \leq C\). Moreover, by Lemma 4.5, it holds that

$$\begin{aligned} \bigl\Vert \mathbf{u}^{n}\bigr\Vert _{\infty } \leq C . \end{aligned}$$

Therefore, the proof is completed. □

5 Convergence and stability of the difference scheme

In this section, we focus on the convergence and stability of the numerical scheme. Firstly, we define the truncation error \(Er_{j}^{n}\) as

$$\begin{aligned} Er_{j}^{n}= {}&\delta_{t}^{2}U_{j}^{n}-A_{h}^{-1} \delta_{x}^{2} U_{j} ^{n} + \mathrm{i}\alpha \delta_{\hat{t}}U_{j}^{n} \\ &{}+ \biggl[ \beta (x_{j}) \frac{F(\vert U_{j}^{n+1}\vert ^{2}) - F(\vert U_{j}^{n-1}\vert ^{2})}{ \vert U_{j}^{n+1}\vert ^{2} - \vert U_{j}^{n-1}\vert ^{2}} \frac{U_{j}^{n+1} + U_{j}^{n-1}}{2} \biggr] . \end{aligned}$$
(5.1)

By Taylor’s expansion, it is easy to check that

$$\bigl\vert Er_{j}^{n}\bigr\vert \leq C \bigl( \tau^{2} + h^{4}\bigr). $$

Before the proof of convergence, we introduce discrete Gronwall’s inequality.

Lemma 5.1

(Discrete Gronwall’s inequality [35])

Suppose that the discrete function \(w_{n}\) satisfies the recurrence formula

$$\begin{aligned} w_{n}-w_{n-1}\leq a\tau w_{n}+b\tau w_{n-1}+c_{n}\tau, \end{aligned}$$

where a, b and \(c_{n}\) (\(n=1,\ldots,N\)) are nonnegative constants. Then

$$\begin{aligned} \max_{1\leq n \leq N}\vert w_{n}\vert \leq \Biggl( w_{0}+\tau \sum_{k=1} ^{N} c_{k} \Biggr) e^{2(a+b)T}, \end{aligned}$$

where τ is small such that \((a+b)\tau \leq \frac{N-1}{2N}\) (\(N>1\)).

Theorem 5.2

Suppose that \(\phi_{0} \in H_{0}^{1}\), \(\phi_{1} \in L_{2}\), \(\beta (x) \geq 0\), \(F(s) \geq 0\), \(s \in [0,+\infty)\), \(\beta, f' \in C^{1}( \mathbb{R})\), and \(\frac{\tau^{2}}{h^{2}} < \frac{1}{3}\), then the solution \(u^{n}\) of difference problem (2.7)(2.9) converges to the solution of problem (1.1)(1.3) with order \(\mathcal{O}(\tau^{2} + h^{4})\) in the maximal norm.

Proof

Let \(\mathbf{Er}^{n} = (Er_{1}^{n} , \ldots, Er_{J-1}^{n})^{T}\) and \(\mathbf{e}^{n} = \mathbf{U}^{n}-\mathbf{u}^{n}\). Firstly, subtracting (2.2) from the vector form of (5.1), the error equations satisfy

$$\begin{aligned} \mathbf{Er}^{n} ={} &\delta_{t}^{2} \mathbf{e}^{n} - \mathbf{HA} \mathbf{e}^{n} + \mathrm{i}\alpha \delta_{\hat{t}}\mathbf{e}^{n} + G\bigl( \mathbf{U}^{n} \bigr)\frac{\mathbf{U}^{n+1} + \mathbf{U}^{n-1} }{2} - G\bigl( \mathbf{u}^{n}\bigr) \frac{\mathbf{u}^{n+1} + \mathbf{u}^{n-1} }{2} \\ = {}& \delta_{t}^{2} \mathbf{e}^{n} - \mathbf{HA} \mathbf{e}^{n} + \mathrm{i}\alpha \delta_{\hat{t}}\mathbf{e}^{n} + G\bigl(\mathbf{U}^{n}\bigr)\frac{ \mathbf{e}^{n+1} + \mathbf{e}^{n-1} }{2} \\ &{}+ \bigl( G\bigl(\mathbf{U}^{n}\bigr)- G\bigl(\mathbf{u}^{n} \bigr) \bigr) \frac{ \mathbf{u}^{n+1} + \mathbf{u}^{n-1} }{2}. \end{aligned}$$
(5.2)

Computing the inner product with both sides of (5.2) with \(\delta_{\hat{t}}\mathbf{e}^{n} \) and considering the real part, we obtain

$$\begin{aligned} &\operatorname{Re}\bigl(\mathbf{Er}^{n}, \delta_{\hat{t}}\mathbf{e}^{n}\bigr) \\ &\quad = \frac{1}{2\tau }\bigl(\bigl\Vert \delta_{t} \mathbf{e}^{n}\bigr\Vert ^{2} - \bigl\Vert \delta_{t}\mathbf{e}^{n-1}\bigr\Vert ^{2} \bigr) + \frac{1}{4\tau } \bigl(\bigl\Vert \mathbf{R}\mathbf{e}^{n+1}\bigr\Vert ^{2} - \bigl\Vert \mathbf{R}\mathbf{e}^{n-1}\bigr\Vert ^{2}\bigr) \\ &\qquad {}-\frac{\tau }{4} \bigl( \bigl\Vert \mathbf{R}\delta_{t} \mathbf{e}^{n}\bigr\Vert ^{2} - \bigl\Vert \mathbf{R} \delta_{t}\mathbf{e}^{n-1}\bigr\Vert ^{2} \bigr) + \operatorname{Re}\biggl( G\bigl(\mathbf{U}^{n}\bigr) \frac{\mathbf{e}^{n+1} + \mathbf{e}^{n-1} }{2}, \delta_{\hat{t}} \mathbf{e}^{n} \biggr) \\ &\qquad {}+ \operatorname{Re}\biggl( \bigl( G\bigl(\mathbf{U}^{n}\bigr) - G\bigl( \mathbf{u} ^{n}\bigr) \bigr) \frac{\mathbf{u}^{n+1} + \mathbf{u}^{n-1} }{2}, \delta_{\hat{t}} \mathbf{e}^{n} \biggr). \end{aligned}$$
(5.3)

Noticing that \(\vert G(\mathbf{U}^{n})\vert \leq C\) and \(f'(s) \in C^{1}\), we have

$$\begin{aligned} &\operatorname{Re}\bigl(\mathbf{Er}^{n}, \delta_{\hat{t}} \mathbf{e}^{n}\bigr) \leq C \bigl( \bigl\Vert \mathbf{Er}^{n} \bigr\Vert ^{2} + \bigl\Vert \delta_{t} \mathbf{e}^{n}\bigr\Vert ^{2} +\bigl\Vert \delta_{t}\mathbf{e}^{n-1}\bigr\Vert ^{2} \bigr), \end{aligned}$$
(5.4)
$$\begin{aligned} &\operatorname{Re}\biggl(G\bigl( \mathbf{U}^{n} \bigr)\frac{\mathbf{e}^{n+1} + \mathbf{e}^{n-1} }{2} , \delta_{\hat{t}}\mathbf{e}^{n}\biggr) \leq C \bigl( \bigl\Vert \mathbf{e}^{n+1} \bigr\Vert ^{2} + \bigl\Vert \mathbf{e}^{n-1}\bigr\Vert ^{2} + \bigl\Vert \delta_{t}\mathbf{e}^{n}\bigr\Vert ^{2} + \bigl\Vert \delta_{t}\mathbf{e}^{n-1}\bigr\Vert ^{2} \bigr), \end{aligned}$$
(5.5)
$$\begin{aligned} &\operatorname{Re}\biggl( \bigl( G\bigl(\mathbf{U}^{n} \bigr) - G\bigl( \mathbf{u} ^{n} \bigr) \bigr) \frac{\mathbf{u}^{n+1} + \mathbf{u}^{n-1} }{2}, \delta_{\hat{t}} \mathbf{e}^{n}\biggr) \leq C \bigl( \bigl\Vert \delta_{t} \mathbf{e}^{n}\bigr\Vert ^{2} + \bigl\Vert \delta_{t}\mathbf{e}^{n-1}\bigr\Vert ^{2} + \bigl\Vert \mathbf{e}^{n}\bigr\Vert ^{2} \bigr). \end{aligned}$$
(5.6)

It follows from Lemma 4.4 that

$$\begin{aligned} \frac{1}{\tau }\bigl(\bigl\Vert \mathbf{e}^{n} \bigr\Vert ^{2} - \bigl\Vert \mathbf{e}^{n-1}\bigr\Vert ^{2} \bigr) \leq C\bigl(\bigl\Vert \delta_{t} \mathbf{e}^{n-1}\bigr\Vert ^{2} + \bigl\Vert \mathbf{e}^{n-1}\bigr\Vert ^{2} + \bigl\Vert \mathbf{e}^{n}\bigr\Vert ^{2}\bigr). \end{aligned}$$
(5.7)

Substituting (5.4)–(5.6) into (5.3) and combining with (5.7), we obtain

$$\begin{aligned} &\frac{1}{2\tau }\bigl(\bigl\Vert \delta_{t} \mathbf{e}^{n}\bigr\Vert ^{2} - \bigl\Vert \delta_{t}\mathbf{e}^{n -1}\bigr\Vert ^{2} \bigr)+ \frac{1}{4\tau }\bigl(\bigl\Vert \mathbf{R}\mathbf{e}^{n + 1}\bigr\Vert ^{2}- \bigl\Vert \mathbf{R} \mathbf{e}^{n-1}\bigr\Vert ^{2}\bigr) \\ &\qquad {}+\frac{1}{\tau }\bigl(\bigl\Vert \mathbf{e}^{n}\bigr\Vert ^{2}-\bigl\Vert \mathbf{e}^{n - 1}\bigr\Vert ^{2} \bigr)-\frac{\tau }{4}\bigl(\bigl\Vert \mathbf{R}\delta_{t} \mathbf{e}^{n}\bigr\Vert ^{2} -\bigl\Vert \mathbf{R} \delta_{t}\mathbf{e}^{n-1}\bigr\Vert ^{2} \bigr) \\ &\quad \leq C \bigl( \bigl\Vert \mathbf{Er}^{n}\bigr\Vert ^{2} + \bigl\Vert \delta_{t}\mathbf{e}^{n}\bigr\Vert ^{2} + \bigl\Vert \delta_{t}\mathbf{e}^{n-1} \bigr\Vert ^{2} + \bigl\Vert \mathbf{e}^{n+1} \bigr\Vert ^{2} + \bigl\Vert \mathbf{e}^{n}\bigr\Vert ^{2} + \bigl\Vert \mathbf{e}^{n-1}\bigr\Vert ^{2} \bigr). \end{aligned}$$
(5.8)

Summing inequalities (5.8) up for n leads to

$$\begin{aligned} &\bigl\Vert \delta_{t} \mathbf{e}^{n}\bigr\Vert ^{2} + \frac{1}{2} \bigl( \bigl\Vert \mathbf{R} \mathbf{e}^{n+1}\bigr\Vert ^{2} + \bigl\Vert \mathbf{R} \mathbf{e}^{n}\bigr\Vert ^{2} \bigr) + 2 \bigl\Vert \mathbf{e}^{n}\bigr\Vert ^{2} -\frac{\tau^{2}}{2}\bigl\Vert \mathbf{R}\delta_{t}\mathbf{e}^{n}\bigr\Vert ^{2} \\ & \quad \leq\tau C \sum_{i=1}^{n} \biggl[ \bigl\Vert \delta_{t} \mathbf{e}^{i}\bigr\Vert ^{2} + \frac{1}{2} \bigl( \bigl\Vert \mathbf{R} \mathbf{e}^{i+1}\bigr\Vert ^{2} + \bigl\Vert \mathbf{R} \mathbf{e}^{i}\bigr\Vert ^{2} \bigr) + 2\bigl\Vert \mathbf{e}^{i}\bigr\Vert ^{2} \\ & \qquad {}-\frac{\tau^{2}}{2} \bigl\Vert \mathbf{R}\delta_{t} \mathbf{e}^{i}\bigr\Vert ^{2} \biggr] + CT\bigl( \tau^{2} + h^{4}\bigr)^{2}. \end{aligned}$$
(5.9)

According to Lemma 5.1, it yields that

$$\begin{aligned} &\bigl\Vert \delta_{t} \mathbf{e}^{n}\bigr\Vert ^{2} + \frac{1}{2} \bigl( \bigl\Vert \mathbf{R} \mathbf{e}^{n+1}\bigr\Vert ^{2} + \bigl\Vert \mathbf{R} \mathbf{e}^{n}\bigr\Vert ^{2} \bigr) + 2 \bigl\Vert \mathbf{e}^{n}\bigr\Vert ^{2} -\frac{\tau^{2}}{2}\bigl\Vert \mathbf{R}\delta_{t}\mathbf{e}^{n}\bigr\Vert ^{2} \\ &\quad \leq CT\bigl(\tau^{2} + h^{4}\bigr)^{2}. \end{aligned}$$
(5.10)

Moreover, combining inequality (4.5) and using Lemma 4.2, we get

$$\begin{aligned} & \biggl( 1- \frac{3\tau^{2}}{h^{2}} \biggr) \bigl\Vert \delta_{t} \mathbf{e}^{n}\bigr\Vert ^{2} + \frac{1}{2} \bigl( \bigl\Vert \mathbf{R}\mathbf{e}^{n+1}\bigr\Vert ^{2} + \bigl\Vert \mathbf{R}\mathbf{e}^{n}\bigr\Vert ^{2} \bigr) + 2 \bigl\Vert \mathbf{e}^{n}\bigr\Vert ^{2} \\ &\quad \leq CT\bigl(\tau^{2} + h^{4}\bigr)^{2}. \end{aligned}$$
(5.11)

The rest of the proof of convergence is similar to that of Theorem 4.6. As a result, we have

$$\begin{aligned} \bigl\Vert \mathbf{e}^{n} \bigr\Vert _{\infty } \leq \mathcal{O}\bigl(\tau^{2} + h^{4}\bigr). \end{aligned}$$
(5.12)

The proof is completed. □

Similarly, we present the stability of difference scheme (2.7)–(2.9).

Theorem 5.3

Under the conditions of Theorem 5.2, the difference scheme (2.7)(2.9) is stable for the initial data.

6 Some extensions

In this section, we present several other conservative compact schemes, which conserve the discrete conservative law. Moreover, we use Richardson extrapolation to improve the accuracy in the temporal direction.

6.1 Several conservative compact schemes

In this subsection, the proofs of the boundedness of numerical solutions, the stability and convergence of numerical schemes are similar to those in the previous sections. We only list the numerical schemes and the discrete energy conservative laws for all schemes.

Scheme 1

$$\begin{aligned} &A_{h}\delta_{t}^{2}u_{j}^{n}- \delta_{x}^{2} \frac{u_{j}^{n+1} + u _{j}^{n-1}}{2} + \mathrm{i}\alpha A_{h}\delta_{\hat{t}}u_{j}^{n} \\ &\qquad {}+ A_{h} \biggl[ \beta (x_{j}) \frac{F(\vert u_{j}^{n+1}\vert ^{2}) - F(\vert u_{j}^{n-1}\vert ^{2})}{ \vert u_{j}^{n+1}\vert ^{2} - \vert u_{j}^{n-1}\vert ^{2}} \frac{u_{j}^{n+1} + u_{j}^{n-1}}{2} \biggr] = 0, \\ &\quad 1\leq j\leq J-1, 1\leq n \leq N-1, \\ &u_{j}^{0} = \phi_{0}(x_{j}),\quad \delta_{\hat{t}}(x_{j},0) = \phi_{1}(x_{j}),\quad 0\leq j\leq J, \\ &u_{0}^{n} = u_{J}^{n} = 0,\quad 0 \leq n \leq N. \end{aligned}$$

The discrete conservative law of Scheme 1 is

$$\begin{aligned} E^{n} = &\bigl\Vert \delta_{t}\mathbf{u}^{n} \bigr\Vert ^{2} + \frac{1}{2}\bigl(\bigl\Vert \mathbf{R} \mathbf{u}^{n}\bigr\Vert ^{2} + \bigl\Vert \mathbf{R} \mathbf{u}^{n+1}\bigr\Vert ^{2}\bigr) + \frac{h}{2}\sum _{j=1}^{J-1} \beta_{j} \bigl[ F \bigl(\bigl\vert u_{j}^{n}\bigr\vert ^{2}\bigr) + F\bigl(\bigl\vert u_{j}^{n+1}\bigr\vert ^{2} \bigr) \bigr] = E^{0}. \end{aligned}$$

Scheme 2

$$\begin{aligned} &A_{h}\delta_{t}^{2}u_{j}^{n} - \delta_{x}^{2} \frac{u_{j}^{n+1} + u _{j}^{n-1}}{2} + \mathrm{i}\alpha A_{h}\delta_{\hat{t}}u_{j}^{n} \\ &\qquad {}+ A_{h} \biggl[ \beta (x_{j}) \frac{F ( \frac{\vert u_{j}^{n+1}\vert ^{2} + \vert u_{j}^{n}\vert ^{2}}{2} ) -F ( \frac{\vert u_{j}^{n}\vert ^{2} + \vert u_{j}^{n-1}\vert ^{2}}{2} ) }{ \vert u_{j}^{n+1}\vert ^{2}- \vert u_{j}^{n-1}\vert ^{2}} \bigl(u_{j}^{n+1} + u_{j}^{n-1}\bigr) \biggr] = 0, \\ &\quad 1\leq j\leq J-1, 1\leq n \leq N-1, \\ &u_{j}^{0} = \phi_{0}(x_{j}),\qquad \delta_{\hat{t}}(x_{j},0) = \phi_{1}(x_{j}),\quad 0\leq j\leq J, \\ &u_{0}^{n} = u_{J}^{n} = 0,\quad 0 \leq n \leq N. \end{aligned}$$

The discrete conservative law of Scheme 2 is

$$\begin{aligned} &E^{n} = \bigl\Vert \delta_{t}\mathbf{u}^{n} \bigr\Vert ^{2} + \frac{1}{2}\bigl(\bigl\Vert \mathbf{R} \mathbf{u}^{n}\bigr\Vert ^{2} + \bigl\Vert \mathbf{R} \mathbf{u}^{n+1}\bigr\Vert ^{2}\bigr) + h\sum _{j=1}^{J-1} \beta_{j}F \biggl( \frac{\vert u_{j}^{n+1}\vert ^{2} + \vert u_{j}^{n}\vert ^{2}}{2} \biggr) = E^{0}. \end{aligned}$$

Scheme 3

$$\begin{aligned} &A_{h}\delta_{t}^{2}u_{j}^{n}- \delta_{x}^{2} u_{j}^{n} + \mathrm{i}\alpha A _{h}\delta_{\hat{t}}u_{j}^{n} \\ &\qquad +A_{h} \biggl[ \beta (x_{j}) \frac{F ( \frac{\vert u_{j}^{n+1}\vert ^{2} + \vert u_{j}^{n}\vert ^{2}}{2} ) - F ( \frac{\vert u_{j}^{n}\vert ^{2} + \vert u_{j}^{n-1}\vert ^{2}}{2} ) }{\vert u_{j}^{n+1}\vert ^{2} - \vert u_{j}^{n-1}\vert ^{2}} \bigl(u_{j}^{n+1} + u_{j}^{n-1}\bigr) \biggr] = 0, \\ &\quad 1\leq j\leq J-1, 1\leq n \leq N-1, \\ &u_{j}^{0} = \phi_{0}(x_{j}),\qquad \delta_{\hat{t}}(x_{j},0) = \phi_{1}(x_{j}),\quad 0\leq j\leq J, \\ &u_{0}^{n} = u_{J}^{n} = 0,\quad 0 \leq n \leq N. \end{aligned}$$

The discrete conservative law of Scheme 3 is

$$\begin{aligned} E^{n} = {}& \bigl\Vert \delta_{t}\mathbf{u}^{n} \bigr\Vert ^{2} +\frac{1}{2} \bigl(\bigl\Vert \mathbf{R} \mathbf{u}^{n}\bigr\Vert ^{2} + \bigl\Vert \mathbf{R} \mathbf{u}^{n+1}\bigr\Vert ^{2}\bigr) - \frac{ \tau^{2}}{2} \bigl\Vert \mathbf{R}\delta_{t}\mathbf{u}^{n}\bigr\Vert ^{2} \\ &{}+ h\sum_{j=1}^{J-1}\beta_{j}F \biggl( \frac{\vert u_{j}^{n+1}\vert ^{2} + \vert u_{j}^{n}\vert ^{2}}{2} \biggr) = E^{0}. \end{aligned}$$

Scheme 4

$$\begin{aligned} &A_{h}\delta_{t}^{2}\frac{u_{j}^{n+1} + u_{j}^{n}}{2}- \delta_{x}^{2} \frac{u _{j}^{n+1} + u_{j}^{n}}{2} + \mathrm{i}\alpha A_{h}\delta_{t}u_{j}^{n} \\ &\qquad {}+ A_{h} \biggl[ \beta (x_{j}) \frac{F(\vert u_{j}^{n+1}\vert ^{2}) - F(\vert u_{j}^{n}\vert ^{2})}{ \vert u_{j}^{n+1}\vert ^{2} - \vert u_{j}^{n}\vert ^{2}} \frac{u_{j}^{n+1} + u _{j}^{n}}{2} \biggr] = 0, \\ &\quad 1\leq j\leq J-1, 1\leq n \leq N-1, \\ &u_{j}^{0} = \phi_{0}(x_{j}),\qquad \delta_{\hat{t}}(x_{j},0) = \phi_{1}(x_{j}),\quad 0\leq j\leq J, \\ &u_{0}^{n} = u_{J}^{n} = 0,\quad 0 \leq n \leq N. \end{aligned}$$

The discrete conservative law of Scheme 4 is

$$\begin{aligned} E^{n} ={}& \frac{1}{2} \bigl( \bigl\Vert \delta_{t} \mathbf{u}^{n}\bigr\Vert ^{2} + \bigl\Vert \delta_{\bar{t}}\mathbf{u}^{n}\bigr\Vert ^{2} \bigr) - \frac{\tau^{2}}{2}\bigl\Vert \delta_{t}^{2} \mathbf{u}^{n}\bigr\Vert ^{2} \\ &{}+ \bigl\Vert \mathbf{R} \mathbf{u}^{n}\bigr\Vert ^{2} + h\sum _{j=1}^{J-1}\beta_{j} F\bigl(\bigl\vert u_{j}^{n}\bigr\vert ^{2}\bigr) = E^{0}. \end{aligned}$$

6.2 Richardson extrapolation

In order to improve the accuracy in the temporal direction, we apply Richardson extrapolation, which is given by a linear combination of numerical solutions under different mesh grids. Applying Taylor’s expansion, we obtain that the main term of truncation error \(Er_{j}^{n}\) is \(\mathcal{O}(\tau^{2} + \tau^{4} + h^{4})\). Hence, we use the following Richardson method (see [36]):

$$\begin{aligned} (u_{R})_{j}^{n} = \frac{4}{3}u_{j}^{2n} \biggl(h, \frac{\tau }{2}\biggr) - \frac{1}{3}u_{j}^{n}(h, \tau), \end{aligned}$$

where \(u_{j}^{n}(h,\tau)\) is the numerical solutions at the grid point \((x_{j}, t_{n})\) with spatial step size h and temporal step size τ, and \(u_{j}^{2n}(h, \frac{\tau }{2})\) is the numerical solutions at the grid point \((x_{j}, t_{n})\) with spatial step size h and temporal step size \(\frac{\tau }{2}\). Here, the convergence order of the Richardson method is \(\mathcal{O}(\tau^{4} + h^{4})\).

7 Numerical experiments

In this section, we use serval numerical experiments to confirm the discrete conservation law, convergence as well as stability. Due to the implicitness and nonlinearity in scheme (2.7)–(2.9), the split iterative algorithm [37] is used to resolve this problem. We take 10−8 as the iterative tolerance.

Example 1

We present some accuracy tests by considering the following equation:

$$\begin{aligned} &u_{tt} - u_{xx} + \mathrm{i}u_{t} + \vert u\vert ^{4}u = f(x,t), \quad (x,t)\in (0,1)\times (0,1), \end{aligned}$$
(7.1)
$$\begin{aligned} &u(x,0) = x(x-1), \qquad u_{t}(x,0) = -\mathrm{i}x(x-1),\quad x\in [0,1], \end{aligned}$$
(7.2)
$$\begin{aligned} &u(0,t) = u(1,t) = 0,\quad t\in [0,1], \end{aligned}$$
(7.3)

where \(f(x,t) = -2e^{-\mathrm{i}t} + x^{5}(x-1)^{5}e^{-\mathrm{i}t}\).

The exact solution of the problem is

$$\begin{aligned} u(x,t) = e^{-\mathrm{i}t}(x-1)x. \end{aligned}$$

In this example, the maximum norm is defined as follows:

$$\begin{aligned} &\Vert \mathit{err}1\Vert _{\infty } = \max_{ \substack{0\leq j\leq J \\ 0\leq n \leq N}}\bigl\vert u(x_{j},t_{n})-u_{j}^{n}\bigr\vert , \\ &\Vert \mathit{err}_{R}1\Vert _{\infty } = \max_{\substack{0\leq j\leq J \\ 0\leq n \leq N}} \biggl\vert u(x_{j},t_{n})- \biggl( \frac{4}{3}u_{j}^{2n} \biggl(h, \frac{\tau }{2}\biggr) - \frac{1}{3}u_{j} ^{n}(h,\tau) \biggr) \biggr\vert . \end{aligned}$$

Scheme (2.7)–(2.9) with \(\tau = h^{2}\) is applied to solve (7.1)–(7.3). The numerical errors are plotted in Fig. 1. It indicates that the convergence order of the scheme is \(\mathcal{O}(\tau^{2} + h^{4})\). To improve temporal accuracy, Richardson extrapolation with \(\tau =h\) is applied to solve the problem. The numerical errors are given in Fig. 2. Clearly, it implies that the convergence order of the method is \(\mathcal{O}(\tau^{4} + h ^{4})\). We also numerically solve the problem with \(h = 0.01\), \(\tau = h ^{2}\), and \(T=10\). Figs. 3 and 4 indicate the long-term behavior of numerical solutions with respect to scheme (2.7)–(2.9) and Richardson extrapolation, respectively. Figs. 5 and 6 further show the movement of \(\vert u\vert \) at different times, i.e., \(t = 2, 5, 10\). These figures further imply that the numerical schemes are effective.

Figure 1
figure 1

The convergence order of scheme (2.7)–(2.9) for Example 1

Figure 2
figure 2

The convergence order of Richardson extrapolation for Example 1

Figure 3
figure 3

The long-term behavior of numerical solutions corresponding to scheme (2.7)–(2.9) from \(t = 0\) to \(t = 10\) at \(h = 0.01\), \(\tau = h^{2}\) for Example 1

Figure 4
figure 4

The long-term behavior of numerical solutions corresponding to Richardson extrapolation from \(t = 0\) to \(t = 10\) at \(h = 0.01\), \(\tau = h^{2}\) for Example 1

Figure 5
figure 5

The movement of \(\vert u\vert \) of scheme (2.7)–(2.9) at \(t = 2, 5, 10\) for Example 1

Figure 6
figure 6

The movement of \(\vert u\vert \) of Richardson extrapolation at \(t = 2, 5, 10\) for Example 1

Example 2

In order to further confirm the theoretical results, we present the following tests by considering the following equation:

$$\begin{aligned} &u_{tt} - u_{xx} + \mathrm{i}u_{t} + \vert u\vert ^{2}u = 0,\quad (x,t)\in (-40,40)\times (0,1), \\ &u(x,0) = (1+\mathrm{i})xe^{-10(1-x)^{2}},\qquad u_{t}(x,0) = 0,\quad x\in [-40, 40]. \end{aligned}$$

The maximum norm in this test is defined as follows:

$$\begin{aligned} &\Vert \mathit{err}2\Vert _{\infty } = \max_{ \substack{0\leq j\leq J \\ 0\leq n \leq N}}\bigl\vert u(x_{j},t_{n})-u_{j}^{n}\bigr\vert , \\ &\Vert \mathit{err}_{R}2\Vert _{\infty } = \max_{\substack{0\leq j\leq J \\ 0\leq n \leq N}} \biggl\vert u(x_{j},t_{n})- \biggl( \frac{4}{3}u_{j}^{2n} \biggl(h, \frac{\tau }{2}\biggr) - \frac{1}{3}u_{j} ^{n}(h,\tau) \biggr) \biggr\vert . \end{aligned}$$

Since the exact solution of the problem is unknown, we take the numerical solution with \(h = 0.0125\), \(\tau = h^{2}\) as the reference solution. To numerically solve problem, we still apply scheme (2.7)–(2.9) with \(\tau = h^{2}\) and Richardson extrapolation with \(\tau =h\). The numerical errors with different methods are shown in Figs. 7 and 8. Again, the numerical results indicate that the convergence order of scheme (2.7)–(2.9) is \(\mathcal{O}(\tau^{2} + h^{4})\) and the convergence order of the scheme with Richardson extrapolation is \(\mathcal{O}(\tau^{4} + h^{4})\). Moreover, Figs. 9 and 10 display the wave propagation of scheme (2.7)–(2.9) and Richardson extrapolation with \(h = 0.1\), \(\tau = h^{2}\), and \(T=10\), respectively. Figs. 11 and 12 show the movement of \(\vert u\vert \) of scheme (2.7)–(2.9) and Richardson extrapolation at \(t = 2, 5, 10\), respectively. In order to further confirm the discrete conservation law, we choose \(h = 0.05\), \(\tau = h^{2}\) to compute the numerical solution from \(t=0\) to \(t=10\). The discrete energy is listed in Table 1. Clearly, it confirms the energy-conserving property of the fully discrete numerical scheme.

Figure 7
figure 7

The convergence order of scheme (2.7)–(2.9) for Example 2

Figure 8
figure 8

The convergence order of Richardson extrapolation for Example 2

Figure 9
figure 9

The wave propagation of scheme (2.7)–(2.9) at \(h = 0.1\), \(\tau = h^{2}\) for Example 2

Figure 10
figure 10

The wave propagation of Richardson extrapolation at \(h = 0.1\), \(\tau = h^{2}\) for Example 2

Figure 11
figure 11

The movement of \(\vert u\vert \) of scheme (2.7)–(2.9) at \(t = 2, 5, 10\) for Example 2

Figure 12
figure 12

The movement of \(\vert u\vert \) of Richardson extrapolation at \(t = 2, 5, 10\) for Example 2

Table 1 The discrete energy E at different time with \(h = 0.05\), \(\tau = h^{2}\) for Example 2

8 Conclusion

In this work, we presented several conservative compact schemes for solving a class of nonlinear Schrödinger equations with wave operator. By the energy method, it was proved that the numerical solution is bounded and numerical scheme (2.7)–(2.9) is convergent and stable. The convergence rate is \(\mathcal{O}(\tau^{2} + h^{4})\) in \(l_{\infty }\) norm. Furthermore, the order of scheme (2.7)–(2.9) is improved to \(\mathcal{O}(\tau^{4} + h^{4})\) by applying Richardson extrapolation. Finally, all the numerical results show that difference scheme (2.7)–(2.9) and Richardson extrapolation are efficient.