Environments#
Many of the algorithms described in previous sections require MPS/MPOs’ product contractions.
Those are supported by environment classes, initialized by Env() function.
- yastn.tn.mps.Env(bra, target, **kwargs)[source]#
Initialize a proper environment supporting contraction of MPS/MPO’s: \(\langle \textrm{bra} | \textrm{target} \rangle\) where \(|\textrm{target} \rangle\) can be an MPS/MPO, an operator acting on MPS/MPO, or a sum of thereof.
- Parameters:
bra (yastn.tn.mps.MpsMpoOBC) – Can be an MPS or an MPO – the target should be of the matching form.
target (Sequence | yastn.tn.mps.MpsMpoOBC) – Dispatch over a set of supported targets:
ket or [ket] for \(\langle \textrm{bra} | \textrm{ket} \rangle\).
[mpo, ket] for \(\langle \textrm{bra} | \textrm{mpo} | \textrm{ket} \rangle\).
[[mpo_1, mpo_2, …], ket] for \(\langle \textrm{bra} | \sum_i \textrm{mpo}_i | \textrm{ket} \rangle\).
[[ket_1], [mpo_2, ket_2], [[mpo_3, mpo_4], ket_3]] for a sum of any combination of the above.
Note
compression_directly callsEnv(psi, target).dmrg_andtdvp_callEnv(psi, target=[H, psi]).
- yastn.tn.mps.MpsMpoOBC.on_bra(self) _MpsMpoParent#
A shallow copy of the tensor with an added
on_braflag.The flag is only relevant in functions using
Env(). It makes the Mpo operator acting on an Mpo state to be applied on the bra legs (or auxiliary legs), instead of a default application on ket legs. For instance,Heff = [-H, H.on_bra()]can be used to evolve an operator in the Heisenberg picture.This flag gets propagated by __mul__, conj, transpose, and other functions employing shallow_copy. It is not saved/loaded, or propagated by more complicated functions.
Environment classes#
They inherit from the EnvParent class and contain, among others, the following methods:
- class yastn.tn.mps._env.EnvParent(bra=None)[source]#
Interface for environments of 1D TNs.
- abstractmethod Heff0(C, bd) Tensor[source]#
Action of Heff on central block
Heff0 @ C.- Parameters:
C (tensor) – a central block
bd (tuple) – index of bond on which it acts, e.g. (1, 2) [or (2, 1) as it is ordered]
- abstractmethod Heff1(A, n) Tensor[source]#
Action of Heff on a single site MPS tensor
Heff1 @ A.- Parameters:
A (tensor) – site tensor
n (int) – index of corresponding site
- abstractmethod Heff2(AA, bd) Tensor[source]#
Action of Heff on central block
Heff2 @ AA.- Parameters:
AA (tensor) – merged tensor for 2 sites. Physical legs should be fused turning it effectively into 1-site update.
bd (tuple) – index of bond on which it acts, e.g. (1, 2) [or (2, 1) as it gets ordered]
- clear_site_(*args)[source]#
Clear environments pointing from sites whose indices are provided in args.
- abstractmethod measure(bd=None) Number[source]#
Calculate overlap between environments at
bdbond.- Parameters:
bd (tuple) – index of bond at which to calculate overlap.