[关闭]
@wudawufanfan 2016-12-27T07:14:56.000000Z 字数 1030 阅读 492

在此处输入标题

未分类


在此输入正文

  1. def find_analytic_energies(en):
  2. """
  3. Calculates Energy values for the finite square well using analytical
  4. model (Griffiths, Introduction to Quantum Mechanics, page 62.)
  5. """
  6. z = sqrt(2*en)
  7. z0 = sqrt(2*Vo)
  8. z_zeroes = []
  9. f_sym = lambda z: tan(z)-sqrt((z0/z)**2-1) # Formula 2.138, symmetrical case
  10. f_asym = lambda z: -1/tan(z)-sqrt((z0/z)**2-1) # Formula 2.138, antisymmetrical case
  11. # first find the zeroes for the symmetrical case
  12. s = sign(f_sym(z))
  13. for i in range(len(s)-1): # find zeroes of this crazy function
  14. if s[i]+s[i+1] == 0:
  15. zero = brentq(f_sym, z[i], z[i+1])
  16. z_zeroes.append(zero)
  17. print "Energies from the analytical model are: "
  18. print "Symmetrical case)"
  19. for i in range(0, len(z_zeroes),2): # discard z=(2n-1)pi/2 solutions cause that's where tan(z) is discontinuous
  20. print "%.4f" %(z_zeroes[i]**2/2)
  21. # Now for the asymmetrical
  22. z_zeroes = []
  23. s = sign(f_asym(z))
  24. for i in range(len(s)-1): # find zeroes of this crazy function
  25. if s[i]+s[i+1] == 0:
  26. zero = brentq(f_asym, z[i], z[i+1])
  27. z_zeroes.append(zero)
  28. print "(Antisymmetrical case)"
  29. for i in range(0, len(z_zeroes),2): # discard z=npi solutions cause that's where cot(z) is discontinuous
  30. print "%.4f" %(z_zeroes[i]**2/2)
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注