1 Introduction

It is well known that numerous complex and interesting phenomena are caused by the competition between convection and diffusion procedures, thus the studies on the solution of convection–diffusion equation (CDE) are of great importance in many fields of science and engineering. However, it may be very difficult to obtain exact solution for general CDE, especially for those with variable coefficients. In contrast, the numerical methods, including best-approximation weighted-residuals method [1], analytical upstream collocation solution [2], finite-difference method [3], finite volume method [4], finite element method [57] and so on, can be served as an alternative, and have been developed to solve CDE with the development of computer technology.

In the past two decades, the lattice Boltzmann method (LBM), as a promising numerical approach, has been successfully applied in the study of the complex fluid flows [810], including porous media flow [11, 12], multiphase and/or multicomponent flow [13], electromagnetic waves propagation [14], electro-osmotic flow [15, 16], relativistic fluid dynamics [17, 18] and others [1921]. Compared with some traditional numerical methods, the LBM is intrinsically parallel, easy programming, and efficient in dealing with complicated boundary conditions, and also extended to solve nonlinear systems, including the Burgers equation [22], KPZ equation [23], reaction–diffusion equation [24], Poisson equation [25, 26], convection–diffusion equations (CDEs) [2731] and so on.

However, almost all the existing LB models for CDEs focus on the unsteady equations. When used for solving steady problems, these models usually have defects of computing complexity, sometimes inefficiency, and even producing wrong solution. A detailed counterexample can be found in Ref. [25]. Besides, nearly all of the previous models are dealing with constant coefficient CDE. For example, a general lattice Boltzmann (LB) model has been proposed for the nonlinear CDEs through introducing an auxiliary moment \(\mathbf {C}_0\) [27], usually the moment \(\mathbf {C}_0\) is a complicated function with an integral form, and may not be determined analytically. In this paper, following the same idea in our previous work [27], a new simple and efficient LB model for steady CDE with variable coefficients is proposed through constructing a proper equilibrium distribution function, and simultaneously, the problems mentioned above can be overcome.

The rest of the paper is organized as follows. In Sect. 2, a lattice Bhatnagar-Gross-Krook (LBGK) model for steady CDE with variable coefficients is proposed and some of its special cases are discussed. In Sect. 3, some numerical tests on the proposed model are performed, and finally, a brief summary is given in Sect. 4.

2 Modified LBGK Model

The n-dimensional steady CDE with a source term can be written in the following form

$$\begin{aligned} \nabla \cdot \mathbf {B(\mathbf {x},\phi )}= \nabla \cdot [ \alpha (\mathbf {x})\nabla D(\phi ) ] + F(\mathbf {x},\phi ), \end{aligned}$$
(1)

where \(\nabla \) is the gradient operator with respect to the position \(\mathbf {x}\) in n dimensions. \(\mathbf {B(\mathbf {x},\phi )}\) is the convection term, which is the known function of position \(\mathbf {x}\) and the scalar function \(\phi \). \(D(\phi )\) is the diffusion term related to \(\phi \), which is an unknown real/complex-valued scalar function of position \(\mathbf {x}\). \(\alpha (\mathbf {x})\) is the diffusion coefficient, and \(F(\mathbf {x},\phi )\) is the source term with respect to the spatial coordinate \(\mathbf {x}\) and \(\phi \) in \(\textit{n}\) dimensions.

In this work, the lattice Bhatnagar-Gross-Krook (LBGK) model is considered for its simplicity and efficiency in the study of the fluid flows and nonlinear CDEs. The evolution equation of the LBGK model reads

$$\begin{aligned} f_i(\mathbf {x}\!+\!\mathbf {c}_i\varDelta t,t\!+\!\varDelta t)-f_i(\mathbf {x},t)\!=\!-\frac{1}{\tau }[f_i(\mathbf {x},t)\!-\!f_i^{eq}(\mathbf {x},t)]\!+\!\varDelta tF_i(\mathbf {x},t),i\!=\!0,\ldots q-1,\nonumber \\ \end{aligned}$$
(2)

