Environment CTM#
Corner transfer matrix renormalization group (CTMRG) associates a local CTM environment with each lattice site and the corresponding rank-4 PEPS tensors a (potentially, coming from a double-layer contraction of bra and ket PEPSs). We show it below with the convention for ordering the indices in the CTMRG environment tensors:
┌──────┐ ┌─────┐ ┌──────┐
| C_tl ├── 1 0 ──┤ T_t ├── 2 0 ──┤ C_tr |
└──┬───┘ └──┬──┘ └───┬──┘
| | |
0 1 1
2 0 0
│ | |
┌──┴──┐ ┌──┴──┐ ┌──┴──┐
| T_l ├── 1 1 ──┤ a ├── 3 1 ──┤ T_r |
└──┬──┘ └──┬──┘ └──┬──┘
| | |
0 2 2
1 1 0
| | |
┌──┴───┐ ┌──┴──┐ ┌───┴──┐
| C_bl ├── 0 2 ──┤ T_b ├── 0 1 ──┤ C_br |
└──────┘ └─────┘ └──────┘
Operations on the CTM environment are supported by yastn.tn.fpeps.EnvCTM
,
where each local CTM environment yastn.tn.fpeps.EnvCTM_local
can be accessed specifying site coordinates in []
and PEPS network of rank-4 tensors is available via attribute psi
.
The CTM environment class supports CTMRG updates for converging the environment, expectation value calculations,
bond metric, sampling, etc.
A single iteration of the CTMRG update, consisting of horizontal and vertical moves,
is performed with yastn.tn.fpeps.EnvCTM.update_()
.
Performing multiple updates is automatized in yastn.tn.fpeps.EnvCTM.ctmrg_()
.
One can stop the CTM after a fixed number of iterations or, e.g., convergence of corner singular values.
Stopping criteria can also be set based on the convergence of one or more observables, e.g., total energy.
Once the CTMRG converges, it is straightforward to obtain one-site yastn.tn.fpeps.EnvCTM.measure_1site()
and
two-site nearest-neighbor observables yastn.tn.fpeps.EnvCTM.measure_nn()
, or other expectation values of interests.
- class yastn.tn.fpeps.EnvCTM(psi, init='rand', leg=None)[source]#
Environment used in Corner Transfer Matrix Renormalization Group algorithm.
- Note:
Index convention for environment tensor
enlarged corners: anti-clockwise
- Parameters:
psi (yastn.tn.Peps) – PEPS lattice to be contracted using CTM. If
psi
has physical legs, a double-layer PEPS with no physical legs is formed.init (str) – None, ‘eye’ or ‘rand’. Initialization scheme, see
yastn.tn.fpeps.EnvCTM.reset_()
.leg (Optional[yastn.Leg]) – Passed to
yastn.tn.fpeps.EnvCTM.reset_()
to further customize initialization.
- bond_metric(Q0, Q1, s0, s1, dirn)[source]#
Calculates Full-Update metric tensor.
If dirn == 'h': tl═══t═══════t═══tr ║ ║ ║ ║ l════Q0══ ══Q1═══r ║ ║ ║ ║ bl═══b═══════b═══br If dirn == 'v': tl═══t═══tr ║ ║ ║ l═══0Q0═══r ║ ╳ ║ l═══1Q1═══r ║ ║ ║ bl═══b═══br
- ctmrg_(opts_svd=None, method='2site', max_sweeps=1, iterator_step=None, corner_tol=None, truncation_f: Callable = None, **kwargs)[source]#
Perform CTMRG updates
yastn.tn.fpeps.EnvCTM.update_()
until convergence. Convergence can be measured based on singular values of CTM environment corner tensors.Outputs iterator if
iterator_step
is given, which allows inspectingenv
, e.g., calculating expectation values, outside ofctmrg_
function after everyiterator_step
sweeps.- Parameters:
opts_svd (dict) – A dictionary of options to pass to SVD truncation algorithm. This sets EnvCTM bond dimension.
method (str) – ‘2site’ or ‘1site’. The default is ‘2site’. ‘2site’ uses the standard 4x4 enlarged corners, allowing to enlarge EnvCTM bond dimension. ‘1site’ uses smaller 4x2 corners. It is significantly faster, but is less stable and does not allow to grow EnvCTM bond dimension.
max_sweeps (int) – Maximal number of sweeps.
iterator_step (int) – If int,
ctmrg_
returns a generator that would yield output after every iterator_step sweeps. The default isNone
, in which casectmrg_
sweeps are performed immediately.corner_tol (float) – Convergence tolerance for the change of singular values of all corners in a single update. The default is None, in which case convergence is not checked and it is up to user to implement convergence check.
truncation_f – Custom projector truncation function with signature
truncation_f(S: Tensor)->Tensor
, consuming rank-1 tensor with singular values. If provided, truncation parameters passed to SVD decomposition are ignored.checkpoint_move (Union[str, bool]) – Whether to use checkpointing for the CTM updates. The default is
False
. Otherwise, in case of PyTorch backend it can be set to ‘reentrant’ for reentrant checkpointing or ‘nonreentrant’ for non-reentrant checkpointing, see https://pytorch.org/docs/stable/checkpoint.html.
- Returns:
Generator if iterator_step is not
None
.CTMRG_out(NamedTuple) –
NamedTuple including fields:
sweeps
number of performed ctmrg updates.max_dsv
norm of singular values change in the worst corner in the last sweep.converged
whether convergence based oncorner_tol
has been reached.
- measure_1site(O, site=None) dict [source]#
Calculate local expectation values within CTM environment.
Returns a number if
site
is provided. IfNone
, returns a dictionary {site: value} for all unique lattice sites.- Parameters:
env (EnvCtm) – Class containing CTM environment tensors along with lattice structure data.
O (Tensor) – Single-site operator
- measure_2x2(*operators, sites=None)[source]#
Calculate expectation value of a product of local operators in a \(2 \times 2\) window within the CTM environment.
At the moment, it works only for bosonic operators (fermionic are todo).
- Parameters:
operators (Sequence[yastn.Tensor]) – List of local operators to calculate <O0_s0 O1_s1 …>.
sites (Sequence[tuple[int, int]]) – A list of sites [s0, s1, …] matching corresponding operators.
- measure_line(*operators, sites=None)[source]#
Calculate expectation value of a product of local opertors along a horizontal or vertical line within CTM environment.
At the moment works only for bosonic operators (fermionic are to do).
- Parameters:
operators (Sequence[yastn.Tensor]) – List of local operators to calculate <O0_s0 O1_s1 …>.
sites (Sequence[tuple[int, int]]) – List of sites that should match operators.
- measure_nn(O, P, bond=None) dict [source]#
Calculate nearest-neighbor expectation values within CTM environment.
Return a number if the nearest-neighbor
bond
is 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.
- reset_(init='rand', leg=None, **kwargs)[source]#
Initialize CTMRG environment.
- Parameters:
init (str) – [‘eye’, ‘rand’, ‘dl’] For ‘eye’ starts with identity environments of dimension 1. For ‘rand’ sets environments randomly. For ‘dl’ and Env of double-layer PEPS, trace on-site tensors to initialize environment.
leg (None | yastn.Leg) – If not provided, random initialization has CTMRG bond dimension set to 1. Otherwise, the provided Leg is used to initialize CTMRG virtual legs.
- sample(xrange, yrange, projectors, number=1, opts_svd=None, opts_var=None, progressbar=False, return_info=False) dict[Site, list] [source]#
Sample random configurations from PEPS. Output a dictionary linking sites with lists of sampled projectors` keys for each site.
It does not check whether projectors sum up to identity – probabilities of provided projectors get normalized to one. If negative probabilities are observed (signaling contraction errors),
error = max(abs(negatives))
, and all probabilities below that error level are fixed to error (before consecutive renormalization of probabilities to one).- Parameters:
xrange (tuple[int, int]) – range of rows to sample from, [r0, r1); r0 included, r1 excluded.
yrange (tuple[int, int]) – range of columns to sample from.
projectors (Dict[Any, yast.Tensor] | Sequence[yast.Tensor] | Dict[Site, Dict[Any, yast.Tensor]]) – Projectors to sample from. We can provide a dict(key: projector), where the sampled results will be given as keys, and the same set of projectors is used at each site. For a list of projectors, the keys follow from enumeration. Finally, we can provide a dictionary between each site and sets of projectors.
number (int) – Number of drawn samples.
opts_svd (dict) – Options passed to
yastn.linalg.svd()
used to truncate virtual spaces of boundary MPSs used in sampling. The default isNone
, in which case takeD_total
as the largest dimension from CTM environment.opts_var (dict) – Options passed to
yastn.tn.mps.compression_()
used in the refining of boundary MPSs. The default isNone
, in which case make 2 variational sweeps.progressbar (bool) – Whether to display progressbar. The default is
False
.return_info (bool) – Whether to include in the outputted dictionary a field
info
with dictionary that contains information about the amplitude of contraction errors (largest negative probability), D_total, etc. The default isFalse
.
- update_(opts_svd, method='2site', **kwargs)[source]#
Perform one step of CTMRG update. Environment tensors are updated in place.
The function performs a CTMRG update for a square lattice using the corner transfer matrix renormalization group (CTMRG) algorithm. The update is performed in two steps: a horizontal move and a vertical move. The projectors for each move are calculated first, and then the tensors in the CTM environment are updated using the projectors. The boundary conditions of the lattice determine whether trivial projectors are needed for the move.
- Parameters:
opts_svd (dict) – A dictionary of options to pass to SVD truncation algorithm. This sets EnvCTM bond dimension.
method (str) – ‘2site’ or ‘1site’. The default is ‘2site’. ‘2site’ uses the standard 4x4 enlarged corners, allowing to enlarge EnvCTM bond dimension. ‘1site’ uses smaller 4x2 corners. It is significantly faster, but is less stable and does not allow to grow EnvCTM bond dimension.
checkpoint_move (bool) – Whether to use (reentrant) checkpointing for the move. The default is
False
- Returns:
proj
- Return type:
Peps structure loaded with CTM projectors related to all lattice site.
- class yastn.tn.fpeps.EnvCTM_local(tl: Tensor | None = None, t: Tensor | None = None, tr: Tensor | None = None, r: Tensor | None = None, br: Tensor | None = None, b: Tensor | None = None, bl: Tensor | None = None, l: Tensor | None = None)[source]#
Dataclass for CTM environment tensors associated with Peps lattice site.
Contains fields
tl
,t
,tr
,r
,br
,b
,bl
,l