Finite Difference: How to handle a square wave boundary condition for the diffusion equation?

104 Views Asked by At

A semi-infinite rod (L ~ 10 m) with one end at $u(0,t) = f(t)$ and other at $u(L,t) = 0$ has an initial condition given by $u(x,0) = f(t_0)e^{-0.8x} $.

$f(t)$ is a square wave with period $2\pi$ and amplitude $A=2$ (assume wave is symmetric about x-axis).


Edit: If the problem used a sine/cosine wave boundary then I think it'd be easier to deal with however how to deal with a square wave and correctly simulate the lag it introduces (just like sine/cosine wave)?


$\textbf{My attempt}$: I used the Backward Euler discretization and for the time interval $(0,2\pi)$ and used the boundary values $u (0| L, t) = f(t_0), 0$ along with the initial condition.

However, this won't work I guess because the true solution has a phase lag while my approach doesn't produce any. My problem is: How do I formulate the boundary condition properly in this case?

Any help/suggestion is appreciated. Thanks in advance.