[关闭]
@wudawufanfan 2017-01-02T01:24:34.000000Z 字数 771 阅读 425

在此处输入标题

未分类


在此输入正文

  1. """
  2. Solve Schodinger's equation and plot the eigenfunctions
  3. """
  4. from __future__ import print_function
  5. import matplotlib.pyplot as plt
  6. import numpy as np
  7. import schrod
  8. # Specify the potential
  9. x = np.linspace(-3, 3, 200)
  10. V = x + 0.5*x**4
  11. # Create and solve Schrodinger's equation
  12. eqn = schrod.Schrod(x, V, n_basis=40)
  13. eqn.solve()
  14. # Get the eigenvalues and eigenvectors
  15. eig_vals = eqn.eigs
  16. psis = eqn.psi_eig_x()
  17. # Plot everything
  18. plt.xlim((x[0],x[-1]))
  19. plt.ylim((-1,9))
  20. plt.title("Wave functions for\n$V(x) = x + 0.5 x^4$", fontsize=18)
  21. plt.xlabel("$x$")
  22. plt.ylabel('Energy')
  23. n_eigs_plt = 5
  24. plt.plot(x, V, 'b-', lw=2)
  25. for i in range(n_eigs_plt):
  26. plt.plot(x, eig_vals[i]+0.75*psis[i], color='red', lw=1.5)
  27. plt.axhline(eig_vals[i], ls='--', color='black', lw=2)
  28. # Optionally show/save
  29. # plt.show()
  30. plt.tight_layout()
  31. plt.savefig("./plots/wave_func.png", dpi=100)
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注