|
| 1 | +struct BimoduleSector{Name} <: Sector |
| 2 | + i::Int |
| 3 | + j::Int |
| 4 | + label::Int |
| 5 | +end |
| 6 | + |
| 7 | +const A4Object = BimoduleSector{:A4} |
| 8 | + |
| 9 | +# Data from files |
| 10 | +# --------------- |
| 11 | +const artifact_path = joinpath(artifact"fusiondata", "MultiTensorKit.jl-data-v0.1.0") |
| 12 | + |
| 13 | +function extract_Nsymbol(::Type{A4Object}) |
| 14 | + filename = joinpath(artifact_path, "A4", "Nsymbol.json") |
| 15 | + isfile(filename) || throw(LoadError(filename, 0, "Nsymbol file not found for $Name")) |
| 16 | + json_string = read(filename, String) |
| 17 | + Narray = copy(JSON3.read(json_string)) |
| 18 | + return map(reshape(Narray, 12, 12, 12)) do x |
| 19 | + y = Dict{NTuple{3,Int},Int}() |
| 20 | + for (k, v) in x |
| 21 | + a, b, c = parse.(Int, split(string(k)[2:(end - 1)], ", ")) |
| 22 | + y[(a, b, c)] = v |
| 23 | + end |
| 24 | + end |
| 25 | +end |
| 26 | + |
| 27 | +let Ncache = extract_Nsymbol(A4Object) |
| 28 | + function TensorKitSectors.Nsymbol(a::I, b::I, c::I) where {I<:A4Object} |
| 29 | + # TODO: should this error or return 0? |
| 30 | + (a.j == b.i && a.i == c.i && b.j == c.j) || |
| 31 | + throw(ArgumentError("invalid fusion channel")) |
| 32 | + i, j, k = a.i, a.j, b.j |
| 33 | + return get(Ncache[i, j, k], (a.label, b.label, c.label), 0) |
| 34 | + end |
| 35 | +end |
| 36 | + |
| 37 | +function extract_Fsymbol(::Type{A4Object}) |
| 38 | + return mapreduce(vcat, 1:12) do i |
| 39 | + filename = joinpath(artifact_path, "A4", "Fsymbol$i.json") |
| 40 | + @assert isfile(filename) |
| 41 | + json_string = read(filename, String) |
| 42 | + Farray_part = copy(JSON3.read(json_string)) |
| 43 | + return map(reshape(Farray_part, 12, 12, 12, 12)) do x |
| 44 | + y = Dict{NTuple{6,Int},ComplexF64}() |
| 45 | + for (k, v) in x |
| 46 | + a, b, c, d, e, f = parse.(Int, split(string(k)[2:(end - 1)], ", ")) |
| 47 | + y[(a, b, c, d, e, f)] = v |
| 48 | + end |
| 49 | + end |
| 50 | + end |
| 51 | +end |
| 52 | + |
| 53 | +let Fcache = extract_Fsymbol(A4Object) |
| 54 | + function TensorKitSectors.Fsymbol(a::I, b::I, c::I, d::I, e::I, |
| 55 | + f::I) where {I<:A4Object} |
| 56 | + # TODO: should this error or return 0? |
| 57 | + (a.j == b.i && b.j == c.i && a.i == d.i && c.j == d.j && |
| 58 | + a.i == e.i && b.j == e.j && f.i == a.j && f.j == c.j) || |
| 59 | + throw(ArgumentError("invalid fusion channel")) |
| 60 | + |
| 61 | + i, j, k, l = a.i, a.j, b.j, c.j |
| 62 | + return get(Fcache[i, j, k, l], |
| 63 | + (a.label, b.label, c.label, d.label, e.label, f.label)) do |
| 64 | + return zeros(sectorscalartype(A4Object), |
| 65 | + (Nsymbol(a, b, e), Nsymbol(e, c, d), Nsymbol(b, c, f), |
| 66 | + Nsymbol(a, f, d))) |
| 67 | + end |
| 68 | + end |
| 69 | +end |
0 commit comments