Created
May 6, 2012 12:56
-
-
Save ibab/2622218 to your computer and use it in GitHub Desktop.
Graphical solutions of the Schrödinger-equation for an idealised H_2 potential well
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
# Needs the python2 version of maplotlib because of a bug in the python3 version :( | |
from pylab import * | |
coth = lambda x: cosh(x)/sinh(x) | |
# ∞ ∞ | |
# | | | |
# | | | |
# | __ | _ | |
# | | | | | V0 | |
# |____| |____| _| | |
# | |
# |__| | |
# 2a | |
def mkplot(V0, a): | |
# For plotting E on the x-axis | |
#left = lambda E: a*tan(a*sqrt(E)) | |
#right1 = lambda E: sqrt(E)/sqrt(V0-E)*coth(a*sqrt(V0-E)) | |
#right2 = lambda E: sqrt(E)/sqrt(V0-E)*tanh(a*sqrt(V0-E)) | |
# for plotting sqrt(E) on the x-axis | |
left = lambda sqrtE: a*tan(a*sqrtE) | |
right1 = lambda sqrtE: sqrtE/sqrt(V0-sqrtE**2)*coth(a*sqrt(V0-sqrtE**2)) | |
right2 = lambda sqrtE: sqrtE/sqrt(V0-sqrtE**2)*tanh(a*sqrt(V0-sqrtE**2)) | |
xs = linspace(0, V0, 40000) | |
xs_filtered = ma.masked_where(abs(left(xs)) > 70, xs) | |
plot(xs_filtered, left(xs_filtered), 'b-', label=r'$\mathrm{tan}(\alpha)$') | |
plot(xs, right1(xs), 'r-', label=r'$\frac{\alpha}{\beta}\,\mathrm{cotanh}(\beta a)$ (symmetric)') | |
plot(xs, right2(xs), 'g-', label=r'$\frac{\alpha}{\beta}\,\mathrm{tanh}(\beta a)$ (asymmetric)') | |
xlim(0, sqrt(V0)) | |
ylim(0, 10) | |
xlabel(r'$\sqrt{E}\ / \ \sqrt{\mathrm{J}}$') | |
legend(loc=2) | |
def V0_sweep(): | |
for V in logspace(1, 3, 200): | |
mkplot(V, 1) | |
title('V = {}'.format(V)) | |
savefig('V0_sweep_%020.7f.png' % V) | |
clf() | |
def a_sweep(): | |
for a in linspace(0.1, 10, 200): | |
mkplot(40, a) | |
title('a = {}'.format(a)) | |
savefig('a_sweep_%011.7f.png' % a) | |
clf() | |
def assignment(): | |
mkplot(50, 1) | |
title('small potential $V_0$') | |
savefig('V0_small.pdf') | |
clf() | |
mkplot(500, 1) | |
title(u'large potential $V = 10 V_0$') | |
savefig('V0_large.pdf') | |
clf() | |
mkplot(20, 2) | |
title('small distance $a_0$') | |
savefig('a_small.pdf') | |
clf() | |
mkplot(20, 10) | |
title(u'large distance $a = 5 a_0$') | |
savefig('a_large.pdf') | |
clf() | |
assignment() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment