Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c101c79
Change ALS tensor axis order
Yue-Zhengyuan Apr 6, 2026
2fdd026
bondenv_ctm for PEPO
Yue-Zhengyuan Apr 6, 2026
1a13c39
Rotation of LocalCircuit
Yue-Zhengyuan Apr 6, 2026
bfb826a
Use vector of sites in `nearest_neighbours` etc
Yue-Zhengyuan Apr 7, 2026
0c74c01
Merge branch 'rotate-circuit' into bondenv-ntu
Yue-Zhengyuan Apr 8, 2026
f6554f3
Neighbourhood tensor update
Yue-Zhengyuan Apr 8, 2026
2540e48
Fix benv_tensor for dual physical space
Yue-Zhengyuan Apr 8, 2026
24145b1
Add NTU tests
Yue-Zhengyuan Apr 8, 2026
f9d029a
Remove unneeded bipartite restrictions
Yue-Zhengyuan Apr 8, 2026
71e6e31
Merge remote-tracking branch 'upstream/master' into bondenv-ntu
Yue-Zhengyuan Apr 10, 2026
c51b54b
Test `timestep` for NTU
Yue-Zhengyuan Apr 12, 2026
e8f07eb
Convergence check for NTU
Yue-Zhengyuan Apr 12, 2026
a4de5ff
Streamline convergence checks
Yue-Zhengyuan Apr 15, 2026
c14fa16
Merge #360
Yue-Zhengyuan Apr 17, 2026
3a915c4
FixedSpaceTruncation for NTU
Yue-Zhengyuan Apr 17, 2026
6bfb34f
Fix time_evolve interface in tests
Yue-Zhengyuan Apr 17, 2026
26344d2
Fix realtime Ising test
Yue-Zhengyuan Apr 18, 2026
8ed7d13
Fix FixedSpaceTruncation for simple update
Yue-Zhengyuan Apr 24, 2026
3498fea
Improve efficiency of bond truncation
Yue-Zhengyuan Apr 24, 2026
ea0a968
Make j1j2 finiteT test work for all allowed symmetries
Yue-Zhengyuan Apr 24, 2026
3cc7769
Reorganize code to get bond tensors
Yue-Zhengyuan Apr 24, 2026
5a90194
Improve NTU struct type stability
Yue-Zhengyuan Apr 24, 2026
3d1c3f9
Fix FixedSpaceTruncation again
Yue-Zhengyuan Apr 25, 2026
99e3e48
Require bond tensor to be an MPSTensor
Yue-Zhengyuan Apr 25, 2026
b6aeff3
Replace `_qr_bond` with `bond_tensor` functions
Yue-Zhengyuan Apr 25, 2026
bbc3bc4
Fix `undo_bond_tensor_last`
Yue-Zhengyuan Apr 25, 2026
de5a5d5
Change bond_tensor return order
Yue-Zhengyuan Apr 25, 2026
2d90e04
Do not move phys leg to bond tensor for middle cluster sites
Yue-Zhengyuan Apr 26, 2026
931a575
Fix bondenv tests
Yue-Zhengyuan Apr 26, 2026
14c2fde
Get rid of ncon in benv_tensor
Yue-Zhengyuan May 3, 2026
f8aaff0
More optimizations for benv_tensor
Yue-Zhengyuan May 3, 2026
9079316
Improve simple update performance
Yue-Zhengyuan May 4, 2026
511a654
Fix formatting
Yue-Zhengyuan May 4, 2026
eb06fc0
Merge remote-tracking branch 'upstream/master' into bondenv-ntu
Yue-Zhengyuan May 4, 2026
c60ab31
Add Printf to test environment
Yue-Zhengyuan May 4, 2026
dbb4a6b
Remove unnecessary type specification
Yue-Zhengyuan May 5, 2026
d0bcf0e
Merge remote-tracking branch 'upstream/master' into bondenv-ntu
Yue-Zhengyuan May 5, 2026
5234126
Revert a comment
Yue-Zhengyuan May 5, 2026
6034a67
Change default opt_alg for NTU
Yue-Zhengyuan May 7, 2026
8e4d44a
Add verbosity setting for NTU
Yue-Zhengyuan May 7, 2026
fa109bc
Test coverage on NTU for ground state
Yue-Zhengyuan May 7, 2026
e16c935
Unexport infinite_temperature_density_matrix
Yue-Zhengyuan May 7, 2026
fba41a2
Merge remote-tracking branch 'upstream/main' into bondenv-ntu
Yue-Zhengyuan May 8, 2026
1fdc81c
Use periodic indexing
Yue-Zhengyuan May 8, 2026
1655e48
Slightly reduce output
Yue-Zhengyuan May 8, 2026
03d2c8f
Update tests
Yue-Zhengyuan May 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/PEPSKit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module PEPSKit
using LinearAlgebra, Statistics, Base.Threads, Base.Iterators, Printf
using Random
using Compat
using Accessors: @set, @reset
using Accessors: @set, @reset, @insert
using VectorInterface
import VectorInterface as VI

