MPOGraph
full name: tenpy.networks.mpo.MPOGraph
parent module:
tenpy.networks.mpotype: 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 |
Get the i-th site. |
|
|
True if there is an edge from keyL on bond (i-1, i) to keyR on bond (i, i+1). |
|
Shift an Array by an integer multiple of unit cells. |
|
Shift a site by an integer multiple of unit cells. |
|
Shift charges by an integer multiple of unit cells. |
Sanity check, raises ValueErrors, if something is wrong. |
Class Attributes and Properties
Number of physical sites; for an iMPS the len of the MPS unit cell. |
|
Number of sites per horizontal lattice spacing. |
|
List of local physical dimensions. |
|
Distinguish MPS vs iMPS. |
|
Slice of the non-trivial bond indices, depending on |
- class tenpy.networks.mpo.MPOGraph(sites, bc='finite', max_range=None, unit_cell_width=None)[source]
Bases:
MPSGeometryRepresentation 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
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 ‘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:
- max_range
Maximum range of hopping/interactions (in unit of sites) of the MPO.
Nonefor 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, unit_cell_width=None)[source]
Initialize an
MPOGraphfrom OnsiteTerms and CouplingTerms.- Parameters:
terms (iterable of
tenpy.networks.terms.*Termsclasses) – Entries can beOnsiteTerms,CouplingTerms,MultiCouplingTermsorExponentialCouplingTerms. 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().unit_cell_width (int) – See
mps_unit_cell_width.
- Returns:
graph – Initialized with the given terms.
- Return type:
See also
from_term_listequivalent for representation by
TermList.
- classmethod from_term_list(term_list, sites, bc, insert_all_id=True, unit_cell_width=None)[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().unit_cell_width (int) – See
mps_unit_cell_width.
- Returns:
graph – Initialized with the given terms.
- Return type:
See also
from_termsequivalent for other representation of terms.
- 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. IfFalseand 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.unit_cell_width (int) – See
mps_unit_cell_width.
- Returns:
mpo – the MPO which self represents.
- Return type:
- property L
Number of physical sites; for an iMPS the len of the MPS unit cell.
- property N_sites_per_hor_spacing
Number of sites per horizontal lattice spacing.
This is the number of MPS sites one has to traverse to travel one lattice spacing in the first dimension, such that
self.unit_cell_width * N_sites_per_hor_spacing == self.L.
- property dim
List of local physical dimensions.
- property finite
Distinguish MPS vs iMPS.
True for an MPS (
bc='finite', 'segment'), False for an iMPS (bc='infinite').
- get_site(i)[source]
Get the i-th site.
This is
self.sites[i]if i is in the unit cell and takes care of shifting the charges otherwise.
- property nontrivial_bonds
Slice of the non-trivial bond indices, depending on
self.bc.
- shift_Array_unit_cells(arr, num_unit_cells, inplace: bool = False)[source]
Shift an Array by an integer multiple of unit cells.
See the notes on Dipole Conservation.
A unit cell has length
Land a shift by one unit cell is purely horizontal and shifts byunit_cell_widthlattice spacings.
- shift_Site_unit_cells(site, num_unit_cells)[source]
Shift a site by an integer multiple of unit cells.
See the notes on Dipole Conservation.
A unit cell has length
Land a shift by one unit cell is purely horizontal and shifts byunit_cell_widthlattice spacings.
- shift_charges_unit_cells(charges, num_unit_cells)[source]
Shift charges by an integer multiple of unit cells.
See the notes on Dipole Conservation.
A unit cell has length
Land a shift by one unit cell is purely horizontal and shifts byunit_cell_widthlattice spacings.Essentially, this is a convenience wrapper around \(tenpy.linalg.charges.ChargeInfo.shift_charges_horizontal\).
- Parameters:
charges (2D ndarray of dtype QTYPE) – The charges to shift.
num_unit_cells (int) – The number of unit cells.
- Returns:
The shifted charges.
- Return type:
2D ndarray of dtype QTYPE