Skip to content

Commit

Permalink
Fix issue and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
emstoudenmire committed Jul 28, 2023
1 parent b752466 commit e82d31a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/physics/autompo/opsum_to_mpo_qn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ function qn_svdMPO(os::OpSum{C}, sites; kwargs...)::MPO where {C}
for (q_op, M) in block
op_prod = q_op[2]
Op = computeSiteProd(sites, Prod(op_prod))
(nnzblocks(Op) == 0) && continue

rq = q_op[1]
sq = flux(Op)
Expand Down
16 changes: 16 additions & 0 deletions test/ITensorLegacyMPS/base/test_autompo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,22 @@ end
@test all(linkdims(H) .<= 2)
@test_broken all(linkdims(H) .== 1)
end

@testset "Regression test (Issue 1150): Zero blocks operator" begin
N = 4
sites = siteinds("Fermion", N; conserve_qns=true)
os = OpSum()
os += (1.111, "Cdag", 3, "Cdag", 4, "C", 2, "C", 1)
os += (2.222, "Cdag", 4, "Cdag", 1, "C", 3, "C", 2)
os += (3.333, "Cdag", 1, "Cdag", 4, "C", 4, "C", 1)
os += (4.444, "Cdag", 2, "Cdag", 3, "C", 1, "C", 4)
# The following operator has C on site 2 twice, resulting
# in a local operator with no blocks (exactly zero),
# causing a certain logical step in working out the column qn
# to fail:
os += (5.555, "Cdag", 4, "Cdag", 4, "C", 2, "C", 2)
@test_nowarn H = MPO(os, sites)
end
end

nothing

0 comments on commit e82d31a

Please sign in to comment.