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)[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.

Notes

compression_ directly calls Env(psi, target). dmrg_ and tdvp_ call Env(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) yastn.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) yastn.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) yastn.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 factor() number[source]#

Collect factors from constituent MPSs and MPOs.

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_1(n) yastn.Tensor[source]#

Action of Heff1 on n-th ket MPS tensor Heff1 @ ket[n].

project_ket_on_bra_2(bd) yastn.Tensor[source]#

Action of Heff2 on bd=(n, n+1) ket MPS tensors Heff2 @ AA.

setup_(to='last')[source]#

Setup all environments in given direction.

Parameters:

to (str) – first or last.

abstract update_env_(n, to='last')[source]#

Update environment including site n, in the direction given by to.

Parameters:
  • n (int) – index of site to include to the environment

  • to (str) – first or last.