Monday, November 12, 2012

Visualizing Wave Packets

Purpose:
The purpose of this experiment is to teach students to understand and visualize wave packets. Student will practice the Python program to plot some functions such as Gaussian function, sinusoidal function and superposition of fourier components. Students will use the integral in \psi(x)=\int_{0}^{\infty}B(k) \:{\rm cos}\: kx \: dk  to determine the Shrodinger equation depending on function B(k). The function B(k) is given   B\left( k \right) = \left\{ {\begin{array}{*{20}c}     0 & {k < 0}  \\     {1/k_0 {\rm{,}}} & {0 \le k \le k_0 }  \\     {0,} & {k > k_0 }  \\  \end{array}} \right.     .  Moreover, student will use the program called Python to plot the graphs of the Shrodinger equation versus x(L).

Procedure:

Gaussian function:
Sample code:
from pylab import *
center = 2
sigma = .5
coeff = 1/(sqrt(2*pi)*sigma)
gauss_list = []
for x in arange (0,10,.1):
    gauss = coeff * exp(-(x-center)**2/(2.*sigma**2))
    gauss_list.append(gauss)
plot(gauss_list)
show()






Sinusoidal function:
sample code:
from pylab import *
A=1
w=1
for i in range (1,4):
    x=[]
    sine_function=[]
    for t in arange(-3.14,3.14,0.01):
        sine_f=A*sin(i*w*t)
        sine_function.append(sine_f)
        x.append(t)
    plot(x,sine_function)
show()

Superpostion:

from pylab import *
A=1
w=1
Fourier_Series = []
for i in range (1,3):
    x = []
    sine_function = []
    for t in arange (-3.14,3.14,0.01):
        sine_f = A*sin(i*w*t)
        sine_function.append(sine_f)
        x.append(t)
    #plot(x,sine_function)
    Fourier_Series.append(sine_function)

superposition = zeros(len(sine_function))
                     
for sine_function in Fourier_Series :
    for i in range(len(sine_function)):
        superposition[i]+= sine_function[i]
                    
plot(x,superposition)
show()






The Gaussian Wave Packet
from pylab import *
center = 3
sigma = 1
coeff = 1/sqrt(2*pi)*sigma

#define constant
A=1
w=1
Fourier_Series =[]

for i in range (1,6):
    x=[]
    sine_function=[]
    A=coeff*exp(-(i-center)**2/(2.*sigma**2))
    print A
    for t in arange(-3.14,3.14,0.01):
        sine_f=A*sin(i*w*t)
        sine_function.append(sine_f)
        x.append(t)
       # plot(x,sine_function)
    Fourier_Series.append(sine_function)
    superposition = zeros(len(sine_function))
for function in Fourier_Series:
    for i in range(len(function)):
        superposition[i]+=function[i]
plot(x,superposition)
show()





Derive the Shrodinger equation:

Plotting the graph B(x) vs. k for ko = 2pi/L

Sample code:
from pylab import*
A=1
l=1
k=2*pi/l
B_list=[]
for l in arange(-3.14,3.14,0.1):
        B=1/k
        B_list.append(B)

plot(B_list)
show()

B(k) vs. k

Plotting the Graph \psi \left( x \right) versus x for the case k_0 = 2\pi /L, where L is a length.
Sample code:
from pylab import *
A=1
l=1
k=2*pi/l
y_function=[]
for i in range (1,3):
    y=[]
    y_function=[]
    for x in arange(-3.14,3.14,0.01):
        y_f=sin(k*x)/(k*x)
        y_function.append(y_f)
        y.append(x)
plot(y,y_function)
show()
 \psi \left( x \right) vs.  x(L)

 Graph \psi \left( x \right) versus x for the case k_0 = \pi /L, where L is a length.


 Sample code:
from pylab import *
A=1
l=1
k=pi/l
y_function=[]
for i in range (1,3):
    y=[]
    y_function=[]
    for x in arange(-6.28,6.28,0.01):
        y_f=sin(k*x)/(k*x)
        y_function.append(y_f)
        y.append(x)
plot(y,y_function)
show()
 \psi \left( x \right) vs.  x(L)
Summary:
The experiment successfully taught students how to use a simple programming to graph some functions which are hard to do by hands. Moreover, students can understand the wave packets. Students can plot a large number of sine functions and add them together.




No comments:

Post a Comment