Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions examples/vumps/vumps_2d_heisenberg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ conserve_qns = true
solver_tol = (x -> x / 10)
outer_iters = 10 # Number of times to increase the bond dimension
width = 4
yperiodic = false # OBC vs cylinder

##############################################################################
# CODE BELOW HERE DOES NOT NEED TO BE MODIFIED
Expand All @@ -30,24 +31,29 @@ initstate(n) = isodd(n) ? "↑" : "↓"
s = infsiteinds("S=1/2", N; conserve_qns, initstate)
ψ = InfMPS(s, initstate)

function ITensorInfiniteMPS.unit_cell_terms(::Model"heisenberg2D"; width)
function ITensorInfiniteMPS.unit_cell_terms(::Model"heisenberg2D"; width, yperiodic)
opsum = OpSum()
for i in 1:width
# Vertical
opsum += -0.5, "S+", i, "S-", mod(i + 1, width)
opsum += -0.5, "S-", i, "S+", mod(i + 1, width)
opsum += "Sz", i, "Sz", mod(i + 1, width)
opsum += -0.5, "S+", i, "S-", i + 1
opsum += -0.5, "S-", i, "S+", i + 1
opsum += "Sz", i, "Sz", i + 1
# Horizontal
opsum += -0.5, "S+", i, "S-", i + width
opsum += -0.5, "S-", i, "S+", i + width
opsum += "Sz", i, "Sz", i + width
end
if yperiodic
opsum += -0.5, "S+", 1, "S-", width
opsum += -0.5, "S-", 1, "S+", width
opsum += "Sz", 1, "Sz", width
end
return opsum
end
model = Model("heisenberg2D")

# Form the Hamiltonian
H = InfiniteSum{MPO}(model, s; width)
H = InfiniteSum{MPO}(model, s; width, yperiodic)

# Check translational invariance
# println("\nCheck translation invariance of the initial VUMPS state")
Expand Down
8 changes: 8 additions & 0 deletions src/models/models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ function infinite_terms(opsum::OpSum; kwargs...)
# stores all terms starting on site `i`.
opsum_cell_dict = groupreduce(minimum ∘ ITensors.sites, +, opsum)
nsites = maximum(keys(opsum_cell_dict))
# check that we don't have terms we will ignore
dropped = filter(x -> x <= 0, keys(opsum_cell_dict))
if length(dropped) > 0
error(
"The input unit cell terms include terms that are being ignored on sites: $([d for d in dropped])",
)
end

# Assumes each site in the unit cell has a term
for j in 1:nsites
if !haskey(opsum_cell_dict, j)
Expand Down
Loading