mdopt.mps.explicit module#
This module contains the ExplicitMPS class.
Hereafter saying the MPS is in the explicit form will mean that
the state is stored in the following format:
for each three-dimensional tensor at site i denoted by ( ),
there exists a singular values diagonal matrix at bond i denoted by <>:
i i i+1 i+1
...---<>---( )---<>---( )---...
| |
| |
For “ghost” bonds at indices 0, L-1 (i.e., bonds of dimension 1),
where L is the length of the MPS,
the corresponding singular value tensors at the boundaries
would be the identities of the same dimension.
We index MPS tensors with i from 0 to L-1,
while the singular values matrices are indexed from the left of each tensor, i.e.,
the singular values matrux with index i is to the left of site i.
Essentially, it corresponds to storing each Γ[i] and Λ[i] as shown in
fig.4b in reference `[1]`_.
- class mdopt.mps.explicit.ExplicitMPS(tensors: List[ndarray], singular_values: List[List], tolerance: float = 1e-12, chi_max: int = 10000)#
Class for finite-size explicit matrix product states (MPS) with open boundary conditions.
- tensors#
The “physical” tensors of the MPS, one for each physical site. Each tensor has legs (virtual left, physical, virtual right), in short
(vL, i, vR).- Type:
List[np.ndarray]
- singular_values#
The singular values at each of the bonds,
singular_values[i]is left oftensors[i]. Each singular values list at each bond is normalised to 1.- Type:
List[List]
- tolerance#
Absolute tolerance of the normalisation of the singular value spectrum at each bond.
- Type:
float
- num_sites#
Number of sites.
- Type:
int
- num_bonds#
Number of non-trivial bonds, which is equal to
num_sites - 1.- Type:
int
- Raises:
ValueError – If the
tensorsand thesingular_valueslists do not have corresponding lengths. The number of singular value matrices should be equal to the number of tensors + 1, because there are two trivial singular value matrices at each of the ghost bonds.ValueError – If any of the MPS tensors is not three-dimensional.
ValueError – If any of the singular-values tensors is not normalised within the tolerance attribute.
- property all_dimensions: List[Tuple[int, ...]]#
Returns the list of all dimensions of the MPS.
- property bond_dimensions: List[int]#
Returns the list of all bond dimensions of the MPS.
- compress(chi_max: int = 10000, cut: float = 1e-17, renormalise: bool = False, return_truncation_errors: bool = False) Tuple[ExplicitMPS, List[float | None]]#
Compresses the MPS, i.e., runs the
compress_bondmethod for each bond.- Parameters:
chi_max (int) – The maximum bond dimension to keep.
cut (float) – Singular values smaller than this will be discarded.
renormalise (bool) – Whether to renormalise the singular value spectrum after the cut.
return_truncation_errors (bool) – Whether to return the list of truncation errors (for each bond).
- Returns:
compressed_mps (CanonicalMPS) – The new compressed Matrix Product State.
truncation_errors (Optional[List[float]]) – The truncation errors. Returned only if return_truncation_errors is set to True.
- compress_bond(bond: int, chi_max: int = 10000, cut: float = 1e-17, renormalise: bool = False, return_truncation_error: bool = False) Tuple[ExplicitMPS, float | None]#
Compresses the bond at a given site, i.e., reduces its bond dimension. The compression is performed via trimming the singular values at the bond.
- Parameters:
bond (int) – The index of the bond to compress.
chi_max (int) – The maximum bond dimension to keep.
cut (float) – Singular values smaller than this will be discarded.
renormalise (bool) – Whether to renormalise the singular value spectrum after the cut.
return_truncation_error (bool) – Whether to return the truncation error.
- Returns:
compressed_mps (ExplicitMPS) – The new compressed Matrix Product State.
truncation_error (Optional[float]) – The truncation error. Returned only if return_truncation_error is True.
- Raises:
ValueError – If the bond index is out of range.
Notes
The bonds are being enumerated from the right side of the tensors. For example, the bond
0is a bond to the right of tensor0. Note, the singular value matrices obey a different numbering.
- conjugate() ExplicitMPS#
Returns a complex-conjugated version of the current MPS.
- copy() ExplicitMPS#
Returns a copy of the current MPS.
- dense(flatten: bool = True, renormalise: bool = False, norm: None | float | Literal['fro', 'nuc'] = 2) ndarray#
Returns a dense representation of the MPS.
Warning: this method can cause memory overload for number of sites > ~20!
- Parameters:
flatten (bool) – Whether to merge all the physical indices to form a vector or not.
renormalise (bool) – Whether to renormalise the resulting tensor.
norm (Union[str, int]) – Which norm to use for renormalisation of the final tensor.
- density_mpo() List[ndarray]#
Returns the MPO representation (as a list of tensors) of the density matrix defined by a given MPS. This operation is depicted in the following picture:
i j a | | c i j ...---(*)---<>*---(*)---<>*---... ab | | cd --> ...---[ ]---[ ]---... ...---( )---<>----( )---<>----... | | b | | d k l k l
In the cartoon, {i,j,k,l} and {a,b,c,d} are single indices, while ab and cd denote multi indices. Here, the ( )’s represent the MPS tensors, the <>’s — the singular values tensors, the [ ]’s — the MPO tensors. The MPS with the physical legs up is complex-conjugated element-wise, this is denoted by the star sign. The empty line between the MPS and its complex-conjugated version stands for the tensor (kronecker) product.
Each tensor in the MPO list has legs (vL, vR, pU, pD), where v stands for “virtual”, p – for “physical”, and L, R, U, D stand for “left”, “right”, “up”, “down”.
- entanglement_entropy() ndarray#
Returns the entanglement entropy for bipartitions at each of the bonds.
- left_canonical() CanonicalMPS#
Returns the current MPS in the left-canonical form given the MPS in the explicit form.
(see eq.19 in https://scipost.org/10.21468/SciPostPhysLectNotes.5 for reference),
- marginal(sites_to_marginalise: List[int], renormalise: bool = False) ExplicitMPS | CanonicalMPS#
Computes a marginal over a subset of sites of an MPS via CanonicalMPS path.
- mixed_canonical(orth_centre: int) CanonicalMPS#
Returns the current MPS in the mixed-canonical form with the orthogonality centre being located at
orth_centre.- Parameters:
orth_centre_index (int) – An integer which can take values
0, 1, ..., num_sites-1. Denotes the position of the orthogonality centre – the only non-isometry in the new canonical MPS.
- norm() float#
Computes the norm of the current MPS, that is, the modulus squared of its inner product with itself.
- one_site_expectation_value(site: int, operator: ndarray) float | complex128#
Computes an expectation value of an arbitrary one-site operator (not necessarily unitary) on the given site.
- Parameters:
site (int) – The site where the operator is applied.
operator (np.ndarray) – The one-site operator
Notes
An example of a one-site expectation value is shown in the following diagram:
( )-<>-( )-<>-( )-<>-( ) | | | | | (o) | | | | | | ( )-<>-( )-<>-( )-<>-( )
- one_site_left_iso(site: int) ndarray#
Computes a one-site left isometry at a given site: diag(Λ[i]) @ Γ[i] -> scale vL axis by Λ[i].
- one_site_left_iso_iter() Iterable#
Iterator over the left isometries for every site.
- one_site_right_iso(site: int) ndarray#
Computes a one-site right isometry at a given site: Γ[i] @ diag(Λ[i+1]) -> scale vR axis by Λ[i+1].
- one_site_right_iso_iter() Iterable#
Iterator over the right isometries for every site.
- property phys_dimensions: List[int]#
Returns the list of all physical dimensions of the MPS.
- reverse() ExplicitMPS#
Returns a reversed version of the current MPS.
- right_canonical() CanonicalMPS#
Returns the current MPS in the right-canonical form given the MPS in the explicit form.
(see eq.19 in https://scipost.org/10.21468/SciPostPhysLectNotes.5 for reference),
- two_site_expectation_value(site: int, operator: ndarray) float | complex128#
Computes an expectation value of an arbitrary two-site operator (not necessarily unitary) on the given site and its next neighbour. The operator has legs
(UL, DL, UR, DR), whereL,R,U,Dstand for “left”, “right”, “up”, “down” accordingly.- Parameters:
site (int) – The first site where the operator is applied, the second site to be
site + 1.operator (np.ndarray) – The two-site operator.
Notes
An example of a two-site expectation value is shown in the following diagram:
( )-<>-( )-<>-( )-<>-( ) | | | | | (operator) | | | | | ( )-<>-( )-<>-( )-<>-( )
- two_site_left_iso(site: int) ndarray#
Two-site left isometry from two one-site left isometries.
- two_site_left_iso_iter() Iterable#
Iterator over the two-site left isometries for every site and its right neighbour.
- two_site_right_iso(site: int) ndarray#
Two-site right isometry from two one-site right isometries.
- two_site_right_iso_iter() Iterable#
Iterator over the two-site right isometries for every site and its right neighbour.