3
$\begingroup$

I am trying to plot Eigen values of my System Hamiltonian in Mathematica. This is generating very noisy plot. This is my code.

ϵ = 0;
A[α_, c_, b_, q_] := ϵ + 
2*Cos[k2*b + 2*π*α]*Exp[-π 1/(2*q)]*
LaguerreL[c, 0, (π*1/q)]
B[a_, q_] := Exp[I*k1*q*a]
B1[a_, q_] := Exp[-I*k1*q*a]
b[α_, q_] := 
SparseArray[{Band[{1, 1}] -> A[α, 0, 1, q], 
Band[{1, 2}] -> B[1, q], Band[{2, 1}] -> B1[1, q], 
Band[{1, q}] -> B1[1, q], Band[{q, 1}] -> B[1, q]}, {q, q}];
Plot3D[Eigenvalues[b[1, 3]][[2]], {k1, -3, 3}, {k2, -π, π}]

enter image description here

This is not even correct. Since this is mixing different eigen values solutions. Any help will be highly appreciated.

$\endgroup$
7
  • $\begingroup$ You could experiment with MaxRecursion to smooth the plot. For example, Plot3D[Eigenvalues[b[1, 3]][[2]], {k1, -3, 3}, {k2, -\[Pi], \[Pi]}, MaxRecursion -> 6]. You could also increase the number of PlotPoints. $\endgroup$
    – Tim Laska
    Commented Aug 18, 2020 at 1:22
  • $\begingroup$ @Tim Laska, It takes for ever for 10 recurssion and for 6 recurssion it takes a lot of time and still useless result. Its mixing eigenvalues. Mathematica is almost completely inefficient in calculating eigen values. I have always found these type of problems in mathematica. $\endgroup$ Commented Aug 18, 2020 at 2:01
  • $\begingroup$ @HazoorImran have you tried using Eigensystem? I find it is much more convenient. How large are your matrices? I calculate 1000x1000 and larger often in seconds or less. $\endgroup$ Commented Aug 18, 2020 at 2:24
  • 1
    $\begingroup$ @CATrevillian I used all of them but thenever it gives me a torn stripe plots. I did this with 100 points as well. But its better than what i was getting before. However still not acceptable. $\endgroup$ Commented Aug 18, 2020 at 4:55
  • 2
    $\begingroup$ There is no reason to expect the second eigenvalues will change continuously as a function of the parameters. In fact there is sound reason to expect they will not do so. $\endgroup$ Commented Aug 18, 2020 at 18:46

1 Answer 1

5
$\begingroup$

So my first step was to redefine your functions as such:

ClearAll[A,ε,B,B1,b];

A[α_, c_, b_, q_, ε_][k2_]:=ε + Cos[k2*b + 2*Pi*α]*Exp[-Pi 1/(2*q)]*LaguerreL[c, 0, (Pi*1/q)];

B[a_, q_][k1_]:=Exp[I*k1*q*a];

B1[a_, q_][k1_]:=Exp[-I*k1*q*a];

b[α_, q_][k1_,k2_] :=
SparseArray[{Band[{1, 1}] -> A[α, 0, 1, q, 0][k2],
Band[{1, 2}] -> B[1, q][k1], Band[{2, 1}] -> B1[1, q][k1],
Band[{1, q}] -> B1[1, q][k1], Band[{q, 1}] -> B[1, q][k1]}, {q, q}];

Then I could plot using the following:

Plot3D[Sort[Eigensystem[N[b[1,3][k1,k2]]][[1]]][[2]],{k1,-3,3},{k2,-Pi,Pi},PlotPoints->50]

Which gives:

Plot3D produced by above code.

Similarly,

Plot3D[Sort[Eigenvalues[N[b[1,3][k1,k2]]]][[2]],{k1,-3,3},{k2,-Pi,Pi},PlotPoints->50]  

And

Plot3D[Sort[Eigenvalues[b[1,3][k1,k2]]][[2]],{k1,-3,3},{k2,-Pi,Pi},PlotPoints->50]

Both give the same output due to their use of Sort.

However,

Plot3D[Eigensystem[N[b[1,3][k1,k2]]][[1]][[2]],{k1,-3,3},{k2,-Pi,Pi},PlotPoints->50]

Gives the disconnected & severely noisy plot

Noisy Plot3D of the above code that does not use Sort.

And this is due to the lack of use of Sort. We can also see this same output with:

Plot3D[Eigenvalues[N[b[1,3][k1,k2]]][[2]],{k1,-3,3},{k2,-Pi,Pi},PlotPoints->50]

And

Plot3D[Eigenvalues[b[1,3][k1,k2]][[2]],{k1,-3,3},{k2,-Pi,Pi},PlotPoints->50]

Which both produce the same noisy & mixed eigenvalue plot seen previously.

If this is not what you are looking for, please, let me know? I hope this helps!


After realizing an error in translating OP’s initial codeblock, the following no longer applies:

You might also speed up your matrix assembly by observing that your setting of ε = 0 makes the diagonal go to 0, which could prevent the need to do such extraneous computations when assembling runs of your matrices.


Tl;dr: Using Sort is key to helping eliminate the noise that was present.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.