From bdb140af70fff0e6829a56fdcc9f6be232965b82 Mon Sep 17 00:00:00 2001 From: Ryan Levy Date: Fri, 11 Oct 2024 08:23:35 -0400 Subject: [PATCH 1/4] Fix 2d heisenberg and add warning --- examples/vumps/vumps_2d_heisenberg.jl | 6 +++--- src/models/models.jl | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/vumps/vumps_2d_heisenberg.jl b/examples/vumps/vumps_2d_heisenberg.jl index 968606d..35118d1 100644 --- a/examples/vumps/vumps_2d_heisenberg.jl +++ b/examples/vumps/vumps_2d_heisenberg.jl @@ -34,9 +34,9 @@ function ITensorInfiniteMPS.unit_cell_terms(::Model"heisenberg2D"; width) 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-", mod(i, width) + 1 + opsum += -0.5, "S-", i, "S+", mod(i, width) + 1 + opsum += "Sz", i, "Sz", mod(i, width) + 1 # Horizontal opsum += -0.5, "S+", i, "S-", i + width opsum += -0.5, "S-", i, "S+", i + width diff --git a/src/models/models.jl b/src/models/models.jl index 206defd..ac0b3a2 100644 --- a/src/models/models.jl +++ b/src/models/models.jl @@ -245,6 +245,12 @@ 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 + @warn "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) From f75c6e887a60185ea5de5d98f3af5237b5bf0176 Mon Sep 17 00:00:00 2001 From: Ryan Levy Date: Fri, 11 Oct 2024 13:45:18 -0400 Subject: [PATCH 2/4] Cleanup --- examples/vumps/vumps_2d_heisenberg.jl | 6 +++--- src/models/models.jl | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/vumps/vumps_2d_heisenberg.jl b/examples/vumps/vumps_2d_heisenberg.jl index 35118d1..b66b94e 100644 --- a/examples/vumps/vumps_2d_heisenberg.jl +++ b/examples/vumps/vumps_2d_heisenberg.jl @@ -34,9 +34,9 @@ function ITensorInfiniteMPS.unit_cell_terms(::Model"heisenberg2D"; width) opsum = OpSum() for i in 1:width # Vertical - opsum += -0.5, "S+", i, "S-", mod(i, width) + 1 - opsum += -0.5, "S-", i, "S+", mod(i, width) + 1 - opsum += "Sz", i, "Sz", mod(i, width) + 1 + 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 diff --git a/src/models/models.jl b/src/models/models.jl index ac0b3a2..e159175 100644 --- a/src/models/models.jl +++ b/src/models/models.jl @@ -248,7 +248,9 @@ function infinite_terms(opsum::OpSum; kwargs...) # check that we don't have terms we will ignore dropped = filter(x -> x <= 0, keys(opsum_cell_dict)) if length(dropped) > 0 - @warn "The input unit cell terms include terms that are being ignored on sites: $([d for d in dropped])" + 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 From 1a08e3285f509528b0c7e65aedd1c9c1955d5715 Mon Sep 17 00:00:00 2001 From: Ryan Levy Date: Mon, 14 Oct 2024 07:12:04 -0400 Subject: [PATCH 3/4] Add yperiodic option --- examples/vumps/vumps_2d_heisenberg.jl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/vumps/vumps_2d_heisenberg.jl b/examples/vumps/vumps_2d_heisenberg.jl index b66b94e..47a69f4 100644 --- a/examples/vumps/vumps_2d_heisenberg.jl +++ b/examples/vumps/vumps_2d_heisenberg.jl @@ -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 @@ -30,7 +31,7 @@ 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 @@ -42,12 +43,17 @@ function ITensorInfiniteMPS.unit_cell_terms(::Model"heisenberg2D"; 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") From bbb6106f39440ba1c2daf15aa8e446d49f7784cf Mon Sep 17 00:00:00 2001 From: Ryan Levy Date: Mon, 14 Oct 2024 11:15:24 -0400 Subject: [PATCH 4/4] Negative sign fix --- examples/vumps/vumps_2d_heisenberg.jl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/vumps/vumps_2d_heisenberg.jl b/examples/vumps/vumps_2d_heisenberg.jl index 47a69f4..f82c03c 100644 --- a/examples/vumps/vumps_2d_heisenberg.jl +++ b/examples/vumps/vumps_2d_heisenberg.jl @@ -35,17 +35,17 @@ function ITensorInfiniteMPS.unit_cell_terms(::Model"heisenberg2D"; width, yperio opsum = OpSum() for i in 1:width # Vertical - opsum += -0.5, "S+", i, "S-", i + 1 - opsum += -0.5, "S-", i, "S+", i + 1 + 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 -= 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 -= 0.5, "S+", 1, "S-", width + opsum -= 0.5, "S-", 1, "S+", width opsum += "Sz", 1, "Sz", width end return opsum