Skip to content

Commit

Permalink
Start of multiplicity rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
BramVancraeynest authored Sep 21, 2023
1 parent c40df59 commit 47b20da
Showing 1 changed file with 72 additions and 28 deletions.
100 changes: 72 additions & 28 deletions src/CategoryData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,38 @@ using TensorKit: SimpleFusion, GenericFusion, Anyonic, NoBraiding

using SparseArrayKit

export FusionRing, UnitaryFusionCategory, UFC, PreModularFusionCategory, PMFC, Object
export FusionRing, SimpleFusionRing, UnitaryFusionCategory, UFC, PreModularFusionCategory, PMFC, Object
export multiplicity, rank

export H1, H3, ν, η, μ, ρ

######################
## Type definitions ##
######################
abstract type FusionRing{R,N,I} end
fusionring(::Type{<:FusionRing{R,N,I}}) where {R,N,I} = FusionRing{R,N,I}
Base.string(::Type{FusionRing{R,N,I}}) where {R,N,I} = "FR_$(R)_$(N)_$(I)"
abstract type FusionRing{R,N,I,m} end
fusionring(::Type{<:FusionRing{R,N,I,m}}) where {R,N,I,m} = FusionRing{R,N,I,m}
Base.string(::Type{FusionRing{R,N,I,m}}) where {R,N,I,m} = "FR_$(R)_$(N)_$(I)_$(m)"

rank(::Type{<:FusionRing{R}}) where {R} = R
selfduality(::Type{<:FusionRing{R,N}}) where {R,N} = N
multiplicity(::Type{<:FusionRing}) = 1 # currently does not allow multiplicity
multiplicity(::Type{<:FusionRing{R,N,I,m}}) where {R,N,I,m} = m # Support non-trivial multiplicity in development

const SimpleFusionRing{R,N,I} = FusionRing{R,N,I,1}
Base.string(::Type{SimpleFusionRing{R,N,I}}) where {R,N,I} = "FR_$(R)_$(N)_$(I)"

abstract type UnitaryFusionCategory{R,N,I,D} <: FusionRing{R,N,I} end
abstract type UnitaryFusionCategory{R,N,I,m,D} <: FusionRing{R,N,I,m} end

category_index(::Type{<:UnitaryFusionCategory{R,N,I,D}}) where {R,N,I,D} = D
category_index(::Type{<:UnitaryFusionCategory{R,N,I,m,D}}) where {R,N,I,m,D} = D

function Base.string(::Type{UnitaryFusionCategory{R,N,I,D}}) where {R,N,I,D}
return "FR_$(R)_$(N)_$(I)_$(D)"
end

abstract type PreModularFusionCategory{R,N,I,D₁,D₂} <: UnitaryFusionCategory{R,N,I,D₁} end
abstract type PreModularFusionCategory{R,N,I,m,D₁,D₂} <: UnitaryFusionCategory{R,N,I,m,D₁} end

braid_index(::Type{<:PreModularFusionCategory{R,N,I,D₁,D₂}}) where {R,N,I,D₁,D₂} = D₂
braid_index(::Type{<:PreModularFusionCategory{R,N,I,m,D₁,D₂}}) where {R,N,I,m,D₁,D₂} = D₂

function Base.string(::Type{PreModularFusionCategory{R,N,I,D₁,D₂}}) where {R,N,I,D₁,D₂}
function Base.string(::Type{PreModularFusionCategory{R,N,I,m,D₁,D₂}}) where {R,N,I,m,D₁,D₂}
return "FR_$(R)_$(N)_$(I)_$(D₁)_$(D₂)"
end

Expand All @@ -53,7 +58,8 @@ end
## Type aliases ##
##################

const UFC{R,N,I,D} = UnitaryFusionCategory{R,N,I,D}
const FR{R,N,I,m} = FusionRing{R,N,I,m}
const UFC{R,N,I,m,D} = UnitaryFusionCategory{R,N,I,m,D}
const PMFC{R,N,I,D₁,D₂} = PreModularFusionCategory{R,N,I,D₁,D₂}

const Z2 = PMFC{2,0,1,0,0}
Expand All @@ -69,9 +75,14 @@ const RepS4 = PMFC{5,0,6,1,0}
const Z5 = PMFC{5,4,1,0,0}
const Z6 = PMFC{6,4,1,0,0}

const Fib = UFC{2,0,2,0}
const H2 = UFC{6,2,8,2}
const H3 = UFC{6,2,8,3}
const H1 = UFC{4,0,1,2,0}
const μ = Object{H1}(2)
const η = Object{H1}(3)
const ν = Object{H1}(4)
const Fib = UFC{2,0,2,1,0}
const H2 = UFC{6,2,8,1,2}
const H3 = UFC{6,2,8,1,3}
const ρ = Object{H3}(4) # Need to double check!

##########################
## Common functionality ##
Expand Down Expand Up @@ -124,6 +135,7 @@ function _renew_artifacthash(filename="$versionName.tar.gz")
end

function list_available()
simplefusionrings = Type{<:SimpleFusionRing}[]
fusionrings = Type{<:FusionRing}[]
fusioncategories = Type{<:UnitaryFusionCategory}[]
braidedcategories = Type{<:PreModularFusionCategory}[]
Expand All @@ -132,30 +144,53 @@ function list_available()
FR_str = last(splitpath(dir))
prefix, R, N, I = split(FR_str, "_")
R, N, I = parse.(Int, (R, N, I))
push!(fusionrings, FusionRing{R,N,I})
push!(simplefusionrings, SimpleFusionRing{R,N,I})
elseif files == ["F.txt"]
FR_str, D_str = splitpath(dir)[(end - 1):end]
prefix, R, N, I = split(FR_str, "_")
R, N, I, D = parse.(Int, (R, N, I, D_str))
push!(fusioncategories, UnitaryFusionCategory{R,N,I,D})
push!(fusioncategories, UnitaryFusionCategory{R,N,I,1,D})
elseif files == ["R.txt"]
FR_str, D₁_str, D₂_str = splitpath(dir)[(end - 2):end]
prefix, R, N, I = split(FR_str, "_")
R, N, I, D₁, D₂ = parse.(Int, (R, N, I, D₁_str, D₂_str))
push!(braidedcategories, PreModularFusionCategory{R,N,I,D₁,D₂})
push!(braidedcategories, PreModularFusionCategory{R,N,I,1,D₁,D₂})
end
end
for (dir,_,files) in walkdir("folder")
if files == ["Nabc.txt"]
FR_str = last(splitpath(dir))
_, R, N, I, m = split(FR_str, "_")
R, N, I, m = parse.(Int, (R, N, I, m))
push!(fusionrings, FusionRing{R,N,I,m})
elseif files == ["F.txt"]
FR_str, D_str = splitpath(dir)[(end - 1):end]
prefix, R, N, I, m = split(FR_str, "_")
R, N, I, m, D = parse.(Int, (R, N, I, m, D_str))
push!(fusioncategories, UnitaryFusionCategory{R,N,I,m,D})
end
end
return fusionrings, fusioncategories, braidedcategories
return simplefusionrings, fusionrings, fusioncategories, braidedcategories
end

function Nsymbol_filename(ring::Type{<:FusionRing})
return joinpath(artifact"fusiondata", versionName, "uFC", string(fusionring(ring)),
if multiplicity(ring) == 1
return joinpath(artifact"fusiondata", versionName, "uFC", string(fusionring(ring)),
"Nabc.txt")
else
return joinpath(dirname(@__FILE__), "../data/", string(fusionring(ring)),
"Nabc.txt")
end
end

function Fsymbol_filename(ring::Type{<:UnitaryFusionCategory})
return joinpath(artifact"fusiondata", versionName, "uFC", string(fusionring(ring)),
if multiplicity(ring) == 1
return joinpath(artifact"fusiondata", versionName, "uFC", string(fusionring(ring)),
"$(category_index(ring))", "F.txt")
else
return joinpath(dirname(@__FILE__), "../data/", string(fusionring(ring)),
"F.txt")
end
end

function Rsymbol_filename(ring::Type{<:PreModularFusionCategory})
Expand Down Expand Up @@ -203,15 +238,24 @@ function parse_Fsymbol(line)
return labels..., val
end

function extract_Fsymbol(category::Type{<:UFC{R,N,I,D}}) where {R,N,I,D}
function extract_Fsymbol(category::Type{<:UFC{R,N,I,m,D}}) where {R,N,I,m,D}
filename = Fsymbol_filename(category)
r = rank(category)
F_array = SparseArray{ComplexF64}(undef, (r, r, r, r, r, r))

for line in eachline(filename)
a, b, c, d, α, e, β, μ, f, ν, val = parse_Fsymbol(line)
μ == ν == α == β == 1 || error("not multiplicity-free")
F_array[a, b, c, d, e, f] = val
if m == 1 # Is this optimal?
F_array = SparseArray{ComplexF64}(undef, (R, R, R, R, R, R))

for line in eachline(filename)
a, b, c, d, α, e, β, μ, f, ν, val = parse_Fsymbol(line)
μ == ν == α == β == 1 || error("not multiplicity-free")
F_array[a, b, c, d, e, f] = val
end
else
F_array = SparseArray{ComplexF64}(undef, (R, R, R, R, R, R, m, m, m, m))

for line in eachline(filename)
a, b, c, d, α, e, β, μ, f, ν, val = parse_Fsymbol(line)
F_array[a, b, c, d, e, f, α, β, μ, ν] = val
end
end

return isreal(F_array) ? convert(SparseArray{Float64}, F_array) : F_array
Expand Down Expand Up @@ -268,4 +312,4 @@ end
return :(getindex($(R_array), a.id, b.id, c.id))
end

end
end

0 comments on commit 47b20da

Please sign in to comment.