  We present here a Hofstadter's butterfly spectrum for the magic angle twisted
bilayer graphene obtained using an ab initio based multi-million atom
tight-binding model. We incorporate a hexagonal boron nitride substrate and
out-of-plane atomic relaxation. The effects of a magnetic field are introduced
via the Peierls modification of the long-range tight-binding matrix elements
and the Zeeman spin splitting effects. A nanoribbon geometry is studied, and
the quantum size effects for the sample widths up to 1 $\mu$m are analyzed both
for a large energy window and for the flatband around the Fermi level. For
sufficiently wide ribbons, where the role of the finite geometry is minimized,
we obtain and plot the Hofstadter spectrum and identify the in-gap Chern
numbers by counting the total number of chiral edge states crossing these gaps.
Subsequently, we examine the Wannier diagrams to identify the insulating states
at charge neutrality. We establish the presence of three types of electronic
states: moir\'e, mixed, and conventional. These states describe both the bulk
Landau levels and the edge states crossing gaps in the spectrum. The evolution
of the bulk moir\'e flatband wavefunctions in the magnetic field is
investigated, predicting a decay of the electronic density from the moir\'e
centers as the magnetic flux increases. Furthermore, the spatial properties of
the three types of edge states are studied, illustrating the evolution of their
localization as a function of the nanoribbon momentum.
