Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions docs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ When releasing a new version, move the "Unreleased" changes to a new version sec

### Changed

- In `correlator`, sites `js` are allowed on either side of the reference site `i` by adding right-to-left contractions (#399)

### Deprecated

### Removed
Expand Down
2 changes: 2 additions & 0 deletions src/PEPSKit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ include("algorithms/contractions/bondenv/gaugefix.jl")
include("algorithms/contractions/bondenv/als_solve.jl")
include("algorithms/contractions/bondenv/benv_ctm.jl")
include("algorithms/contractions/correlator/peps.jl")
include("algorithms/contractions/correlator/pepo_purified.jl")
include("algorithms/contractions/correlator/pepo_1layer.jl")

include("algorithms/ctmrg/sparse_environments.jl")
Expand Down Expand Up @@ -126,6 +127,7 @@ include("algorithms/bp/gaugefix.jl")

include("algorithms/transfermatrix.jl")
include("algorithms/toolbox.jl")
include("algorithms/correlator_adapters.jl")
include("algorithms/correlators.jl")

include("algorithms/optimization/fixed_point_differentiation.jl")
Expand Down
71 changes: 66 additions & 5 deletions src/algorithms/contractions/correlator/pepo_1layer.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
function start_correlator(
# -------- For left-to-right correlator contraction --------

function start_correlator_left(
i::CartesianIndex{2}, ρ::InfinitePEPO,
O::PFTensor, env::CTMRGEnv
)
Expand All @@ -25,8 +27,8 @@ function start_correlator(
return Vn, Vo
end

function end_correlator_numerator(
j::CartesianIndex{2}, V::CTMRGEdgeTensor{T, S, 3},
function end_correlator_right_numerator(
j::CartesianIndex{2}, V::AbstractTensorMap{T, S, 3, 1},

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the V tensors (partially contracted correlator network) are not actually CTMRG edge tensors, I prefer just annotate their type using AbstractTensorMap.

ρ::InfinitePEPO, O::PFTensor, env::CTMRGEnv
) where {T, S}
(size(ρ, 3) == 1) ||
Expand All @@ -44,8 +46,8 @@ function end_correlator_numerator(
t[d1 d2; DN DE DS DW] * removeunit(O, 4)[dstring d2; d1]
end

function end_correlator_denominator(
j::CartesianIndex{2}, V::CTMRGEdgeTensor{T, S, 2}, env::CTMRGEnv
function end_correlator_right_denominator(
j::CartesianIndex{2}, V::AbstractTensorMap{T, S, 2, 1}, env::CTMRGEnv
) where {T, S}
r, c = Tuple(j)
C_northeast = corner(env, NORTHEAST, r - 1, c + 1)
Expand All @@ -54,3 +56,62 @@ function end_correlator_denominator(
return @autoopt @tensor V[χS DE; χN] * C_northeast[χN; χNE] *
E_east[χNE DE; χSE] * C_southeast[χSE; χS]
end

# -------- For right-to-left correlator contraction --------

function start_correlator_right(
i::CartesianIndex{2}, ρ::InfinitePEPO,
O::PFTensor, env::CTMRGEnv
)
(size(ρ, 3) == 1) ||
throw(ArgumentError("The input PEPO ρ must have only one layer."))
r, c = Tuple(i)
E_north = edge(env, NORTH, r - 1, c)
E_east = edge(env, EAST, r, c + 1)
E_south = edge(env, SOUTH, r + 1, c)
C_northeast = corner(env, NORTHEAST, r - 1, c + 1)
C_southeast = corner(env, SOUTHEAST, r + 1, c + 1)
t = twistdual(ρ[r, c], 1:2)
@autoopt @tensor Vn[χNW DW; χSW] :=
E_south[χSSE DS; χSW] * E_east[χNEE DE; χSEE] *
E_north[χNW DN; χNNE] * C_northeast[χNNE; χNEE] *
C_southeast[χSEE; χSSE] * t[d d; DN DE DS DW]
@autoopt @tensor Vo[χNW DW dstring; χSW] :=
E_south[χSSE DS; χSW] * E_east[χNEE DE; χSEE] *
E_north[χNW DN; χNNE] * C_northeast[χNNE; χNEE] *
C_southeast[χSEE; χSSE] *
removeunit(O, 1)[d2; d1 dstring] * t[d1 d2; DN DE DS DW]
return Vn, Vo
end


function end_correlator_left_numerator(
j::CartesianIndex{2}, V::AbstractTensorMap{T, S, 3, 1},
ρ::InfinitePEPO, O::PFTensor, env::CTMRGEnv
) where {T, S}
(size(ρ, 3) == 1) ||
throw(ArgumentError("The input PEPO ρ must have only one layer."))
r, c = Tuple(j)
E_north = edge(env, NORTH, r - 1, c)
E_south = edge(env, SOUTH, r + 1, c)
E_west = edge(env, WEST, r, c - 1)
C_northwest = corner(env, NORTHWEST, r - 1, c - 1)
C_southwest = corner(env, SOUTHWEST, r + 1, c - 1)
t = twistdual(ρ[r, c], 1:2)
return @autoopt @tensor V[χNE DE dstring; χSE] *
E_south[χSE DS; χSW2] * C_southwest[χSW2; χSW] *
E_west[χSW DW; χNW] * C_northwest[χNW; χN] *
E_north[χN DN; χNE] *
t[d1 d2; DN DE DS DW] * removeunit(O, 4)[dstring d2; d1]
end

function end_correlator_left_denominator(
j::CartesianIndex{2}, V::AbstractTensorMap{T, S, 2, 1}, env::CTMRGEnv
) where {T, S}
r, c = Tuple(j)
C_northwest = corner(env, NORTHWEST, r - 1, c - 1)
E_west = edge(env, WEST, r, c - 1)
C_southwest = corner(env, SOUTHWEST, r + 1, c - 1)
return @autoopt @tensor V[χN DE; χS] * C_southwest[χS; χSW] *
E_west[χSW DE; χNW] * C_northwest[χNW; χN]
end
135 changes: 135 additions & 0 deletions src/algorithms/contractions/correlator/pepo_purified.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# -------- For left-to-right correlator contraction --------

function start_correlator_left(
i::CartesianIndex{2},
below::InfinitePEPO,
O::MPOTensor,
above::InfinitePEPO,
env::CTMRGEnv,
)
r, c = Tuple(i)
E_north = edge(env, NORTH, r - 1, c)
E_south = edge(env, SOUTH, r + 1, c)
E_west = edge(env, WEST, r, c - 1)
C_northwest = corner(env, NORTHWEST, r - 1, c - 1)
C_southwest = corner(env, SOUTHWEST, r + 1, c - 1)
ket = twistdual(below[r, c], (1, 2))
bra = above[r, c]

@autoopt @tensor Vn[χSE Detop Debot; χNE] :=
E_south[χSE Dstop Dsbot; χSW2] *
C_southwest[χSW2; χSW] *
E_west[χSW Dwtop Dwbot; χNW] *
C_northwest[χNW; χN] *
conj(bra[d a; Dnbot Debot Dsbot Dwbot]) *
ket[d a; Dntop Detop Dstop Dwtop] *
E_north[χN Dntop Dnbot; χNE]

@autoopt @tensor Vo[χSE Detop dstring Debot; χNE] :=
E_south[χSE Dstop Dsbot; χSW2] *
C_southwest[χSW2; χSW] *
E_west[χSW Dwtop Dwbot; χNW] *
C_northwest[χNW; χN] *
conj(bra[d1 a; Dnbot Debot Dsbot Dwbot]) *
removeunit(O, 1)[d1; d2 dstring] *
ket[d2 a; Dntop Detop Dstop Dwtop] *
E_north[χN Dntop Dnbot; χNE]

return Vn, Vo
end

function end_correlator_right_numerator(
j::CartesianIndex{2},
V::AbstractTensorMap{T, S, 4, 1},
above::InfinitePEPO,
O::MPOTensor,
below::InfinitePEPO,
env::CTMRGEnv,
) where {T, S}
r, c = Tuple(j)
E_north = edge(env, NORTH, r - 1, c)
E_east = edge(env, EAST, r, c + 1)
E_south = edge(env, SOUTH, r + 1, c)
C_northeast = corner(env, NORTHEAST, r - 1, c + 1)
C_southeast = corner(env, SOUTHEAST, r + 1, c + 1)
ket = twistdual(above[r, c], (1, 2))
bra = below[r, c]

return @autoopt @tensor V[χSW DWt dstring DWb; χNW] *
E_south[χSSE DSt DSb; χSW] *
E_east[χNEE DEt DEb; χSEE] *
E_north[χNW DNt DNb; χNNE] *
C_northeast[χNNE; χNEE] *
C_southeast[χSEE; χSSE] *
conj(bra[db a; DNb DEb DSb DWb]) *
ket[dt a; DNt DEt DSt DWt] *
removeunit(O, 4)[dstring db; dt]
end

# -------- For right-to-left correlator contraction --------

function start_correlator_right(
i::CartesianIndex{2},
below::InfinitePEPO,
O::MPOTensor,
above::InfinitePEPO,
env::CTMRGEnv,
)
r, c = Tuple(i)
E_north = edge(env, NORTH, r - 1, c)
E_east = edge(env, EAST, r, c + 1)
E_south = edge(env, SOUTH, r + 1, c)
C_northeast = corner(env, NORTHEAST, r - 1, c + 1)
C_southeast = corner(env, SOUTHEAST, r + 1, c + 1)
ket = twistdual(below[r, c], (1, 2))
bra = above[r, c]

@autoopt @tensor Vn[χNW DWtop DWbot; χSW] :=
E_south[χSSE Dstop Dsbot; χSW] *
E_east[χNEE Detop Debot; χSEE] *
E_north[χNW Dntop Dnbot; χNNE] *
C_northeast[χNNE; χNEE] *
C_southeast[χSEE; χSSE] *
conj(bra[d a; Dnbot Debot Dsbot DWbot]) *
ket[d a; Dntop Detop Dstop DWtop]

@autoopt @tensor Vo[χNW DWtop dstring DWbot; χSW] :=
E_south[χSSE Dstop Dsbot; χSW] *
E_east[χNEE Detop Debot; χSEE] *
E_north[χNW Dntop Dnbot; χNNE] *
C_northeast[χNNE; χNEE] *
C_southeast[χSEE; χSSE] *
conj(bra[d1 a; Dnbot Debot Dsbot DWbot]) *
removeunit(O, 1)[d1; d2 dstring] *
ket[d2 a; Dntop Detop Dstop DWtop]

return Vn, Vo
end

function end_correlator_left_numerator(
j::CartesianIndex{2},
V::AbstractTensorMap{T, S, 4, 1},
above::InfinitePEPO,
O::MPOTensor,
below::InfinitePEPO,
env::CTMRGEnv,
) where {T, S}
r, c = Tuple(j)
E_north = edge(env, NORTH, r - 1, c)
E_south = edge(env, SOUTH, r + 1, c)
E_west = edge(env, WEST, r, c - 1)
C_northwest = corner(env, NORTHWEST, r - 1, c - 1)
C_southwest = corner(env, SOUTHWEST, r + 1, c - 1)
ket = twistdual(above[r, c], (1, 2))
bra = below[r, c]

return @autoopt @tensor V[χNE DEt dstring DEb; χSE] *
E_south[χSE DSt DSb; χSW2] *
C_southwest[χSW2; χSW] *
E_west[χSW DWt DWb; χNW] *
C_northwest[χNW; χN] *
E_north[χN DNt DNb; χNE] *
conj(bra[db a; DNb DEb DSb DWb]) *
ket[dt a; DNt DEt DSt DWt] *
removeunit(O, 4)[dstring db; dt]
end
89 changes: 86 additions & 3 deletions src/algorithms/contractions/correlator/peps.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
function start_correlator(
# -------- For left-to-right correlator contraction --------

function start_correlator_left(
i::CartesianIndex{2},
below::InfinitePEPS,
O::MPOTensor,
Expand Down Expand Up @@ -37,7 +39,7 @@ function start_correlator(
return Vn, Vo
end

function end_correlator_numerator(
function end_correlator_right_numerator(
j::CartesianIndex{2},
V::AbstractTensorMap{T, S, 4, 1},
above::InfinitePEPS,
Expand All @@ -64,7 +66,7 @@ function end_correlator_numerator(
removeunit(O, 4)[dstring db; dt]
end

function end_correlator_denominator(
function end_correlator_right_denominator(
j::CartesianIndex{2}, V::AbstractTensorMap{T, S, 3, 1},
env::CTMRGEnv
) where {T, S}
Expand All @@ -78,3 +80,84 @@ function end_correlator_denominator(
E_east[χNE DEt DEb; χSE] *
C_southeast[χSE; χS]
end

# -------- For right-to-left correlator contraction --------

function start_correlator_right(
i::CartesianIndex{2},
below::InfinitePEPS,
O::MPOTensor,
above::InfinitePEPS,
env::CTMRGEnv,
)
r, c = Tuple(i)
E_north = edge(env, NORTH, r - 1, c)
E_east = edge(env, EAST, r, c + 1)
E_south = edge(env, SOUTH, r + 1, c)
C_northeast = corner(env, NORTHEAST, r - 1, c + 1)
C_southeast = corner(env, SOUTHEAST, r + 1, c + 1)
sandwich = (below[r, c], above[r, c])

@autoopt @tensor Vn[χNW DWtop DWbot; χSW] :=
E_south[χSSE Dstop Dsbot; χSW] *
E_east[χNEE Detop Debot; χSEE] *
E_north[χNW Dntop Dnbot; χNNE] *
C_northeast[χNNE; χNEE] *
C_southeast[χSEE; χSSE] *
conj(bra(sandwich)[d; Dnbot Debot Dsbot DWbot]) *
ket(sandwich)[d; Dntop Detop Dstop DWtop]

@autoopt @tensor Vo[χNW DWtop dstring DWbot; χSW] :=
E_south[χSSE Dstop Dsbot; χSW] *
E_east[χNEE Detop Debot; χSEE] *
E_north[χNW Dntop Dnbot; χNNE] *
C_northeast[χNNE; χNEE] *
C_southeast[χSEE; χSSE] *
conj(bra(sandwich)[d1; Dnbot Debot Dsbot DWbot]) *
removeunit(O, 1)[d1; d2 dstring] *
ket(sandwich)[d2; Dntop Detop Dstop DWtop]

return Vn, Vo
end

function end_correlator_left_numerator(
j::CartesianIndex{2},
V::AbstractTensorMap{T, S, 4, 1},
above::InfinitePEPS,
O::MPOTensor,
below::InfinitePEPS,
env::CTMRGEnv,
) where {T, S}
r, c = Tuple(j)
E_north = edge(env, NORTH, r - 1, c)
E_south = edge(env, SOUTH, r + 1, c)
E_west = edge(env, WEST, r, c - 1)
C_northwest = corner(env, NORTHWEST, r - 1, c - 1)
C_southwest = corner(env, SOUTHWEST, r + 1, c - 1)
sandwich = (above[r, c], below[r, c])

return @autoopt @tensor V[χNE DEt dstring DEb; χSE] *
E_south[χSE DSt DSb; χSW2] *
C_southwest[χSW2; χSW] *
E_west[χSW DWt DWb; χNW] *
C_northwest[χNW; χN] *
E_north[χN DNt DNb; χNE] *
conj(bra(sandwich)[db; DNb DEb DSb DWb]) *
ket(sandwich)[dt; DNt DEt DSt DWt] *
removeunit(O, 4)[dstring db; dt]
end

function end_correlator_left_denominator(
j::CartesianIndex{2}, V::AbstractTensorMap{T, S, 3, 1},
env::CTMRGEnv
) where {T, S}
r, c = Tuple(j)
C_northwest = corner(env, NORTHWEST, r - 1, c - 1)
E_west = edge(env, WEST, r, c - 1)
C_southwest = corner(env, SOUTHWEST, r + 1, c - 1)

return @autoopt @tensor V[χN DEt DEb; χS] *
C_southwest[χS; χSW] *
E_west[χSW DEt DEb; χNW] *
C_northwest[χNW; χN]
end
Loading
Loading