I Would like to construct these matrices to represent a system with Atoms. The way I did, I can't get the linear case (n=1) in the right way, I just got these blocks growing by two elements. It would be good if I make them grow linear, like n=1 its a vector, n=2 its a 2x2 matrix, and go on...
Energy = DiagonalMatrix[Flatten[{1, Table[{1, 1}, {i, 1, n}]}],
0]*(w + \[Eta]*I);
UAB = UBA =
DiagonalMatrix[Flatten[{t, Table[{t, t}, {i, 1, n}]}], 0];
HA = DiagonalMatrix[
Flatten[{\[Epsilon], Table[{\[Epsilon], \[Epsilon]}, {i, 1, n}]}],
0] + DiagonalMatrix[Flatten[{Table[{0, t}, {i, 1, n}]}], 1] +
DiagonalMatrix[Flatten[{Table[{0, t}, {i, 1, n}]}], -1];
HB = DiagonalMatrix[
Flatten[{\[Epsilon], Table[{\[Epsilon], \[Epsilon]}, {i, 1, n}]}],
0] + DiagonalMatrix[Flatten[{Table[{t, 0}, {i, 1, n}]}], 1] +
DiagonalMatrix[Flatten[{Table[{t, 0}, {i, 1, n}]}], -1]
I made something like this, there is a compact way?
Energy = IdentityMatrix[n]*(w + I*\[Eta]) // MatrixForm
UAB = UBA = Table[If[i == j, t, 0], {i, 1, n}, {j, 1, n}] // MatrixForm
HA = Table[
If[i == j - 1, If[Abs[i - If[OddQ[j], j, i]] == 1, t, 0], 0], {i,
1, n}, {j, 1, n}] +
Table[If[i == j + 1, If[Abs[i - If[OddQ[j], j, i]] == 1, 0, t],
0], {i, 1, n}, {j, 1, n}] +
Table[If[i == j, \[Epsilon], 0], {i, 1, n}, {j, 1, n}] // MatrixForm
HB = Table[
If[i == j - 1, If[Abs[i - If[OddQ[j], j, i]] == 1, 0, t], 0], {i,
1, n}, {j, 1, n}] +
Table[If[i == j + 1, If[Abs[i - If[OddQ[j], j, i]] == 1, t, 0],
0], {i, 1, n}, {j, 1, n}] +
Table[If[i == j, \[Epsilon], 0], {i, 1, n}, {j, 1, n}] //
MatrixForm
I think this produces the same result, is more compact and fixes your size issue.
n=8;
va=Mod[Range[n]+1,2]*t;(*List of alternating 0 and t*)
vb=Mod[Range[n],2]*t; (*List of alternating t and 0*)
Energy = IdentityMatrix[n]*(w + I*η);
UAB = UBA = IdentityMatrix[n]*t;
HA=DiagonalMatrix[va,1,n]+DiagonalMatrix[va,-1,n]+IdentityMatrix[n]*ε;
HB=DiagonalMatrix[vb,1,n]+DiagonalMatrix[vb,-1,n]+IdentityMatrix[n]*ε;
Test this carefully and make certain that everything is correct.