Hello everyone!
I’d like to ask a question about how to set the total number of particles in bose-hubbard model “without controlling the particle number of every site”.
Its Hamiltonian is
\hat{H}=-t\sum*{i=1}^L(\hat{b}*i^\dagger \hat{b}*{i+1}+H.c.)+\frac{U}{2}\sum*{i=1}^L\hat{n}*i(\hat{n}*i-1)-\mu\sum*{i=1}^L\hat{n}*i
I want to calculate its phase diagram through its ground-state energy difference when one particle was added or removed.
\mu(N)_+=E(N+1)-E(N)
\mu(N)_-=E(N)-E(N-1)
Here is my code by Julia version. I want to know how my code runs correctly and control the particle number on every site but I just want to control the total number of particles, not every site.
using ITensors
J = parse(Float64, ARGS[1])
miu = parse(Float64, ARGS[2])
U = parse(Float64, ARGS[3])
V = parse(Float64, ARGS[4])
L = parse(Int, ARGS[5])
sites = Boson(L, "MaxOcc=", 5, "ConserveQNs", true, "ConserveNb", false)
sweeps = Sweeps(8)
sweeps.maxdim() .= [40, 80, 400, 400, 800, 800, 1000, 1000]
sweeps.cutoff() = 1E-16
ampo = AutoMPO(sites)
for i in 1:L-1
add!(ampo, -miu - U/2, "N", i)
add!(ampo, U/2, "N", i, "N", i)
add!(ampo, -J, "A", i, "Adag", i + 1)
add!(ampo, -J, "Adag", i, "A", i + 1)
add!(ampo, V, "N", i, "N", i + 1)
end
add!(ampo, -miu - U/2, "N", L)
add!(ampo, U/2, "N", L, "N", L)
H = toMPO(ampo)
state = InitState(sites)
for i in 1:L
setindex!(state, "3", i)
end
PrintData(sweeps)
psi0 = randomMPS(state)
energy, psi = dmrg(H, psi0, sweeps, "Quiet=", true)
file_name1 = "your_file1.txt"
open(file_name1, "w") do fp
println(fp, "$miu,$energy")
end
file_name2 = "your_file2.txt"
open(file_name2, "w") do fp
println(fp, "i,j,lgj,corf")
Numall = 0
for i in 1:L
position(psi, i)
ket = psi[i]
bra = dag(prime(ket, "Site"))
Numop = op(sites, "N", i)
Numi = elt(bra * Numop * ket)
Numall += Numi
println(fp, "$i,%.12f", Numi)
end
println(fp, "i,j,lgj,corf")
i = 1
for j in 2:L
position(psi, i)
corfop_i = op(sites, "Adag", i)
corfop_j = op(sites, "A", j)
psidag = dag(psi)
psidag.prime("Link")
l_i = leftLinkIndex(psi, i)
C = prime(psi[i], l_i) * corfop_i
C *= prime(psidag[i], "Site")
for k in i+1:j-1
C *= psi[k]
C *= psidag[k]
end
lj = rightLinkIndex(psi, j)
C *= prime(psi[j], lj) * corfop_j
C *= prime(psidag[j], "Site")
corf_1j = elt(C)
println(fp, "$i,$j,$(log10(j)),$corf_1j")
end
end
return 0
Looking forward to your help.