Clear[dx,dy,l,ll]

l=Length[liens];
ll=Length[cparmodcom];
rat=5*Sqrt[2];
Mat=Table[0,{x,ll},{y,ll}];
cut=0.5;

Do[{dx=cparmodcom[[liens[[m,1]],1]]-cparmodcom[[liens[[m,2]],1]];dy=cparmodcom[[liens[[m,1]],2]]-cparmodcom[[liens[[m,2]],2]];If[(Abs[dx]>cut)&&(Abs[dy]>cut),{Mat[[liens[[m,1]],liens[[m,2]]]]=-Exp[I*(kx*rat*(dx-Sign[dx])+ky*rat*(dy-Sign[dy]))],Mat[[liens[[m,2]],liens[[m,1]]]]=-Exp[-I*rat*(kx*(dx-Sign[dx])+ky*(dy-Sign[dy]))]},If[(Abs[dx]>cut),{Mat[[liens[[m,1]],liens[[m,2]]]]=-Exp[I*rat*(kx*(dx-Sign[dx])+ky*(dy))],Mat[[liens[[m,2]],liens[[m,1]]]]=-Exp[-I*rat*(kx*(dx-Sign[dx])+ky*(dy))]},If[(Abs[dy]>cut),{Mat[[liens[[m,1]],liens[[m,2]]]]=-Exp[I*rat*(kx*(dx)+ky*(dy-Sign[dy]))],Mat[[liens[[m,2]],liens[[m,1]]]]=-Exp[-I*rat*(kx*(dx)+ky*(dy-Sign[dy]))]},{Mat[[liens[[m,1]],liens[[m,2]]]]=-Exp[I*rat*(kx*(dx)+ky*(dy))],Mat[[liens[[m,2]],liens[[m,1]]]]=-Exp[-I*rat*(kx*(dx)+ky*(dy))]}]]]},{m,1,l}];

liens

dist={};
Do[{dx=cparmodcom[[liens[[m,1]],1]]-cparmodcom[[liens[[m,2]],1]];dy=cparmodcom[[liens[[m,1]],2]]-cparmodcom[[liens[[m,2]],2]];If[(Abs[dx]>cut)&&(Abs[dy]>cut),AppendTo[dist,Norm[{dx-Sign[dx],dy-Sign[dy]}]],If[(Abs[dx]>cut),AppendTo[dist,Norm[{dx-Sign[dx],dy}]],If[(Abs[dy]>cut),AppendTo[dist,Norm[{dx,dy-Sign[dy]}]],AppendTo[dist,Norm[{dx,dy}]]]]]},{m,1,l}];

Norm[cparmodcom[[4]]-cparmodcom[[7]]]

spx2={};

Do[AppendTo[spx2,Flatten[{Pi*n/(50*5*Sqrt[2]),Eigenvalues[Mat/.kx->Pi*n/(50*5*Sqrt[2])/.ky->0][[1]]}]],{n,-10,10,1}];

g1=ListPlot[spx2]

spy2={};Do[AppendTo[spy2,Flatten[{Pi*n/(50*5*Sqrt[2]),Eigenvalues[Mat/.ky->Pi*n/(50*5*Sqrt[2])/.kx->0][[1]]}]],{n,-10,10,1}];g2=ListPlot[spy2,PlotStyle->Red]

Show[g2,g1]

Fit[spx2,{1,xx,(xx^(2 ))},xx]

Fit[spy2,{1,xx,(xx^(2 ))},xx]

spxy2={};Do[AppendTo[spxy2,Flatten[{Pi*n/(50*5*Sqrt[2]),Eigenvalues[Mat/.ky->Pi*n/(50*5*Sqrt[2])/.kx->Pi*n/(50*5*Sqrt[2])][[1]]}]],{n,-10,10,1}];

Fit[spxy2,{1,xx,(xx^(2 ))},xx]

alphax2=2*1.5034446622362394`;

alphay2=2*1.5034446622362394`;

alphaxy2=3.023667741321088`-1.5034446622362394`-1.5034446622362394`;

alphaxy2

tensor2={{alphax2,alphaxy2},{alphaxy2,alphay2}}

MassEffInv2=Sqrt[Det[tensor2]]

ListPlot[spxy2]

tot={}

ListPlot[Eigenvalues[Mat/.kx->0/.ky->0]]

Eigenvalues[Mat/.kx->0/.ky->0,1]

Mat/.kx->0/.ky->0