# Explicit Methods for the Model Hyperbolic PDE

The one-dimensional wave equation or linear convection equation is given by the following partial differential equation.

$$
\frac{\partial u}{\partial t} + c \frac{\partial u}{\partial x} = 0
$$

When we solve this PDE numerically, we divide the spatial and temporal domains into a series of mesh points and time points. Assume our problem domain is of length $L$, and that we want to compute the solution of $u(x,t)$ between time equals to zero to some final time, $t_f$ for all values of $x$ between zero and $L$. The first step in solving our PDE numerically is to divide the domain, $0 \leq x \leq L$, into a discrete number of mesh points or nodes, $N_x$. Likewise, we also divide the time domain, $0 \leq t \leq t_f$, into a discrete number of time steps, $N_t$. If we do so uniformally in time and space, then the distance bewteen each mesh point is $\Delta x$, and the distance between each time step is $\Delta t$. 

In other words, for a uniform mesh size and a uniform time step, the value of $x$ for the i-th node is 

$$
x_i = i \Delta x
$$

and the time at each time step, $n$, is

$$
t_n = n \Delta t
$$

The goal is to approximate this PDE as a difference equation, meaning that we want to represent the PDE using only a discrete number of mesh points, $N_x$, and time points, $N_t$. To do this requires using a Taylor series expansion about each point in the mesh, both in time and space, to approximate the time and space derivatives of $u$ in terms of a difference formula. Since in our Taylor series expansion we choose only a finite number of terms, these difference formulas are known as finite-difference approximations.

Since there are many different finite-difference formulas, let use define a common nomenclature. Let the symbol $\mathcal{D}$ represent a difference approximation. The subscript of $\mathcal{D}$ shall represent the direction of the finite-difference, forward (+), backward (-), or central (0). Last, let the denominator represent the domain over which the finite-difference formula is used. For the Cartesian domain, let us use the $\Delta x$ to represent a finite-difference approximation in the $x$-direction. Likewise, $\Delta y$ would represent a finite-difference approximation in the $y$-direction.




## First-Derivative Approximations

Using this nomenclature described above, let use define a set of finite-difference approximations for the first directive of the variable $\phi$ with respect to $x$. In other words, what are the available finite-difference formulae for 

$$
\frac{ \partial \phi }{ \partial x} = \textrm{Finite-difference Approximation} + \textrm{Truncation Error}
$$

These expressions can be derived using a Taylor series expansion. By keeping track of the order of the higher-order terms neglected or truncated from the Taylor series expansion, we can also provide an estimate of the truncation error. We say that a finite-difference approximation is first-order accurate if the truncation error is of order $\mathcal{O} (\Delta x)$. It is second-order accurate if the truncation error is of order $\mathcal{O} (\Delta x^2)$. 

**Forward difference**, first-order accurate, $\mathcal{O} (\Delta x)$

- Equally spaced

$$
\frac{\mathcal{D}_{+}\cdot}{\Delta x} \phi_i = \frac{\phi_{i+1} - \phi_i}{\Delta x}
$$

- Nonequally spaced

$$
\frac{\mathcal{D}_{+}\cdot}{\Delta x} \phi_i = \frac{\phi_{i+1} - \phi_i}{x_{i+1} - x_i}
$$


**Backward difference**, first-order accurate, $\mathcal{O} (\Delta x)$

- Equally spaced

$$
\frac{\mathcal{D}_{-}\cdot}{\Delta x} \phi_i = \frac{\phi_{i} - \phi_{i-1}}{\Delta x}
$$

- Nonequally spaced

$$
\frac{\mathcal{D}_{-}\cdot}{\Delta x} \phi_i = \frac{\phi_{i} - \phi_{i-1}}{x_{i} - x_{i-1}}
$$

**Central difference**, second-order accurate, $\mathcal{O} (\Delta x^2)$

- Equally spaced

$$
\frac{\mathcal{D}_{0}\cdot}{\Delta x} \phi_i = \frac{\phi_{i+1} - \phi_{i-1}}{2\Delta x}
$$

