I'm attempting to solve the particle-in-a-box problem using Scipy (with the help of http://www.physics.buffalo.edu/phy410-505/2011/topic4/app2/index.html). At first, I used a 16x16 matrix to model the Hamiltonian, like the link, and my results corresponded to theirs. However, when I used a larger matrix (50x50), I found many extraneous eigenvalues in my results due to the larger matrix size.
Why does a 16x16 matrix produce exactly the correct eigenstates while a larger one produces extraneous ones? When using a larger matrix (which I thought would increase the accuracy of the simulation due to fewer basis elements being omitted), how can I tell which elements correspond to actual eigenstates and which are extraneous?
My code is below:
from scipy import linalg, mat, matrix
def Sfun(m,n):
if (m+n)%2==0:
v1 = 2/(m+n+5)
v2 = 4/(m+n+3)
v3 = 2/(m+n+1)
return v1 - v2 + v3
else:
return 0
def Hfun(m,n):
if (m+n)%2==0:
return -8*(1-m-n-2*m*n)/((m+n+3)*(m+n+1)*(m+n-1))
else:
return 0
Slist = []
Hlist = []
for m in range(0,16):
tlist = []
for n in range(0,16):
tlist.append(Sfun(m,n))
Slist.append(tlist)
for m in range(0,16):
tlist = []
for n in range(0,16):
tlist.append(Hfun(m,n))
Hlist.append(tlist)
Smat = matrix(Slist)
Hmat = matrix(Hlist)
vals,vecs = linalg.eig(Hmat, Smat)
for i in range(0,16):
print('Vector: ', end="")
print(vecs[i], end="")
print(" Value: ", end="")
print(vals[i])