Canonizing MPS/MPO#
MPS/MPO can be put into canonical form to reveal the most advantageous truncation or as a part of the setup for many algorithms, including DMRG and TDVP.
The canonical form obtained by QR decomposition is fast, but does not allow for truncation of the virtual spaces of MPS/MPO.
- MpsMpoOBC.canonize_(to='first', normalize=True) yastn.tn.mps.MpsMpoOBC [source]#
Sweep through the MPS/MPO and put it in right/left canonical form (
to='first'
orto='last'
, respectively) usingQR decomposition
. It is assumed that tensors are enumerated by index increasing from 0 (first
) to N-1 (last
).Finally, the trivial central block of dimension 1 obtained for terminal sites is attached at the end of the chain.
It updates MPS/MPO in place.
- Parameters:
to (str) –
'first'
(default) or'last'
.normalize (bool) – Whether to keep track of the norm of the state by accumulating it in self.factor; default is True, i.e., sets the norm to unity. The individual tensors at the end of the procedure are in a proper canonical form.
See examples: Canonical form by QR.
The canonization by SVD allows truncating virtual dimension/spaces with the lowest weights (smallest singular values).
- MpsMpoOBC.truncate_(to='last', opts_svd=None, normalize=True) number [source]#
Sweep through the MPS/MPO and put it in right/left canonical form (
to='first'
orto='last'
, respectively) usingyastn.linalg.svd_with_truncation()
decomposition. It is assumed that tensors are enumerated by index increasing from 0 (first
) to N-1 (last
).Access to singular values during sweeping allows truncation of virtual spaces.
The truncation is effective when it is done in the canonical form. The canonical form has to be ensured prior truncation by setting it opposite to the sweep of
truncate_
. I.e., prepare MPS/MPO in the right canonical form (to='first'
) for truncation withto='last'
and left canonical form (to='last'
) for truncation withto='first'
.The MPS/MPO is updated in place.
Returns the norm of truncated elements normalized by the norm of the untruncated state.
- Parameters:
to (str) –
'last'
(default) or'first'
.normalize (bool) – Whether to keep in self.factor the norm of the initial state projected on the direction of the truncated state; default is True, i.e., sets the norm to unity. The individual tensors at the end of the procedure are in a proper canonical form.
opts_svd (dict) – options passed to
yastn.linalg.svd_with_truncation()
, including options governing truncation.
See examples: Canonical form by SVD.
The above routines operate on entire MPS or MPO. They are built from functions operating on individual tensors of MPS/MPO:
- MpsMpoOBC.orthogonalize_site_(n, to='first', normalize=True) None [source]#
Performs QR (or RQ) decomposition of on-site tensor at
n
-th position. Two modes of usage areto='last'
- Advance left canonical form: Assuming first n - 1 sites are already in the left canonical form, brings n-th site to left canonical form, i.e., extends left canonical form by one site towards'last'
site:--A--- -- | | = Identity| --A*-- --
to='first'
- Advance right canonical form: Assuming all m > n sites are already in right canonical form, brings n-th site to right canonical form, i.e., extends right canonical form by one site towards'first'
site:--A--- -- | | = |Identity --A*-- --
- Parameters:
n (int) – index of site to be orthogonalized
to (str) – a choice of canonical form:
'last'
or'first'
.normalize (bool) – Whether to keep track of the norm by accumulating it in self.factor; default is True, i.e., sets the norm to unity. The central blocks at the end of the procedure is normalized to unity.
- MpsMpoOBC.absorb_central_(to='last') None [source]#
Absorb central block towards the first or the last site.
If the central block is outside of the chain, it goes in the one direction possible. Do nothing if central does not exist.
- Parameters:
to (str) – ‘last’ or ‘first’.
- MpsMpoOBC.diagonalize_central_(opts_svd, normalize=True) number [source]#
Use svd() to perform SVD of the central block C = U @ S @ V, where S contains singular (Schmidt) values. Truncation is done based on opts_svd.
Attach U and V respectively to the left and right sites (or to the central site at the edges when there are no left or right sites).
Returns the norm of truncated Schmidt values, normalized by the norm of all Schmidt values.
- Parameters:
opts_svd (dict) – Options passed to
yastn.linalg.truncation_mask()
. It includes information on how to truncate the Schmidt values.normalize (bool) – Whether to keep track of the norm of retained Schmidt values by accumulating it in self.factor; default is True, i.e., sets the norm to unity. The truncated Schmidt values (central block) at the end of the procedure are normalized to unity.