I am trying to animate the solution of a wave equation with initial condition being a gaussian wave packet travelling the the right. I know that the mathematical equation is something like $e^{\frac{-(x-a-vt)^2}{b^2}}$, where $a$ and $b$ are constants and $v$ is the velocity.
So I try to make the initial condition as $\psi(x,0)=e^{\frac{-(x-a)^2}{b^2}}$ and $\frac{\partial \psi(x,t)}{\partial t}\Bigr|_{t=0}=2v(x-a)/b^2e^{\frac{-(x-a)^2}{b^2}}$
Here is my code (where I have set $a=0.3$, $b=0.1, v=0.2)$:
ydum = x/L[t];
expr1 = 1/c^2 D[\[Psi][ydum, t], {t, 2}] -
D[\[Psi][ydum, t], {x, 2}] + (m^2 c^2)/
h^2 \[Psi][ydum, t] /. \[Psi][ydum, t] -> \[Psi][y, t] /.
x -> y L[t] // Expand
m = 1;
c = 1;
h = 1;
\[Omega] = 1;
L[t_] := 2 + Sin[\[Omega] t];
sol = NDSolve[{expr1 == 0,
DirichletCondition[\[Psi][y, t] == 0, y > 1], \[Psi][1, t] ==
0, \[Psi][0, t] == 0, \[Psi][y, 0] == Exp[-(y - 0.3)^2/0.01],
D[\[Psi][y, t], t] == 0.4 (y - 0.3)/0.01 Exp[-(y - 0.3)^2/0.01] /.
t -> 0}, \[Psi], {y, 0, 1}, {t, 0, 20}]
Manipulate[
Plot[{Abs@Evaluate[\[Psi][y, t] /. y -> y/L[t]] /. sol,
100 Sign[y - L[t]]}, {y, 0, 10}, ExclusionsStyle -> Red,
PlotRange -> {{0, 4}, {0, 2}}], {t, 0, 20}]
(This is an animated gif, but not looping)
As can be seen, the wave splits into 2 parts, one going to the right and the other to the left. What I want is for the gaussian wave packet to travel to the right entirely. Can anyone give me a solution to this?
EDIT
Thanks to user21, I have figured out my mistake during the set up of the initial conditions. I should have let $v$ (the speed of the gaussian) to be equal to $c$ (the speed of the wave in the wave equation). Implementing this on Klein-Gordon Equation gives me :
kge = 1/c^2 D[\[Psi][x, t], {t, 2}] -
D[\[Psi][x, t], {x, 2}] + \[Psi][x, t];
c = 1;
gaussian = Exp[-(x - 0.3 - c t)^2/0.01];
ic = {\[Psi][x, 0] == gaussian /. t -> 0,
D[\[Psi][x, t], t] == D[gaussian, t] /. t -> 0}
sol = NDSolve[{kge == 0,
DirichletCondition[\[Psi][x, t] == 0, x >= 1], \[Psi][0, t] == 0,
ic}, \[Psi], {x, 0, 1}, {t, 0, 10}]
Manipulate[
Plot[Evaluate[\[Psi][x, t] /. ss], {x, 0, 2},
PlotRange -> {{0, 3}, {-1, 1}}], {t, 0, 10}]
which is exactly what I want minus the backside of the gaussian descending a little as it moves, probably due to the extra $+ \psi[x,t]$ term in the wave equation, but I am fine with this.
Going back to the original problem, in which I have changed my coordinate system $$(x,t) \to (y,t)$$ where $y=\frac{x}{L(t)}$ and $L(t)=2+sin(\omega t)$, and setting the right boundary to $\psi (1,t)=0$ (in the $(y,t)$ coordinate)
ydum = x/L[t];
expr1 = 1/c^2 D[\[Psi][ydum, t], {t, 2}] -
D[\[Psi][ydum, t], {x, 2}] + (m^2 c^2)/
h^2 \[Psi][ydum, t] /. \[Psi][ydum, t] -> \[Psi][y, t] /.
x -> y L[t] // Expand
m = 1;
c = 1;
h = 1;
\[Omega] = 1;
L[t_] := 2 + Sin[\[Omega] t];
gaussian = Exp[-(x - 0.3 - c t)^2/0.01];
ic = {\[Psi][y, 0] == gaussian /. x -> y L[t] /. t -> 0,
D[\[Psi][y, t], t] == D[gaussian /. x -> y L[t], t] /. t -> 0}
sol = NDSolve[{expr1 == 0,
DirichletCondition[\[Psi][y, t] == 0, y >= 1], \[Psi][0, t] == 0,
ic}, \[Psi], {y, 0, 1}, {t, 0, 10}]
Manipulate[
Plot[{Abs@Evaluate[\[Psi][y, t]] /. sol}, {y , 0, 3},
AxesLabel -> {y, \[Psi]}, PlotRange -> {{0, 4}, {0, 2}}], {t, 0,
10}]
The gaussian makes some wiggly lines at its base. I am very confused as to why it does that. The problem that I am solving is the same as before (at least before the wave hits the right boundary), only that the coordinate has been scaled $x \to \frac{x}{2+sin(\omega t)}$. Is there any error in my code?
AcousticPDEComponent
. What should I do? $\endgroup$