- Nonequally spaced

$$
\frac{\mathcal{D}_{0}\cdot}{\Delta x} \phi_i = \frac{\phi_{i+1} - \phi_{i-1}}{x_{i+1} - x_{i-1}}
$$

## Difference Equations for the Model Hyperbolic PDE

Let us use the above finite-difference approximations to derive several difference equations for the model hyperbolic PDEs. We have free reign in this choice, and most importantly, we certainly not limited to those provided above. It is possible to derive, third and fourth-order finite-difference approximations. These higher-order methods can become increasingly complex. Note, however, that while we can freely choose the difference approximation, we still need to check that this difference equation is not only consistent but also stable. Different combinations of time and spatial difference approximations result in different numerically stability.

### Forward-Time, Backward Space

Using a forward-time, backward-space difference approximation, the partial differential equation, 

$$
\frac{\partial u}{\partial t} + c \frac{\partial u}{\partial x} = 0
$$

is transformed into the following difference equation, 

$$
\frac{\mathcal{D}_{+}}{\Delta t} \Big( u^n_i \Big) + c \frac{\mathcal{D}_{-}}{\Delta x} \Big( u^n_i \Big)  = 0,
$$

which we can then expand as 

$$
\frac{ u^{n+1}_i -  u^n_i }{\Delta t} + c \frac{ u^n_i -  u^n_{i-1} }{\Delta x}  = 0.
$$

From the truncation error of the difference approximations, we can say that this method is first-order accurate in time and space, in other words the truncation error is of the order $\mathcal{O}(\Delta t, \Delta x)$. We can represent this numerical method using the following diagram.



The *stencil* diagram visually shows the mesh points and time points that are used in the difference equation.


### Forward-Time, Forward Space

Using a forward-time, forward-space difference approximation, the partial differential equation, 

$$
\frac{\partial u}{\partial t} + c \frac{\partial u}{\partial x} = 0
$$

is transformed into the following difference equation, 

$$
\frac{\mathcal{D}_{+}}{\Delta t} \Big( u^n_i \Big) + c \frac{\mathcal{D}_{+}}{\Delta x} \Big( u^n_i \Big)  = 0,
$$

which we can then expand as 

$$
\frac{ u^{n+1}_i -  u^n_i }{\Delta t} + c \frac{ u^n_{i+1} -  u^n_{i} }{\Delta x}  = 0.
$$

From the truncation error of the difference approximations, we can say that this method is first-order accurate in time and space, in other words the truncation error is of the order $\mathcal{O}(\Delta t, \Delta x)$. We can represent this numerical method using the following diagram.



The *stencil* diagram visually shows the mesh points and time points that are used in the difference equation.



### Forward-Time, Central Space

Using a forward-time, central-space difference approximation, the partial differential equation, 

$$
\frac{\partial u}{\partial t} + c \frac{\partial u}{\partial x} = 0
$$

is transformed into the following difference equation, 

$$
\frac{\mathcal{D}_{+}}{\Delta t} \Big( u^n_i \Big) + c \frac{\mathcal{D}_{0}}{\Delta x} \Big( u^n_i \Big)  = 0,
$$

which we can then expand as 

$$
\frac{ u^{n+1}_i -  u^n_i }{\Delta t} + c \frac{ u^n_{i+1} -  u^n_{i-1} }{2 \Delta x}  = 0.
$$

From the truncation error of the difference approximations, we can say that this method is first-order accurate in time and second-order in space, in other words the truncation error is of the order $\mathcal{O}(\Delta t, \Delta x^2)$. We can represent this numerical method using the following diagram.



The *stencil* diagram visually shows the mesh points and time points that are used in the difference equation.




## Are all these methods stable? 

***We need to apply von Neumann stability analysis to each of these difference equations to determine under what conditions, i.e., for what values of $\Delta t$ and $\Delta x$, is the numerical method stable?***

# Summary of Numerical Methods

## Explicit, Forward-Time, Backward-Space (FTBS)

