MPOGraph

Inheritance Diagram

Inheritance diagram of tenpy.networks.mpo.MPOGraph

Methods

MPOGraph.__init__(sites[, bc, max_range])

Initialize self.

MPOGraph.add(i, keyL, keyR, opname, strength)

Insert an edge into the graph.

MPOGraph.add_missing_IdL_IdR([insert_all_id])

Add missing identity (‘Id’) edges connecting 'IdL'->'IdL' and ``'IdR'->'IdR'.

MPOGraph.add_string(i, j, key[, opname, …])

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

MPOGraph.build_MPO([Ws_qtotal])

Build the MPO represented by the graph (self).

MPOGraph.from_term_list(term_list, sites, bc)

Initialize form a list of operator terms and prefactors.

MPOGraph.from_terms(onsite_terms, …[, …])

Initialize an MPOGraph from OnsiteTerms and CouplingTerms.

MPOGraph.has_edge(i, keyL, keyR)

True if there is an edge from keyL on bond (i-1, i) to keyR on bond (i, i+1).

MPOGraph.test_sanity()

Sanity check, raises ValueErrors, if something is wrong.

Class Attributes and Properties

MPOGraph.L

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 and wR. They can be anything hash-able like a str, 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 entry W[keyL, keyR] connects the state keyL on bond (i-1, i) with the state keyR 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.

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 enries.

Type

list of set of keys

graph

For each site i a dictionary {keyL: {keyR: [(opname, strength)]}} with keyL in vertices[i] and keyR 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, insert_all_id=True)[source]

Initialize an MPOGraph from OnsiteTerms and CouplingTerms.

Parameters
Returns

graph – Initialized with the given terms.

Return type

MPOGraph

See also

from_term_list()

equivalent for other representation terms.

classmethod from_term_list(term_list, sites, bc, insert_all_id=True)[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.

  • 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

MPOGraph

See also

from_terms()

equivalent for other representation of terms.

test_sanity()[source]

Sanity check, raises ValueErrors, if something is wrong.

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(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 (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).

  • 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

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(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. If False 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

MPO