Hi,
I have been trying to calculate the entanglement entropy for the SSH model with open boundary conditions. I’m very new to the Julia language but to the best of my knowledge, I believe I’ve coded it correctly. Below is the full code that I’ve written following different discussions here as well as in the ITensor documentation.
Im trying to calculate the bipartite entropy for a fixed lattice size, but with one of the hopping parameters varying between a certain range.
using ITensors
using Plots
@time let
N = 60
t1 = collect(0.5:0.01:2.5)
function SSH_OBC(N,t1)
sites = siteinds("Fermion", N; conserve_qns=false)
t2 = 1.8
os = OpSum()
for b in 1:(N-1)
if isodd(b)
os += -t1, "Cdag", b, "C", b + 1
os += -t1, "Cdag", b+1, "C", b
elseif iseven(b)
os += -t2, "Cdag", b, "C", b + 1
os += -t2, "Cdag", b+1, "C", b
end
end
H = MPO(os, sites)
return sites,H
end
function ent(psi::MPS; kwargs...)
N = length(psi)
b = ÷(N,2)
orthogonalize!(psi, b)
s = siteinds(psi)
U,S,V = svd(psi[b], (linkind(psi, b-1), s[b]))
SvN = 0.0
for n in 1:dim(S, 1)
p = S[n,n]^2
SvN -= p*log(p)
end
return SvN
end
energies = []
states = MPS[]
SvN = 0.0
SvN_loop = []
for t1 in t1
sites,Hlist = SSH_OBC(N,t1)
state = []
for n in 1:N
if isodd(n)
push!(state,"1")
elseif iseven(n)
push!(state,"0")
end
end
psi0 = randomMPS(sites,state,10)
nsweeps = 15
maxdim = [50, 100, 200, 400, 800, 800]
cutoff = [1E-12]
println("---------------------------------------------------------")
println("Running DMRG for t1 = $t1")
energy, psi = dmrg(Hlist, psi0; nsweeps, maxdim, cutoff)
println("---------------------------------------------------------")
SvN = ent(psi)
push!(energies,energy)
push!(states,psi)
push!(SvN_loop,SvN)
end
println("t1\t G.S Energy\t Entropy")
for j in 1:length(energies)
println("$(t1[j])\t $(energies[j])\t $(SvN_loop[j])")
end
p = plot(t1,SvN_loop,seriestype=:scatter,show = true)
savefig(p, "myplot.pdf")
end
The ground state found by the DMRG algorithm matches with my exact diagonalization code. There are a few things I’m getting wrong in this calculation.
-
When I run this code inside the REPL environment vs. when I run it in cmd with "julia *.jl ", I see slightly different results in my final plot, particularly along the regions where the t1 approaches the value of t2. There is a topological phase transition at t1=t2 so I’m guessing the inclusion of more singular values in the truncation part causes slight variation. Is that what is happening?
There are also abrupt changes in the entropy values along the transition regime. Might that also be a numerical artifact? -
The entanglement entropy behaviour is different from the analytical calculations I’ve done for the same system. I’m unsure if there is some syntax error or if there is some physical argument I’m missing.
TIA!