The classical advection equation is given by: $$ \begin{equation} \label{eq:6101} \frac{\partial u}{\partial t} + a_0 \frac{\partial u}{\partial x} = 0, \end{equation} $$
where \( u = u(x, t) \). It is linear and also have an analytical solution: $$ \begin{equation}\label{eq:hyp_analytical} u = u_0(x-a_0\,t ), \end{equation} $$
In which \( u_0(x) \) is an initial solution/wave (\( u(x, 0)=u_0(x) \)), which we choose to be a smooth sine squared wave between \( x=0 \) and \( x=0.2 \): $$ \begin{align}\label{eq:initialWave} u_0(x) = sin^2(\pi(x/0.2)), \quad 0 < x < 0.2, \\ u_0(x) = 0, \quad 0.2 \leq x \leq l, \label{_auto1} \end{align} $$
where \( l = 1 \). Choose a suitable discretization \( \Delta x = \frac{l}{N} \) and calculate \( \Delta t \) from the CFL condition. Simulate from \( t_{start}=0 \) to \( t_{end}=0.8 \). This way we avoid the need to introduce special boundary conditions. (The wave will not leave the domain, and \( u(0)=0 \) and \( u(l)=0 \)). Otherwise the following boundarycondtions should be applied at the right boundary: $$ \begin{equation}\label{eq:bc} u(l)^{n + 1} = u(l - a \cdot \Delta t)^n, \end{equation} $$
where \( n \) denotes the previous timestep, \( a \) is the wavespeed (\( a_0 \)), and \( u(l - a \cdot \Delta t) \) can be found by interpolation.
The forward in time backward in space (ftbs), or upwind scheme in non-conservative form may be written as follows: $$ \begin{equation} \label{eq:ftbs_conservative} u_j^{n+1}=u_j^n - \frac{a_0 \Delta t}{\Delta x}\left(u_j^n-u_{j-1}^n\right) \end{equation} $$
a) Compare ftbs with the analytical solution for the linear advection equation. choose \( a_0=1 \) and a cfl-constraint condition of \( c=1 \).
Now let's look at a nonlinear case of the advection equation, in which the wavespeed a is nolonger constant: $$ \begin{equation} \label{eq:advection_nonLin} \frac{\partial u}{\partial t} + a(u) \frac{\partial u}{\partial x} = \frac{\partial u}{\partial t} + (0.9 + 0.1u) \frac{\partial u}{\partial x} = 0 \end{equation} $$
Now we can modify the nonconservative ftbs scheme to work for the non-constant wavespeed: $$ \begin{equation} \label{eq:ftbs_conservative_nonLin} u_j^{n+1}=u_j^n - \frac{a_j^n \Delta t}{\Delta x}\left(u_j^n-u_{j-1}^n\right) \end{equation} $$
b) set \( a(u) = 0.9 + 0.1u \) and solve Eq. \eqref{eq:advection_nonLin} with the scheme given in \eqref{eq:ftbs_conservative_nonLin}
c) Rewrite Eq. \eqref{eq:advection_nonLin} so that it is written in conservative form: $$ \begin{equation} \label{eq:advection_nonLin2} \frac{\partial u}{\partial t} + \frac{\partial F}{\partial x} = 0 \end{equation} $$
What is the expression of \( F \) if \( a(u) = 0.9 + 0.1u \)? Solve Eq. \eqref{eq:advection_nonLin2} numerically with a conservative ftbs scheme: $$ \begin{equation} \label{eq:ftbs_conservativeFlux} u_j^{n+1}=u_j^n - \frac{\Delta t}{\Delta x}\left(F_j^n-F_{j-1}^n\right) \end{equation} $$
d) Do a), b), and c) but using the MacCormack scheme instead of ftbs