@@ -370,3 +370,49 @@ function Base.rot180(wts::SUWeight)
370370 wts_y = circshift (rot180 (wts[2 , :, :]), (1 , 0 ))
371371 return SUWeight (wts_x, wts_y)
372372end
373+
374+ function _CTMRGEnv (wts:: SUWeight , flips:: Array{Bool, 3} )
375+ @assert size (wts) == size (flips)
376+ _, Nr, Nc = size (wts)
377+ edges = map (Iterators. product (1 : 4 , 1 : Nr, 1 : Nc)) do (d, r, c)
378+ wt_idx = if d == NORTH
379+ CartesianIndex (2 , _next (r, Nr), c)
380+ elseif d == EAST
381+ CartesianIndex (1 , r, _prev (c, Nc))
382+ elseif d == SOUTH
383+ CartesianIndex (2 , r, c)
384+ else # WEST
385+ CartesianIndex (1 , r, c)
386+ end
387+ wt = deepcopy (wts[wt_idx])
388+ if (flips[wt_idx] && d in (NORTH, EAST)) || (! flips[wt_idx] && d in (SOUTH, WEST))
389+ wt = permute (wt, ((2 ,), (1 ,)))
390+ end
391+ twistdual! (wt, 1 )
392+ wt = insertrightunit (insertleftunit (wt, 1 ))
393+ return permute (wt, ((1 , 2 , 3 ), (4 ,)))
394+ end
395+ corners = map (CartesianIndices (edges)) do idx
396+ return TensorKit. id (Float64, codomain (edges[idx], 1 ))
397+ end
398+ return CTMRGEnv (corners, edges)
399+ end
400+
401+ """
402+ CTMRGEnv(wts::SUWeight, peps::InfinitePEPS)
403+
404+ Construct a CTMRG environment with bond dimension χ = 1
405+ for an InfinitePEPS `peps` from the accompanying SUWeight `wts`.
406+ The scalartype of the returned environment is always `Float64`.
407+ """
408+ function CTMRGEnv (wts:: SUWeight , peps:: InfinitePEPS )
409+ _, Nr, Nc = size (wts)
410+ flips = map (Iterators. product (1 : 2 , 1 : Nr, 1 : Nc)) do (d, r, c)
411+ return if d == 1
412+ isdual (domain (peps[r, c], EAST))
413+ else
414+ isdual (domain (peps[r, c], NORTH))
415+ end
416+ end
417+ return _CTMRGEnv (wts, flips)
418+ end
0 commit comments