MPOGraph¶
full name: tenpy.networks.mpo.MPOGraph
parent module:
tenpy.networks.mpo
type: class
Inheritance Diagram
Methods

Initialize self. 

Insert an edge into the graph. 
Add missing identity (‘Id’) edges connecting 


Insert a bunch of edges for an ‘operator string’ into the graph. 

Build the MPO represented by the graph (self). 

Initialize form a list of operator terms and prefactors. 

Initialize an 

True if there is an edge from keyL on bond (i1, 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 virtul bonds of the MPOs, i.e., the indices on legs
wL
andwR
. They can be anything hashable 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(i1, i)
with the statekeyR
on bond(i, i+1)
.The keys
'IdR'
(for ‘idenity 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.

L
¶

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(i1, i)
of the MPO. Type
list of set of keys

graph
¶ For each site i a dictionary
{keyL: {keyR: [(opname, strength)]}}
withkeyL in vertices[i]
andkeyR in vertices[i+1]
. Type
list of dict of dict of list of tuples

_grid_legs
¶ The charges for the MPO
 Type
None  list of LegCharge

classmethod
from_terms
(onsite_terms, coupling_terms, sites, bc)[source]¶ Initialize an
MPOGraph
from OnsiteTerms and CouplingTerms. Parameters
onsite_terms (
OnsiteTerms
) – Onsite terms to be added to the newMPOGraph
.coupling_terms (
CouplingTerms
MultiCouplingTerms
) – Coupling terms to be added to the newMPOGraph
.sites (list of
Site
) – Local sites of the Hilbert space.bc (
'finite'  'infinite'
) – MPO boundary conditions.
 Returns
graph – Initialized with the given terms.
 Return type
See also
from_term_list()
equivalent for other representation terms.

classmethod
from_term_list
(term_list, sites, bc)[source]¶ Initialize form 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.
 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 (i1, 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
(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
j (i,) – An edge is inserted on all bonds 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 (hashable) – The state at bond (i1, i) to connect from and on bond (j1, j) to connect to. Also used for the intermediate states. No operator is inserted on a site i < k < j if
has_edge(k, key, key)
.opname (str) – Name of the operator to be used for the string. Useful for the JordanWigner transformation to fermions.
skip_existing (bool) – Whether existing graph nodes should be skipped.
 Returns
label_j – The key on the left of site j to connect to. Usually the same as the parameter key, except if
j  i > self.L
, in which case we use the additional labels(key, 1)
,(key, 2)
, … to generate couplings over multiple unit cells. Return type
hashable

add_missing_IdL_IdR
()[source]¶ Add missing identity (‘Id’) edges connecting
'IdL'>'IdL' and ``'IdR'>'IdR'
.For
bc='infinite'
, insert missing identities at all bonds. Forbc='finite'  'segment'
only insert'IdL'>'IdL'
to the left of the rightmost existing ‘IdL’ and'IdR'>'IdR'
to the right of the leftmost existing ‘IdR’.This function should be called after all other operators have been inserted.

has_edge
(i, keyL, keyR)[source]¶ True if there is an edge from keyL on bond (i1, i) to keyR on bond (i, i+1).

build_MPO
(Ws_qtotal=None, leg0=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.leg0 (None 
npc.LegCharge
) – The charges to be used for the very first leg (which is a gauge freedom). IfNone
(default), use zeros.
 Returns
mpo – the MPO which self represents.
 Return type