  We address in this work the question of the discretization of two-dimensional
periodic Dirac Hamiltonians. Standard finite differences methods on rectangular
grids are plagued with the so-called Fermion doubling problem, which creates
spurious unphysical modes. The classical way around the difficulty used in the
physics community is to work in the Fourier space, with the inconvenience of
having to compute the Fourier decomposition of the coefficients in the
Hamiltonian and related convolutions. We propose in this work a simple
real-space method immune to the Fermion doubling problem and applicable to all
two-dimensional periodic lattices. The method is based on spectral
differentiation techniques. We apply our numerical scheme to the study of flat
bands in graphene subject to periodic magnetic fields and in twisted bilayer
graphene.
