1
$\begingroup$

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.

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

1 Answer 1

3
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ Thanks! It actually just turned out to be a typo in my code. $\endgroup$
    – Mike D
    Nov 10, 2020 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.