Saturday, November 12, 2011

Python project for interference of waves

Purpose:
We are going to use python to display the interference of many waves, and we are going to determine a wave function for a function B(k).

We first plot Gaussian distribution with setting constant mean, sigma and coefficient.
We show the plot of the distribution, and we plot the sinusoidal function so we define a new sinusoidal function with constant amplitude and angular constant, we also set the range of x. There are inference of two waves with different frequency. We apply Gaussian function to wave packet. We set 5 harmonics width different amplitude. Then we set the number of harmonic of waves to be very large. We finally have a graph of inference of many waves.

When sigma is small.

Uncertainty of momentum is small.
Uncertainty of position is large.
We have the wave packet is not localized.

When sigma is large.


Uncertainty of momentum is large.
Uncertainty of position is small.

Here is our program:

from pylab import*

#constants
mean = 3
sigma = 1
coeff = 1/(sigma*sqrt(2*pi))
harmonics = 5

gauss_list = [] #creates an empty list

for x in arange(1,(harmonics+1),1): #between x 0 to 10
gauss = coeff*exp(-(x-mean)**2/(2.0*sigma**2)) #calculates y value
gauss_list.append(gauss) #saves y value to list

#constants
w = 1 #omega
Fourier_series = [] #creates a list to hold the fourier lists

for n in range(1,(harmonics+1)): #harmonics 1 thru 5
x = [] #empty the lists
y = []
for t in arange(-3.14,3.14,0.1): #plot from -pi to pi
sine_function = gauss_list[n-1]*sin(n*w*t) #calculate y value
y.append(sine_function) #store y value in list
x.append(t) #store x value in list
Fourier_series.append(y) #stores the y list into one element of fourier list

superposition = zeros(len(x)) #create a new list the same size as x

for array in Fourier_series: #for each array in the fourier list
for i in range(len(array)): #for each element in the array
superposition[i] = superposition[i] + array[i] #create a superposition

plot(x,superposition) #plots x verses the superposition
show()

Exercise 39.69

c. The value of w(x) is 1L.
d. The value of w(x) is 2L.
e. The value of w(x) is 2L.
f. The value of w(x) * w(p) is h.
g. The value of w(x) * w(p) is h.
h. We have the product of width of B w(p) and width of two closest maximum width w(x) is same even the value of k(0) changes.

No comments:

Post a Comment