blob: 0d1cc8c70d35982d93abf7fc1568970a6bd4f6a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
using LinearAlgebra
# Define the tight binding Hamiltonian
function tight_binding_hamiltonian(n_sites::Int64, t::Float64)
H = zeros(n_sites, n_sites)
for i in 1:(n_sites-1)
H[i, i+1] = t
H[i+1, i] = t
end
H
end
# Find the eigenenergies of the Hamiltonian
function eigenenergies(H::Array{Float64, 2})
eigvals(H)
end
n_sites = 10 # number of sites in the chain
t = 1.0 # hopping parameter
H = tight_binding_hamiltonian(n_sites, t)
energies = eigenenergies(H)
println(energies)
|