I'm trying to find a convergent finite difference scheme for the PDE \begin{equation} \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} \end{equation} 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 \begin{equation} \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 \end{equation} 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.
1 Answer
The choice of $k$ is restricted also by the discretization of the source term. To see it, rewrite your scheme to \begin{equation} 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 \,. \end{equation} 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.
-
$\begingroup$ Thanks! It actually just turned out to be a typo in my code. $\endgroup$– Mike DNov 10, 2020 at 17:31