Choppy solution for square wave finite differenced wave equation

53 Views Asked by At

I am solving this wave equation $u_{tt} = 0.1 u_{xx}$

I am using central differences : $u_m^{n+1} = - u_m^{n-1} + 2u_m^n + \lambda (u^n_{m+1} - 2 u_m^n + u_{m - 1}^n)$

I set $dx = 0.1$ and $dt = 0.2$ so $\lambda = 0.4$

My boundaries are $u = 0$ for $x = 0, x=L$

My initial condition is a square wave : enter image description here

My question is, why does the solution look so choppy? Why doesn't the solution become smoother? Here is the solution after 600 time steps :

finite

I didn't perform the stability analysis, but I read somewhere that this scheme is stable for $\lambda < 1$.

5000 time steps : enter image description here

1

There are 1 best solutions below

0
On

Solved the problem. You need two initial conditions $u(t=1) = u^1, u(t=0) = u^0$.

I just built a square wave and set $u^1 = u^0$, this is why there was a problem. I needed to shift $u^1$ by a time step, and then the solution worked. enter image description here