# How numerical diffusion is related to advection term?

I have crude idea that numerical diffusion arises while using upwind scheme and causes solution to deviate from its original one. But I am unable to understand how numerical diffusion phenomenon is (directly) related to advection phenomenon?

I would like to add that besides the spatial discretization the temporal discretization can also introduce numerical diffusion.

Consider the advection equation $$u_t + cu_x = 0$$ where I use the subscripts for partial derivatives: $$u_i \equiv \frac{\partial u}{\partial i}$$.

Applying a general $$\theta$$-scheme to discretize the temporal derivative yields the semi-discrete formulation: $$\frac{u^{(n + 1)} - u^{(n)}}{\Delta t} = - c\Big( \theta u_x^{(n + 1)} + (1 - \theta) u_x^{(n)} \Big)$$ where $$\theta \in [0, 1]$$ and $$n$$ denotes the time index which is written in parantheses to distinguish it from powers. Note that $$\theta = \begin{cases} 0 & \text{Euler Forward} \\ 0.5 & \text{Crank-Nicolson} \\ 1 & \text{Euler Backward} \\ \end{cases}$$

Now expand $$u$$ (assuming sufficient regularity) for a fixed $$\theta$$ around $$t^\star \equiv t^{(n)} + \theta \Delta t$$ in a Taylor-Series:

\begin{align} u(t^{(n)}) = u^{(n)} =& u(t^\star) + u_t(t^\star) (t^{(n)} - t^\star) + 0.5 u_{tt}(t^\star) (t^{(n)} - t^\star) + \mathcal{O}\big((\Delta t)^3\big) \\ =& u(t^\star) -\theta \Delta t u_t(t^\star) + 0.5 u_{tt}(t^\star) \theta^2 (\Delta t)^2 + \mathcal{O}\big((\Delta t)^3\big) \end{align} and \begin{align} u(t^{(n + 1)}) = u^{(n + 1)} =& u(t^\star) + u_t(t^\star) (t^{(n + 1)} - t^\star) + 0.5 u_{tt}(t^\star) (t^{(n + 1)} - t^\star) + \mathcal{O}\big((\Delta t)^3\big) \\ =& u(t^\star) + (1 - \theta) \Delta t u_t(t^\star) + 0.5 u_{tt}(t^\star) (1 - \theta)^2 (\Delta t)^2 + \mathcal{O}\big((\Delta t)^3\big) \end{align}

thus $$\frac{u^{(n + 1)} - u^{(n)}}{\Delta t} = u_t(t^\star) + 0.5 ( 1- 2 \theta) \Delta t u_{tt}(t^\star) + \mathcal{O}\big((\Delta t)^2\big)$$

At the same time (using the Taylor-Expansions written out above) for the spatial derivative $$u_x$$ and truncating already after the linear term gives

$$u_x^{(n)} = u_x(t^\star) -\theta \Delta t u_{xt}(t^\star) + \mathcal{O}\big((\Delta t)^2\big)$$ and $$u_x^{(n + 1)} = u_x(t^\star) + (1 - \theta) \Delta t u_{xt}(t^\star) + \mathcal{O}\big((\Delta t)^2\big)$$

and thus

$$\theta u_x^{(n + 1)} + (1 - \theta) u_x^{(n)} = u_x(t^\star) + \mathcal{O}\big((\Delta t)^2\big)$$

We performed a Taylor Expansion, so let's take a look at the truncation error: \begin{align} e =& \frac{u^{(n + 1)} - u^{(n)}}{\Delta t} \Bigg|_\text{Taylor} + c\Big( \theta u_x^{(n + 1)} + (1 - \theta) u_x^{(n)} \Big)\Bigg|_\text{Taylor} \\ =& u_t(t^\star) + 0.5 ( 1- 2 \theta) \Delta t u_{tt}(t^\star) + c u_x(t^\star) + \mathcal{O}\big((\Delta t)^2\big) \\ \overset{u_t(t) + cu_x(t) = 0 \: \forall \: t}{=}& (0.5 - \theta) \Delta t u_{tt}(t^\star) + \mathcal{O}\big((\Delta t)^2\big) \end{align}

Deriving the original PDE with respect to time yields $$u_{tt} + c u_{xt} = 0$$ and noting that $$u_{xt} = \partial_x u_t = \partial_x (-c u_x) = -c u_{xx}$$ so $$e = c(-0.5 + \theta) \Delta t u_{xx}(t^\star) + \mathcal{O}\big((\Delta t)^2\big)$$ so the differential equation that is solved turns out to be $$\tilde u_t + c \Big( (\theta - 0.5) \Delta t \tilde u_{xx} + \tilde u_x \Big) = 0$$ This is why for the Crank-Nicolson scheme is preferably used when advection-related phenomena are of particular interest.

The numerical diffusion is not related to an equation specifically but is related to the way you discretize this equation.

Depending on the discretization stencil you choose (upwind, downwind, centered, hybrid...), you scheme can be diffusive, compressive or dispersive according to the sign and the order of the derivatives involved in the truncation error. You can understand that by deriving and analysing the truncation error through a Taylor expansion, I did an example here where I explain why the advection equation discretized with an upwind scheme produces numerical diffusion.