Numerical solution of the convection–diffusion equation

The convection–diffusion equation describes the flow of heat, particles, or other physical quantities in situations where there is both diffusion and convection or advection. For information about the equation, its derivation, and its conceptual importance and consequences, see the main article convection–diffusion equation. This article describes how to use a computer to calculate an approximate numerical solution of the discretized equation, in a time-dependent situation.

In order to be concrete, this article focuses on heat flow, an important example where the convection–diffusion equation applies. However, the same mathematical analysis works equally well to other situations like particle flow.

A general discontinuous finite element formulation is needed. The unsteady convection–diffusion problem is considered, at first the known temperature T is expanded into a Taylor series with respect to time taking into account its three components. Next, using the convection diffusion equation an equation is obtained from the differentiation of this equation.

General
The following convection diffusion equation is considered here

$$c \rho\left[\frac{\partial T(x,t)}{\partial t} + \epsilon u \frac{\partial T(x,t)}{\partial x}\right]=\lambda \frac{\partial^2 T(x,t)}{\partial x^2} + Q(x,t)$$

In the above equation, four terms represents transience, convection, diffusion and a source term respectively, where
 * $T$ is the temperature in particular case of heat transfer otherwise it is the variable of interest
 * $t$ is time
 * $c$ is the specific heat
 * $u$ is velocity
 * $ε$ is porosity that is the ratio of liquid volume to the total volume
 * $ρ$ is mass density
 * $λ$ is thermal conductivity
 * $Q(x,t)$ is source term representing the capacity of internal sources

The equation above can be written in the form

$$\frac{\partial T}{\partial t} = a \frac{\partial^2 T}{\partial x^2} - \epsilon u \frac{\partial T}{\partial x} + \frac{Q}{c \rho}$$

where $a = λ⁄cρ$ is the diffusion coefficient.

Solving the convection–diffusion equation using the finite difference method
A solution of the transient convection–diffusion equation can be approximated through a finite difference approach, known as the finite difference method (FDM).

Explicit scheme
An explicit scheme of FDM has been considered and stability criteria are formulated. In this scheme, temperature is totally dependent on the old temperature (the initial conditions) and $θ$, a weighting parameter between 0 and 1. Substitution of $θ = 0$ gives the explicit discretization of the unsteady conductive heat transfer equation.

$$\frac{T_i ^f - T_i ^{f-1}}{\Delta t} = a \frac{T_{i-1} ^{f-1} - 2T_i ^{f-1} + T_{i+1} ^{f-1}}{h^2} - \epsilon u \frac{T_{i+1} ^{f-1} - T_{i-1} ^{f-1}}{2h} + \frac{Q_i ^{f-1}}{c \rho}$$

where
 * $h$ is the uniform grid spacing (mesh step)
 * $h$ is the uniform grid spacing (mesh step)

$$T_i^f = \left(1-\frac{2a\Delta t}{h^2}\right) T_i ^{f-1} + \left(\frac{a \Delta t}{h^2} + \frac{\epsilon u \Delta t}{2h}\right) T_{i-1} ^{f-1} + \left(\frac{a \Delta t}{h^2} - \frac{\epsilon u \Delta t}{2h}\right) T_{i+1} ^{f-1} + \frac{Q_i ^{f-1}}{c \rho} \Delta t$$

Stability criteria
$$\begin{align} h &< \frac{2a}{\epsilon u}, & \Delta t &< \frac{h^2}{2a} \end{align}$$

These inequalities set a stringent maximum limit to the time step size and represents a serious limitation for the explicit scheme. This method is not recommended for general transient problems because the maximum possible time step has to be reduced as the square of $t$.

Implicit scheme
In implicit scheme, the temperature is dependent at the new time level $Δt = t^{f} − t^{f − 1}$. After using implicit scheme, it was found that all coefficients are positive. It makes the implicit scheme unconditionally stable for any size of time step. This scheme is preferred for general purpose transient calculations because of its robustness and unconditional stability. The disadvantage of this method is that more procedures are involved and due to larger $t + Δt$, truncation error is also larger.

Crank–Nicolson scheme
In the Crank–Nicolson method, the temperature is equally dependent on ⇭⇭⇭ and $Δt$. It is a second-order method in time and this method is generally used in diffusion problems.

Stability criteria
$$\Delta t < \frac{h^2}{a}$$

This time step limitation is less restricted than the explicit method. The Crank–Nicolson method is based on the central differencing and hence it is second-order accurate in time.

Finite element solution to convection–diffusion problem
Unlike the conduction equation (a finite element solution is used), a numerical solution for the convection–diffusion equation has to deal with the convection part of the governing equation in addition to diffusion. When the Péclet number (Pe) exceeds a critical value, the spurious oscillations result in space and this problem is not unique to finite elements as all other discretization techniques have the same difficulties. In a finite difference formulation, the spatial oscillations are reduced by a family of discretization schemes like upwind scheme. In this method, the basic shape function is modified to obtain the upwinding effect. This method is an extension of Runge–Kutta discontinuous for a convection-diffusion equation. For time-dependent equations, a different kind of approach is followed. The finite difference scheme has an equivalent in the finite element method (Galerkin method). Another similar method is the characteristic Galerkin method (which uses an implicit algorithm). For scalar variables, the above two methods are identical.