I am calculating eigenvalues of a Hamiltonian numerically but I am getting avoided crossing and gap in the curves which is not correct. Please help me out to resolve this issue in the attached notebook. Thanks.
I tried to zoom in with a few of the curves:
Plot[{list[B, 93], list[B, 94], list[B, 95], list[B, 96], list[B, 97], list[B, 98], list[B, 99]}, {B, 30, 40}, ImageSize -> 500]
They seem to touch, but they do not cross.
Thanks! Yes, you are right but this trend is wrong. The curve must cross each other. If you have any idea how to resolve this issue, please share it.
Your functions list[B,n] are the result of a sorting eigenvalues in increasing order:
list[B,n]
list[B_?NumericQ] := Sort@Eigenvalues[H[N[B]]]
I don't expect them to cross.
But they must cross each other. You can also see from the spectrum another issue of curve gaps e.g., see the red curve around B=20 T.
How can they cross, if by your definition, list[B, n] <= list[B, n + 1].?
list[B, n] <= list[B, n + 1]
I don't understand what you mean by "gap", and there are many curves that can be described as red. Please clarify.
Please follow the circle in the figure to see the gaps in the curves
Perhaps there is a misunderstanding about what we mean by "curve". The functions list[B, n] that you plot are continuous, but their graphics go zigzag.
list[B, n]
In the circle I see a violet "curve" on top, below it a yellow curve, then a green one, then a dark red one, and finally a blue curve. They touch each other, but they do not cross.
I am calling every line of list[B, n] in plot as curve. Yes, you are right, they are not crossing. But they should not behave like zigzag as you pointed out. Their zigzag behavior means their something wrong in the code.
I think that the zigzag is to be expected. Try a simpler example:
mat[x_?NumericQ] := {{2 x, 0}, {0, x + 1}}; eigen1[x_?NumericQ] := Min[Eigenvalues[mat[x]]]; eigen2[x_?NumericQ] := Max[Eigenvalues[mat[x]]]; Plot[{eigen1[x], eigen2[x]}, {x, 0, 2}]
The curves of eigen1 and eigen2 go zigzag and they do not cross.
eigen1
eigen2
The sorted eigenvalues will of course always show the seventh (for example) below (or equal to) the eighth. If instead you were to compute these paths by tracking smooth (not just continuous) curves, the crossing would I think be more obvious.
OK. Could you please elaborate your answer further? I am unable to follow , "how can I draw the curves to follow the crossings?" Have you any idea how can I remove the zigzag trend among the curves?
One very simple way to remove the zigzag is to give all curves the same color, for example with PlotStyle->Black.
PlotStyle->Black
You are right but in my case zigzag trend should not be there. Any way to systematically get rid of this trend?
Yes, I can. But I need these energies to evaluate transport properties where these zigzag trends make problems. Therefore, I need to get rid of them.
Crossposted here.