(* Jauge theta = 0, f = p/2N *)
MatConFluxPBC[v_,p_,npt_,m_]:=Module[{jn,jjn,rep,lcl,l,res,id},lcl=ListeClasses2[p];rep=Rep2[lcl];l=Length[rep];
res=Table[0,{x,l},{y,l}];Do[{id=Voisrep[rep[[j]],lcl,v];Do[{jjn=(Position [rep,id[[jj]]])[[1,1]];res[[j,jjn]]=-Exp[I*Pi*(m/(2*npt))*((p[[id[[jj]]]])[[2]]-(p[[rep[[j]]]])[[2]])*((p[[id[[jj]]]])[[1]]+(p[[rep[[j]]]])[[1]])];res[[jjn,j]]=-Exp[I*Pi*(m/(2*npt))*((-p[[id[[jj]]]])[[2]]+(p[[rep[[j]]]])[[2]])*((p[[id[[jj]]]])[[1]]+(p[[rep[[j]]]])[[1]])]},{jj,1,Length[id]}]},{j,1,l}];res];

Classej2[j_,l_]:=Module[{res={j},n=Length[l],ll,q},ll=n*normalise[l];q=ll[[j]];If[j≤4,AppendTo[res,Enleve[j,{1,2,3,4}]],If[(n-1<q[[1]]≤n)||(n-1<q[[2]]≤ n)||(q[[1]]<1)||(q[[2]]<1),Do[If[((Abs[q[[1]]-ll[[k,1]]]<1)&&(n-1<Abs[q[[2]]-ll[[k,2]]]≤n))||((Abs[q[[2]]-ll[[k,2]]]<1)&&(n-1<Abs[q[[1]]-ll[[k,1]]]≤n)),AppendTo[res,k]],{k,1,n}]]];res];

Rep2[l_]:=Module[{res={},k=1},Do[If[!MemberQ[res,l[[j,1]]],AppendTo[res,l[[j,1]]]],{j,1,Length[l]}];res];

ListeClasses2[l_]:=Module[{res={},n=Length[l]},Do[AppendTo[res,Sort[Flatten[Classej2[j,l]]]],{j,1,n}];res];

Voisdej[j_,v_]:=Module[{l=Length[v],res={},t},Do[If[v[[k,1]]==j,AppendTo[res,v[[k,2]]]],{k,1,l}];res];

Voisrep[j_,lcl_,vois_]:=Module[{res={},n=Length[lcl],v,cl},cl=lcl[[j]];Do[{v=Voisdej[cl[[m]],vois];Do[If[!MemberQ[res,lcl[[k,1]]],Do[If[MemberQ[v,lcl[[k,jj]]],AppendTo[res,lcl[[k,1]]]],{jj,1,Length[lcl[[k]]]}]],{k,1,n}]},{m,1,Length[cl]}];res];

normalise[l_]:=l/Max[l];

Enleve[x_,l_]:=Module[{res={},n=Length[l]},Do[If[l[[j]]!=x,AppendTo[res,l[[j]]]],{j,1,n}];res];

tb=Import["papPBC3.dat"]

vois3=Import["vois3.dat"];

ppn=Import["ppniso3norm.dat"];

d3={};

Length[MatConFluxPBC[vois3,ppn,12,0]]

For[j=1,j<26,j++,AppendTo[d3,Sort[Eigenvalues[MatConFluxPBC[vois3,ppn,12,j-1]]]]];

ListPlot[Table[{i,d3[[i,j]]},{i,1,25},{j,1,239}]]

pap4=Import["pap4.dat"]