MPOGraph
full name: tenpy.networks.mpo.MPOGraph
parent module:
tenpy.networks.mpo
type: class
Inheritance Diagram
Methods
|
|
|
Insert an edge into the graph. |
|
Add missing identity ('Id') edges connecting |
|
Insert a bunch of edges for an 'operator string' into the graph. |
|
Insert a bunch of edges for an 'operator string' into the graph. |
|
Build the MPO represented by the graph (self). |
|
Initialize from a list of operator terms and prefactors. |
|
Initialize an |
|
True if there is an edge from keyL on bond (i-1, i) to keyR on bond (i, i+1). |
Sanity check, raises ValueErrors, if something is wrong. |
Class Attributes and Properties
Number of physical sites; for infinite boundaries the length of the unit cell. |
- class tenpy.networks.mpo.MPOGraph(sites, bc='finite', max_range=None)[source]
Bases:
object
Representation of an MPO by a graph, based on a ‘finite state machine’.
This representation is used for building H_MPO from the interactions. The idea is to view the MPO as a kind of ‘finite state machine’. The states or keys of this finite state machine life on the MPO bonds between the Ws. They label the indices of the virtual bonds of the MPOs, i.e., the indices on legs
wL
andwR
. They can be anything hash-able like astr
,int
or a tuple of them.The edges of the graph are the entries
W[keyL, keyR]
, which itself are onsite operators on the local Hilbert space. The indices keyL and keyR correspond to the legs'wL', 'wR'
of the MPO. The entryW[keyL, keyR]
connects the statekeyL
on bond(i-1, i)
with the statekeyR
on bond(i, i+1)
.The keys
'IdR'
(for ‘identity left’) and'IdR'
(for ‘identity right’) are reserved to represent only'Id'
(=identity) operators to the left and right of the bond, respectively.Todo
might be useful to add a “cleanup” function which removes operators cancelling each other and/or unused states. Or better use a ‘compress’ of the MPO?
- Parameters:
sites (list of
Site
) – Local sites of the Hilbert space.bc ({'finite', 'infinite'}) – MPO boundary conditions.
max_range (int | np.inf | None) – Maximum range of hopping/interactions (in unit of sites) of the MPO.
None
for unknown.
- sites
Defines the local Hilbert space for each site.
- Type:
list of
Site
- chinfo
The nature of the charge.
- Type:
ChargeInfo
- bc
MPO boundary conditions.
- Type:
{‘finite’, ‘infinite’}
- max_range
Maximum range of hopping/interactions (in unit of sites) of the MPO.
None
for unknown.- Type:
int | np.inf | None
- states
states[i]
gives the possible keys at the virtual bond(i-1, i)
of the MPO. L+1 entries.
- graph
For each site i a dictionary
{keyL: {keyR: [(opname, strength)]}}
withkeyL in states[i]
andkeyR in states[i+1]
.
- classmethod from_terms(terms, sites, bc, insert_all_id=True)[source]
Initialize an
MPOGraph
from OnsiteTerms and CouplingTerms.- Parameters:
terms (iterable of
tenpy.networks.terms.*Terms
classes) – Entries can beOnsiteTerms
,CouplingTerms
,MultiCouplingTerms
orExponentialCouplingTerms
. All the entries get added to the newMPOGraph
.sites (list of
Site
) – Local sites of the Hilbert space.bc (
'finite' | 'infinite'
) – MPO boundary conditions.insert_all_id (bool) – Whether to insert identities such that IdL and IdR are defined on each bond. See
add_missing_IdL_IdR()
.
- Returns:
graph – Initialized with the given terms.
- Return type:
See also
from_term_list
equivalent for representation by
TermList
.
- classmethod from_term_list(term_list, sites, bc, insert_all_id=True)[source]
Initialize from a list of operator terms and prefactors.
- Parameters:
term_list (
TermList
) – Terms to be added to the MPOGraph.sites (list of
Site
) – Local sites of the Hilbert space.bc (
'finite' | 'infinite'
) – MPO boundary conditions.insert_all_id (bool) – Whether to insert identities such that IdL and IdR are defined on each bond. See
add_missing_IdL_IdR()
.
- Returns:
graph – Initialized with the given terms.
- Return type:
See also
from_terms
equivalent for other representation of terms.
- property L
Number of physical sites; for infinite boundaries the length of the unit cell.
- add(i, keyL, keyR, opname, strength, check_op=True, skip_existing=False)[source]
Insert an edge into the graph.
- Parameters:
i (int) – Site index at which the edge of the graph is to be inserted.
keyL (hashable) – The state at bond (i-1, i) to connect from.
keyR (hashable) – The state at bond (i, i+1) to connect to.
opname (str) – Name of the operator.
strength (str) – Prefactor of the operator to be inserted.
check_op (bool) – Whether to check that ‘opname’ exists on the given site.
skip_existing (bool) – If
True
, skip adding the graph node if it exists (with same keys and opname).
- add_string_left_to_right(i, j, key, opname='Id', check_op=True, skip_existing=True)[source]
Insert a bunch of edges for an ‘operator string’ into the graph.
Terms like \(S^z_i S^z_j\) actually stand for \(S^z_i \otimes \prod_{i < k < j} \mathbb{1}_k \otimes S^z_j\). This function adds the \(\mathbb{1}\) terms to the graph.
- Parameters:
i (int) – An edge is inserted on all sites between i and j, i < j. j can be larger than
L
, in which case the operators are supposed to act on different MPS unit cells.j (int) – An edge is inserted on all sites between i and j, i < j. j can be larger than
L
, in which case the operators are supposed to act on different MPS unit cells.key (tuple) – The key at bond (i+1, i) to connect from.
opname (str) – Name of the operator to be used for the string. Useful for the Jordan-Wigner transformation to fermions.
skip_existing (bool) – Whether existing graph nodes should be skipped.
- Returns:
key_i – The key on the right of site i we connected to.
- Return type:
- add_string_right_to_left(j, i, key, opname='Id', check_op=True, skip_existing=True)[source]
Insert a bunch of edges for an ‘operator string’ into the graph.
Similar as
add_string_left_to_right()
, but in the other direction.- Parameters:
j (int) – An edge is inserted on all sites between i and j, i < j. Note the switched argument order compared to
add_string_left_to_right()
.i (int) – An edge is inserted on all sites between i and j, i < j. Note the switched argument order compared to
add_string_left_to_right()
.key (tuple) – The key at bond (j-1, j) to connect from.
opname (str) – Name of the operator to be used for the string. Useful for the Jordan-Wigner transformation to fermions.
skip_existing (bool) – Whether existing graph nodes should be skipped.
- Returns:
key_i – The key on the right of site i we connected to.
- Return type:
hashable
- add_missing_IdL_IdR(insert_all_id=True)[source]
Add missing identity (‘Id’) edges connecting
'IdL'->'IdL' and ``'IdR'->'IdR'
.This function should be called after all other operators have been inserted.
- Parameters:
insert_all_id (bool) – If
True
, insert ‘Id’ edges on all bonds. IfFalse
and boundary conditions are finite, only insert'IdL'->'IdL'
to the left of the rightmost existing ‘IdL’ and'IdR'->'IdR'
to the right of the leftmost existing ‘IdR’. The latter avoid “dead ends” in the MPO, but some functions (like make_WI) expect ‘IdL’/’IdR’ to exist on all bonds.
- has_edge(i, keyL, keyR)[source]
True if there is an edge from keyL on bond (i-1, i) to keyR on bond (i, i+1).
- build_MPO(Ws_qtotal=None)[source]
Build the MPO represented by the graph (self).
- Parameters:
Ws_qtotal (None | (list of) charges) – The qtotal for each of the Ws to be generated, default (
None
) means 0 charge. A single qtotal holds for each site.- Returns:
mpo – the MPO which self represents.
- Return type: