@wudawufanfan
2016-12-27T07:14:56.000000Z
字数 1030
阅读 492
未分类
在此输入正文
def find_analytic_energies(en):
"""
Calculates Energy values for the finite square well using analytical
model (Griffiths, Introduction to Quantum Mechanics, page 62.)
"""
z = sqrt(2*en)
z0 = sqrt(2*Vo)
z_zeroes = []
f_sym = lambda z: tan(z)-sqrt((z0/z)**2-1) # Formula 2.138, symmetrical case
f_asym = lambda z: -1/tan(z)-sqrt((z0/z)**2-1) # Formula 2.138, antisymmetrical case
# first find the zeroes for the symmetrical case
s = sign(f_sym(z))
for i in range(len(s)-1): # find zeroes of this crazy function
if s[i]+s[i+1] == 0:
zero = brentq(f_sym, z[i], z[i+1])
z_zeroes.append(zero)
print "Energies from the analytical model are: "
print "Symmetrical case)"
for i in range(0, len(z_zeroes),2): # discard z=(2n-1)pi/2 solutions cause that's where tan(z) is discontinuous
print "%.4f" %(z_zeroes[i]**2/2)
# Now for the asymmetrical
z_zeroes = []
s = sign(f_asym(z))
for i in range(len(s)-1): # find zeroes of this crazy function
if s[i]+s[i+1] == 0:
zero = brentq(f_asym, z[i], z[i+1])
z_zeroes.append(zero)
print "(Antisymmetrical case)"
for i in range(0, len(z_zeroes),2): # discard z=npi solutions cause that's where cot(z) is discontinuous
print "%.4f" %(z_zeroes[i]**2/2)