Skip to content

Commit 4e32695

Browse files
committed
Add initial fileloading
1 parent b80c391 commit 4e32695

File tree

4 files changed

+90
-1
lines changed

4 files changed

+90
-1
lines changed

Artifacts.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[fusiondata]
2+
git-tree-sha1 = "78815c991b175f649504b29f6d52101bc7ee8ead"
3+
4+
[[fusiondata.download]]
5+
sha256 = "95de3103709cdf08e25f098ead80eb9bec9965568720ddbec80d83e52f9102a5"
6+
url = "https://github.com/QuantumKitHub/MultiTensorKit.jl/archive/refs/tags/data-v0.1.0.tar.gz"

Project.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,13 @@ uuid = "f0555a46-f681-4ef1-bed5-d64870568636"
33
authors = ["Boris De Vos, Laurens Lootens and Lukas Devos"]
44
version = "0.1.0"
55

6+
[deps]
7+
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
8+
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
9+
TensorKitSectors = "13a9c161-d5da-41f0-bcbd-e1a08ae0647f"
10+
611
[compat]
12+
Artifacts = "1.11.0"
13+
JSON3 = "1.14.1"
14+
TensorKitSectors = "0.1.2"
715
julia = "1.10"

src/MultiTensorKit.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
module MultiTensorKit
22

3-
# Write your package code here.
3+
export BimoduleSector, A4Object
4+
5+
using JSON3
6+
using Artifacts
7+
using TensorKitSectors
8+
9+
include("bimodulesector.jl")
410

511
end

src/bimodulesector.jl

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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

Comments
 (0)