# 2D quantum well energy spectrum (analytical vs numerical)

I am trying to understand the energy spectrum difference between the analytical and the approximated solution for a quantum well. The particle is inside a box with domain $\Omega=(0,0)$X$(1,1)$. For this I have $\hbar = m = 1$ and the energy is given analytically by $E_{m,n}=\frac{\pi^2}{2}(n^2 + m^2)$

My approximation is done using finite differences with a grid of $60$X$60$. The eigenvalues that I'm getting with the exact solution are always positive whereas the eigenvalues I'm getting with the approximated solution are always negative.

I am not familiar with quantum mechanics. That said, can you help me understand this? What can be happening, is it a big error due to the approximation? Where or what can I think of to try to understand these results?

I hope the question and the problem are well stated if not just tell me, probably I missed some important data and/or assumption.

UPDATE

Here I paste the code used to do this little simulation

clc;
xO = 0;
xL = 1;
N = 60;
%First build the matrix for a 1D-mesh
h = (xL - xO) / (N-1);
H = diag( (-2/h^2)*ones(1,N), 0 ) + ...
diag( (1/h^2)*ones(1,N-1), 1 ) + ...
diag( (1/h^2)*ones(1,N-1), -1 );
%Using the tensor product build the matrix for the 2D-mesh
H = kron(H, eye(N)) + kron(eye(N), H);
H = (-1/2) .* H;

%Compute the eigenvalues E and eigenvectors Psi
[Pcomp, Ecomp] = eig(H);

fEexac = @(m,n) ((pi^2)/2) * (n^2 + m^2);
Eexac = [];
for n=1:N
for m=1:N
Eexac((n-1)*N+m,(n-1)*N+m) = fEexac(n,m);
end
end

%Plot energy from analytical vs computed
figure(1); hold on;
plot(1:N^2, sort(diag(Eexac)), 'b', 1:N^2, sort(diag(Ecomp)), 'r');

%Plot discretized energy spectrum
figure(2); hold on;
plot(1:40, diag(Ecomp(1:40,1:40)), 'r');

%Compare lowest 300 eigenvalues (exact and computed)
figure(3); hold on;
x = 1:300;
plot(1:300, sort(diag(Eexac(1:300,1:300))), 'b', ...
1:300, sort(diag(Ecomp(1:300,1:300))), 'r');

-
Could be a simple offset in the ground state energy. Check the differences between your eigenvalues first and see if they are the same for the exact and discrete solution. The analytical solution has energy 0 at the bottom of the well. Is the same true for your grid? Also, maybe you have a sign error in your Hamiltonian? –  Lagerbaer Mar 25 '13 at 17:53
Indeed I checked my Hamiltonian, there was a minus sign missing. Now both are positive. But I still see a big difference between the approximated eigenvalues and the real ones, see image any tips you can give, I don't want the answer but I don't know where to start to understand this. –  BRabbit27 Mar 25 '13 at 18:27
Hm, at this point it would help to post your code, or at least the relevant portions of it. –  Lagerbaer Mar 25 '13 at 19:23
Are you following a particular text, that would help us understand your code? I just want to check something. Quantum wells have a confining potential only in one dimension, the others are "in plane" unconfined directions. For example, if this was 2D box of semiconductor material I wouldn't expect 1D quantum well solutions. Maybe this could be an explanation? Or maybe it's just a case if using different definitions. –  boyfarrell Mar 26 '13 at 5:43
Nope, I'm not following a particular text and as I said I'm not familiar with quantum mechanics it was more oriented to understand the application of eigenvalues and eigenvectors on numerical approximations. –  BRabbit27 Mar 26 '13 at 6:45
show 3 more comments