Forward Euler PDE (grid method) misunderstanding – Is the question missing a detail

numerical methodspartial differential equations

We are interested in solving the advection equation $u_t = u_x$ where $0\leq x < 1$, $t \geq 0$

with periodic boundary conditions and $u(x,0) = f(x),f(x) = f(x+1)$
In the grid $x_0,x_1,\dots x_N$, $t_0,t_1,\dots t_N$.

using the forward euler method, or $\frac{v(x_j,t_{n+1}) – v(x_j,t_n)}{\Delta t}= \frac{v(x_{j+1},t_n)-v(x_{j-1},t_n)}{2\Delta x}$ where $v$ is the approximation of $u$ at the grid points.

What I don't understand:

We are essentially using $v(x_{j-1},t_n), v(x_j,t_n),v(x_{j+1},t_n)$ to calculate $v(x_j,t_{n+1})$. Initially this is fine because $v(x_j,0)$ is known for all $j$, but how would we calculate $v(x_0,t_1)$? we can't, since that would require us to know $v(x_{-1}, t_0)$ which doesn't exist. And this issue propagates, each new $t_n$ we can calculate one less point than $t_{n-1}$.

What am I missing?

Best Answer

Your recurrence relation for the forward time, central space scheme is $$u_{j}^{n+1} = -\gamma u_{j-1}^{n} + u_{j}^{n} + \gamma u_{j+1}^{n}$$ where $\gamma = \Delta t/(2\Delta x)$. Writing the first few terms out (for $j=1,..,M-1$) yields

\begin{align} u_{1}^{n+1} &= -\gamma u_{0}^{n} + u_{1}^{n} + \gamma u_{2}^{n} \\ u_{2}^{n+1} &= -\gamma u_{1}^{n} + u_{2}^{n} + \gamma u_{3}^{n} \\ \vdots \\ u_{M-1}^{n+1} &= -\gamma u_{M-2}^{n} + u_{M-1}^{n} + \gamma u_{M}^{n} \end{align}

which we can write as a matrix

$$\begin{pmatrix} u_{1}^{n+1} \\ u_{2}^{n+1} \\ u_{3}^{n+1} \\ \vdots \\ u_{M-1}^{n+1} \end{pmatrix} = \begin{pmatrix} 1 & \gamma & & & \\ -\gamma & 1 & \gamma & \\ & -\gamma & 1 & \gamma & \\ \\ & & & -\gamma & 1 \end{pmatrix} \begin{pmatrix} u_{1}^{n} \\ u_{2}^{n} \\ u_{3}^{n} \\ \vdots \\ u_{M-1}^{n} \end{pmatrix} + \begin{pmatrix} -\gamma u_{0}^{n} \\ 0 \\ 0 \\ \vdots \\ \gamma u_{M}^{n} \end{pmatrix} \tag 1$$

To answer your question 'how would we calculate $v(x_{0},t_{1})$?', periodic boundary conditions imply $u_{0}^{n} = u_{M-1}^{n}$ and $u_{1}^{n} = u_{M}^{n}$ for all $n$ (time). Therefore, we can rewrite the matrix equation $(1)$ as

$$\begin{pmatrix} u_{1}^{n+1} \\ u_{2}^{n+1} \\ u_{3}^{n+1} \\ \vdots \\ u_{M-1}^{n+1} \end{pmatrix} = \begin{pmatrix} 1 & \gamma & & & -\gamma \\ -\gamma & 1 & \gamma & \\ & -\gamma & 1 & \gamma & \\ \\ \gamma & & & -\gamma & 1 \end{pmatrix} \begin{pmatrix} u_{1}^{n} \\ u_{2}^{n} \\ u_{3}^{n} \\ \vdots \\ u_{M-1}^{n} \end{pmatrix} \tag 2$$

We also know that the initial condition $u(x,0) = f(x) \implies u_{j}^{0} = f_{j}$ where $f_{j} = f(x_{j})$ is $f(x)$ evaluated at the spatial grid points $x_{j}$. So for the first iteration we need to solve

$$\begin{pmatrix} u_{1}^{1} \\ u_{2}^{1} \\ u_{3}^{1} \\ \vdots \\ u_{M-1}^{1} \end{pmatrix} = \begin{pmatrix} 1 & \gamma & & & -\gamma \\ -\gamma & 1 & \gamma & \\ & -\gamma & 1 & \gamma & \\ \\ \gamma & & & -\gamma & 1 \end{pmatrix} \begin{pmatrix} f_{1} \\ f_{2} \\ f_{3} \\ \vdots \\ f_{M-1} \end{pmatrix}$$

and thereafter we solve $(2)$.

Related Question