You're referring to the
update_LP_RP
defined in
get_sweep_schedule for
n=2
, i.e. a two-site update. As you can see from the
i0s, move_right
variables, we do 2L updates in total, each updating 2 sites, in the order
(0, 1), ..., (L-2, L-1), (L-1, L), (L, L+1), (L-1, L), ..., (1, 2)
.
Note that this is going a little bit further than you might have expected naively, each bond is updated twice, including the bond (0, 1) == (L, L+1). This detail is a bit different from the toycode, which only goes up to (L-1, L).
The
update_LP_RP
are "just" an optimization trying to minimize the actual environment updates calculated and environments kept in cache/memory. If you set all of them to True (what we do in the toy code), it will still give the same results, but you would do some extra work:
For finite DMRG, whenever we move to the right, we don't need the right environment any more, because we will re-build it with an updated state when moving to the left again. For this reason, we neither need to calculate the new right environment nor keep it in memory.
The same is true for the infinite case, except for the first two updates - 2 because we have two-site DMRG: we will use the right environments from the (0,1) (1, 2) updates (updated to be to the left of sites 1 and 2, i.e. right of site 0, 1, respectively) for updating the bonds (L-1, L) and (L, L+1). Note that this is the step where the right environment grows by one unit cell!
Setting the update_LP_RP to False in the other right-moves ensures that we don't do extra work and don't keep a total of 2L environments, but only a little bit more than L - if I remember correctly, we only need L+2 environments at once in cache. (This is important because these environments are the biggest tensors for cylinder DMRG where the MPO bond dimension easily exceeds physical dimensions.)
Overall, both the left and right environments grow by one unit cell for each call of
sweep()
. You can see this by the growing number of the "age" in the log: the "age" is just the total number of sites involved in both the left and right environments and your current MPS unit cell, so it grows L -> 3L -> 5L -> 7L ... with the sweeps. Keeping track of the age is important to correctly identify the energy density from the total energy - really, what we use is \(\frac{E(s) - E(s-1)}{age(s) - age(s-1)}\), where s is the sweep index.