Generating TTN
TenNetLib.jl defines following functions to generate TTNs with random entries.
For the standard TTN with the default hierarchical binary tree structure, follwoing function can be used.
TenNetLib.default_randomTTN
— Functionfunction default_randomTTN(sites::Vector{Index{T}}, chi::Int, qn::QN = QN()) where T
Returns a TTN object, having random elements, from site Index
s sites
, initial bond dimension chi
and (optional) global QN sector qn
. The structure is a default hierarchical binary tree graph. Automatically handles situations where the number of sites is not a power of 2.
Note: For QN conserving TTN, the bond dimension might be off by one or two from chi
.
The underlying default binary tree for the function above is generated by the following function.
TenNetLib.default_graph_sitenodes
— Methodfunction default_graph_sitenodes(N::Int)
Given the total number of sites, N::Int
, generates the default hierarchical binary tree graph and a Dict{Int, Int2}
object that maps each site to the corresponding node. Automatically handles situations where the number of sites is not a power of 2.
Return values:
::Graph{Int2}
: Default hierarchical tree graph to accomodateN
number of sites in a TTN.::Dict{Int, Int2}
: Maps each site to the corresponding node.
Example:
graph, sitenodes = default_graph_sitenodes(32)
sitenodes[1] == (1,1) # true
sitenodes[2] == (1,1) # true
sitenodes[3] == (1,2) # true
sitenodes[4] == (1,2) # true
sitenodes[31] == (1,16) # true
sitenodes[32] == (1,16) # true
In the generic scenario, a random TTN with user-defined structure can be generated by the following function.
TenNetLib.randomTTN
— Functionfunction randomTTN(sites::Vector{Index{T}}, graph::Graph{Int2},
sitenodes::Dict{Int, Int2}, chi::Int, qn::QN = QN()) where T
Returns a TTN object, having random elements, from site Index
s sites
, the underlyting graph
, sitenodes::Dict{Int, Int2}
that maps each site to the corresponding node, initial bond dimension chi
, and (optional) global QN sector qn
. The structure is determined by the input graph
object.
Note: This function can be used to generate any loop-free tensor network.
Note: For QN conserving TTN, the bond dimension might be off by one or two from chi
.
The above function can be used to generate any loop-free tensor network.