12 replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
source | link

One could also combine this algorithm with my answer herehere to insure that the eigenvalues and eigenvectors are sorted in the correct way.

This is the two-dimensional generalization of what I did in a closely related answer herehere.

One could also combine this algorithm with my answer here to insure that the eigenvalues and eigenvectors are sorted in the correct way.

This is the two-dimensional generalization of what I did in a closely related answer here.

One could also combine this algorithm with my answer here to insure that the eigenvalues and eigenvectors are sorted in the correct way.

This is the two-dimensional generalization of what I did in a closely related answer here.

11 In last code block, removed additive term in Hamiltonian left over from previous method.
source | link
nX = 20;
a = .2;

Clear[v];
v[x_, y_] := 1/2 (x^2 + y^2 + x y)

vGrid = Table[v[a i, a j], {i, -nX, nX}, {j, -nX, nX}];
xRange = Range[1, 2 nX + 1];
xyList = Tuples[xRange, 2];

h2 = DiagonalMatrix[
    SparseArray[(vGrid[[##]] & @@@ xyList) + 2/a^2]]]] - 
    1/(2 a^2) Sum[
     NDSolve`FiniteDifferenceDerivative[i, {xRange, xRange}, 
       "DifferenceOrder" -> 4]["DifferentiationMatrix"], 
    {i, {{2, 0}, {0, 2}}}];

{en2, ψ2} = Eigensystem[h2, -10];

ListDensityPlot[Partition[ψ2[[5]], 2 nX + 1], PlotRange -> All]
nX = 20;
a = .2;

Clear[v];
v[x_, y_] := 1/2 (x^2 + y^2 + x y)

vGrid = Table[v[a i, a j], {i, -nX, nX}, {j, -nX, nX}];
xRange = Range[1, 2 nX + 1];
xyList = Tuples[xRange, 2];

h2 = DiagonalMatrix[
    SparseArray[(vGrid[[##]] & @@@ xyList) + 2/a^2]] - 
    1/(2 a^2) Sum[
     NDSolve`FiniteDifferenceDerivative[i, {xRange, xRange}, 
       "DifferenceOrder" -> 4]["DifferentiationMatrix"], 
    {i, {{2, 0}, {0, 2}}}];

{en2, ψ2} = Eigensystem[h2, -10];

ListDensityPlot[Partition[ψ2[[5]], 2 nX + 1], PlotRange -> All]
nX = 20;
a = .2;

Clear[v];
v[x_, y_] := 1/2 (x^2 + y^2 + x y)

vGrid = Table[v[a i, a j], {i, -nX, nX}, {j, -nX, nX}];
xRange = Range[1, 2 nX + 1];
xyList = Tuples[xRange, 2];

h2 = DiagonalMatrix[
    SparseArray[(vGrid[[##]] & @@@ xyList)]] - 
    1/(2 a^2) Sum[
     NDSolve`FiniteDifferenceDerivative[i, {xRange, xRange}, 
       "DifferenceOrder" -> 4]["DifferentiationMatrix"], 
    {i, {{2, 0}, {0, 2}}}];

{en2, ψ2} = Eigensystem[h2, -10];

ListDensityPlot[Partition[ψ2[[5]], 2 nX + 1], PlotRange -> All]
10 deleted 9 characters in body
source | link
nX = 20;
a = .2;

Clear[v];
v[x_, y_] := 1/2 (x^2 + y^2 + x y)

vGrid = Table[v[a i, a j], {i, -nX, nX}, {j, -nX, nX}];
xRange = Range[1, 2 nX + 1];
xyList = Tuples[xRange, 2];

h2 = DiagonalMatrix[
    SparseArray[(vGrid[[##]] & @@@ xyList) + 2/a^2]] - 
    1/(2 a^2) 
    Sum[
     NDSolve`FiniteDifferenceDerivative[i, {xRange, xRange}, 
       "DifferenceOrder" -> 4]["DifferentiationMatrix"], 
    {i, {{2, 0}, {0, 2}}}];

{en2, ψ2} = Eigensystem[h2, -10];

ListDensityPlot[Partition[ψ2[[5]], 2 nX + 1], PlotRange -> All]
nX = 20;
a = .2;

Clear[v];
v[x_, y_] := 1/2 (x^2 + y^2 + x y)

vGrid = Table[v[a i, a j], {i, -nX, nX}, {j, -nX, nX}];
xRange = Range[1, 2 nX + 1];
xyList = Tuples[xRange, 2];

h2 = DiagonalMatrix[
    SparseArray[(vGrid[[##]] & @@@ xyList) + 2/a^2]] - 
   1/(2 a^2) 
    Sum[
     NDSolve`FiniteDifferenceDerivative[i, {xRange, xRange}, 
       "DifferenceOrder" -> 4]["DifferentiationMatrix"], 
    {i, {{2, 0}, {0, 2}}}];

{en2, ψ2} = Eigensystem[h2, -10];

ListDensityPlot[Partition[ψ2[[5]], 2 nX + 1], PlotRange -> All]
nX = 20;
a = .2;

Clear[v];
v[x_, y_] := 1/2 (x^2 + y^2 + x y)

vGrid = Table[v[a i, a j], {i, -nX, nX}, {j, -nX, nX}];
xRange = Range[1, 2 nX + 1];
xyList = Tuples[xRange, 2];

h2 = DiagonalMatrix[
    SparseArray[(vGrid[[##]] & @@@ xyList) + 2/a^2]] - 
    1/(2 a^2) Sum[
     NDSolve`FiniteDifferenceDerivative[i, {xRange, xRange}, 
       "DifferenceOrder" -> 4]["DifferentiationMatrix"], 
    {i, {{2, 0}, {0, 2}}}];

{en2, ψ2} = Eigensystem[h2, -10];

ListDensityPlot[Partition[ψ2[[5]], 2 nX + 1], PlotRange -> All]
9 Added built-in functionality for DifferenceOrder
source | link
8 Clarified meaning of grid spacing versus boundary effects
source | link
7 responded to comment
source | link
6 Generalize first approach
source | link
5 Generalize first approach
source | link
4 Added more basic approach.
source | link
3 Added anisotropy
source | link
2 added 1220 characters in body
source | link
1
source | link