where \(\mathbf {c}_i\)=c \(\mathbf {e}_i\) is the set of possible discrete velocity directions, c is particle velocity and defined by c \( = \varDelta x/\varDelta t\) with \(\varDelta x\) and \(\varDelta t\) representing the discrete steps of space and time, respectively. \(\tau \) is the dimensionless relaxation time, \(f_i(\mathbf {x},t)\) and \(f_i^{eq}(\mathbf {x},t)\) are the local particle distribution function and equilibrium distribution function at position \(\mathbf {x}\) and time t, respectively. Here the isotropic lattice is used in LBM for considering the isotropic diffusion. Our model is based on the DnQq lattice (q velocity directions in n-dimensional space), and the lattice velocity vector must satisfy some reasonable isotropic constraints

$$\begin{aligned} \sum _{i=0}^{q-1} \omega _i= \sum _{i=0}^{q-1} \varpi _i=1, \sum _{i=0}^{q-1}\mathbf {c}_i\omega _i= \sum _{i=0}^{q-1} \mathbf {c}_i \varpi _i=\mathbf {0}, \sum _{i=0}^{q-1}\mathbf {c}_i\mathbf {c}_i\omega _i=c_s^2\mathbf {I}, \end{aligned}$$
(3)

where \(\omega _i\) and \(\varpi _i\) are weight coefficients in the equilibrium distribution function and source term [see following Eqs. (6) and (7)]. \(\mathbf {I}\) is the unit matrix. \(c_s\) is the so called lattice sound speed, which is related to the particle velocity c and weight coefficients \(\omega _i\) through the relation \(\sum _{i=0}^{q-1}\mathbf {c}_i\mathbf {c}_i\omega _i=c_s^2\mathbf {I}\). Here some commonly used DnQq models are listed in Table 1. Besides \(\varpi _0 = 0 \) is needed as in the following numerical simulation.

Table 1 The discrete velocity directions and corresponding weight coefficients of DnQq

In order to satisfy the above isotropic requirements and to recover Eq. (1) exactly, the distribution functions should satisfy the following relations:

$$\begin{aligned} \sum _{i=0}^{q-1} f_i&= \sum _{i=0}^{q-1} f_i^{eq}=0, \sum _{i=0}^{q-1}\mathbf {c}_if_i^{eq}=\mathbf {B}(\mathbf {x},\phi ), \sum _{i=0}^{q-1}\mathbf {c}_i\mathbf {c}_if_i^{eq}=c_s^2 D(\phi )\mathbf {I}.\end{aligned}$$
(4)
$$\begin{aligned} \sum _{i=0}^{q-1}F_i&= F(\mathbf {x},\phi ), \sum _{i=0}^{q-1}\mathbf {c}_iF_i=\mathbf {0}. \end{aligned}$$
(5)

According to the above equations and following the work in Ref. [27], the equilibrium distribution function and the linear source term are taken as,

