tnpy.tsdrg.TensorTree
4.2. tnpy.tsdrg.TensorTree#
- class tnpy.tsdrg.TensorTree(mpo)[source]#
Bases:
object
The bottom-up binary tree where each node contains a tensor.
- Parameters
mpo (MatrixProductOperator) – The matrix product operator.
- __init__(mpo)[source]#
The bottom-up binary tree where each node contains a tensor.
- Parameters
mpo (tnpy.operators.MatrixProductOperator) – The matrix product operator.
Methods
__init__
(mpo)The bottom-up binary tree where each node contains a tensor.
Accessory decorator for checking the existence of root in
TensorTree
.common_ancestor
(node_id1, node_id2[, lowest])Find all common ancestor of two given nodes in the order starting from the root.
find_path
(node_id[, return_itself])Find the path from the root to the targeted node
node_id
.fuse
(left_id, right_id, new_id, data)Fuse two nodes into one and assign the given data one it.
plot
([view])Plot the tree with
graphviz.Digraph
.tensor_network
([node_ids, conj, ...])Construct the
qtn.TensorNetwork
object from the given list of node_ids.Attributes
The horizon is a moving line to track the node ids in the current renormalized system.
A dictionary to leaves, i.e. matrix product operator.
Compute the number of layers in this tree, leaves included.
The number of leaves, namely the system size.
Total number of nodes in tree, including leaves.
The root of tree.
The ID of root.
- class Syntax(node='Node', conj_node='ConjNode', level_idx='LevelIdx')[source]#
Bases:
object
The name of indices follows a standardized syntax.
Examples
For open index: Node<node_id>LevelIdx<nth_idx>
For connected index: Node<node1_id>-Node<node2_id>
In the presence of conjugated node, replace Node with ConjNode
- Parameters
node (str) –
conj_node (str) –
level_idx (str) –
- Return type
None
- node: str = 'Node'#
- conj_node: str = 'ConjNode'#
- level_idx: str = 'LevelIdx'#
- __init__(node='Node', conj_node='ConjNode', level_idx='LevelIdx')#
- Parameters
node (str) –
conj_node (str) –
level_idx (str) –
- Return type
None
- __init__(mpo)[source]#
The bottom-up binary tree where each node contains a tensor.
- Parameters
mpo (tnpy.operators.MatrixProductOperator) – The matrix product operator.
- property root_id: int | None#
The ID of root.
- Returns
None if the tree is not constructed yet.
- property root: tnpy.tsdrg.Node#
The root of tree.
- Raises
KeyError – If the tree is not constructed yet.
- property leaves: Dict[int, tnpy.tsdrg.Node]#
A dictionary to leaves, i.e. matrix product operator.
- property horizon: List[int]#
The horizon is a moving line to track the node ids in the current renormalized system. This can be useful during the bottom-up construction of the tree, until there is only one node on the horizon, that is the root.
- Returns
The horizon as a list of node ids.
- property n_nodes: int#
Total number of nodes in tree, including leaves.
- property n_leaves: int#
The number of leaves, namely the system size.
- fuse(left_id, right_id, new_id, data)[source]#
Fuse two nodes into one and assign the given data one it. Meanwhile, the
horizon
will be updated accordingly. Note that thedata
should be provided from outer scope, and this method is only responsible to create new node in the tree.- Parameters
left_id (int) – The ID of left node to be fused.
right_id (int) – The ID of right node to be fused.
new_id (int) – The ID of new node.
data (numpy.ndarray) – Data that will be assigned to the new node.
- check_root()[source]#
Accessory decorator for checking the existence of root in
TensorTree
.Returns:
- Parameters
func (Callable) –
- Return type
Callable
- property n_layers: int#
Compute the number of layers in this tree, leaves included.
- tensor_network(node_ids=None, conj=False, mangle_outer=True, with_leaves=False)[source]#
Construct the
qtn.TensorNetwork
object from the given list of node_ids. Physical quantities often don’t require all nodes, and one could cooperate this method withfind_path()
orcommon_ancestor()
.- Parameters
node_ids (Sequence[int]) – The id of nodes that will be selected from the tree.
conj (bool) – Take a conjugate on this network. This will change the indices on physical bonds, as well as the internal indices within the network. This will be an inplace operation.
mangle_outer (bool) – For conjugate network only, namely when
conj
is True. If this parameter is set to False, the indices on physical bonds will remain untouched. This can be useful for taking inner product on the state, i.e. \(\langle\psi|\psi\rangle\).with_leaves (bool) – Whether the leaves, that is, the MPOs, should be taken into account in this network.
- Return type
quimb.tensor.tensor_core.TensorNetwork
Returns:
- find_path(node_id, return_itself=False)[source]#
Find the path from the root to the targeted node
node_id
.- Parameters
node_id (int) – The id of node we are looking for.
return_itself (bool) – Should the target node be included in returning path.
- Returns
ID of nodes on the path from the root to the targeted node.
- Raises
KeyError – If no path can be found to the given
node_id
.- Return type
List[int]