Expand Down Expand Up @@ -92,6 +92,7 @@ include("algorithms/contractions/bp_contractions.jl")
include("algorithms/contractions/bondenv/benv_tools.jl")
include("algorithms/contractions/bondenv/gaugefix.jl")
include("algorithms/contractions/bondenv/als_solve.jl")
include("algorithms/contractions/bondenv/benv_ntu.jl")
include("algorithms/contractions/bondenv/benv_ctm.jl")
include("algorithms/contractions/correlator/peps.jl")
include("algorithms/contractions/correlator/pepo_1layer.jl")
Expand All @@ -116,6 +117,8 @@ include("algorithms/time_evolution/trotter_gate.jl")
include("algorithms/time_evolution/time_evolve.jl")
include("algorithms/time_evolution/simpleupdate.jl")
include("algorithms/time_evolution/simpleupdate3site.jl")
include("algorithms/time_evolution/ntupdate.jl")
include("algorithms/time_evolution/ntupdate3site.jl")
include("algorithms/time_evolution/gaugefix_su.jl")

include("algorithms/bp/beliefpropagation.jl")
Expand Down Expand Up @@ -149,7 +152,8 @@ export fixedpoint

export absorb_weight
export ALSTruncation, FullEnvTruncation
export SimpleUpdate
export NNEnv, NNpEnv, NNNEnv
export SimpleUpdate, NeighbourUpdate
export TimeEvolver, timestep, time_evolve

