Skip to content

Commit b3e6fb0

Browse files
committed
Update docstring and error messages
1 parent 66922a7 commit b3e6fb0

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/algorithms/contractions/localoperator.jl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ function _contract_state_expr(rowrange, colrange, height, cartesian_inds = nothi
160160
end
161161

162162
function _contract_pepo_state_expr(rowrange, colrange, height, cartesian_inds = nothing)
163+
@assert height == 1 || height == 2 "Contraction with more than 2 layers of PEPO is unintended."
163164
rmin, rmax = extrema(rowrange)
164165
cmin, cmax = extrema(colrange)
165166
gridsize = (rmax - rmin + 1, cmax - cmin + 1)
166-
167167
return map(1:height) do side
168168
return map(Iterators.product(1:gridsize[1], 1:gridsize[2])) do (i, j)
169169
inds_id = if isnothing(cartesian_inds)
@@ -183,7 +183,7 @@ function _contract_pepo_state_expr(rowrange, colrange, height, cartesian_inds =
183183
physicallabel(:O, 1, inds_id)
184184
end
185185
tensor_name = :(twistdual(state[1][mod1($(rmin + i - 1), end), mod1($(cmin + j - 1), end)], 2))
186-
elseif height == 2
186+
else
187187
physical_label_in = if isnothing(inds_id)
188188
physicallabel(:in, i, j)
189189
else
@@ -199,8 +199,6 @@ function _contract_pepo_state_expr(rowrange, colrange, height, cartesian_inds =
199199
else
200200
:(twistdual(state[1][mod1($(rmin + i - 1), end), mod1($(cmin + j - 1), end)], (1, 2)))
201201
end
202-
else
203-
error("tba")
204202
end
205203

206204
return tensorexpr(
@@ -315,8 +313,8 @@ end
315313
@doc """
316314
$(SIGNATURES)
317315
318-
Construct the reduced density matrix `ρ` of the PEPS `peps` with open indices `inds` using the environment `env`.
319-
Alternatively, construct the reduced density matrix `ρ` of a full density matrix PEPO with open indices `inds` using the environment `env`.
316+
Construct the reduced density matrix `ρ` of PEPS or PEPO (representing PEPS with ancilla legs) `ket`, `bra` with open indices `inds` using the environment `env`.
317+
Alternatively, construct the reduced density matrix `ρ` of a mixed state specified by the density matrix PEPO `state` with open indices `inds` using the environment `env`.
320318
321319
This works by generating the appropriate contraction on a rectangular patch with its corners
322320
specified by `inds`. The result is normalized such that `tr(ρ) = 1`.
@@ -553,13 +551,13 @@ end
553551
@generated function _contract_densitymatrix(
554552
inds::NTuple{N, Val}, state::Tuple{InfinitePEPO, Vararg{InfinitePEPO, M}}, env::CTMRGEnv
555553
) where {N, M}
554+
height = M + 1
555+
@assert height == 1 || height == 2 "Contraction with more than 2 layers of PEPO is unintended."
556556
cartesian_inds = collect(CartesianIndex{2}, map(x -> x.parameters[1], inds.parameters)) # weird hack to extract information from Val
557557
allunique(cartesian_inds) ||
558558
throw(ArgumentError("Indices should not overlap: $cartesian_inds."))
559559
rowrange = getindex.(cartesian_inds, 1)
560560
colrange = getindex.(cartesian_inds, 2)
561-
height = M + 1
562-
@assert height == 1 || height == 2 "TBA"
563561

564562
corner_NW, corner_NE, corner_SE, corner_SW = _contract_corner_expr(rowrange, colrange)
565563
edges_N, edges_E, edges_S, edges_W = _contract_edge_expr(rowrange, colrange, height)

0 commit comments

Comments
 (0)