$$\begin{aligned} f_i^{eq}(\mathbf {x},t)&= \left\{ \begin{array}{l@{\quad }l} (\omega _0-1)\phi +\omega _0 \frac{(\phi - D)\mathbf {I}:\mathbf {I}}{2}, &{} i=0,\\ \omega _i[\phi +\frac{\mathbf {c}_i\cdot \mathbf {B(\mathbf {x},\phi )}}{c_s^2}+\frac{( D-\phi )\mathbf {I}:(\mathbf {c}_i \mathbf {c}_i - c_s^2\mathbf {I})}{2c_s^2}], &{} i=1,\ldots ,q-1. \end{array} \right. \end{aligned}$$
(6)
$$\begin{aligned} F_i(\mathbf {x},t)&= \varpi _i F(\mathbf {x},\phi ),i=0,\ldots , q-1, \end{aligned}$$
(7)

where Eq. (6) is an extension of the common equilibrium distribution function in the LBGK model, which is obtained through modifying that in Ref. [27] according to the moments in Eq. (4). Thus the macroscopic variable \(\phi \) is calculated by \(\phi = \sum _{i=1}^{q-1}f_i/{(1-\omega _0)}\) when \( D = \phi \). If \(D\) is not equal to \(\phi \), the macroscopic variable \(\phi \) is also obtained by above equation through the following conversion [Eq. (25)] in Remark 3.

In what follows, we will present a detailed Chapman–Enskog analysis [27] to derive Eq. (1). The distribution function, the source term, and the derivations of the space and time can be expanded as,

$$\begin{aligned} \begin{array}{lll} f_i = f_i^{(0)} + \epsilon f_i^{(1)} + \epsilon ^2 f_i^{(2)} + \epsilon ^3 f_i^{(3)} + \cdots \!,\\ F = \epsilon F^{(1)}, \partial _t = \epsilon \partial _{t_1} + \epsilon ^2 \partial _{t_2}, \nabla = \epsilon \nabla _1, \end{array} \end{aligned}$$
(8)

where \(\epsilon \) is a small expansion parameter. Taking the Taylor series expansion to Eq. (2) at time \(t\) and space \(\mathbf {x}\), we have

$$\begin{aligned} \triangle tD_if_i+\frac{\triangle t^2}{2}D_i^2f_i+ \cdots =-\frac{1}{\tau }(f_i-f_i^{eq})+\triangle tF_i, \end{aligned}$$
(9)

where \(D_i = \varepsilon D_{1i} + \epsilon ^2\partial _{t_2}\) and \(D_{1i} = \partial _{t_1} + \mathbf {c}_i\cdot \nabla _1\). Substituting Eq. (8) into Eq. (9), yields the following equation:

$$\begin{aligned}&(\epsilon ^2 \partial _{t_2} + \epsilon D_{1i})(f_i^{(0)} + \epsilon f_i^{(1)}+\epsilon ^2f_i^{(2)} + \cdots )\nonumber \\&\qquad +\frac{\triangle t}{2}(\epsilon ^2\partial _{t_2} + \epsilon D_{1i})^2(f_i^{(0)} + \epsilon f_i^{(1)}+\epsilon ^2f_i^{(2)} + \cdots ) + \cdots \\&\quad = -\frac{1}{\tau \triangle t}(\epsilon f_i^{(1)}+\epsilon ^2f_i^{(2)} + \cdots ) + \epsilon F_i^{(1)}.\nonumber \end{aligned}$$
(10)

Based on this equation, we can derive the equations at different orders of \(\epsilon \),

$$\begin{aligned}&\displaystyle f_i^{(0)} = f_i^{eq},\end{aligned}$$
(11)
$$\begin{aligned}&\displaystyle D_{1i}f_i^{(0)} = -\frac{1}{\tau \triangle t}f_i^{(1)} + F_i^{(1)},\end{aligned}$$
(12)
$$\begin{aligned}&\displaystyle \partial _{t_2}f_i^{(0)} + D_{1i}f_i^{(1)} +\frac{\triangle t}{2}D_{1i}^2f_i^{(0)} = -\frac{1}{\tau \triangle t}f_i^{(2)}. \end{aligned}$$
(13)

From Eqs. (4), (8) and (11), we can get the mass conservation condition, namely

$$\begin{aligned} \sum _{i=0}^{q-1} f_i^{(k)} = 0, (k \ge 1). \end{aligned}$$
(14)

Substituting Eq. (12), into Eq. (13), we can rewrite the Eq. (13) in another form

$$\begin{aligned} \partial _{t_2}f_i^{eq} + D_{1i}\left( 1-\frac{1}{2\tau }\right) f_i^{(1)} + \frac{\triangle t}{2}D_{1i}F_i^{(1)} = -\frac{1}{\tau \triangle t}f_i^{(2)}. \end{aligned}$$
(15)

Summing Eqs. (12) and (15) over \(\textit{i}\) and with the help of Eqs. (4), (5) and (8), we have

$$\begin{aligned}&\displaystyle \nabla _1\cdot \ \mathbf {B} = F^{(1)},\end{aligned}$$
(16)
$$\begin{aligned}&\displaystyle \nabla _1\cdot \left[ \left( 1-\frac{1}{2\tau }\right) \sum _i \mathbf{c}_if_i^{(1)}\right] = 0, \end{aligned}$$
(17)

where the relation \(\sum _{i=0}^{q-1} f_i=\sum _{i=0}^{q-1} f_i^{eq}=0\) is used to eliminate the time derivative. Coupling Eqs. (4), (5) and (12), one can obtain

$$\begin{aligned} \sum _{i=0}^{q-1} \mathbf{c}_if_i^{(1)} = -\tau \triangle t \sum _i \mathbf{c}_i(D_{1i}f_i^{eq} - F_i^{(1)}) = -\tau \triangle t \nabla _1\cdot c_s^2 D\mathbf {I}. \end{aligned}$$
(18)

With the help of above equation, Eq. (17) can be written as

$$\begin{aligned} 0 = \nabla _1\cdot \left[ c_s^2\left( \tau - \frac{1}{2}\right) \Delta t\nabla _1 D\right] . \end{aligned}$$
(19)

Taking Eq. (16) \(\times \epsilon \) + Eq. (19) \(\times \epsilon ^2\), we can obtain the recovered equation

$$\begin{aligned} \nabla \cdot \mathbf {B(\mathbf {x},\phi )}= \nabla \cdot [ \alpha (\mathbf{x}) \nabla D(\phi ) ] + F(\mathbf {x},\phi ), \end{aligned}$$
(20)

with

$$\begin{aligned} \alpha (\mathbf{x}) = c_s^2\left( \tau - \frac{1}{2}\right) \triangle t. \end{aligned}$$
(21)

Finally, some remarks on the present model are listed as follows.

Remark 1

From above Chapman–Enskog analysis, it is found that there is no any assumption or auxiliary moment in our model, and through selecting the weights values of each equilibrium distribution for each velocity vector properly, the present model is more accurate and efficient for the general steady CDEs with variable coefficients [see numerical results in Sect. 3].

Remark 2

It is worth noting that when \(\mathbf {B} = \mathbf {0} \,\,\mathrm{and}\,\, D = \phi \), Eq. (1) becomes the Poisson equation and the equilibrium distribution function can be simplified for this special equation,

$$\begin{aligned} f_i^{eq}(\mathbf {x},t)= \left\{ \begin{array}{l@{\quad }l} (\omega _0-1)\phi , &{} i=0,\\ \omega _i\phi , &{} i=1,\ldots ,\, q-1, \end{array}\right. \end{aligned}$$
(22)

which has the same expression as that in Ref. [25].

Remark 3

Similar to Ref. [27], Eq. (1) can also be rewritten in another form

$$\begin{aligned} \nabla \cdot \mathbf {B(\phi ,\mathbf {x})}= \nabla \cdot [ \alpha D'(\phi )\nabla \phi ] + F(\mathbf {x},\phi ). \end{aligned}$$
(23)

Based on Eq. (23), we can give a simple LB model with the following equilibrium distribution function and diffusion coefficient

$$\begin{aligned} f_i^{eq}(\mathbf {x},t)&= \left\{ \begin{array}{l@{\quad }l} (\omega _0-1)\phi , &{} i=0,\\ \omega _i\left[ \phi +\frac{\mathbf {c}_i\cdot \mathbf {B(\mathbf {x},\phi )}}{c_s^2}\right] , &{} i=1,\ldots ,q-1, \end{array} \right. \end{aligned}$$
(24)
$$\begin{aligned} \alpha D'(\phi )&= c_s^2\left( \tau - \frac{1}{2}\right) \Delta t. \end{aligned}$$
(25)

Remark 4

For Eq.  (23), similar to the method in Ref. [32], we can introduce two parameters to adjust the convergence speed, accuracy and stability. To this end, the equilibrium distribution function, diffusion coefficient and the discrete source term should be modified by

$$\begin{aligned} f_i^{eq}(\mathbf {x},t)&= \left\{ \begin{array}{l@{\quad }l} (\omega _0-1)\gamma \phi , &{} i=0,\\ \omega _i\left[ \gamma \phi +\frac{\mathbf {c}_i\cdot \beta \mathbf {B(\mathbf {x},\phi )}}{c_s^2}\right] , &{} i=1,\ldots ,q-1, \end{array} \right. \end{aligned}$$
(26)
$$\begin{aligned} \alpha D'(\phi )&= \frac{\gamma }{\beta }c_s^2\left( \tau - \frac{1}{2}\right) \Delta t,\end{aligned}$$
(27)
$$\begin{aligned} F_i(\mathbf {x}, t)&= \varpi _i \beta F(\mathbf {x},\phi ), i = 0, \ldots q-1. \end{aligned}$$
(28)

The macroscopic variable \(\phi \) is obtained by

$$\begin{aligned} \phi =\frac{f_0}{\gamma (\omega _0-1)}=\frac{\sum _{i=1}^{q-1} f_i(\mathbf {x},t)}{\gamma (1-\omega _0)}, \end{aligned}$$
(29)

where the role of \(\gamma \) and \(\beta \) is similar to Ref. [32]. In fact, when the diffusion coefficient is fixed, the dimensionless relaxation time \(\tau \) can be adjusted in a proper range through changing the parameters \(\gamma \) and \(\beta \), and thus, the stability and accuracy of the model can be improved properly.

Remark 5

Based on our previous work, we can derive another useful LB model with the following equilibrium distribution function

$$\begin{aligned} f_i^{eq}(\mathbf {x},t)= \left\{ \begin{array}{l@{\quad }l} \omega _0\phi , &{} i=0,\\ \omega _i\left[ \phi +\frac{\mathbf {c}_i\cdot \mathbf {B(\mathbf {x},\phi )}}{c_s^2}\right] , &{} i=1,\ldots ,q-1, \end{array} \right. \end{aligned}$$
(30)

and the macroscopic variable can be obtained by the relation \(\phi = \sum _{i=0}^{q-1}f_i\). In the following, this new model [Eqs. (2) and (30) with Eq. (21)] is denoted by method 2.

3 Numerical Simulation

In this section, numerical experiments on several n-dimensional (n = 1, 2, 3) steady CDEs are carried out to test the proposed model. The non-equilibrium extrapolation scheme proposed by Guo et al. [33] is used for the boundary treatments, and the following convergence criterion is adopted,

$$\begin{aligned} \varepsilon (t)=\frac{\sum _j|\phi (\mathbf {x}_j,t) - \phi (\mathbf {x}_j,t-100\Delta t)|}{\sum _j|\phi (\mathbf {x}_j,t)|}< 1 \times 10^{-6}. \end{aligned}$$
(31)

The global relative error (RE) and global maximum error (ME) are used to measure the accuracy of the present model, and defined by

$$\begin{aligned} RE = \frac{\sum _j|\phi (\mathbf {x}_j) - \phi ^*(\mathbf {x}_j)|}{ \sum _j|\phi ^*(\mathbf {x}_j)|}, ME =MAX_j|\phi (\mathbf {x}_j) - \phi ^*(\mathbf {x}_j)|, \end{aligned}$$
(32)

where \(\phi (\mathbf {x}_j)\) and \(\phi ^*(\mathbf {x}_j)\) are the numerical and analytical solutions at position \(\mathbf {x}_j\), respectively. The summation is performed on all grid points.

For simplicity, to conduct a comparison between different models, we denoted the LB model in Ref. [27], the new model given in Remark 5 and present model as method 1 (M1), method 2 (M2) and method 3 (M3). Without otherwise statement, the method 3 is used in the following simulations, and u = 0 is adopted to initialize the equilibrium distribution function except for given boundary conditions.

3.1 One-Dimensional Steady CDEs

Example 3.1

The steady Burgers–Fisher equation (BFE) [34]

$$\begin{aligned} u\frac{\partial u}{\partial x} = \upsilon \frac{\partial ^2 u}{\partial x^2}, \end{aligned}$$
(33)

with the boundary conditions

$$\begin{aligned} u(-1) = tanh{\frac{1}{2\upsilon }}, u(1) = tanh{\frac{-1}{2\upsilon }}, \end{aligned}$$
(34)

is first considered. The exact solution to this problem is given by \( u(x) = tanh \frac{-x}{2\upsilon }\). We used the D1Q3 model to study this problem, and took \(\Delta x = 0.02\), \(c = 10\) under different diffusion coefficients \(\upsilon \). We presented the results in Fig. 1, and found that the numerical results agree well with the corresponding exact solutions. Besides that, we also observed that although the values around the position \(x=0\) are changing more and more sharply with the decrease of the diffusion coefficient \(\upsilon \), the present model still works well.

Fig. 1
figure 1

Comparison between analytic solutions (solid) and numerical results (symbol)

To test the accuracy of the proposed model, simulations were performed for different lattice resolutions \((\Delta x = 1/50 - 1/800)\), and c was correspondingly changed from 3 to 48. Based on the RE and ME in Fig. 2, the slopes of the fitting lines for different results are very close to 2, which indicates that all of the three models have a seconder-order accuracy in space.

Fig. 2
figure 2

The errors of different models with different lattice steps (1, 2 and 3: the results obtained by methods 1, 2 and 3)

Furthermore, we conducted a comparison of precision and convergent rate between different models, and presented the results in Table 2 where \(c = 10\), \(\Delta x = 0.0025\). From Table 2, we can see that the present model (method 3) performs better than the previous methods 1 and 2 in precision and convergence rate, especially when \(\upsilon \) is relatively larger. We also gave a comparison between present model and the high-resolution numerical perturbation algorithm [34] in Table 3, and found that the present model is at least comparable to the high-order (7th-order) numerical perturbation algorithm [34] when \(\upsilon = 0.001\) and \(c = 10\). Based the results presented above, we can conclude that the present model is an accurate and efficient algorithm in solving this special CDE.

Table 2 Errors and iteration steps of different models (M1: previous model [27], M2: the model in Remark 5, M3: present model, IT: iteration steps)
Table 3 RE of different methods for the Burgers equation with \(\upsilon = 0.001\) (2-CD: second-order central difference, NP: numerical perturbation, M3: method 3, OS: oscillatory solution)

Example 3.2

We also used a linear convection–diffusion equation with a source term

$$\begin{aligned} \frac{\partial u}{\partial x} = \upsilon \frac{\partial ^2 u}{\partial x^2} + \upsilon \pi ^2 sin (\pi x) + \pi cos (\pi x), \end{aligned}$$
(35)

to test present model. The problem has the following analytical solution

$$\begin{aligned} u(x) = sin(\pi x) +(e^{x/\upsilon }-1)/(e^{1/\upsilon }-1). \end{aligned}$$
(36)

We used the D1Q3 model to solve this problem in the interval [0, 1] by using different \(\varpi _0\), and showed the results in Fig. 3 where \(\Delta x = 1/80, c = 5, \upsilon = 0.001\). As seen from this figure, the numerical results derived by M3 with \(\varpi _0 = 0\) and M1/2 are in good agreement with the exact solutions. Figure 3 also shows that \(\varpi _0 = 0\) is essential for M3, but not essential for M1 or M2, which may be due to the different definitions in computing macroscopic variable.

Fig. 3
figure 3

Comparison between analytic solution (solid) and numerical result (symbol)

In addition, we carried out a comparison of RE and iteration steps between different models for the case of \(c = 5, \upsilon = 0.001\) with different lattices, and presented the results in Table 4. From Table 4, it can be seen that the present model is better than other two models in the convergence rate and precision, and LB models are also better or comparable to the method in Ref. [34]. Besides, the relaxation time effect on the numerical results is also studied. For given \(\Delta x = 0.01\) and \(\upsilon = 0.01\), we can derive the RE under different relaxation time \(\tau \), and plot the results in Fig. 4. As shown in this figure, there is an optimal relaxation time that can be used to give smallest error. Although the optimal values for different models are different from each other, all of them are less than 1 for this special example.

Fig. 4
figure 4

The RE at different relaxation times (1, 2 and 3: methods 1, 2 and 3)

Table 4 The results of different methods for the case of \(\upsilon = 0.001\) (2-CD: second order central difference, NP: numerical perturbation; M1, 2 and 3: methods 1, 2 and 3; IT: iteration steps)

Finally, we also investigated the convergence procedures of different models under various lattice speeds, and presented the results in Fig. 5 where the lattice is 640 and the diffusion coefficient \(\upsilon = 0.001\). From this figure, one can find that the method 3 converges to the exact solution with a fastest rate while M2 is better than M1 in precision, although both of them have the same convergence rate.

Fig. 5
figure 5

Convergence histories of different methods for the case of \(\upsilon = 0.001\)

Example 3.3

The conservation air pocket equation

$$\begin{aligned} \frac{\partial (1-2x)u}{\partial x} = \upsilon \frac{\partial ^2 u}{\partial x^2}, \end{aligned}$$
(37)

with the boundary conditions

$$\begin{aligned} u(0) = 1, u(1) = 1, \end{aligned}$$
(38)

is also considered in this work. The analytical solution to this problem can be given as

$$\begin{aligned} u(x) = e^{\frac{ x(1-x)}{\upsilon } }. \end{aligned}$$
(39)

We still used the D1Q3 model to study this problem, and take \( \upsilon = 0.1, c = 60, \Delta x = 0.01\). We presented the results in Fig. 6, and found that the numerical results agree well with the corresponding exact solutions.

Fig. 6
figure 6

Comparison between analytic solution (solid) and numerical solution (symbol)

To test the accuracy of the proposed model for this problem, some simulations were performed under different lattice resolutions (\(\Delta x = 1/40 - 1/100\)), and c was correspondingly changed from 24 to 60. Based on the RE and ME in Fig. 7, the slopes of the fitting lines are about 2, indicating that all of the three models are second-order accurate in space. In addition, we also conducted a comparison of precision and convergence rate between different models, and presented the results in Table 5 where \(c = 60\), \(\Delta x = 0.01\). From Table 5, we can see that the present model (method 3) performs much better than the previous M1 and M2.

Fig. 7
figure 7

The errors of different models with different lattice steps (1, 2 and 3: methods 1, 2 and 3)

Table 5 Errors and iteration steps of different models (M1, 2 and 3: methods 1, 2 and 3; IT: iteration steps)

3.2 Two-Dimensional Steady CDEs

Example 3.4

We also used 2D steady Burgers equation [34]

$$\begin{aligned} u\frac{\partial u}{\partial x}+u\frac{\partial u}{\partial y} = \upsilon \left( \frac{\partial ^2 u}{\partial x^2}+\frac{\partial ^2 u}{\partial y^2}\right) , \end{aligned}$$
(40)

to test present model. The problem has the following exact solution

$$\begin{aligned} u(x,y) = tanh\left( \frac{-(x+y)}{2 \upsilon }\right) . \end{aligned}$$
(41)

The D2Q5 model was applied to solve this problem in the domain \([-1, 1]^2\), and the results were presented in Fig. 8 where \(\upsilon = 0.01, \Delta x = 0.01\) and \(\Delta t = 0.001\). As seen from this figure, the numerical result is in good agreement with the exact solution. Similar to above discussion, to test the accuracy of the proposed model for this special two-dimensional problem, some simulations were conducted under different lattice resolutions (\(\Delta x = 1/50 - 1/400\)), and c was correspondingly varied from 3 to 24. Based on the results of RE and ME in Fig. 9, one can find that the slopes of the fitting lines for different results are close to 2, which indicates that all of the three models have a second-order accuracy in space. Besides that, we also conducted a comparison of precision and convergence rate between different models, and presented the results in Table 6 where \(\Delta x= 0.01, \tau = 1\). As seen from Table 6, the present model (method 3) also performs better than the previous M1 and M2 in precision and convergence rate.

Fig. 8
figure 8

Analytical and numerical solutions of 2D nonlinear Burgers equation

Fig. 9
figure 9

The errors of different models with different lattice steps (1, 2 and 3: methods 1, 2 and 3)

Finally, the convergence procedures of different models under various lattice speeds were also investigated, and the results were shown in Fig. 10 where the lattice and diffusion coefficient are fixed to be \(200\times 200\) and \(\upsilon = 0.05\). From this figure, one can find that the present model (method 3) also converges to the exact solution with a fastest rate for this two-dimensional Burgers equation.

Fig. 10
figure 10

Convergence histories of different methods for the case of \(\upsilon = 0.05\)

Table 6 Errors and iteration steps of different models for 2D Burgers equation (M1, M2 and M3: methods 1, 2 and 3; IT: iteration steps)

Example 3.5

The 2D convection–diffusion equation with variable coefficient

$$\begin{aligned} \left( y-\frac{1}{2}\right) \frac{\partial u}{\partial x}+\left( x-\frac{1}{2}\right) \frac{\partial u}{\partial y} = \upsilon \left( \frac{\partial ^2 u}{\partial x^2}+\frac{\partial ^2 u}{\partial y^2}\right) , \end{aligned}$$
(42)

was further considered. The exact solution of this problem is given by \(u(x,y) = exp[{(x-0.5)(y-0.5)}/\upsilon ]\). We adopted the D2Q5 model to study this problem in the domain \([0,1]^2 \), and took \(\Delta x = 0.01, c =6\) and diffusion coefficient \(\upsilon = 0.01 \). We presented the results in Fig. 11, and found that the numerical result agrees very well with the corresponding analytic solution. Besides that, we can also observe that although the values around the point (0, 0) and (1, 1) have dramatic changes, the present model still works well.

Fig. 11
figure 11

Comparison between analytical solution and numerical result

Furthermore, we also studied the precision and convergence rate between different models, and presented the results in Table 7 where \(\Delta x = 0.01, \tau = 1\). As seen from Table 7, the present model (method 3) also performs better than the previous method 1 and 2 in precision and convergence rate, and D2Q5 is better than D2Q9. To test the accuracy of the proposed model, simulations were also carried out at different lattice resolutions (\( \Delta x = 1/50 - 1/800\)), and c was changed from 3 to 48. Based on the RE in Fig. 12 where the diffusion coefficient was set to be \( \upsilon = 0.01 \), the slopes of the fitting lines are about 2, indicating that all of these three models have a second-order accuracy in space. Based on the results presented above, one can conclude that the present model is accurate and more efficient in solving these two-dimensional problem.

Fig. 12
figure 12

The errors of different models with different lattice steps (1, 2 and 3: methods 1, 2 and 3)

Table 7 RE and iteration steps of different models (M1, M2 and M3: methods 1, 2 and 3; IT: iteration steps)

3.3 Three-Dimensional Steady CDE

Example 3.6

The 3D nonlinear Burgers equation

$$\begin{aligned} u\frac{\partial u}{\partial x}+u\frac{\partial u}{\partial y}+ u\frac{\partial u}{\partial z}= \upsilon \left( \frac{\partial ^2 u}{\partial x^2}+\frac{\partial ^2 u}{\partial y^2} + \frac{\partial ^2 u}{\partial z^2}\right) , \end{aligned}$$
(43)

with following exact solution

$$\begin{aligned} u(x,y) = tanh\frac{-(x+y+z)}{2 \upsilon }, \end{aligned}$$
(44)

was also adopted to test present model. We applied the simple D3Q7 model to solve this problem in the domain \( [-1,1]^3 \), and showed the results in Fig. 13 where \(\upsilon = 0.01\), \(\Delta x = 0.02\), and \(c=6\). As seen from this figure, the numerical result agree with the exact solution. We also tested the accuracy of the proposed model for this three-dimensional problem, and presented RE at different lattice resolutions (\(\Delta x = 2/25 - 2/150\)) in Fig. 14. From this figure, one can find that all slopes of the fitting lines are close to 2, which indicates that all of the three models have a second-order accuracy in space.

Fig. 13
figure 13

Comparisons between analytical solution (solid) and numerical result (symbol) of 3D Burgers equation

Fig. 14
figure 14

The errors of different models with different lattice steps

In addition, we also conducted a comparison of precision and convergence rate between different models, and presented the results in Table 8 where \(\Delta x = 0.02, \tau = 0.75\). From Table 8, we can see that the present model (method 3) has a faster convergence rate than the previous methods 1 and 2, and D3Q7 is better than other D3Qq models in precision. From the results shown above, we can also conclude that the present model is more efficient in solving this special three-dimensional CDE.

Table 8 RE and iteration steps of different models (1, 2 and 3: methods 1, 2 and 3; IT: iteration steps)

4 Conclusion

In the present work, a unified LBGK model for the n-dimensional steady CDE is proposed. Efficiency and accuracy of the present model are tested through some classic CDEs, and the numerical results show that the present model performs better than previous models in precision and convergence rate. In addition, through a comparison with some previous models, we can also find some distinct characteristics of the present model. First of all, the present model can be served as a general solver for the steady CDE with variable coefficients, while previous models dealing with time dependent CDEs are not a very good solution to the steady problems with variable coefficients. Second, the previous models for CDEs are sometimes dependent on the initial value, but the present model are not and can accelerate convergence. And finally, in the computation of macroscopic quantity \(u\), only q-1 velocities are used in the present model.