Demonstrating interference in 1D square well

Remove["Global`*"]
L=1;m=1;ℏ=1;

Write down functions for the wave functions and energies

u[n_]=Sqrt[2/L]Sin[n Pi x/L];
energy[n_]=ℏ^2Pi^2/(2m)n^2;

Animate the wave function and the probability for some examples

First example: A stationary state. Note that we’ll only plot the real part of the wave function

nVal=1;
ψ1[t_]=(Exp[-I energy[nVal] t/ℏ]) u[nVal];

Animate[
Plot[Re[ψ1[t]],
{x,0,L},PlotRange->{-1.5,1.5}],{t,0,10},
AnimationRunning->False]

Animate[
Plot[ComplexExpand[Conjugate[ψ1[t]]]ComplexExpand[ψ1[t]],
{x,0,L},PlotRange->{0,2}],{t,0,10},
AnimationRunning->False]

Second example: Superposition of two states. Note that the whole state is normalized

nVal1=1;
nVal2=2;
ψ2[t_]=
Sqrt[1/2](Exp[-I energy[nVal1] t/ℏ]) u[nVal1]+Sqrt[1/2](Exp[-I energy[nVal2] t/ℏ]) u[nVal2];

Animate[
Plot[Re[ψ2[t]],
{x,0,L},PlotRange->{-2,2}],{t,0,10},
AnimationRunning->False]

Animate[
Plot[ComplexExpand[Conjugate[ψ2[t]]]ComplexExpand[ψ2[t]],
{x,0,L},PlotRange->{0,3.5}],{t,0,10},
AnimationRunning->False]