seemps.state.MPS#
- class seemps.state.MPS#
Bases:
TensorArrayMPS (Matrix Product State) class.
This implements a bare-bones Matrix Product State object with open boundary conditions. The tensors have three indices, A[α,d,β], where α,β are the internal labels and d is the physical state of the given site.
- Parameters:
- data
Iterable[Tensor3] Sequence of three-legged tensors A[α,si,β]. The dimensions are not verified for consistency.
- error
float, default=0.0 Accumulated truncation error in the previous tensors.
- data
- all_expectation1(operator: TypeAliasForwardRef('~seemps.typing.Operator') | list[TypeAliasForwardRef('~seemps.typing.Operator')]) Vector[source]#
Vector of expectation values of the given operator acting on all possible sites of the MPS.
- Parameters:
- operator
Operator|list[Operator] If operator is an observable, it is applied on each possible site. If it is a list, the expectation value of operator[i] is computed on the i-th site.
- operator
- Returns:
VectorNumpy array of expectation values.
- bond_dimensions() list[int][source]#
List of bond dimensions for the matrix product state.
Returns a list or vector of N+1 integers, for an MPS of size N. The integers 1 to N-1 are the bond dimensions between the respective pairs of tensors. The first and last index are 1, as it corresponds to a matrix product state with open boundary conditions.
Examples
>>> A = np.ones(1,2,3) >>> B = np.ones(3,2,1) >>> mps = MPS([A, B]) >>> mps.bond_dimensions() [1, 3, 1]
- error() float[source]#
Upper bound of the accumulated truncation error on this state.
If this quantum state results from N steps in which we have obtained truncation errors \(\delta_i\), this function returns the estimate \(\sum_{i}\delta_i\).
- Returns:
floatUpper bound for the actual error when approximating this state.
- expectation1(O: Operator, site: int) Weight[source]#
Compute the expectation value \(\langle\psi|O_i|\psi\rangle\) of an operator O acting on the i-th site
- expectation2(Opi: Operator, Opj: Operator, i: int, j: int | None = None) Weight[source]#
Compute the expectation value \(\langle\psi|O_i Q_j|\psi\rangle\) of two operators O and Q acting on the i-th and j-th subsystems.
- extend(L: int, sites: Sequence[int] | None = None, dimensions: int | list[int] = 2, state: Vector | None = None)[source]#
Enlarge an MPS so that it lives in a Hilbert space with L sites.
- Parameters:
- L
int The new size of the MPS. Must be strictly larger than self.size.
- sites
Iterable[int],optional Sequence of integers describing the sites that occupied by the tensors in this state.
- dimensions
int|list[int],default= 2 Dimension of the added sites. It can be the same integer or a list of integers with the same length as sites.
- L
- Returns:
MPSThe extended MPS.
Examples
>>> import seemps.state >>> mps = seemps.state.random_uniform_mps(2, 10) >>> mps.physical_dimensions() [2, 2, 2, 2, 2, 2, 2, 2, 2, 2] >>> mps = mps.extend(12, [0, 2, 4, 5, 6, 7, 8, 9, 10, 11], 3) >>> mps.physical_dimensions() [2, 3, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2]
- classmethod from_tensor(state: ndarray, strategy: Strategy = DEFAULT_STRATEGY, normalize: bool = True) MPS[source]#
Create a matrix-product state from a tensor that represents a composite quantum system.
The tensor state must have N>=1 indices, each of them associated to an individual quantum system, in left-to-right order. This function decomposes the tensor into a contraction of N three-legged tensors as expected from an MPS.
- Parameters:
- state
np.ndarray Real or complex tensor with N legs.
- strategy
Strategy,default=DEFAULT_STRATEGY Default truncation strategy for algorithms working on this state.
- normalizebool,
default=True Whether the state is normalized to compensate truncation errors.
- state
- Returns:
MPSA valid matrix-product state approximating this state vector.
- classmethod from_vector(ψ: VectorLike, dimensions: Sequence[int], strategy: Strategy = DEFAULT_STRATEGY, normalize: bool = True, center: int = -1) MPS[source]#
Create a matrix-product state from a state vector.
- Parameters:
- ψ
VectorLike Real or complex vector of a wavefunction.
- dimensions
Sequence[int] Sequence of integers representing the dimensions of the quantum systems that form this state.
- strategy
Strategy,default=DEFAULT_STRATEGY Default truncation strategy for algorithms working on this state.
- normalizebool,
default=True Whether the state is normalized to compensate truncation errors.
- center
int,default= -1 Center of the canonicalized matrix product state
- ψ
- Returns:
MPSA valid matrix-product state approximating this state vector.
- left_environment(site: int) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]#
Environment matrix for systems to the left of site.
- norm2() float[source]#
Deprecated alias for
norm_squared().
- reverse() MPS[source]#
Reverse the sites and tensors.
Creates a new matrix product operator where tensors 0, 1, …, N-1 are mapped to N-1, N-2, …, 0. For the MPS to be consistent, this also implies reversing the order of the intermediate indices. Thus, if we label as A and B the tensors of the original and of the reversed MPOs, we have
\[B_{a_{n-1},i_n,a_n} = A_{a_{N-n-1},i_{N-n-1},a_{N-n-2}}\]
- right_environment(site: int) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]#
Environment matrix for systems to the right of site.