Skip to content

Commit 25976bc

Browse files
committed
Some spinoperator fixes
1 parent 4291bed commit 25976bc

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/operators/spinoperators.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,19 @@ function S_y(elt::Type{<:Complex}, ::Type{U1Irrep}; spin=1 // 2, side=:L)
147147
for (f1, f2) in fusiontrees(Y)
148148
c₁, c₂ = f1.uncoupled[1], f2.uncoupled[1]
149149
if c₁.charge == c₂.charge + 1
150-
Y[f1, f2] .= _pauliterm(spin, c₁, c₂)im
151-
elseif c₁.charge + 1 == c₂.charge
152150
Y[f1, f2] .= -_pauliterm(spin, c₁, c₂)im
151+
elseif c₁.charge + 1 == c₂.charge
152+
Y[f1, f2] .= +_pauliterm(spin, c₁, c₂)im
153153
end
154154
end
155155
elseif side == :R
156156
Y = TensorMap(zeros, elt, vspace pspace pspace)
157157
for (f1, f2) in fusiontrees(Y)
158158
c₁, c₂ = f1.uncoupled[2], f2.uncoupled[1]
159159
if c₁.charge == c₂.charge + 1
160-
Y[f1, f2] .= _pauliterm(spin, c₁, c₂)im
161-
elseif c₁.charge + 1 == c₂.charge
162160
Y[f1, f2] .= -_pauliterm(spin, c₁, c₂)im
161+
elseif c₁.charge + 1 == c₂.charge
162+
Y[f1, f2] .= _pauliterm(spin, c₁, c₂)im
163163
end
164164
end
165165
else
@@ -215,8 +215,8 @@ function S_z(elt::Type{<:Number}, ::Type{U1Irrep}; spin=1 // 2)
215215
charges = U1Irrep.((-spin):spin)
216216
pspace = U1Space((v => 1 for v in charges))
217217
Z = TensorMap(zeros, elt, pspace pspace)
218-
for (i, c) in enumerate(charges)
219-
blocks(Z)[c] .= spin + 1 - i
218+
for (c, b) in blocks(Z)
219+
b .= c.charge
220220
end
221221
return Z
222222
end
@@ -265,16 +265,16 @@ end
265265
function S_plus(elt::Type{<:Number}, ::Type{U1Irrep}; spin=1 // 2, side=:L)
266266
pspace = U1Space(i => 1 for i in (-spin):spin)
267267
if side == :L
268-
vspace = U1Space(-1 => 1)
268+
vspace = U1Space(1 => 1)
269269
S⁺ = TensorMap(zeros, elt, pspace pspace vspace)
270270
for (c, b) in blocks(S⁺)
271-
b .= 2 * _pauliterm(spin, c, only(c U1Irrep(+1)))
271+
b .= 2 * _pauliterm(spin, c, only(c U1Irrep(-1)))
272272
end
273273
elseif side == :R
274-
vspace = U1Space(1 => 1)
274+
vspace = U1Space(-1 => 1)
275275
S⁺ = TensorMap(zeros, elt, vspace pspace pspace)
276276
for (c, b) in blocks(S⁺)
277-
b .= 2 * _pauliterm(spin, only(c U1Irrep(-1)), c)
277+
b .= 2 * _pauliterm(spin, only(c U1Irrep(+1)), c)
278278
end
279279
else
280280
throw(ArgumentError("invalid side `:$side`"))
@@ -326,16 +326,16 @@ end
326326
function S_min(elt::Type{<:Number}, ::Type{U1Irrep}; spin=1 // 2, side=:L)
327327
pspace = U1Space(i => 1 for i in (-spin):spin)
328328
if side == :L
329-
vspace = U1Space(1 => 1)
329+
vspace = U1Space(-1 => 1)
330330
S⁻ = TensorMap(zeros, elt, pspace pspace vspace)
331331
for (c, b) in blocks(S⁻)
332-
b .= 2 * _pauliterm(spin, only(c U1Irrep(-1)), c)
332+
b .= 2 * _pauliterm(spin, only(c U1Irrep(+1)), c)
333333
end
334334
elseif side == :R
335-
vspace = U1Space(-1 => 1)
335+
vspace = U1Space(+1 => 1)
336336
S⁻ = TensorMap(zeros, elt, vspace pspace pspace)
337337
for (c, b) in blocks(S⁻)
338-
b .= 2 * _pauliterm(spin, c, only(c U1Irrep(+1)))
338+
b .= 2 * _pauliterm(spin, c, only(c U1Irrep(-1)))
339339
end
340340
else
341341
throw(ArgumentError("invalid side `:$side`"))

test/spinoperators.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ end
9797
@testset "U1-symmetric spin $(Int(2spin))/2 operators" for spin in (1 // 2):(1 // 2):4
9898
# array conversion
9999
N = Int(2spin + 1)
100-
p = sortperm((-spin):spin; by=x -> abs(x - 0.1)) # sort as 0, 1, -1, 2, -2, ...
100+
p = sortperm(reverse((-spin):spin); by=x -> abs(x - 0.1)) # sort as 0, 1, -1, 2, -2, ...
101101
H = one(zeros(N, N))[p, :]
102102
@test H * convert(Array, S_z(; spin=spin)) * H'
103103
convert(Array, S_z(U1Irrep; spin=spin))

0 commit comments

Comments
 (0)