# Time and space discretization of one dimensional advection equation

I have the following one-dimensional advection equation:

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

and I would like to discretise this equation after time and space (either one of them or both) based on finite difference using the upwind scheme in first order.

So from Taylor series follows:

$$f(x+\Delta x)=f(x)+\Delta x\frac{f'(x)}{1}+\ldots$$

$$\Rightarrow f'(x)=\frac{f(x+\Delta x)-f(x)}{\Delta x}+\mathcal{O}(\Delta x)$$

How could I now exactly derive the time and space (time, space, time + space) discretization (so the numerical equation) of the one-dimensional advection equation?

One of the results looks as follows (found it in old code of mine - means I once knew what to do here):

$$u_2=u_1-c\cdot\frac{\Delta t}{\Delta x}(u_1-u_0)$$

not sure if this is a time or a space discretization or both?

I only thought about replacing $$\frac{\partial u}{\partial t}$$ with $$\frac{u_1-u_0}{\Delta t}$$ and $$\frac{\partial u}{\partial x}$$ with $$\frac{u_1-u_0}{\Delta x}$$

which leads to

$$(u_1-u_0)\left(\frac{1}{\Delta t}+c\cdot\frac{1}{\Delta x}\right)$$

but not to the result above - which seems to be the correct one (plotted the above/or the code I've written some time ago creates an animation of plots over $$t$$ which seems to be correct)

• I don’t understand your question. Just pick a grid of nodes that discretizes the domain and then formulate the appropriate differences. For example on a bounded space-time domain $[0,T]\times [a, b]$ one can use the equal step partition $(t_i, x_j)$ where $t_i=\Delta t i$ and $x_j=a+j\Delta x$ where $\Delta t=T/N$ and $\Delta x = (b-a)/M$ for some large naturals $N,M$. If the region is unbounded then you must impose artificial boundaries. Is this not sufficient? – Nap D. Lover Jul 15 at 18:33
• Could you be so kind and show it for the 3 examples (time, space, time and space discretization) from the question? – baxbear Jul 16 at 1:07
• You are going to have to clarify what you mean because I don’t understand and I already mentioned this in my first comment. I gave you a discretization of $[0,T]\times [a,b]$ where the first coordinate is time and the second coordinate is space. You then approximate the partials of $u(t,x)$ by finite differences on these grids. – Nap D. Lover Jul 16 at 1:18
• Okay, I add something to question which I think it could help. – baxbear Jul 16 at 10:40
• Well it certainly makes no sense to use the same indexes $u_1$ and $u_0$ when approximating derivatives in different variables! Look you wish to approximate the partial derivative at $(t,x)$, so we look at the grid $(t_i,x_j)$, and approximate the derivative at the grid point by a finite difference of $u_{ij}\approx u(t_i, x_j)$ where the first index and coordinate is for time and the second space. Then the time derivative could be approximated by forward difference at $(i,j)$ by $\frac{u_{i+1 j}-u_{ij}}{\Delta t}$. You similarly fix the time node in the difference approximation to $u_x$ – Nap D. Lover Jul 16 at 18:22