# run this cell first
%pylab inline
from matplotlib import *
Question 1 The following Python code will calculate the energy value and wavefunction for an electron in a box 1 pm long, in 5 different quantum states (quantum numbers from 1 to 5). The calculation is based on the analytical solution of the time independent Schroedinger's equation for an infinite potential well, seen during the lectures. Running the code will plot the graphs of the wavefunctions, overlapping with their corresponding energy. Run the code once and then modify it to obtain the energy values and wavefunctions for quantum levels up to 10.
m = 9.10938291e-31 # kg
h = 6.62606957e-34 # m2 kg / s
L = 1e-12 # m
N = 10 # max quantum number
x = linspace(0, L, 1000)
#setup the plot
fig = plt.figure(num=None, figsize=(15, 10), facecolor='w', edgecolor='k')
ax = fig.add_subplot(111)
#2 lists to collect the Energy and wavefunction results for each quantum number.
E_List = []
PSI_List = []
# do the calculations for each quantum number n and plot the results
for n in range(1, N+1):
energy = ((n * h)**2) / (8 * m * L**2)
wavefunction = sqrt(2./L) * sin(n * pi * x / L)
E_List.append(energy)
PSI_List.append(wavefunction)
# scale the energy results by h^2/b*m*L^2
# scale the wavefunction by sqrt(2/L) and shift it vertically
# by the value of energy.
# This results in each wavefunction sitting on top of its corresponding
# energy value in the plot.
# The original values are still stored in the E and PSI variables
ax.plot([x[0], x[len(x)-1]], [energy/(((h)**2) / (8 * m * L**2)),
energy/(((h)**2) / (8 * m * L**2))])
ax.plot(x, (wavefunction / sqrt(2 / L)) +
energy/(((h)**2) / (8 * m * L**2)))
#label the axes and the axes ticks
ax.set_ylabel(r'$E$', fontsize=18)
plt.xlabel('$x$', fontsize=18)
ax2 = ax.twinx()
ax2.set_ylabel(r'$\psi$', fontsize=18)
ax.set_yticks([n**2 for n in range(N+1)])
ax.set_yticklabels([n for n in range(N+1)])
ax2.set_yticks([])
#finally show the graph
plt.show()
Question 2 Plot the probability density $P(x) =\psi^{*} \psi$ for quantum numbers 1 and 2
plot(x,PSI_List[0]**2)
plot(x, PSI_List[1]**2)
Question 3 The probability density for quantum number $n = 2$ is $0$ for $x = 0.5 L$, while it's greater than $0$ elsewhere (excluding the box walls of course). How can you explain that the particle has a finite probability to be found in the left or right portion of the box, but no probability to be found in the center? How can the particle get from one side of the box to the other in the $n = 2$ state?
#wave particle duality
Question 4 Using the formulae in the code supplied above, calculate the energy, wavefunction and probability density for $n=50$. Plot the wavefunction.
m = 9.10938291e-31 # kg
h = 6.62606957e-34 # m2 kg / s
L = 1e-12 # m
N = 50 # max quantum number
x = linspace(0, L, 1000)
fig = plt.figure(num=None, figsize=(15, 10), facecolor='w', edgecolor='k')
ax = fig.add_subplot(111)
energy = ((50 * h)**2) / (8 * m * L**2)
wavefunction = sqrt(2./L) * sin(50 * pi * x / L)
E_List.append(energy)
PSI_List.append(wavefunction)
ax.plot([x[0], x[len(x)-1]], [energy/(((h)**2) / (8 * m * L**2)),
energy/(((h)**2) / (8 * m * L**2))])
ax.plot(x, (wavefunction / sqrt(2 / L)) +
energy/(((h)**2) / (8 * m * L**2)))
ax.set_ylabel(r'$E$', fontsize=18)
plt.xlabel('$x$', fontsize=18)
ax2 = ax.twinx()
ax2.set_ylabel(r'$\psi$', fontsize=18)
ax.set_yticks([n**2 for n in range(N+1)])
ax.set_yticklabels([n for n in range(N+1)])
ax2.set_yticks([])
plot(wavefunction)
Question 5 Plot the probability density for $n = 50$.
plot(x,wavefunction**2)
Question 6 Discuss the results of question 3 and 4 in comparison to classical mechanics and in the light of De Broglie's theory of matter-wave .
Question 7 In the beta-carotene molecule there are 22 conjugated carbon-carbon bonds (the alternating single and double bonds you see in the long chain). The total length of the chain is 1.83 nm. Each of the carbon atoms contributes one $\pi$ electron, for a total of 22 electrons.
Why are carrots orange?
Hint: model the HOMO-LUMO transition using a quantum mechanical particle in a box approximation.
m = 9.10938291e-31 # kg
h = 6.62606957e-34 # m2 kg / s
L = 1.83e-9 # m
energy11 = ((11 * h)**2) / (8 * m * L**2)
energy12 = ((12 * h)**2) / (8 * m * L**2)
delta_energy = energy12 - energy11
wavelength = (h*299792458)/delta_energy #299792458 is the speed of light in m/s
print wavelength