Initialization

SetOptions[Plot,PlotStyle->{Black,AbsoluteThickness[2]},
ImageSize->500,AxesStyle->Directive[FontFamily->"Arial",FontSize->18,Black,AbsoluteThickness[0.5],Arrowheads[0.04]]];

Reflections and Transmissions
Copyright Janet Tate 1997

This worksheet explores the reflection and transmission of a sinusoidal wave at a boundary at x = 0.  The wave on the left of the boundary is the sum of an incident (right-traveling) wave and a reflected wave with an amplitude of R(<1) times the incident.  To the right is a transmitted (right-traveling) wave, amplitude T times the incident.

Define the wave function, with wavevectors k on the left, and κ on the right.  R and T are the reflection and transmission coefficients, respectively.The wave displacement ψ can be written as the real part of a complex exponential.  The exponential notation is very convenient, but to visualize a physical displacement, the real part must be considered.

Clear[R,T,ω,k1,k2]

ψ[x_,t_]:=Piecewise[{{Simplify[ComplexExpand[Re[Exp[I*(-ω*t+k1*x)]]+R*Re[Exp[I*(-ω*t-k1*x)]]]],x<0},{T*Simplify[ComplexExpand[Re[Exp[I*(-ω*t+k2*x)]]]],x≥0}}]

gi[x_,t_]:=Piecewise[{{Simplify[ComplexExpand[Re[Exp[I*(-ω*t+k1*x)]]]],x<0},{0,x≥0}}]

gr[x_,t_]:=Piecewise[{{Simplify[ComplexExpand[R*Re[Exp[I*(-ω*t-k1*x)]]]],x<0},{0,x≥0}}]

h[x_,t_]:=Piecewise[{{0,x<0},{T*Simplify[ComplexExpand[Re[Exp[I(-ω*t+k2*x)]]]],x≥0}}]

R=(k1-k2)/(k1+k2)
T=2*k1/(k1+k2)

Choose a value for the period of about 1 second.

ω=2*Pi

Choose values for the wavevectors k1 and k2 but choose them via the velocities in the respective media.  This is more intuitive.  Set (Subscript[v, 1])=1 for convenience, and let (Subscript[v, 2])vary from much larger to much smaller.  What happens if they're the same?

v1=1
v2=0.5

k1=ω/v1
k2=ω/v2

Animate the function for your choice of velocities (you may wish to slow it down).

Animate[Plot[ψ[x,t],{x,-3,3},
AxesLabel->{x,ψ},
PlotLabel->t,
PlotRange->{{-3,3},{-2,2}}],
{t,0,6},
AnimationRate->0.25,
AnimationRunning-> False]

It is helpful to separate the waveform on the left (black) into its incident (red) and reflected (blue) components.

Animate[Plot[{gi[x,t],gr[x,t],ψ[x,t]},{x,-3,3},
AxesLabel->{x,"ψ,ψ_inc,ψ_ref"},PlotLabel->t,PlotStyle->{{Red,AbsoluteThickness[2]},{Blue,AbsoluteThickness[2]},{Black,AbsoluteThickness[2]}},PlotRange->{{-3,3},{-2,2}}],{t,0,6},
AnimationRate->0.25,
AnimationRunning->False]

Add some ranges when the info above has been digested (it makes the plot busier).

Animate[Plot[{gi[x,t],gr[x,t],ψ[x,t],-R,R,-(1-R),1-R,-(1+R),1+R,-1,1},{x,-3,3},
AxesLabel->{x,"ψ,ψ_inc,ψ_ref"},PlotLabel->t,PlotStyle->{{Red,AbsoluteThickness[2]},{Blue,AbsoluteThickness[2]},{Black,AbsoluteThickness[2]},{Blue,Dashed},{Blue,Dashed}, {Black,Dashed},{Black,Dashed},{Black,Dashed},{Black,Dashed},{Red,Dashed},{Red,Dashed}},PlotRange->{{-3,3},{-2,2}}],{t,0,6},
AnimationRate->0.25,
AnimationRunning->False]

Choose different velocities that are similar in magnitude.  Then choose velocities very different in magnitude.  Predict the outcome in each case.

Once the above is mastered, the system cand be effectively studied by inserting a slider control for the velocity in the second medium.  To achieve this in Mathematica, it is necessary to make v an argument of the wave function, which is not good practice pedagocially.  Nevertheless ...

Ψ[x_,t_,v2_]:=Piecewise[{{Simplify[ComplexExpand[Re[Exp[I*(-ω*t+ω/1*x)]]+(ω/1-ω/v2)/(ω/1+ω/v2)*Re[Exp[I*(-ω*t-ω/1*x)]]]],x<0},{2*ω/1/(ω/1+ω/v2)*Simplify[ComplexExpand[Re[Exp[I*(-ω*t+ω/v2*x)]]]],x≥0}}]

Ginc[x_,t_,v2_]:=Piecewise[{{Simplify[ComplexExpand[Re[Exp[I*(-ω*t+ω/1*x)]]]],x<0},{0,x≥0}}]

Gref[x_,t_,v2_]:=Piecewise[{{Simplify[ComplexExpand[(ω/1-ω/v2)/(ω/1+ω/v2)*Re[Exp[I*(-ω*t-ω/1*x)]]]],x<0},{0,x≥0}}]

Htran[x_,t_,v2_]:=Piecewise[{{0,x<0},{2*ω/1/(ω/1+ω/v2)*Simplify[ComplexExpand[Re[Exp[I(-ω*t+ω/v2*x)]]]],x≥0}}]

Manipulate[Plot[Ψ[x,t,v],{x,-3,3},
AxesLabel->{x,Ψ},
PlotRange->{{-3,3},{-2,2}}],
{{t,0,t},0,6},{{v,1,v},0.1,10}]