$$
\begin{align}
\textrm{Method :}\quad & u^{n+1}_i = u^n_i - c \Delta t \frac{\mathcal{D}_{-} \cdot}{\Delta x} u_i^n \\
\textrm{Stability Criteria :}\quad & c > 0, \quad \Delta t \le \frac{\Delta x}{|c|} \\
\textrm{Order of Accuracy :}\quad & \mathcal{O}\left(\Delta t, \Delta x\right)
\end{align}
$$

## Explicit, Forward-Time, Forward-Space (FTFS)

$$
\begin{align}
\textrm{Method :}\quad & u^{n+1}_i = u^n_i - c \Delta t \frac{\mathcal{D}_{+} \cdot}{\Delta x} u_i^n \\
\textrm{Stability Criteria :}\quad & c < 0, \quad \Delta t \le \frac{\Delta x}{|c|} \\
\textrm{Order of Accuracy :}\quad & \mathcal{O}\left(\Delta t, \Delta x\right)
\end{align}
$$

Note that this method is only stable for $c < 0$.

## Explicit, Forward-Time, Central-Space (FTCS)

$$
\begin{align}
\textrm{Method :}\quad & u^{n+1}_i = u^n_i - c \Delta t \frac{\mathcal{D}_{0} \cdot}{\Delta x} u_i^n \\
\textrm{Stability Criteria :}\quad & \textrm{Always unstable} \\
\textrm{Order of Accuracy :}\quad & \mathcal{O}\left(\Delta t, \Delta x^2\right)
\end{align}
$$

This method is *always* unstable.

## Lax


$$
\begin{align}
\textrm{Method :}\quad & u^{n+1}_i = \frac{u^n_{i-1} + u^n_{i+1}}{2} - c \Delta t \frac{\mathcal{D}_{0} \cdot}{\Delta x} u_i^n \\
\textrm{Stability Criteria :}\quad & \Delta t \le \frac{\Delta x}{|c|} \\
\textrm{Order of Accuracy :}\quad & \mathcal{O}\left(\Delta t, \frac{\Delta x^2 } { \Delta t}, \Delta x^2\right)
\end{align}
$$

The Lax algorithm is an *inconsistent* difference equation because the truncation error is not gaurenteed to go to zero. It only does so if $\Delta x^2$ goes to zero faster than $\Delta t$.

## Lax-Wendroff


$$
\begin{align}
\textrm{Method :}\quad & u^{n+1}_i = u^n_i - c \Delta t \frac{\mathcal{D}_{0} \cdot}{\Delta x} u_i^n + \frac{1}{2}c^2 \Delta t^2 \frac{\mathcal{D}_{+} \cdot}{\Delta x} \frac{\mathcal{D}_{-} \cdot}{\Delta x} u_i^n \\
\textrm{Stability Criteria :}\quad & \Delta t \le \frac{\Delta x}{|c|} \\
\textrm{Order of Accuracy :}\quad & \mathcal{O}\left(\Delta t^2, \Delta x^2\right)
\end{align}
$$

## MacCormack


$$
\begin{align}
\textrm{Method :}\quad & u^{\overline{n+1}}_i = u^n_i - c \Delta t \frac{\mathcal{D}_{+} \cdot}{\Delta x} u_i^n \\
                       & u^{n+1}_i = \frac{1}{2} \left[u^n_i + u^{\overline{n+1}}_i - c \Delta t \frac{\mathcal{D}_{-} \cdot}{\Delta x} u^{\overline{n+1}}_i \right] \\
\textrm{Stability Criteria :}\quad & \Delta t \le \frac{\Delta x}{|c|} \\
\textrm{Order of Accuracy :}\quad & \mathcal{O}\left(\Delta t^2, \Delta x^2\right)
\end{align}
$$

## Jameson


$$
\begin{align}
\textrm{Method :}\quad & u^{(0)} = u^n_i \\ 
                       & u^{(k)} = u^n_i - \alpha_k c \Delta t \frac{\mathcal{D}_{0} \cdot}{\Delta x} u_i^{(k-1)} \\
                       & \qquad \textrm{where} \,\, \alpha_k = \frac{1}{5 - k}, \,\, k = 1, 2, 3, 4 \\
                       & u^{n+1}_i = u^{(4)}_i \\
