# Hofstadter Model and its Topology(Julia Version)¶

About the author:

Jia-Qi Cai

Huazhong University of science and Technology, Wuhan

Email: caidish@uw.edu

```
#import essential package
using LinearAlgebra, Statistics, Compat, Plots, LaTeXStrings, SparseArrays
```

In this notebook, we show how to use Julia to simulate quantum Hall effect. We mainly focus on Hofstadter model, the Hamiltonian of which is simply: $$H = \sum_{m,n} – t(c^\dagger_{m+1,n}c_{m,n} + c_{m,n+1}^\dagger c_{m,n}e^{i 2\pi \Phi m} + h.c.)$$

## Energy Band¶

When the flux is commensurable, i.e, $\Phi = \frac{p}{q}$, the model have well difined Bloch excitation, which is band electron with $q$ bands. The eigen equations are: $$-2t\cos(k_x + 2\pi \Phi n)\psi_n – t(e^{-ik_y}\psi_{n-1} + e^{ik_y}\psi_{n+1}) = E_{k_x,k_y}\psi_n$$ where $n = 1,…,q$ and the boudary condition is $\psi_{j+q}= \psi_{j}$. Solving the linear system above will give the band structure of Hofstadter model

```
function TorusHamiltonian(kx,ky,t,p,q)::Array{Complex{Float64},2}
Phi = p/q
diagL = -t*exp(-1*im*ky)*ones(q-1)
diagD = complex(-2*t*cos.(kx*ones(q) + 2*pi*Phi*collect(0:1:q-1)))
diagR = -t*exp(+1*im*ky)*ones(q-1)
H = convert(Array,Tridiagonal(diagL,diagD,diagR))
# We use the method Tridiagonal to setup the matrix, and convert it to normal
# matrix to define the boundary condition
H[q,1] = -t*exp(+1*im*ky)
H[1,q] = -t*exp(-1*im*ky)
# The bouandary condition is set.
return H
end;
```

Let’s try to use the Hamiltonian defined in the BZ (geometrically a torus) to generate the band.

```
p = 1
q = 6
t = 1
kx_step = 100
ky_step = 100
kx_list = LinRange(-pi/q,pi/q,kx_step)
ky_list = LinRange(-pi ,pi ,ky_step)
能带 = zeros(ky_step,kx_step,q)
for (m,kx) = enumerate(kx_list)
for (n,ky) = enumerate(ky_list)
能带[n,m,:] = eigvals(TorusHamiltonian(kx,ky,t,p,q))
end
end
#result = permutedims(result,(2,1,3))
能带 = reshape(能带,(ky_step,kx_step*q))
plot(ky_list,能带,legend=false,xlabel = L"k_y",ylabel = L"\frac{E}{t}")
```