# Finite Difference Method (FDM)

This section describes the formulation and methodology of finite difference method to solve the governing equations on a computational domain.

The finite difference method is the oldest method for the numerical solution of partial differential equations. It is also the easiest to formulate and program for problems which have a simple geometry.

When calculating derivatives finite difference replaces the infinitesimal limiting process with a finite quantity. The derivative of a function at point expressed as: (1)
is replaced by: (2)

The preceding expression is commonly referred to as the forward difference approximation. This derivative can have more refined approximations using a number of approaches such as truncated Taylor series expansions and polynomial fitting.

The term $O\left(\Delta x\right)$ gives an indication of the magnitude of the error as a function of the mesh spacing and is therefore termed as the order of magnitude of the finite difference method. In the above formulation, the finite difference approximation employed is first-order accurate. A second-order approximation would have the order of magnitude expressed as $O\left(\Delta {x}^{2}\right)$ . Most of the finite difference methods used in practice are second-order accurate. An example of a second-order method is the central difference approximation of the first derivative. It is expressed as: (3)
The basic methodology in the simulation process using finite difference approach consists of the following steps.

The finite difference formulation generally employs a structured grid. The most commonly used indices are $i$ , $j$ and $k$ for the grid lines at $x={x}_{i}$ , $y={y}_{j}$ and $z={z}_{k}$ , respectively. The function value at such a grid point is expressed as .

Consider the one dimension advection-diffusion equation for a scalar quantity $\phi$ governed by (4)
$\frac{d\left(\rho u\phi \right)}{dx}=\frac{d}{dx}\left(ϵ\frac{d\phi }{dx}\right)$

where $u$ is the specified velocity, $\rho$ is the density of the fluid and $ϵ$ is the diffusivity.

If the domain is defined by the boundary $x=0$ and $x=L$ and the boundary conditions by $\phi \left(0\right)={\phi }_{0}$ and $\phi \left(L\right)={\phi }_{L}$ , the domain can be discretised (non-uniformly) by a total of $N+1$ grid points for the finite difference solution of the problem.

The diffusion term can be approximated using the central difference (both the inner and outer derivative) as: (5)
$\frac{d}{dx}{\left(ϵ\frac{d\phi }{dx}\right)}_{i}\approx \frac{{\left(ϵ\frac{d\phi }{dx}\right)}_{i+\frac{1}{2}}-{\left(ϵ\frac{d\phi }{dx}\right)}_{i-\frac{1}{2}}}{\frac{1}{2}\left({x}_{i+1}-{x}_{i-1}\right)}$
(6)
$\frac{d}{dx}{\left(ϵ\frac{d\phi }{dx}\right)}_{i}\approx \frac{\left({ϵ}_{i+\frac{1}{2}}\frac{{\phi }_{i+1}-{\phi }_{i}}{{x}_{i+1}-{x}_{i}}\right)-\left({ϵ}_{i-\frac{1}{2}}\frac{{\phi }_{i}-{\phi }_{i-1}}{{x}_{i}-{x}_{i-1}}\right)}{\frac{1}{2}\left({x}_{i+1}-{x}_{i-1}\right)}$
The convection term can also be approximated using the central difference as: (7)
$\frac{d}{dx}{\left(\rho u\phi \right)}_{i}\approx \frac{{\left(\rho u\phi \right)}_{i+1}-{\left(\rho u\phi \right)}_{i-1}}{{x}_{i+1}-{x}_{i-1}}$
If the grid is uniform and the values of density, velocity and coefficient of diffusion are constant throughout the domain the above equations reduce to: (8)
$\rho u\frac{{\phi }_{i+1}-{\phi }_{i-1}}{2\Delta x}=ϵ\frac{{\phi }_{i+1}-2{\phi }_{i}+{\phi }_{i-1}}{\Delta {x}^{2}}$

The resulting set of linear algebraic equations can be solved to get the values of at the grid points.

Finite difference methods are advantageous for the numerical solution of partial differential equations because of their simplicity, efficiency and low computational cost. Their major drawback is their geometrical inflexibility, such as application on an unstructured grid or moving boundaries. Their formulation increases in complexity as the complexity of the domain increases.

The restrictions resulting from the above mentioned geometrical complexities can be alleviated by the use of methods such as grid transformation and immersed boundary techniques.