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) yastn.tn.mps.MpsMpoOBC #
A shallow copy of the tensor with an added
on_bra
flag.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.
- abstract 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]
- abstract 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
- abstract 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.
- abstract measure(bd=None) Number [source]#
Calculate overlap between environments at
bd
bond.- Parameters:
bd (tuple) – index of bond at which to calculate overlap.
- project_ket_on_bra_2(bd) Tensor [source]#
Action of Heff2 on
bd=(n, n+1)
ket MPS tensorsHeff2 @ AA
.