@wudawufanfan
2017-01-02T01:24:34.000000Z
字数 771
阅读 479
未分类
在此输入正文
"""Solve Schodinger's equation and plot the eigenfunctions"""from __future__ import print_functionimport matplotlib.pyplot as pltimport numpy as npimport schrod# Specify the potentialx = np.linspace(-3, 3, 200)V = x + 0.5*x**4# Create and solve Schrodinger's equationeqn = schrod.Schrod(x, V, n_basis=40)eqn.solve()# Get the eigenvalues and eigenvectorseig_vals = eqn.eigspsis = eqn.psi_eig_x()# Plot everythingplt.xlim((x[0],x[-1]))plt.ylim((-1,9))plt.title("Wave functions for\n$V(x) = x + 0.5 x^4$", fontsize=18)plt.xlabel("$x$")plt.ylabel('Energy')n_eigs_plt = 5plt.plot(x, V, 'b-', lw=2)for i in range(n_eigs_plt):plt.plot(x, eig_vals[i]+0.75*psis[i], color='red', lw=1.5)plt.axhline(eig_vals[i], ls='--', color='black', lw=2)# Optionally show/save# plt.show()plt.tight_layout()plt.savefig("./plots/wave_func.png", dpi=100)