Environment BP#
Belief propagation environments#
- class yastn.tn.fpeps.EnvBP(psi, init='eye', tol_positive=1e-12, which='BP')[source]#
Environment used in belief propagation contraction scheme.
- Parameters:
psi (yastn.tn.Peps) – PEPS lattice to be contracted using BP. If
psihas physical legs, a double-layer PEPS with no physical legs is formed.init (str) – None, ‘eye’. Initialization scheme, see
yastn.tn.fpeps.EnvBP.reset_().which (str) – Type of environment from ‘BP’, ‘NN+BP’, ‘NNN+BP’
- bond_metric(Q0, Q1, s0, s1, dirn)[source]#
Calculates bond metric within BP environment.
If which == 'BP': t t ║ ║ l════Q0══ ══Q1═══r ║ ║ b b If which == 'NN+BP': t t ║ ║ l══(-1 +0)══(-1 +1)══r ║ ║ l═════Q0══ ══Q1════r ║ ║ l══(+1 +0)══(+1 +1)══l ║ ║ b b If which == 'NNN+BP': t t t t ║ ║ ║ ║ l══(-1 -1)=(-1 +0)══(-1 +1)=(-1 +2)══r ║ ║ ║ ║ l══(+0 -1)════Q0══ ══Q1═══(+0 +2)══r ║ ║ ║ ║ l══(+1 -1)=(+1 +0)══(+1 +1)=(+1 +2)══r ║ ║ ║ ║ b b b b
- iterate_(max_sweeps=1, iterator_step=None, diff_tol=None)[source]#
Perform BP updates
yastn.tn.fpeps.EnvBP.update_()until convergence. Convergence can be measured based on maximal difference between old and new tensors.Outputs iterator if
iterator_stepis given, which allows inspectingenv, e.g., calculating expectation values, outside ofiterate_function after everyiterator_stepsweeps.- Parameters:
max_sweeps (int) – Maximal number of sweeps.
iterator_step (int) – If int,
iterate_returns a generator that would yield output after every iterator_step sweeps. The default isNone, in which caseiterate_sweeps are performed immediately.diff_tol (float) – Convergence tolerance for the change of belief tensors in one iteration. The default is None, in which case convergence is not checked and it is up to user to implement convergence check.
- Returns:
Generator if iterator_step is not
None.BP_out(NamedTuple) –
NamedTuple including fields:
sweepsnumber of performed lbp updates.max_diffmaximal difference between old and new belief tensors.convergedwhether convergence based ondiff_tolhas been reached.
- measure_1site(O, site=None) dict[source]#
Calculate local expectation values within BP environment.
Returns a number if
siteis provided. IfNone, returns a dictionary {site: value} for all unique lattice sites.- Parameters:
env (EnvBP) – Class containing BP environment tensors along with lattice structure data.
O (Tensor) – Single-site operator
- measure_nn(O, P, bond=None) dict[source]#
Calculate nearest-neighbor expectation values within BP environment.
Return a number if the nearest-neighbor
bondis provided. IfNone, returns a dictionary {bond: value} for all unique lattice bonds.- Parameters:
O, P (yastn.Tensor) – Calculate <O_s0 P_s1>. P is applied first, which might matter for fermionic operators.
bond (yastn.tn.fpeps.Bond | tuple[tuple[int, int], tuple[int, int]]) – Bond of the form (s0, s1). Sites s0 and s1 should be nearest-neighbors on the lattice.