Skip to content

Commit

Permalink
add O(2) group
Browse files Browse the repository at this point in the history
  • Loading branch information
ogauthe committed Aug 15, 2024
1 parent 7397ba6 commit e2548ee
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 2 deletions.
1 change: 1 addition & 0 deletions NDTensors/src/lib/Sectors/src/Sectors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include("symmetry_style.jl")
include("abstractcategory.jl")
include("category_definitions/fib.jl")
include("category_definitions/ising.jl")
include("category_definitions/o2.jl")
include("category_definitions/su.jl")
include("category_definitions/su2k.jl")
include("category_definitions/u1.jl")
Expand Down
64 changes: 64 additions & 0 deletions NDTensors/src/lib/Sectors/src/category_definitions/o2.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#
# Orthogonal group O(2)
# isomorphic to Z_2 ⋉ U(1)
# corresponds to to SU(2) subgroup with Sz conservation + Sz-reversal
#

struct O2 <: AbstractCategory
l::HalfIntegers.Half{Int}
end

SymmetryStyle(::O2) = NonAbelianGroup()

category_label(s::O2) = s.l

trivial(::Type{O2}) = O2(0)
zero_odd(::Type{O2}) = O2(-1)

_iszero(s::O2) = _iszero(category_label(s))
_iszero_even(s::O2) = _iszero_even(category_label(s))
_iszero_odd(s::O2) = _iszero_odd(category_label(s))

_iszero(l::HalfIntegers.HalfInteger) = _iszero_even(l) || _iszero_odd(l)
_iszero_even(l::HalfIntegers.HalfInteger) = l == category_label(trivial(O2))
_iszero_odd(l::HalfIntegers.HalfInteger) = l == category_label(zero_odd(O2))

quantum_dimension(::NonAbelianGroup, s::O2) = 2 - _iszero(s)

GradedAxes.dual(s::O2) = s

function Base.show(io::IO, s::O2)
if _iszero_odd(s)
disp = "0o"
elseif _iszero_even(s)
disp = "0e"
else
disp = "±" * string(category_label(s))
end
return print(io, "O(2)[", disp, "]")
end

function label_fusion_rule(::Type{O2}, l1, l2)
if _iszero(l1)
degens = [1]
if _iszero(l2)
labels = l1 == l2 ? [category_label(trivial(O2))] : [category_label(zero_odd(O2))]
else
labels = [l2]
end
else
if _iszero(l2)
degens = [1]
labels = [l1]
else
if l1 == l2
degens = [1, 1, 1]
labels = [category_label(zero_odd(O2)), category_label(trivial(O2)), 2 * l1]
else
degens = [1, 1]
labels = [abs(l1 - l2), l1 + l2]
end
end
end
return degens, labels
end
25 changes: 24 additions & 1 deletion NDTensors/src/lib/Sectors/test/test_fusion_rules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using NDTensors.GradedAxes:
dual, fusion_product, gradedisequal, gradedrange, flip, tensor_product
using NDTensors.Sectors:
, Fib, Ising, SU, SU2, U1, Z, block_dimensions, quantum_dimension, trivial
, Fib, Ising, O2, SU, SU2, U1, Z, block_dimensions, quantum_dimension, trivial
using Test: @inferred, @test, @testset, @test_throws

@testset "Simple object fusion rules" begin
Expand Down Expand Up @@ -35,6 +35,29 @@ using Test: @inferred, @test, @testset, @test_throws
@test q2 q1 == U1(3)
@test (@inferred q1 q2) == q3 # no better way, see Julia PR 23426
end

@testset "O2 fusion rules" begin
s0e = O2(0)
s0o = O2(-1)
s12 = O2(1//2)
s1 = O2(1)

@test gradedisequal((@inferred s0e s0e), gradedrange([s0e => 1]))
@test gradedisequal((@inferred s0o s0e), gradedrange([s0o => 1]))
@test gradedisequal((@inferred s0o s0e), gradedrange([s0o => 1]))
@test gradedisequal((@inferred s0o s0o), gradedrange([s0e => 1]))

@test gradedisequal((@inferred s0e s12), gradedrange([s12 => 1]))
@test gradedisequal((@inferred s0o s12), gradedrange([s12 => 1]))
@test gradedisequal((@inferred s12 s0e), gradedrange([s12 => 1]))
@test gradedisequal((@inferred s12 s0o), gradedrange([s12 => 1]))
@test gradedisequal((@inferred s12 s1), gradedrange([s12 => 1, O2(3//2) => 1]))
@test gradedisequal((@inferred s12 s12), gradedrange([s0o => 1, s0e => 1, s1 => 1]))

@test (@inferred quantum_dimension(s0o s1)) == 2
@test (@inferred block_dimensions(s0o s1)) == [2]
end

@testset "SU2 fusion rules" begin
j1 = SU2(0)
j2 = SU2(1//2)
Expand Down
33 changes: 32 additions & 1 deletion NDTensors/src/lib/Sectors/test/test_simple_categories.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
@eval module $(gensym())
using NDTensors.GradedAxes: dual
using NDTensors.Sectors:
Fib, Ising, SU, SU2, U1, Z, adjoint, quantum_dimension, fundamental, istrivial, trivial
Fib,
Ising,
O2,
SU,
SU2,
U1,
Z,
adjoint,
quantum_dimension,
fundamental,
istrivial,
trivial
using Test: @inferred, @test, @testset, @test_throws
@testset "Test Category Types" begin
@testset "U(1)" begin
Expand Down Expand Up @@ -41,6 +52,26 @@ using Test: @inferred, @test, @testset, @test_throws
@test !isless(Z{2}(1), Z{2}(0))
end

@testset "O(2)" begin
s0e = O2(0)
s0o = O2(-1)
s12 = O2(1//2)
s1 = O2(1)

@test trivial(O2) == s0e
@test istrivial(s0e)

@test (@inferred quantum_dimension(s0e)) == 1
@test (@inferred quantum_dimension(s0o)) == 1
@test (@inferred quantum_dimension(s12)) == 2
@test (@inferred quantum_dimension(s1)) == 2

@test (@inferred dual(s0e)) == s0e
@test (@inferred dual(s0o)) == s0o
@test (@inferred dual(s12)) == s12
@test (@inferred dual(s1)) == s1
end

@testset "SU2" begin
j1 = SU2(0)
j2 = SU2(1//2) # Rational will be cast to HalfInteger
Expand Down

0 comments on commit e2548ee

Please sign in to comment.