MPOGraph¶
full name: tenpy.networks.mpo.MPOGraph
parent module:
tenpy.networks.mpotype: class
-
class
tenpy.networks.mpo.MPOGraph(sites, bc='finite', max_range=None)[source]¶ Bases:
objectRepresentation 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
wLandwR. They can be anything hash-able like astr,intor 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 statekeyLon bond(i-1, i)with the statekeyRon 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
- siteslist of
Site Local sites of the Hilbert space.
- bc{‘finite’, ‘infinite’}
MPO boundary conditions.
- max_rangeint | np.inf | None
Maximum range of hopping/interactions (in unit of sites) of the MPO.
Nonefor unknown.
- siteslist of
- Attributes
LNumber of physical sites; for infinite boundaries the length of the unit cell.
- siteslist of
Site Defines the local Hilbert space for each site.
- chinfo
ChargeInfo The nature of the charge.
- bc{‘finite’, ‘infinite’}
MPO boundary conditions.
- max_rangeint | np.inf | None
Maximum range of hopping/interactions (in unit of sites) of the MPO.
Nonefor unknown.- stateslist of set of keys
states[i]gives the possible keys at the virtual bond(i-1, i)of the MPO.- graphlist of dict of dict of list of tuples
For each site i a dictionary
{keyL: {keyR: [(opname, strength)]}}withkeyL in vertices[i]andkeyR in vertices[i+1].- _grid_legsNone | list of LegCharge
The charges for the MPO
Methods
add(self, i, keyL, keyR, opname, strength[, …])Insert an edge into the graph.
add_missing_IdL_IdR(self)Add missing identity (‘Id’) edges connecting
'IdL'->'IdL' and ``'IdR'->'IdR'.add_string(self, i, j, key[, opname, …])Insert a bunch of edges for an ‘operator string’ into the graph.
build_MPO(self[, Ws_qtotal, leg0])Build the MPO represented by the graph (self).
from_term_list(term_list, sites, bc)Initialize form a list of operator terms and prefactors.
from_terms(onsite_terms, coupling_terms, …)Initialize an
MPOGraphfrom OnsiteTerms and CouplingTerms.has_edge(self, i, keyL, keyR)True if there is an edge from keyL on bond (i-1, i) to keyR on bond (i, i+1).
test_sanity(self)Sanity check, raises ValueErrors, if something is wrong.
-
classmethod
from_terms(onsite_terms, coupling_terms, sites, bc)[source]¶ Initialize an
MPOGraphfrom OnsiteTerms and CouplingTerms.- Parameters
- onsite_terms
OnsiteTerms Onsite terms to be added to the new
MPOGraph.- coupling_terms :class:`~tenpy.networks.terms.CouplingTerms` | :class:`~tenpy.networks.terms.MultiCouplingTerms`
Coupling terms to be added to the new
MPOGraph.- siteslist of
Site Local sites of the Hilbert space.
- bc
'finite' | 'infinite' MPO boundary conditions.
- onsite_terms
- Returns
- graph
MPOGraph Initialized with the given terms.
- graph
See also
from_term_listequivalent 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.
- siteslist of
Site Local sites of the Hilbert space.
- bc
'finite' | 'infinite' MPO boundary conditions.
- term_list
- Returns
- graph
MPOGraph Initialized with the given terms.
- graph
See also
from_termsequivalent for other representation of terms.
-
property
L¶ Number of physical sites; for infinite boundaries the length of the unit cell.
-
add(self, i, keyL, keyR, opname, strength, check_op=True, skip_existing=False)[source]¶ Insert an edge into the graph.
- Parameters
- iint
Site index at which the edge of the graph is to be inserted.
- keyLhashable
The state at bond (i-1, i) to connect from.
- keyRhashable
The state at bond (i, i+1) to connect to.
- opnamestr
Name of the operator.
- strengthstr
Prefactor of the operator to be inserted.
- check_opbool
Whether to check that ‘opname’ exists on the given site.
- skip_existingbool
If
True, skip adding the graph node if it exists (with same keys and opname).
-
add_string(self, 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, j: int
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 (i-1, i) to connect from and on bond (j-1, 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).- opnamestr
Name of the operator to be used for the string. Useful for the Jordan-Wigner transformation to fermions.
- skip_existingbool
Whether existing graph nodes should be skipped.
- Returns
- label_jhashable
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.
-
add_missing_IdL_IdR(self)[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(self, 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(self, Ws_qtotal=None, leg0=None)[source]¶ Build the MPO represented by the graph (self).
- Parameters
- Ws_qtotalNone | (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.- leg0None |
npc.LegCharge The charges to be used for the very first leg (which is a gauge freedom). If
None(default), use zeros.
- Returns
- mpo
MPO the MPO which self represents.
- mpo