mdopt.contractor package

Submodules

mdopt.contractor.contractor module

This module contains the MPS-MPO contractor functions.

mdopt.contractor.contractor.apply_one_site_operator(tensor: ndarray, operator: ndarray) ndarray

Applies a one-site operator to a MPS as follows:

----(tensor)---  ->  ---(tensor_updated)---
       |                       |
   (operator)                  |
       |                       |

The operator can be non-unitary, however note that a non-unitary operator might break the canonical form. The operator has legs (pU, pD), where p stands for “physical”, and U, D – for “up”, “down” accordingly.

Parameters:
  • tensor (np.ndarray) – The MPS tensor to apply the operator to.

  • operator (np.ndarray) – The operator to be applied.

Returns:

tensor_updated – The updated MPS tensor.

Return type:

np.ndarray

Raises:
  • ValueError – If the MPS tensor is not three-dimensional.

  • ValueError – If the operator tensor is not two-dimensional.

mdopt.contractor.contractor.apply_two_site_unitary(lambda_0: list, b_1: ndarray, b_2: ndarray, unitary: ndarray, chi_max: int = 10000, cut: float32 = 1e-12) Tuple[ndarray, ndarray]

Applies a two-site unitary operator to a right-canonical MPS as follows:

---(lambda_0)---(b_1)---(b_2)---  ->  ---(b_1_updated)---(b_2_updated)---
                  |      |                     |             |
                  (unitary)                    |             |
                  |      |                     |             |

This function uses a trick which allows performing the contraction without computing the inverse of any singular value matrix, which can introduce numerical instabilities for small singular values. Returns back the resulting MPS tensors in the right-canonical form.

Unitary has legs (pUL pUR, pDL pDR), where p stands for “physical”, and L, R, U, D – for “left”, “right”, “up”, “down” accordingly.

Parameters:
  • lambda_0 (list) – A list of singular values to the left of first MPS tensor.

  • b_1 (np.ndarray) – The first MPS right-isometric tensor to apply the unitary to.

  • b_2 (np.ndarray) – The second MPS right-isometric tensor to apply the unitary to.

  • unitary (np.ndarray) – The unitary tensor we apply.

  • cut (np.float32) – Singular values smaller than this will be discarded.

  • chi_max (int) – Maximum number of singular values to keep.

Returns:

  • b_1_updated (np.ndarray) – The first updated MPS right-isometric tensor.

  • b_2_updated (np.ndarray) – The second updated MPS right-isometric tensor.

Raises:
  • ValueError – If the first MPS tensor is not three-dimensional.

  • ValueError – If the second MPS tensor is not three-dimensional.

  • ValueError – If the operator tensor is not four-dimensional.

mdopt.contractor.contractor.mps_mpo_contract(mps: Union[ExplicitMPS, CanonicalMPS], mpo: List[ndarray], start_site: int = 0, renormalise: bool = False, chi_max: int = 10000, cut: float32 = 1e-12, inplace: bool = False, result_to_explicit: bool = False) Union[ExplicitMPS, CanonicalMPS]

Applies an MPO to an MPS.

Applies an operator (not necessarily unitary) in the MPO format to a canonical MPS with the orthogonality centre at site start_site while optionally renormalising singular values at each bond. Returning the updated MPS in the canonical form.

Note, this algorithm goes from left to right. In order to run from right to left, reverse both the MPS and the MPO manually.

The initial configuration looks as follows with ---O--- depicting the orthogonality centre:

...---( )---O----( )---( )---...---( )---...
            |     |     |           |
           [ ]---[ ]---[ ]---...---[ ]
            |     |     |           |

The contraction proceeds as described in the supplementary notes.

Parameters:
  • mps (Union[ExplicitMPS, CanonicalMPS]) – The initial MPS.

  • mpo (List[np.ndarray]) – MPO as a list of tensors, where each tensor is corresponding to an operator applied at a certain site. The operators should be ordered in correspondence with the sites. According to our convention, each operator 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”.

  • start_site (int) – Index of the starting site.

  • renormalise (bool) – Whether to renormalise the singular values after each contraction involving two neigbouring MPS sites.

  • chi_max (int) – Maximum bond dimension to keep.

  • cut (np.float32) – Cutoff for the singular values.

  • inplace (bool) – Whether to modify the current MPS or create a new one.

  • result_to_explicit (bool) – Whether to tranform the result to the explicit form.

Returns:

mps – The updated MPS in the canonical form.

Return type:

Union[ExplicitMPS, CanonicalMPS]

Raises:
  • ValueError – If any of the MPO tensors is not four-dimensional.

  • ValueError – If the length of the MPO and the starting site doesn’t correspond to the number of sites of the MPS.

Module contents