Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Playground for visualisation of the Schrödinger equation solutions in one dimension
import matplotlib.pyplot as plt
import numpy as np
import numpy.linalg as la
width, n= 1., 500 ## width of the 1D quantum system, and number of points
nplot = 10 ## number of quantum states to plot
x = np.linspace(-width/2,width/2,n)
def laplace(n): return (-np.roll(np.eye(n),1) + 2*np.eye(n) - np.roll(np.eye(n),-1))*n**2
V = ((x+.01)**4)*100 - (x-.01)**2 * 10 + .2 ## potential
H = laplace(n) * 1e-4 + np.diag(V) ## Hamiltonian consists of kinetic and potential terms
Es, psis = la.eigh(H)
#order = np.argsort(Es); Es, psis = Es[order], psis[order] ## sorting (not needed)
fig, ax = plt.subplots(1,1)
plt.plot(x, V, label='$V$', c='r') ## potential
for psi,E in zip(psis.T[:nplot],Es[:nplot]):
psi /= (np.sum(psi**2)/n * width)**.5 ## normalize
shift = E*100
ax.fill_between(x, shift+psi**2, shift*np.ones_like(psi), color='grey')
plt.plot(x, shift+psi**2 , label='$\\psi^2$', )
plt.plot(x, shift*np.ones_like(psi), label='$E$', c='k')
## If psi is eigenvector, this should be identical:
#plt.plot(x, shift+E *psi , label='$E \\psi$', c='r', lw=2)
#plt.plot(x,,psi), label='$\\hat H\\psi$', c='g')
## Finish the plot + save
plt.xlabel(u"Position"); plt.ylabel(u"Energy levels; Wavefunction probability"); plt.grid()
plt.savefig("output.png", bbox_inches='tight')

This comment has been minimized.

Copy link
Owner Author

commented Nov 2, 2016

Typical output for an asymmetrical quantum well follows:

First, the left valley is filled with the first and second wavefunction which resemble the first two states of a harmonic oscillator. The following three pairs of states show that the phenomenon of ''state hybridization'' requires the coupling to be not too weak and also not too strong:

  1. For this choice of the potential, the third (cyan line) and fourth (red line) states by coincidence (...or my choice of potential function) have a very close energetic level; however, at this level, the coupling between the left and right wells is so weak that we observe no hybridisation. One state is concentrated in the left valley, the other in the right valley.

  2. The situation changes at higher energy, which enables increased quantum tunneling between the wells. Thus, the fifth and sixth states are hybridized - they have quite similar profile of probability density as obvious from the plots, yet they differ by the mutual phase of their left and right parts (known as "bonding" vs. "antibonding" states, which is not shown in the plots).

  3. The seventh (black) and eighth (blue) states are coupled still much stronger than the previous two. It has a similar impact on their wavefunction shapes, but now even the probabilities obviously differ, and it leads also to appreciable energy splitting.

The sequence of all higher states is similar to the linear harmonic oscillator, except for the potential growing with the 4th power of ''x''.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.