\textrm{Stability Criteria :}\quad & \Delta t \le \frac{2 \sqrt{2} \Delta x}{|c|} \\
\textrm{Order of Accuracy :}\quad & \mathcal{O}\left(\Delta t^4, \Delta x^2\right)
\end{align}
$$

## Warming-Beam


$$
\begin{align}
\textrm{Method :}\quad & u^{n + 1/2}_i = u^n_i - \frac{ c \Delta t }{2} \frac{\mathcal{D}_{-} \cdot}{\Delta x} u_i^n \\
                       & u^{n+1}_i = u^n_i - c \Delta t \frac{\mathcal{D}_{-} \cdot}{\Delta x} 
                       \left[ u^{n+1/2}_i + \frac{\Delta x}{2} \frac{\mathcal{D}_{-} \cdot}{\Delta x} u^n_i \right] \\
\textrm{Stability Criteria :}\quad & \Delta t \le \frac{2 \Delta x}{|c|} \\
\textrm{Order of Accuracy :}\quad & \mathcal{O}\left(\Delta t^2, \Delta x^2\right)
\end{align}
$$

## More difference equations

Let us look more closely at the Lax-Wendroff algorithm. We see the term like the following

$$
\frac{\mathcal{D}_{+} \cdot}{\Delta x} \frac{\mathcal{D}_{-} \cdot}{\Delta x} u_i^n 
$$

what does mean? How do we apply two difference approximations? *This operators can be linearly combined,* so we just need to apply the first difference approximation, and then apply the second difference approximation on each of the remaing terms. Here is what that looks like for the above expression.

$$
\frac{\mathcal{D}_{+} \cdot}{\Delta x} \left[ \frac{\mathcal{D}_{-} \cdot}{\Delta x} u_i^n \right] = 
\frac{\mathcal{D}_{+} \cdot}{\Delta x} \left[ \frac{u^n_i - u^n_{i-1}}{\Delta x} \right] = 
\frac{1}{\Delta x} \left[ \frac{\mathcal{D}_{+} \cdot}{\Delta x}\Big( u^n_i \Big) - \frac{\mathcal{D}_{+} \cdot}{\Delta x} \Big( u^n_{i-1} \Big) \right] 
$$

Now applying the second difference operator, results in 

$$
\frac{\mathcal{D}_{+} \cdot}{\Delta x} \frac{\mathcal{D}_{-} \cdot}{\Delta x} u_i^n = 
\frac{1}{\Delta x} \left[ \frac{\mathcal{D}_{+} \cdot}{\Delta x}\Big( u^n_i \Big) - \frac{\mathcal{D}_{+} \cdot}{\Delta x} \Big( u^n_{i-1} \Big) \right] =
\frac{1}{\Delta x} \left[ \frac{u^n_{i+1} - u^n_i}{\Delta x} - \frac{u^n_{i} - u^n_{i-1}}{\Delta x} \right] =
\frac{u^n_{i+1} - 2 u^n_i + u^n_{i-1} }{\Delta x^2} 
$$





0d3b42f5c5a58015e1efdbc00bf907fca0530b29
ipynb
Jupyter Notebook
Notebooks/LinearConvection/5-LinearConvection-ExplicitMethods.ipynb
jcschulz/ae269
5c467a6e70808bb00e27ffdb8bb0495e0c820ca0
MIT
Notebooks/LinearConvection/5-LinearConvection-ExplicitMethods.ipynb
jcschulz/ae269
5c467a6e70808bb00e27ffdb8bb0495e0c820ca0
MIT
Notebooks/LinearConvection/5-LinearConvection-ExplicitMethods.ipynb
jcschulz/ae269
5c467a6e70808bb00e27ffdb8bb0495e0c820ca0
MIT
Qwen/Qwen-72B
1. YES
2. YES