Finite Potential Well - Scattering

A beam of particles of unit amplitude moves across a well from the left. After scattering, a fraction T of the incident beam is transmitted through the well and the remaining fraction R=1-T is reflected. The interference of the reflected and incident beams shows a characteristic interference pattern to the left of the scattering region. To the right of the scattering region, only the transmitted wave appears, and there is no interference. Only in exceptional circumstances is the well transparent to the incident beam.The energy—real part (green), imaginary part (blue), and square of the wavefunction (orange)—is shown as functions of position in the lower graphic.

V[x_,V0_,a_]:=V0(UnitStep[x+a/2]-UnitStep[x-a/2])
(*The "amplitude" of the reflected wave *)
RR[k_,q_]:=(((E^(-I k)) ((k^2)-(q^2)) Sin[q])/(2 I k q Cos[q]+((k^2)+(q^2)) Sin[q]))
(*The "amplitude" of the transmitted wave.*)
TT[k_,q_]:=(( I 2 k q (E^(-I k)) )/(2 I k q Cos[q]+((k^2)+(q^2)) Sin[q]))
(* The amplitudes of the waves inside the well *)
AA[k_,q_]:=TT[k,q] (q+k)/(2q)Exp[I (k-q)/2]
BB[k_,q_]:=TT[k,q](q-k)/(2q)Exp[I (k+q)/2]
ψ[x_,En_,V0_,a_]:=Module[
{z=x/a,k=a Sqrt[2 En],q=a Sqrt[2(En-V0)],Rv,Tv,Av,Bv},
Rv=RR[k,q];
Tv=TT[k,q];
Av=AA[k,q];
Bv=BB[k,q];
Which[
z<-1/2,Exp[I k z]+Rv*Exp[-I k z],
Abs[z]≤1/2,Av*Exp[I q x/a]+Bv*Exp[-I q z],
z>1/2,Tv*Exp[I k z]]
]
TransmitanceAndReflectance[En_, V0_, a_] := Module[
{k=a Sqrt[2 En],q=a Sqrt[2(En-V0)],Rv,Tv,Av,Bv},
Rv=Abs[RR[k,q]];
Tv=Abs[TT[k,q]];
{Rv^2, Tv^2}                                             ]
xmax            = 10.5;
ymax            = 5.0;
energyMax = 5.0;
Manipulate[
Column[{Plot[TransmitanceAndReflectance[z (*Energy*), V0, a]//Evaluate,
{z, 0, energyMax},
PlotRange -> {0, 1.02},
BaseStyle->Directive[Thick],
Ticks -> {Automatic, {{0.5, "0.5"}, {1.0, "1.0"}}},
AxesLabel -> {Style["E",Italic],  ""},
AspectRatio ->1/5.5,
ImageSize->{490,100},
Exclusions->None,
Epilog -> {ColorData[1,1],Text[Style["R",Italic], {0.1, 0.95}, {-1, +1}],
ColorData[1,2], Text[Style["T",Italic], {0.1, 0.05}, {-1, -1}]}
     ],
Plot[
With[{val=ψ[x,En,V0,a]},
{Abs[val]^2,Re[val],Im[val],En,V[x,V0,a]}
    ]//Evaluate,
{x,-xmax,xmax},
PlotRange->{-ymax,ymax},
PlotPoints -> 75,
PlotStyle->
{RGBColor[1,.47,0],
RGBColor[.38,.61,.51],
RGBColor[.1,.1,.51],
Gray,
Lighter[Orange,.75]
 },
Filling->{5->Bottom},
FillingStyle->Lighter[Orange,.75],
BaseStyle->Directive[Thick],
ImageSize->{490,250},
Exclusions->None,
Epilog ->{Text[Row[{Style["E",Italic],"  =   "}], {0.6xmax, 0.9ymax}, {+1, 0}],
Text[ToString[En], {0.6xmax, 0.9 ymax}, {-1, 0}],
Text[Row[{Subscript[Style["V",Italic],0],"  =   "}], {0.6xmax, 0.8ymax}, {+1, 0}],
Text[ToString[V0], {0.6xmax, 0.8 ymax}, {-1, 0}],
Text[Style[Row[{Style["a",Italic],"  =   "}],Italic], {0.6xmax, 0.7ymax}, {+1, 0}],
Text[ToString[a], {0.6xmax, 0.7ymax}, {-1, 0}]
                }
         ]
},Center],
{{En,1.5,"particle energy E"},0,5,Appearance->"Labeled"},
{{V0,-1,Row[{"potential well depth ",Subscript["V",0]}]},-5,-1,Appearance->"Labeled"},
{{a,5,"potential well width a"},0.5,5,Appearance->"Labeled"},
SaveDefinitions->True
                          ]