Skip to content

Commit ea96a5c

Browse files
committed
Refactor ambiguous braiding checks
1 parent 9474f06 commit ea96a5c

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

src/transfermatrix/transfer.jl

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,21 @@ end
6868
# the transfer operation of a density matrix with a utility leg in its codomain is ill defined - how should one braid the utility leg?
6969
# hence the checks - to make sure that this operation is uniquely defined
7070
function transfer_left(v::MPSTensor{S}, A::MPSTensor{S}, Ab::MPSTensor{S}) where {S}
71-
_can_unambiguously_braid(space(v, 2)) ||
72-
throw(ArgumentError("transfer is not uniquely defined with utility space $(space(v,2))"))
71+
check_ambiguous_braiding(space(v, 2))
7372
@plansor v[-1 -2; -3] := v[1 2; 4] * A[4 5; -3] * τ[2 3; 5 -2] * conj(Ab[1 3; -1])
7473
end
7574
function transfer_right(v::MPSTensor{S}, A::MPSTensor{S}, Ab::MPSTensor{S}) where {S}
76-
_can_unambiguously_braid(space(v, 2)) ||
77-
throw(ArgumentError("transfer is not uniquely defined with utility space $(space(v,2))"))
75+
check_ambiguous_braiding(space(v, 2))
7876
@plansor v[-1 -2; -3] := A[-1 2; 1] * τ[-2 4; 2 3] * conj(Ab[-3 4; 5]) * v[1 3; 5]
7977
end
8078

8179
# the transfer operation with a utility leg in both the domain and codomain is also ill defined - only due to the codomain utility space
8280
function transfer_left(v::MPOTensor{S}, A::MPSTensor{S}, Ab::MPSTensor{S}) where {S}
83-
_can_unambiguously_braid(space(v, 2)) ||
84-
throw(ArgumentError("transfer is not uniquely defined with utility space $(space(v,2))"))
81+
check_ambiguous_braiding(space(v, 2))
8582
@plansor t[-1 -2; -3 -4] := v[1 2; -3 4] * A[4 5; -4] * τ[2 3; 5 -2] * conj(Ab[1 3; -1])
8683
end
8784
function transfer_right(v::MPOTensor{S}, A::MPSTensor{S}, Ab::MPSTensor{S}) where {S}
88-
_can_unambiguously_braid(space(v, 2)) ||
89-
throw(ArgumentError("transfer is not uniquely defined with utility space $(space(v,2))"))
85+
check_ambiguous_braiding(space(v, 2))
9086
@plansor t[-1 -2; -3 -4] := A[-1 2; 1] * τ[-2 4; 2 3] * conj(Ab[-4 4; 5]) * v[1 3; -3 5]
9187
end
9288

src/utility/utility.jl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,6 @@ function _embedders(spaces)
8989
return maps
9090
end
9191

92-
function _can_unambiguously_braid(sp::VectorSpace)
93-
s = sectortype(sp)
94-
95-
BraidingStyle(s) isa SymmetricBraiding && return true
96-
97-
# if it's not symmetric, then we are only really garantueed that this is possible when only one irrep occurs - the trivial one
98-
for sect in sectors(sp)
99-
sect == one(sect) || return false
100-
end
101-
return true
102-
end
10392

10493
#=
10594
map every element in the tensormap to dfun(E)
@@ -143,3 +132,15 @@ end
143132
function fuser(::Type{T}, V1::S, V2::S) where {T,S<:IndexSpace}
144133
return isomorphism(T, fuse(V1 V2), V1 V2)
145134
end
135+
136+
# Verify that the braiding is unambiguous: either through symmetric braiding or because the
137+
# sectors are all trivial
138+
function check_ambiguous_braiding(::Type{Bool}, V::VectorSpace)
139+
I = sectortype(V)
140+
BraidingStyle(I) isa SymmetricBraiding && return true
141+
return all(isone, sectors(V))
142+
end
143+
function check_ambiguous_braiding(V::VectorSpace)
144+
return check_ambiguous_braiding(Bool, V) ||
145+
throw(ArgumentError("cannot unambiguously braid $V"))
146+
end

0 commit comments

Comments
 (0)