Numerical Solution to Advection Equation I was wondering if classic Schemes like Lax-Friedrichs, Lax-Wendroff or Upwind Schemes work for the following PDE
$$\dfrac{\partial u}{\partial t}+e^{-x}(\cos(t)+2)\dfrac{\partial u}{\partial x}=1+u^2$$ with initial condition 
$$u(x,0) = e^{-x^2}$$
I've tried solving them with the schemes mentioned above with different time step $$\Delta t \leq \dfrac{\Delta x}{\max|a(x,t)|}$$ where $a(x,t)=e^{-x}(\cos(t)+2)$ but I always end up with unstable solutions. If anyone could point me in a direction or a source that would be great!
 A: We consider here a balance law of the form
$$
\partial_t u + a \partial_x u = r (u)
$$
where $a = e^{-x}(\cos t + 2)$ and $r (u) = 1+u^2$. As indicated in the comments, the solution from the method of characteristics blows up in finite time. Nevertheless, let us consider numerical integration up to this blow-up time. We write an explicit finite-volume discretization using the Lax-Friedrichs method:
$$
u_i^{n+1} = \frac{1}{2}(u_{i-1}^n+u_{i+1}^n) - \frac{\Delta t}{2\Delta x}a_i^n \left(u_{i+1}^n- u_{i-1}^n\right) + \Delta t\, r(u_i^n)\, ,
$$
where $u_i^n\simeq u(i\Delta x, n\Delta t)$ and $a_i^n = a(i\Delta x, n\Delta t)$.
This method is stable under the condition
$$
\Delta t \leq \min_i \min \left\lbrace \frac{\Delta x}{|a_i^n|}, \frac{2}{|r'(u_i^n)|}\right\rbrace .
$$
The first stability restriction corresponds to the Courant-Friedrichs-Lewy (CFL) condition, while the second stability restriction is due to the first-order explicit time integration (forward Euler integration). Depending on the value of $r(u_i^n)$, this may be penalizing.
An alternative strategy relies on operator splitting, and unconditionally stable integration of the relaxation term. A Godunov splitting scheme based on the Lax-Friedrichs method and the backward Euler method reads
\begin{aligned}
u_i^{*} &= \frac{1}{2}(u_{i-1}^n+u_{i+1}^n) - \frac{\Delta t}{2\Delta x}a_i^n \left(u_{i+1}^n- u_{i-1}^n\right) \\
u_i^{n+1} &= u_i^* + \Delta t\, r(u_i^{n+1})
\end{aligned}
which is stable under the CFL condition.
