2
$\begingroup$

Consider the following heat equation: $$ u_t=u_{xx} \quad\text{ on }\quad(0,\pi) $$ with mix boundary condition $u'(0)+u(0)=0$ and $u'(\pi)+u(\pi)=0$. The eigenfunctions of the laplacian are $$ e^{-x},n\cos(nx)-\sin(nx),\forall n\geq 1. $$

To solve it numerically, I use the standard finite difference, i.e., forward Euler in time and the central difference in space. That is $$ \frac{u^{n+1}_i-u^n_i}{dt}=\frac{u^n_{i-1}-2u^n_{i}+u^n_{i+1}}{h^2} $$ where $u_i^n=u(x_i,t_n)$.

If I take the initial condition as $u_0=e^{-x}$, the numerical solution looks good. However, if $u(x,0)=\cos x-\sin x$, the result is not good.

Let $u(x,0)=\cos x-\sin x$. Then the exact solution should be $e^{-t}(\cos x-\sin x)$. The following figures are the absolutely error and solution at time $T=10$,

absolutely error enter image description here

It seems that the shape of the numerical solution looks like $e^{-x}$ the first eigenfunction of laplacian with the boundary condition.

I am quite confused about this result.

$\endgroup$
11
  • $\begingroup$ I think it would be helpful to supply more information about your discretization. Right now, the problem could be as simple as a sign error somewhere in your discretization, but for a potential answerer of your question this would be difficult to verify. $\endgroup$
    – supinf
    Commented Feb 19, 2020 at 16:53
  • $\begingroup$ Since you provided no information on your boundary condition, I am going to assume that is where the problem is, because Neumann and mixed boundary conditions are not trivial. Can you please explain your implementation of this boundary condition? $\endgroup$
    – whpowell96
    Commented Feb 19, 2020 at 17:23
  • $\begingroup$ This type of error is really not particularly surprising because the eigenvalue corresponding to $e^{-x}$ is positive, so that contribution to the Fourier series of $u(t,\cdot)$ grows exponentially while the others decay exponentially. $\endgroup$
    – Ian
    Commented Feb 19, 2020 at 17:24
  • $\begingroup$ (Cont.) Initially of course you have no contribution from this eigenfunction, but after a time step your numerical solution has some contribution from it due to truncation error, and then that contribution grows exponentially under the dynamics. So this problem is really to be expected even if your implementation of the forward-in-time-centered-in-space scheme is entirely correct. $\endgroup$
    – Ian
    Commented Feb 19, 2020 at 17:25
  • $\begingroup$ @lan Gotcha. Thank you very much. So, in this case, the scheme is kind of not stable for this, right? $\endgroup$
    – Q-Y
    Commented Feb 19, 2020 at 17:31

1 Answer 1

2
$\begingroup$

Just to wrap up the question:

The underlying dynamics in this problem are unstable, because $e^{-x}$ is an eigenfunction of the Laplacian with a positive eigenvalue in this situation. Thus although the true dynamics started from $\cos(x)-\sin(x)$ are just exponential decay, the numerical dynamics deviate slightly from this, enough that effectively a contribution to $u(t,\cdot)$ from $e^{-x}$ appears. The true dynamics then grow this new contribution exponentially, and so do the numerical dynamics. This happens with pretty much any numerical method you might try to use for such a problem.

Physically this is caused by the fact that the boundary condition on the left gives positive feedback: the inward flux at $0$ is proportional to $-u'(0)$ which is proportional to $u(0)$, so effectively you have a situation along the lines of $\frac{d}{dt} u(t,0)=u(t,0)$.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .