Background
So I've been working on making Hamiltonian Matrices for a graphene lattice and till now we've been working manually, I've attached a picture showing the matrices for a 2 by 2 Graphene Lattice where $t$ is the hopping parameter and $\epsilon$ is the on site energy. The empty terms are all zero
Question
I've been working on a way to write a code which generalises these matrices by just taking the input parameters as the dimensions of the lattice, that is 2 by 2 or 4 by 4 or so. But I'm not sure how to set the conditions or how to convert the $A_i$ and $B_i$ basis to $2\times N_i \times N_i$ matrices. Where $N_i$ is the number of unit cells in any direction