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

liens=Import["liensPBC7.dat"];
ppts=Import["PtsPBC7.dat"];
l=Length[liens];
ll=Length[ppts];

cut=0.5;


RawHamFlux=Reap[Do[{rat=N[408*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]}];

408*408*0.01

rulef={Phi->(0.0005+(100+n)/21000)};
ham=SparseArray[RawHamFlux/.rulef];

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

sp7flux001=Eigenvalues[ham,1800];

Export["sp7flux001.dat",N[sp7flux001]];

ListPlot[{Take[Sort[sp6flux001],{1,300}],sp5t1},PlotStyle->PointSize[0.0001]]

ListPlot[sp7flux001]

sp5t1=Table[{(sp5tronc[[i+1]]-sp5tronc[[i]])8119},{i,1,299}]
sp6t1=Table[{(sp6tronc[[i+1]]-sp6tronc[[i]])47321},{i,1,299}]

Position[sp5t1,{5.103410869676463`}]

sp5tronc[[75]]

Position[sp6t1,{2.8713261619108206`}]

sp6tronc[[110]]

169*169*2*0.01

ecart6=-4.1161327596670665`-sp6tronc[[1]]

0.027108659432856896`

ecart5=-4.116245359802382`-sp5tronc[[1]]

0.026677885929995426`

sp5tronc=Take[Sort[sp5flux001],{1,300}];
sp6tronc=Take[Sort[sp6flux001],{1,300}];

sp5t1=Table[{i*1.78,sp5tronc[[i]]},{i,1,300}];

Export["sp6flux001new.dat",N[sp6flux001]];

Export["sp5flux001.dat",N[sp5flux001]]