export InfiniteSquareNetwork
Expand Down
239 changes: 239 additions & 0 deletions src/algorithms/contractions/bondenv/benv_ntu.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
#=
The construction of bond environment for Neighborhood Tensor Update (NTU)
is adapted from YASTN (https://github.com/yastn/yastn).
Copyright 2024 The YASTN Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0
=#

"""
Algorithms to construct bond environment for Neighborhood Tensor Update (NTU).
"""
abstract type NeighbourEnv end

"""
SVD with `truncrank(1)`.
"""
function _svd_cut!(t::AbstractTensorMap)
t1, s, t2 = svd_trunc!(t; trunc = truncrank(1))
return absorb_s(t1, s, t2)
end

"""
Algorithm struct for "NTU-NN" bond environment.
"""
struct NNEnv <: NeighbourEnv end
"""
Calculate the bond environment within "NTU-NN" approximation.
```
-1 ●=======●
║ ║
0 ●===X== ==Y===●
║ ║
1 ●=======●
-1 0 1 2
```
"""
function bondenv_ntu(
row::Int, col::Int, X, Y, state::S, alg::NNEnv
) where {S <: InfiniteState}
neighbors = [(-1, 0), (0, -1), (1, 0), (1, 1), (0, 2), (-1, 1)]
m = collect_neighbors(state, row, col, neighbors)
X, Y = _prepare_site_tensor(X), _prepare_site_tensor(Y)
# southwest half
@autoopt @tensor benv_sw[Dse1 Dse0 Dw1 Dw0 Dnw1 Dnw0] :=
cor_se(m[1, 1])[Dse1 Dse0 Ds1 Ds0] *
cor_sw(m[1, 0])[Dsw1 Dsw0 Ds1 Ds0] *
edge_w(X, hair_w(m[0, -1]))[Dnw1 Dnw0 Dw1 Dw0 Dsw1 Dsw0]
normalize!(benv_sw, Inf)
# northeast half
@autoopt @tensor benv_ne[Dnw1 Dnw0 De1 De0 Dse1 Dse0] :=
cor_nw(m[-1, 0])[Dn1 Dn0 Dnw1 Dnw0] *
cor_ne(m[-1, 1])[Dne1 Dne0 Dn1 Dn0] *
edge_e(Y, hair_e(m[0, 2]))[Dne1 Dne0 Dse1 Dse0 De1 De0]
normalize!(benv_ne, Inf)
@tensor benv[Dw1 De1; Dw0 De0] :=
benv_sw[Dse1 Dse0 Dw1 Dw0 Dnw1 Dnw0] * benv_ne[Dnw1 Dnw0 De1 De0 Dse1 Dse0]
normalize!(benv, Inf)
return benv
end

"""
Algorithm struct for "NTU-NN+" bond environment.
"""
struct NNpEnv <: NeighbourEnv end
"""
Calculate the bond environment within "NTU-NN+" approximation.
```
-2 ●.......●
║ ║
-1 ○===●=======●===○
║ ║ ║ ║
0 ●===●===X== ==Y===●===●
║ ║ ║ ║
1 ○===●=======●===○
║ ║
2 ●.......●
-2 -1 0 1 2 3
```
Dotted lines and ○ are splitted using SVD with `truncrank(1)`.
"""
function bondenv_ntu(
row::Int, col::Int, X, Y, state::S, alg::NNpEnv
) where {S <: InfiniteState}
neighbors = [
(-1, -1), (0, -1), (1, -1), (1, 0), (1, 1), (1, 2), (0, 2), (-1, 2),
(-1, 1), (-1, 0), (0, -2), (2, 0), (2, 1), (0, 3), (-2, 1), (-2, 0),
]
ms = collect_neighbors(state, row, col, neighbors)
X, Y = _prepare_site_tensor(X), _prepare_site_tensor(Y)

# ---- hairs (size D^2) with a 1D auxiliary leg ----

@tensor top[-1 -2; -3 -4] := cor_nw(ms[-2, 0])[1 2 -1 -2] * cor_ne(ms[-2, 1])[-3 -4 1 2]
tl, tr = _svd_cut!(top)

@tensor bot[-1 -2; -3 -4] := cor_sw(ms[2, 0])[-1 -2 1 2] * cor_se(ms[2, 1])[-3 -4 1 2]
bl, br = _svd_cut!(bot)

nw = permute(cor_nw(ms[-1, -1]), ((3, 4), (1, 2)))
nw1, nw2 = _svd_cut!(nw)

ne = permute(cor_ne(ms[-1, 2]), ((3, 4), (1, 2)))
ne1, ne2 = _svd_cut!(ne)

sw = permute(cor_sw(ms[1, -1]), ((1, 2), (3, 4)))
sw1, sw2 = _svd_cut!(sw)

se = permute(cor_se(ms[1, 2]), ((3, 4), (1, 2)))
se1, se2 = _svd_cut!(se)

m = ms[0, -1]
@tensoropt hW[anw DXw1 DXw0 asw] :=
hair_w(ms[0, -2])[Dw21 Dw20] *
nw1[Dnw11 Dnw10 anw] * sw1[Dsw11 Dsw10 asw] *
twistdual(m, 1)[p Dnw10 DXw0 Dsw10 Dw20] *
conj(m[p Dnw11 DXw1 Dsw11 Dw21])

m = ms[0, 2]
@tensoropt hE[ane DYe1 DYe0 ase] :=
hair_e(ms[0, 3])[De21 De20] *
ne2[ane Dne21 Dne20] * se2[ase Dse21 Dse20] *
twistdual(m, 1)[p Dne20 De20 Dse20 DYe0] *
conj(m[p Dne21 De21 Dse21 DYe1])

# ---- corners (size D^4) with a 1D auxiliary leg ----

m = ms[-1, 0]
@tensoropt NW[at Dn1 Dn0 DXn1 DXn0 anw] :=
tl[Dtl1 Dtl0 at] * nw2[anw Dnw21 Dnw20] *
twistdual(m, 1)[p Dtl0 Dn0 DXn0 Dnw20] *
conj(m[p Dtl1 Dn1 DXn1 Dnw21])

m = ms[-1, 1]
@tensoropt NE[at Dn1 Dn0 DYn1 DYn0 ane] :=
tr[at Dtr1 Dtr0] * ne1[Dne11 Dne10 ane] *
twistdual(m, 1)[p Dtr0 Dne10 DYn0 Dn0] *
conj(m[p Dtr1 Dne11 DYn1 Dn1])

m = ms[1, 0]
@tensoropt SW[asw DXs1 DXs0 Ds1 Ds0 ab] :=
bl[Dbl1 Dbl0 ab] * sw2[asw Dsw21 Dsw20] *
twistdual(m, 1)[p DXs0 Ds0 Dbl0 Dsw20] *
conj(m[p DXs1 Ds1 Dbl1 Dsw21])

m = ms[1, 1]
@tensoropt SE[ase DYs1 DYs0 Ds1 Ds0 ab] :=
br[ab Dbr1 Dbr0] * se1[Dse11 Dse10 ase] *
twistdual(m, 1)[p DYs0 Dse10 Dbr0 Ds0] *
conj(m[p DYs1 Dse11 Dbr1 Ds1])

# ---- left half ----
@tensoropt benvL[at Dn1 Dn0 Dw1 Dw0 Ds1 Ds0 ab] :=
hW[anw DXw1 DXw0 asw] *
NW[at Dn1 Dn0 DXn1 DXn0 anw] *
SW[asw DXs1 DXs0 Ds1 Ds0 ab] *
twistdual(X, 1)[p DXn0 Dw0 DXs0 DXw0] *
conj(X[p DXn1 Dw1 DXs1 DXw1])
normalize!(benvL, Inf)

# ---- right half ----

@tensoropt benvR[at Dn1 Dn0 De1 De0 Ds1 Ds0 ab] :=
hE[ane DYe1 DYe0 ase] *
NE[at Dn1 Dn0 DYn1 DYn0 ane] *
SE[ase DYs1 DYs0 Ds1 Ds0 ab] *
twistdual(Y, 1)[p DYn0 DYe0 DYs0 De0] *
conj(Y[p DYn1 DYe1 DYs1 De1])
normalize!(benvR, Inf)

# ---- the full NN+ environment ----

@tensor benv[Dw1, De1; Dw0, De0] :=
benvL[at Dn1 Dn0 Dw1 Dw0 Ds1 Ds0 ab] *
benvR[at Dn1 Dn0 De1 De0 Ds1 Ds0 ab]
normalize!(benv, Inf)
return benv
end

"""
Algorithm struct for "NTU-NNN" bond environment.
"""
struct NNNEnv <: NeighbourEnv end
"""
Calculates the bond environment within "NTU-NNN" approximation.
```
-1 ●===●=======●===●
║ ║ ║ ║
0 ●===X== ==Y===●
║ ║ ║ ║
1 ●===●=======●===●
-1 0 1 2
```
"""
function bondenv_ntu(
row::Int, col::Int, X, Y, state::S, alg::NNNEnv
) where {S <: InfiniteState}
neighbors = [
(-1, -1), (0, -1), (1, -1),
(1, 0), (1, 1), (1, 2), (0, 2),
(-1, 2), (-1, 1), (-1, 0),
]
m = collect_neighbors(state, row, col, neighbors)
X, Y = _prepare_site_tensor(X), _prepare_site_tensor(Y)
#= left half
-1 ●======●=== -1/-2
║ ║
0 ●======X=== -3/-4
║ ║
....D1.....D2...
║ ║
1 ●==D3==●=== -5/-6
-1 0
=#
vecl = enlarge_corner_nw(cor_nw(m[-1, -1]), edge_n(m[-1, 0]), edge_w(m[0, -1]), X)
@tensor vecl[:] :=
cor_sw(m[1, -1])[D11 D10 D31 D30] *
edge_s(m[1, 0])[D21 D20 -5 -6 D31 D30] *
vecl[D11 D10 D21 D20 -1 -2 -3 -4]
normalize!(vecl, Inf)
#= right half
-1 -1/-2===●==D1==●
║ ║
........D2.....D3...
║ ║
0 -3/-4===Y======●
║ ║
1 -5/-6===●======●
1 2
=#
vecr = enlarge_corner_se(cor_se(m[1, 2]), edge_s(m[1, 1]), edge_e(m[0, 2]), Y)
@tensor vecr[:] :=
edge_n(m[-1, 1])[D11 D10 D21 D20 -1 -2] *
cor_ne(m[-1, 2])[D31 D30 D11 D10] *
vecr[D21 D20 D31 D30 -3 -4 -5 -6]
normalize!(vecr, Inf)
# combine left and right part
@tensor benv[-1 -2; -3 -4] := vecl[1 2 -1 -3 3 4] * vecr[1 2 -2 -4 3 4]
normalize!(benv, Inf)
return benv
end
Loading
Loading