-
Notifications
You must be signed in to change notification settings - Fork 1
First draft of FusionTensor #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
3dd5ff2
split project
ogauthe 11a5d88
write intersect_sectors
ogauthe afed27a
define tree_to_block_mapping
ogauthe 5ed5b8e
define getindex
ogauthe d66540c
array cast with FusionTree
ogauthe a9dc29f
clean Base
ogauthe d7edb71
reuse tree_block_mapping in Base operations
ogauthe 4a8f9ba
working permutedims
ogauthe e75d783
fix contract
ogauthe 705b7aa
put imports on top of files
ogauthe deaf6b1
move check_sanity to tests
ogauthe 8ab786e
rewrite test FusionTree
ogauthe 563bae1
cleaning
ogauthe b35757b
cache unitary coeff
ogauthe 0299e4b
fix tests
ogauthe 4647030
simplify cast_to_array
ogauthe e53bffd
update to BlockSparseArrays 0.2.0
ogauthe 2794d60
use map_blocklabels
ogauthe a23939c
fix signatures for fusiontensor_permutedims
ogauthe f9b0daa
define unsafe_cast_from_array
ogauthe d816193
use @strided
ogauthe 899bed8
rename FusionTree SectorFusionTree
ogauthe 3ef076d
use @view!
ogauthe cdd3a2f
use fusiontensor when data_matrix is provided
ogauthe 9ed1f1a
Merge branch 'main' into dev
ogauthe 4f746b8
move tests
ogauthe 6528b63
check matrix axes in fusiontensor
ogauthe cc9c7dc
remove unused variable
ogauthe 067403b
fix tests
ogauthe ee06e3f
Loosen LinearAlgebra compat
mtfishman 837e151
fix names in array_cast
ogauthe 423b275
Bump TypeParameterAccessors to v0.2
mtfishman 7decaa4
remove getindex(::Tuple)
ogauthe 3eb6a8e
remove ndims
ogauthe 62e09ef
simplify similar
ogauthe 4057fe8
rewrite linear_algebra
ogauthe f663d05
use do block
ogauthe 03080e3
use Accessors
ogauthe 9247074
use AbstractArray similar(::FusionTensor)
ogauthe 22c5e51
replace matching_axes with checkaxes
ogauthe ab9a76a
rename to_array
ogauthe aaac06a
define atol and rtol for array_cast
ogauthe 591bcbc
fix sector_type
ogauthe 192fe47
use sector_type(FusionTree)
ogauthe 5f2452d
remove to_tuple
ogauthe 4e94367
define fusiontree_eltype
ogauthe 20a3119
avoid code dupplication
ogauthe 260760f
remove FusedAxes
ogauthe 7342477
better names
ogauthe cb15d63
replace FusionTensor with to_fusiontensor
ogauthe b751f9e
fix to_fusiontensor name
ogauthe 1dc72ae
use do block
ogauthe d3b624e
inline return
ogauthe f6ae180
use BlockedTuple
ogauthe 20d5ff5
fix test
ogauthe 98294e7
use contract for outer product
ogauthe 7ecea43
remove stale dep
ogauthe c754d35
remove unneeded similar
ogauthe 7aad297
improve names and loops
ogauthe 22d91f9
LRU{Any,Float64}
ogauthe 6b68a54
fix zerodim tests
ogauthe bc22b8d
explicit flip of domain tree
ogauthe 64c6ac4
pass basic tests
ogauthe 54c070a
pass tests
ogauthe dc90ecf
fix ambiguity
ogauthe 1a00fd2
remove gen module
ogauthe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,37 @@ | ||
name = "FusionTensors" | ||
uuid = "e16ca583-1f51-4df0-8e12-57d32947d33e" | ||
authors = ["ITensor developers <[email protected]> and contributors"] | ||
version = "0.1.0" | ||
version = "0.2.1" | ||
|
||
[deps] | ||
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" | ||
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e" | ||
BlockSparseArrays = "2c9a651f-6452-4ace-a6ac-809f4280fbb4" | ||
GradedUnitRanges = "e2de450a-8a67-46c7-b59c-01d5a3d041c5" | ||
HalfIntegers = "f0d1745a-41c9-11e9-1dd9-e5d34d218721" | ||
LRUCache = "8ac3fa9e-de4c-5943-b1dc-09c6b5f20637" | ||
LabelledNumbers = "f856a3a6-4152-4ec4-b2a7-02c1a55d7993" | ||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67" | ||
SymmetrySectors = "f8a8ad64-adbc-4fce-92f7-ffe2bb36a86e" | ||
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a" | ||
TensorProducts = "decf83d6-1968-43f4-96dc-fdb3fe15fc6d" | ||
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138" | ||
WignerSymbols = "9f57e263-0b3d-5e2e-b1be-24f2bb48858b" | ||
|
||
[compat] | ||
Accessors = "0.1.39" | ||
BlockArrays = "1.2.0" | ||
BlockSparseArrays = "0.3.9" | ||
GradedUnitRanges = "0.2.2" | ||
HalfIntegers = "1.6.0" | ||
LRUCache = "1.6.1" | ||
LabelledNumbers = "0.1.0" | ||
LinearAlgebra = "1.10.0" | ||
Strided = "2.2.0" | ||
SymmetrySectors = "0.1.7" | ||
TensorAlgebra = "0.2.4" | ||
TensorProducts = "0.1.3" | ||
TypeParameterAccessors = "0.2.0" | ||
WignerSymbols = "2.0.0" | ||
julia = "1.10" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
module FusionTensors | ||
|
||
# Write your package code here. | ||
include("fusion_trees/fusiontree.jl") | ||
include("fusion_trees/clebsch_gordan_tensors.jl") | ||
include("fusiontensor/fusiontensor.jl") | ||
include("fusiontensor/base_interface.jl") | ||
include("fusiontensor/array_cast.jl") | ||
include("fusiontensor/linear_algebra_interface.jl") | ||
include("fusiontensor/tensor_algebra_interface.jl") | ||
include("permutedims/unitaries.jl") | ||
include("permutedims/permutedims.jl") | ||
|
||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
# This file defines Clebsch-Gordan tensors | ||
# one tensor is defined from 3 simple objects s1, s2 and s3 | ||
# and contains the coefficients fusing s1 ⊗ s2 -> s3 | ||
|
||
using HalfIntegers: half | ||
using WignerSymbols: clebschgordan | ||
|
||
using GradedUnitRanges: dual | ||
using SymmetrySectors: | ||
AbelianStyle, | ||
AbstractSector, | ||
NotAbelianStyle, | ||
SymmetryStyle, | ||
O2, | ||
SU, | ||
istrivial, | ||
quantum_dimension, | ||
sector_label, | ||
trivial, | ||
zero_odd | ||
using TensorAlgebra: contract | ||
using TensorProducts: ⊗ | ||
|
||
function symbol_1j(s::AbstractSector) | ||
cgt = clebsch_gordan_tensor(s, dual(s), trivial(s), 1) | ||
return sqrt(quantum_dimension(s)) * cgt[:, :, 1] | ||
end | ||
|
||
function clebsch_gordan_tensor( | ||
s1::AbstractSector, | ||
s2::AbstractSector, | ||
s3::AbstractSector, | ||
arrow1::Bool, | ||
arrow2::Bool, | ||
inner_mult_index::Int, | ||
) | ||
cgt = clebsch_gordan_tensor(s1, s2, s3, inner_mult_index) | ||
if arrow1 | ||
flip1 = symbol_1j(s1) | ||
cgt = contract((1, 2, 3), flip1, (4, 1), cgt, (4, 2, 3)) | ||
end | ||
if arrow2 | ||
flip2 = symbol_1j(s2) | ||
cgt = contract((1, 2, 3), flip2, (4, 2), cgt, (1, 4, 3)) | ||
end | ||
return cgt | ||
end | ||
|
||
function clebsch_gordan_tensor(s1::S, s2::S, s3::S, outer_mult_index::Int) where {S} | ||
return clebsch_gordan_tensor(SymmetryStyle(S), s1, s2, s3, outer_mult_index) | ||
end | ||
|
||
function clebsch_gordan_tensor( | ||
::AbelianStyle, s1::S, s2::S, s3::S, outer_mult_index::Int | ||
) where {S} | ||
@assert outer_mult_index == 1 | ||
return s1 ⊗ s2 == s3 ? ones((1, 1, 1)) : zeros((1, 1, 1)) | ||
end | ||
|
||
function clebsch_gordan_tensor(::NotAbelianStyle, s1::O2, s2::O2, s3::O2, ::Int) | ||
return clebsch_gordan_tensor(s1, s2, s3) # no outer multiplicity | ||
end | ||
|
||
function clebsch_gordan_tensor(s1::O2, s2::O2, s3::O2) | ||
d1 = quantum_dimension(s1) | ||
d2 = quantum_dimension(s2) | ||
d3 = quantum_dimension(s3) | ||
cgt = zeros((d1, d2, d3)) | ||
s3 ∉ blocklabels(s1 ⊗ s2) && return cgt | ||
|
||
# adapted from TensorKit | ||
ogauthe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
l1 = sector_label(s1) | ||
l2 = sector_label(s2) | ||
l3 = sector_label(s3) | ||
if l3 <= 0 # 0even or 0odd | ||
if l1 <= 0 && l2 <= 0 | ||
cgt[1, 1, 1, 1] = 1.0 | ||
else | ||
if istrivial(s3) | ||
cgt[1, 2, 1, 1] = 1.0 / sqrt(2) | ||
cgt[2, 1, 1, 1] = 1.0 / sqrt(2) | ||
else | ||
cgt[1, 2, 1, 1] = 1.0 / sqrt(2) | ||
cgt[2, 1, 1, 1] = -1.0 / sqrt(2) | ||
end | ||
end | ||
elseif l1 <= 0 # 0even or 0odd | ||
cgt[1, 1, 1, 1] = 1.0 | ||
cgt[1, 2, 2, 1] = s1 == zero_odd(O2) ? -1.0 : 1.0 | ||
elseif l2 == 0 | ||
cgt[1, 1, 1, 1] = 1.0 | ||
cgt[2, 1, 2, 1] = s2 == zero_odd(O2) ? -1.0 : 1.0 | ||
elseif l3 == l1 + l2 | ||
cgt[1, 1, 1, 1] = 1.0 | ||
cgt[2, 2, 2, 1] = 1.0 | ||
elseif l3 == l1 - l2 | ||
cgt[1, 2, 1, 1] = 1.0 | ||
cgt[2, 1, 2, 1] = 1.0 | ||
elseif l3 == l2 - l1 | ||
cgt[2, 1, 1, 1] = 1.0 | ||
cgt[1, 2, 2, 1] = 1.0 | ||
end | ||
return cgt | ||
end | ||
|
||
function clebsch_gordan_tensor(::NotAbelianStyle, s1::SU{2}, s2::SU{2}, s3::SU{2}, ::Int) | ||
return clebsch_gordan_tensor(s1, s2, s3) # no outer multiplicity | ||
end | ||
|
||
function clebsch_gordan_tensor(s1::SU{2}, s2::SU{2}, s3::SU{2}) | ||
d1 = quantum_dimension(s1) | ||
d2 = quantum_dimension(s2) | ||
d3 = quantum_dimension(s3) | ||
j1 = half(d1 - 1) | ||
j2 = half(d2 - 1) | ||
j3 = half(d3 - 1) | ||
cgtensor = Array{Float64,3}(undef, (d1, d2, d3)) | ||
for (i, j, k) in Iterators.product(1:d1, 1:d2, 1:d3) | ||
m1 = j1 - i + 1 | ||
m2 = j2 - j + 1 | ||
m3 = j3 - k + 1 | ||
cgtensor[i, j, k] = clebschgordan(j1, m1, j2, m2, j3, m3) | ||
end | ||
return cgtensor | ||
end | ||
|
||
function clebsch_gordan_tensor( | ||
::NotAbelianStyle, s1::SU{3}, s2::SU{3}, s3::SU{3}, outer_mult_index::Int | ||
) | ||
d1 = quantum_dimension(s1) | ||
d2 = quantum_dimension(s2) | ||
d3 = quantum_dimension(s3) | ||
cgtensor = zeros(d1, d2, d3) | ||
# dummy | ||
return cgtensor | ||
end |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.