(* Mathematica notebook, Physics 237, Frank L. H. Wolfs.
This notebook can be used to study the effect of adding matter waves.
The Figure in the Chapter notes for Chapter 3 was generated using this notebook.
The function Psi is defined and used to generate two sets ofplots.
One set of plots shows the sum of two matter waves.
The second set of plots shows the sum of 201 matter wave. *)


(* Define the wavefunction Psi.  The function value of Psi depends on x, t, κ, and υ. *)

Psi[x_,t_,kappa_:1,nu_:1] := Sin[2 Pi (kappa x - nu t)];


(* Add 2 wavefunctions with different values of κ and ν. *)

figSumOf2=Table[Plot[Evaluate[Psi[x,t, 1, 1]+Psi[x,t, 1.05, 1.05]],{x,0,20},PlotRange->2.0, AxesLabel->{"x","Psi"},PlotLabel->"t = "<>ToString[t],Prolog->Thickness[0.001]],{t,0.0,2.5,0.5}];


(* Add 201 wave functions with values of κ between 20 - 1 and 20 + 1.
Each wave function has the same weight. *)

figSumOf201Flat=Table[Plot[Evaluate[(∑_(n=-100)^100)Psi[x,t, 20+0.01*n, 1 + 0.001*n]],{x,-1.5,1.5}, PlotRange->Full, AxesLabel->{"x","Psi"},PlotLabel->"t = "<>ToString[t],Prolog->Thickness[0.001]],{t,0.0,2.5,0.5}];

(* Add 201 wave functions with values of κ between 20 - 1 and 20 + 1.
The weight of each wave function is described by a Gaussian distribution, centered at κ = 20 and with a width of 0.5. *)

figSumOf201Gaussian=Table[Plot[Evaluate[(∑_(n=-100)^100)Exp[-((0.01*n)^2)/(2*0.5^2)]Psi[x,t, 20+0.01*n, 1 + 0.001*n]],{x,-1.5,1.5}, PlotRange->Full, AxesLabel->{"x","Psi"},PlotLabel->"t = "<>ToString[t],Prolog->Thickness[0.001]],{t,0.0,2.5,0.5}];


(* Plot the sum waves at different times. *)

Show[GraphicsGrid[Partition[figSumOf2,2]]]

(* Show the sum of 201 wave functions at different times.. *)

Show[GraphicsGrid[Partition[figSumOf201Flat,2]]]

Show[GraphicsGrid[Partition[figSumOf201Gaussian,2]]]

Export["/Volumes/Home/Users/wolfs/Downloads/201MatterWavesGaussianWeight.jpg",GraphicsGrid[Partition[figSumOf201Gaussian,2]]]

Export["/Volumes/Home/Users/wolfs/Downloads/201MatterWavesEqualWeight.jpg",GraphicsGrid[Partition[figSumOf201Flat,2]]]

Export["/Volumes/Home/Users/wolfs/Downloads/2MatterWaves.jpg",GraphicsGrid[Partition[figSumOf2,2]]]