mdopt.mps.utils module#

This module contains various MPS utilities.

mdopt.mps.utils.create_custom_product_state(string: str, phys_dim: int = 2, form: str = 'Right-canonical', tolerance: float = 1e-12) ExplicitMPS | CanonicalMPS#

Creates a custom product-state MPS defined by the string argument.

Parameters:
  • string (str) – The string defining the product-state MPS. Available characters: 0, 1, +.

  • phys_dim (int) – Dimensionality of the local Hilbert space, i.e., the dimension of each physical leg of the MPS.

  • form (str) – The form of the MPS. Available options: | Explicit : The ExplicitMPS form (by default). | Right-canonical : The CanonicalMPS right-canonical form. | Left-canonical : The CanonicalMPS left-canonical form.

  • tolerance (float) – For the Explicit form: Absolute tolerance of the normalization of the singular value spectrum at each bond. For the Canonical form: Numerical tolerance to zero out the singular values in Singular Value Decomposition.

Returns:

mps – The resulting MPS.

Return type:

Union[ExplicitMPS, CanonicalMPS]

Raises:

ValueError – A symbol inside the string argument does not belong to the available set or the chosen form is mixed-canonical. (This form is not available for product states.)

Notes

Produces a Matrix Product State consisting of tensors with bond dimensions equal to 1. The tensors are defined as follows:

\(|0\rangle = \underbrace{(1, 0, ..., 0, 0)}_{\text{phys_dim}}\),
\(|1\rangle = \underbrace{(0, 0, ..., 0, 1)}_{\text{phys_dim}}\),
\(|+\rangle = \underbrace{(\frac{1}{\sqrt{\text{phys_dim}}}, ..., \frac{1}{\sqrt{\text{phys_dim}}})}_{\text{phys_dim}}\).

The state is renormalised at the end.

mdopt.mps.utils.create_simple_product_state(num_sites: int, which: str = '0', phys_dim: int = 2, form: str = 'Right-canonical', tolerance: float = 1e-12) ExplicitMPS | CanonicalMPS#

Creates a simple product-state MPS.

Parameters:
  • num_sites (int) – The number of sites.

  • which (str) –

    The form of the MPS, for explanation see the notes. Available options:
    0 : The \(|0...0>\) state.
    1 : The \(|1...1>\) state.
    + : The \(|+...+>\) state.

  • phys_dim (int) – Dimensionality of the local Hilbert space, i.e., the dimension of each physical leg of the MPS.

  • form (str) –

    The form of the MPS. Available options:
    Explicit : The ExplicitMPS form (by default).
    Right-canonical : The CanonicalMPS right-canonical form.
    Left-canonical : The CanonicalMPS left-canonical form.

  • tolerance (float) – For the Explicit form: absolute tolerance of the normalisation of the singular value spectrum at each bond. For the Canonical form: numerical tolerance to zero out the singular values in Singular Value Decomposition.

Returns:

mps – The resulting MPS.

Return type:

Union[ExplicitMPS, CanonicalMPS]

Raises:

ValueError – If the chosen form is mixed-canonical. (This form is not available for product states.)

Notes

Produces a Matrix Product State consisting of tensors with bond dimenstions equal to 1. The tensors are defined as follows:

\(| 0 \rangle = \underbrace{(1, 0, ..., 0, 0)}_{\text{phys_dim}}\),
\(| 1 \rangle = \underbrace{(0, 0, ..., 0, 1)}_{\text{phys_dim}}\),
\(| + \rangle = \underbrace{(\frac{1}{\sqrt{\text{phys_dim}}}, ..., \frac{1}{\sqrt{\text{phys_dim}}})}_{\text{phys_dim}}\).

The returned state is normalised.

mdopt.mps.utils.create_state_vector(num_sites: int, phys_dim: int = 2) ndarray#

Creates a random uniform complex-valued vector of norm 1.

Parameters:
  • num_sites (int) – Number of degrees of freedom.

  • phys_dim (int) – Number of dimensions of each degree of freedom.

Returns:

state_vector – The resulting state vector.

Return type:

np.ndarray

mdopt.mps.utils.find_orth_centre(mps: CanonicalMPS, return_orth_flags: bool = False, tolerance: float = 1e-12)#

Returns a list of integers corresponding to positions of orthogonality centres of an MPS.

Parameters:
  • mps (CanonicalMPS) – The MPS to find the orthogonality centre(s) in.

  • return_orth_flags (bool) – Whether to return if each tensor is a right or a left isometry.

  • tolerance (float) – Numerical tolerance for checking the isometry property.

Returns:

  • orth_centres (List[int]) – Indices of sites at which tensors are orthogonality centres.

  • orth_flags_left (Optional[List[bool]]) – Boolean variables for each tensor corresponding to being a left isometry.

  • orth_flags_right (Optional[List[bool]]) – Boolean variables for each tensor corresponding to being a right isometry.

Raises:

ValueError – If an ExplicitMPS instance is passed as an input. They do not have orthogonality centres by definition.

mdopt.mps.utils.inner_product(mps_1: ExplicitMPS | CanonicalMPS, mps_2: ExplicitMPS | CanonicalMPS) float | complex128#

Returns an inner product between 2 Matrix Product States.

Parameters:
  • mps_1 (Union[ExplicitMPS, CanonicalMPS]) – The first MPS in the inner product.

  • mps_1 – The second MPS in the inner product.

Returns:

product – The value of the inner product.

Return type:

Union[float, np.complex128]

Raises:

ValueError – If the Matrix Product States are of different length.

mdopt.mps.utils.is_canonical(mps: CanonicalMPS, tolerance: float = 1e-12)#

Checks if the MPS is in any of the canonical forms.

Parameters:
  • mps (CanonicalMPS) – The MPS to check the canonical form of.

  • tolerance (float) – Numerical tolerance for checking the isometry property.

Returns:

if_canonicalTrue if the MPS is in any of the canonical forms.

Return type:

bool

Raises:

ValueError – If an ExplicitMPS instance is passed as an input. They do not have orthogonality centres by definition.

mdopt.mps.utils.mps_from_dense(state_vector: ndarray, phys_dim: int = 2, chi_max: int = 10000, tolerance: float = 1e-12, form: str = 'Explicit', orth_centre: int | None = None) ExplicitMPS | CanonicalMPS#

Builds an MPS from a dense (state-vector) from.

Parameters:
  • state_vector (np.ndarray) – The initial state vector.

  • phys_dim (int) – Dimensionality of the local Hilbert space, i.e., the dimension of each physical leg of the MPS.

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

  • tolerance (float) – Absolute tolerance of the normalisation of the singular value spectrum at each bond.

  • form (str) –

    The form of the MPS. Available options:
    Explicit : The ExplicitMPS form (by default).
    Right-canonical : The CanonicalMPS right-canonical form.
    Left-canonical : The CanonicalMPS left-canonical form.
    Mixed-canonical : The CanonicalMPS mixed-canonical form.

  • orth_centre (Optional[int]) – The orthogonal centre position for the mixed-canonical form.

Returns:

mps – The resulting MPS.

Return type:

Union[ExplicitMPS, CanonicalMPS]

Raises:

ValueError – If the vector’s length does not correspond to the physical dimension.