# Finite Difference for Advection Equation With Source

I'm trying to find a convergent finite difference scheme for the PDE $$$$\begin{split} u_t + (x-1) u_x &= (x-1)u, \hspace{.5cm} x \in [0,1] \\ u(x,0) &= 1 \\ u(1,t) &= 1. \\ \end{split}$$$$ I know that the exact solution is $$u(x,t) = e^{(x-1)(1-e^{-t})}$$, but just wanted some practice working with finite difference schemes. I naively chose the forward-time forward-space with frozen coeeficients discretization $$$$\frac{u_m^{n+1} - u_m^n}{k} + (x_m-1)\frac{u_{m+1}^n - u_m^n}{h} = (x_m - 1) u_m^n$$$$ since characteristics move from right to left. However, even with $$\frac{k}{h} < 1$$, the approximate solution is highly unstable. Is this type of discretization insufficient for variable-coefficient advection with a source term? Thanks in advance.

• Since $x-1\ge0$, the solution moves to the right, not to the left. You are using a downwind-biased (and therefore unstable) approximation. – David Ketcheson Nov 11 '20 at 5:25

The choice of $$k$$ is restricted also by the discretization of the source term. To see it, rewrite your scheme to $$$$u_m^{n+1} = \left(1 - \frac{k(1-x_m)}{h} - k(1-x_m)\right) u_m^n + \frac{k (1-x_m)}{h} u_{m+1}^n \,.$$$$ You need $$1 - \frac{k(1-x_m)}{h} - k(1-x_m) \ge 0$$ for all $$x_m$$. Taking $$x_m=0$$ (the worst case scenario) you obtain $$1 - \frac{k}{h} - k\ge 0$$ so your time step $$k$$ must satisfy $$k \le \frac{h}{1 + h} < h$$ that is more strict then the restriction you write.
If it still does not work for enough small $$k$$, there should be some implementation problem.