heaviside[x_]:=If [x<0,0,1];

Clear[liens,ppts,l,ll,RawHamFlux];

liens=Import["liensPBC5.dat"];
ppts=Import["PtsPBC5.dat"];
l=Length[liens];
ll=Length[ppts];

cut=0.5;


RawHamFlux=Reap[Do[{rat=N[70*Sqrt[2]];
dx=ppts[[liens[[m,1]],1]]-ppts[[liens[[m,2]],1]];
dy=ppts[[liens[[m,1]],2]]-ppts[[liens[[m,2]],2]];

If[(liens[[m,1]]<liens[[m,2]])&&(Abs[dy]<cut)&&(Abs[dx]<cut),(*Print["Cond  "," ",dx," ",dy," ",liens[[m,1]]," ",liens[[m,2]]];*)
Sow[{{liens[[m,1]],liens[[m,2]]},-Exp[I*Pi*Phi*rat*rat*((ppts[[liens[[m,2]]]])[[2]]-(ppts[[liens[[m,1]]]])[[2]])*((ppts[[liens[[m,2]]]])[[1]]+(ppts[[liens[[m,1]]]])[[1]])]}];
Sow[{{liens[[m,2]],liens[[m,1]]},-Exp[-I*Pi*Phi*rat*rat*((ppts[[liens[[m,2]]]])[[2]]-(ppts[[liens[[m,1]]]])[[2]])*((ppts[[liens[[m,2]]]])[[1]]+(ppts[[liens[[m,1]]]])[[1]])]}];]
},{m,1,l}]][[2,1]];

tmp=Split[Sort[RawHamFlux],#1[[1]]==#2[[1]]&];
RawHamFlux=Table[tmp[[i,1,1]]->Tr[Transpose[tmp[[i]]][[2]]],{i,1,Length[tmp]}];

rulef={Phi->0.01};
ham=SparseArray[RawHamFlux/.rulef];

sp5=Eigenvalues[ham,600];

spi7=Import["sp7flux001.dat"];

Dimensions[sp]

sp[[1]]

spp6=Flatten[spi6];

spp7=Flatten[spi7];

Length[spp7]

sp6=Take[Sort[spp6],{1,300}];

sp7=Take[Sort[spp7],{1,900}];

sp5n=Take[Sort[sp5],{1,300}];

ListPlot[sp7]

sp6[[1]]

sp5n[[1]]

Idos5[x_]:=Sum[(Map[heaviside,x-sp5])[[i]],{i,1,Length[sp5]}];

NIdos5[x_]:=1/Length[sp5tronc]*Sum[(Map[heaviside,x-sp5tronc])[[i]],{i,1,Length[sp5tronc]}];

NIdos6[x_]:=1/Length[sp6]*Sum[(Map[heaviside,x-sp6])[[i]],{i,1,Length[sp6]}];

NIdos7[x_]:=1/Length[sp7tronc]*Sum[(Map[heaviside,x-sp7tronc])[[i]],{i,1,Length[sp7tronc]}];

Sum[{1,2}[[i]],{i,1,2}]

Length[sp5n]

300-85

sp6[[-1]]

sp7tronc[[-1]]

sp5tronc[[-1]]

sp7tronc=Take[sp7,{1,874}];

sp5tronc=Take[sp5n,{1,216}];

Show[DiscretePlot[NIdos5[x],{x,-4.15,-3.77,0.005},PlotStyle->Green],DiscretePlot[NIdos6[x],{x,-4.15,-3.77,0.005},PlotStyle->Red],DiscretePlot[NIdos7[x],{x,-4.15,-3.77,0.005},PlotStyle->Blue]]

Show[DiscretePlot[NIdos5[x],{x,-4.15,-3.77,0.001},PlotStyle->Green],DiscretePlot[NIdos6[x],{x,-4.15,-3.77,0.001},PlotStyle->Red],DiscretePlot[NIdos7[x],{x,-4.15,-3.77,0.001}]]

N[NIdos5[-4.15+9*0.005]]

N[NIdos6[-4.15+12*0.005]]

N[NIdos7[-4.15+14*0.005]]

0.47`

Idos[-4.15]

Idos6[x_]:=Sum[(Map[heaviside,x-sp6])[[i]],{i,1,Length[sp6]}];

DiscretePlot[Idos6[x],{x,-4.15,-3.63,0.005}]

LarLandau5=9*0.005

LarLandau6=12*0.005

LarLandau7=14*0.005