Skip to content
Merged
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
6 changes: 6 additions & 0 deletions ext/PEPSKitAdaptExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,10 @@ function Adapt.adapt_structure(to, x::PEPSKit.CTMRGEnv{C, T}) where {C, T}
return CTMRGEnv{eltype(C′), eltype(T′)}(C′, T′)
end

function Adapt.adapt_structure(to, x::PEPSKit.C4vCTMRGEnv{C, T}) where {C, T}
C′ = map(c -> adapt(to, c), x.corners)
T′ = map(t -> adapt(to, t), x.edges)
return C4vCTMRGEnv{eltype(C′), eltype(T′)}(C′, T′)
end

end
3 changes: 2 additions & 1 deletion src/PEPSKit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ include("operators/lattices/squarelattice.jl")
include("operators/models.jl")

include("environments/ctmrg_environments.jl")
include("environments/c4v_ctmrg_environments.jl")
include("environments/vumps_environments.jl")
include("environments/suweight.jl")
include("environments/bp_environments.jl")
Expand Down Expand Up @@ -176,7 +177,7 @@ include("algorithms/select_algorithm.jl")
using .Defaults: set_scheduler!
export set_scheduler!
export EighAdjoint, IterEigh, SVDAdjoint, IterSVD, OrthAdjoint, QRAdjoint
export CTMRGEnv, SequentialCTMRG, SimultaneousCTMRG
export C4vCTMRGEnv, CTMRGEnv, SequentialCTMRG, SimultaneousCTMRG
export initialize_ctmrg_environment,
RandomInitialization, ProductStateInitialization, ApplicationInitialization, IdentityInitialization
export corner, edge, setcorner!, setedge!
Expand Down
12 changes: 6 additions & 6 deletions src/algorithms/contractions/correlator/pepo_1layer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

function start_correlator_left(
i::CartesianIndex{2}, ρ::InfinitePEPO,
O::PFTensor, env::CTMRGEnv
O::PFTensor, env::AbstractCTMRGEnv
)
(size(ρ, 3) == 1) ||
throw(ArgumentError("The input PEPO ρ must have only one layer."))
Expand All @@ -29,7 +29,7 @@ end

function end_correlator_right_numerator(
j::CartesianIndex{2}, V::AbstractTensorMap{T, S, 3, 1},
ρ::InfinitePEPO, O::PFTensor, env::CTMRGEnv
ρ::InfinitePEPO, O::PFTensor, env::AbstractCTMRGEnv
) where {T, S}
(size(ρ, 3) == 1) ||
throw(ArgumentError("The input PEPO ρ must have only one layer."))
Expand All @@ -47,7 +47,7 @@ function end_correlator_right_numerator(
end

function end_correlator_right_denominator(
j::CartesianIndex{2}, V::AbstractTensorMap{T, S, 2, 1}, env::CTMRGEnv
j::CartesianIndex{2}, V::AbstractTensorMap{T, S, 2, 1}, env::AbstractCTMRGEnv
) where {T, S}
r, c = Tuple(j)
C_northeast = corner(env, NORTHEAST, r - 1, c + 1)
Expand All @@ -61,7 +61,7 @@ end

function start_correlator_right(
i::CartesianIndex{2}, ρ::InfinitePEPO,
O::PFTensor, env::CTMRGEnv
O::PFTensor, env::AbstractCTMRGEnv
)
(size(ρ, 3) == 1) ||
throw(ArgumentError("The input PEPO ρ must have only one layer."))
Expand All @@ -87,7 +87,7 @@ end

function end_correlator_left_numerator(
j::CartesianIndex{2}, V::AbstractTensorMap{T, S, 3, 1},
ρ::InfinitePEPO, O::PFTensor, env::CTMRGEnv
ρ::InfinitePEPO, O::PFTensor, env::AbstractCTMRGEnv
) where {T, S}
(size(ρ, 3) == 1) ||
throw(ArgumentError("The input PEPO ρ must have only one layer."))
Expand All @@ -106,7 +106,7 @@ function end_correlator_left_numerator(
end

function end_correlator_left_denominator(
j::CartesianIndex{2}, V::AbstractTensorMap{T, S, 2, 1}, env::CTMRGEnv
j::CartesianIndex{2}, V::AbstractTensorMap{T, S, 2, 1}, env::AbstractCTMRGEnv
) where {T, S}
r, c = Tuple(j)
C_northwest = corner(env, NORTHWEST, r - 1, c - 1)
Expand Down
8 changes: 4 additions & 4 deletions src/algorithms/contractions/correlator/pepo_purified.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function start_correlator_left(
below::InfinitePEPO,
O::PFTensor,
above::InfinitePEPO,
env::CTMRGEnv,
env::AbstractCTMRGEnv,
)
r, c = Tuple(i)
E_north = edge(env, NORTH, r - 1, c)
Expand Down Expand Up @@ -44,7 +44,7 @@ function end_correlator_right_numerator(
above::InfinitePEPO,
O::PFTensor,
below::InfinitePEPO,
env::CTMRGEnv,
env::AbstractCTMRGEnv,
) where {T, S}
r, c = Tuple(j)
E_north = edge(env, NORTH, r - 1, c)
Expand Down Expand Up @@ -73,7 +73,7 @@ function start_correlator_right(
below::InfinitePEPO,
O::PFTensor,
above::InfinitePEPO,
env::CTMRGEnv,
env::AbstractCTMRGEnv,
)
r, c = Tuple(i)
E_north = edge(env, NORTH, r - 1, c)
Expand Down Expand Up @@ -112,7 +112,7 @@ function end_correlator_left_numerator(
above::InfinitePEPO,
O::PFTensor,
below::InfinitePEPO,
env::CTMRGEnv,
env::AbstractCTMRGEnv,
) where {T, S}
r, c = Tuple(j)
E_north = edge(env, NORTH, r - 1, c)
Expand Down
12 changes: 6 additions & 6 deletions src/algorithms/contractions/correlator/peps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function start_correlator_left(
below::InfinitePEPS,
O::MPOTensor,
above::InfinitePEPS,
env::CTMRGEnv,
env::AbstractCTMRGEnv,
)
r, c = Tuple(i)
E_north = edge(env, NORTH, r - 1, c)
Expand Down Expand Up @@ -45,7 +45,7 @@ function end_correlator_right_numerator(
above::InfinitePEPS,
O::MPOTensor,
below::InfinitePEPS,
env::CTMRGEnv,
env::AbstractCTMRGEnv,
) where {T, S}
r, c = Tuple(j)
E_north = edge(env, NORTH, r - 1, c)
Expand All @@ -68,7 +68,7 @@ end

function end_correlator_right_denominator(
j::CartesianIndex{2}, V::AbstractTensorMap{T, S, 3, 1},
env::CTMRGEnv
env::AbstractCTMRGEnv
) where {T, S}
r, c = Tuple(j)
C_northeast = corner(env, NORTHEAST, r - 1, c + 1)
Expand All @@ -88,7 +88,7 @@ function start_correlator_right(
below::InfinitePEPS,
O::MPOTensor,
above::InfinitePEPS,
env::CTMRGEnv,
env::AbstractCTMRGEnv,
)
r, c = Tuple(i)
E_north = edge(env, NORTH, r - 1, c)
Expand Down Expand Up @@ -126,7 +126,7 @@ function end_correlator_left_numerator(
above::InfinitePEPS,
O::MPOTensor,
below::InfinitePEPS,
env::CTMRGEnv,
env::AbstractCTMRGEnv,
) where {T, S}
r, c = Tuple(j)
E_north = edge(env, NORTH, r - 1, c)
Expand All @@ -149,7 +149,7 @@ end

function end_correlator_left_denominator(
j::CartesianIndex{2}, V::AbstractTensorMap{T, S, 3, 1},
env::CTMRGEnv
env::AbstractCTMRGEnv
) where {T, S}
r, c = Tuple(j)
C_northwest = corner(env, NORTHWEST, r - 1, c - 1)
Expand Down
16 changes: 8 additions & 8 deletions src/algorithms/contractions/ctmrg/gaugefix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $(SIGNATURES)

Apply `fix_gauge_corner` to the northwest corner with appropriate row and column indices.
"""
function fix_gauge_northwest_corner((row, col), env::CTMRGEnv, signs)
function fix_gauge_northwest_corner((row, col), env::AbstractCTMRGEnv, signs)
return fix_gauge_corner(
corner(env, NORTHWEST, row, col),
signs[WEST, row, col],
Expand All @@ -41,7 +41,7 @@ $(SIGNATURES)

Apply `fix_gauge_corner` to the northeast corner with appropriate row and column indices.
"""
function fix_gauge_northeast_corner((row, col), env::CTMRGEnv, signs)
function fix_gauge_northeast_corner((row, col), env::AbstractCTMRGEnv, signs)
return fix_gauge_corner(
corner(env, NORTHEAST, row, col),
signs[NORTH, row, col],
Expand All @@ -54,7 +54,7 @@ $(SIGNATURES)

Apply `fix_gauge_corner` to the southeast corner with appropriate row and column indices.
"""
function fix_gauge_southeast_corner((row, col), env::CTMRGEnv, signs)
function fix_gauge_southeast_corner((row, col), env::AbstractCTMRGEnv, signs)
return fix_gauge_corner(
corner(env, SOUTHEAST, row, col),
signs[EAST, row, col],
Expand All @@ -67,7 +67,7 @@ $(SIGNATURES)

Apply `fix_gauge_corner` to the southwest corner with appropriate row and column indices.
"""
function fix_gauge_southwest_corner((row, col), env::CTMRGEnv, signs)
function fix_gauge_southwest_corner((row, col), env::AbstractCTMRGEnv, signs)
return fix_gauge_corner(
corner(env, SOUTHWEST, row, col),
signs[SOUTH, row, col],
Expand Down Expand Up @@ -111,7 +111,7 @@ $(SIGNATURES)

Apply `fix_gauge_edge` to the north edge with appropriate row and column indices.
"""
function fix_gauge_north_edge((row, col), env::CTMRGEnv, signs)
function fix_gauge_north_edge((row, col), env::AbstractCTMRGEnv, signs)
return fix_gauge_edge(
edge(env, NORTH, row, col), signs[NORTH, row, col], signs[NORTH, row, _next(col, end)],
)
Expand All @@ -122,7 +122,7 @@ $(SIGNATURES)

Apply `fix_gauge_edge` to the east edge with appropriate row and column indices.
"""
function fix_gauge_east_edge((row, col), env::CTMRGEnv, signs)
function fix_gauge_east_edge((row, col), env::AbstractCTMRGEnv, signs)
return fix_gauge_edge(
edge(env, EAST, row, col), signs[EAST, row, col], signs[EAST, _next(row, end), col]
)
Expand All @@ -133,7 +133,7 @@ $(SIGNATURES)

Apply `fix_gauge_edge` to the south edge with appropriate row and column indices.
"""
function fix_gauge_south_edge((row, col), env::CTMRGEnv, signs)
function fix_gauge_south_edge((row, col), env::AbstractCTMRGEnv, signs)
return fix_gauge_edge(
edge(env, SOUTH, row, col), signs[SOUTH, row, col], signs[SOUTH, row, _prev(col, end)],
)
Expand All @@ -144,7 +144,7 @@ $(SIGNATURES)

Apply `fix_gauge_edge` to the west edge with appropriate row and column indices.
"""
function fix_gauge_west_edge((row, col), env::CTMRGEnv, signs)
function fix_gauge_west_edge((row, col), env::AbstractCTMRGEnv, signs)
return fix_gauge_edge(
edge(env, WEST, row, col), signs[WEST, row, col], signs[WEST, _prev(row, end), col]
)
Expand Down
22 changes: 18 additions & 4 deletions src/algorithms/contractions/ctmrg/network_value.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ end
end

"""
_contract_site(ind::Tuple{Int,Int}, network::InfiniteSquareNetwork, env::CTMRGEnv)
_contract_site(ind::Tuple{Int,Int}, network::InfiniteSquareNetwork, env::AbstractCTMRGEnv)

Contract around a single site `ind` of a square network using a given CTMRG environment.
"""
Expand All @@ -88,6 +88,20 @@ function _contract_site(ind::Tuple{Int, Int}, network::InfiniteSquareNetwork, en
)
end

function _contract_site(ind::Tuple{Int, Int}, network::InfiniteSquareNetwork, env::C4vCTMRGEnv)
r, c = ind
@assert r == c == 1 lazy"only trivial unit cells are supported for C4v-CTMRG, ind ($ind) must be (1, 1)"
return _contract_site(
corner(env, NORTHWEST, r - 1, c - 1),
corner(env, NORTHEAST, r - 1, c + 1),
corner(env, SOUTHEAST, r + 1, c + 1),
corner(env, SOUTHWEST, r + 1, c - 1),
edge(env, NORTH, r - 1, c), edge(env, EAST, r, c + 1),
edge(env, SOUTH, r + 1, c), edge(env, WEST, r, c - 1),
Comment thread
kshyatt marked this conversation as resolved.
network[r, c],
)
end

## Normalization contractions
function _contract_corners(
C_northwest::CTMRGCornerTensor, C_northeast::CTMRGCornerTensor,
Expand All @@ -103,7 +117,7 @@ end
Contract all corners around the south-east at position `ind` of the CTMRG
environment `env`.
"""
function _contract_corners(ind::Tuple{Int, Int}, env::CTMRGEnv)
function _contract_corners(ind::Tuple{Int, Int}, env::AbstractCTMRGEnv)
r, c = ind
return _contract_corners(
corner(env, NORTHWEST, r - 1, c - 1),
Expand Down Expand Up @@ -145,7 +159,7 @@ end
Contract the vertical edges and corners around the east edge at position `ind` of the
CTMRG environment `env`.
"""
function _contract_vertical_edges(ind::Tuple{Int, Int}, env::CTMRGEnv)
function _contract_vertical_edges(ind::Tuple{Int, Int}, env::AbstractCTMRGEnv)
r, c = ind
return _contract_vertical_edges(
corner(env, NORTHWEST, r - 1, c - 1),
Expand Down Expand Up @@ -188,7 +202,7 @@ end
Contract the horizontal edges and corners around the south edge at position `ind` of the
CTMRG environment `env`.
"""
function _contract_horizontal_edges(ind::Tuple{Int, Int}, env::CTMRGEnv)
function _contract_horizontal_edges(ind::Tuple{Int, Int}, env::AbstractCTMRGEnv)
r, c = ind
return _contract_horizontal_edges(
corner(env, NORTHWEST, r - 1, c - 1),
Expand Down
4 changes: 2 additions & 2 deletions src/algorithms/contractions/ctmrg/renormalize_corner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ Apply left projector to southwest corner and south edge.
C -- E --out
```
"""
function renormalize_southwest_corner((row, col), env::CTMRGEnv, projectors)
function renormalize_southwest_corner((row, col), env::AbstractCTMRGEnv, projectors)
C_southwest = corner(env, SOUTHWEST, row, col - 1)
E_south = edge(env, SOUTH, row, col)
P_left = projectors[1][row]
Expand Down Expand Up @@ -448,7 +448,7 @@ Apply right projector to northwest corner and north edge.
out
```
"""
function renormalize_northwest_corner((row, col), env::CTMRGEnv, projectors)
function renormalize_northwest_corner((row, col), env::AbstractCTMRGEnv, projectors)
C_northwest = corner(env, NORTHWEST, row, col - 1)
E_north = edge(env, NORTH, row, col)
P_right = projectors[2][_next(row, end)]
Expand Down
10 changes: 5 additions & 5 deletions src/algorithms/contractions/ctmrg/renormalize_edge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ environment tensors.
```
"""
function renormalize_north_edge(
(row, col), env::CTMRGEnv, P_left, P_right, network::InfiniteSquareNetwork
(row, col), env::AbstractCTMRGEnv, P_left, P_right, network::InfiniteSquareNetwork
)
return renormalize_north_edge(
edge(env, NORTH, row - 1, col),
Expand Down Expand Up @@ -87,7 +87,7 @@ environment tensors.
```
"""
function renormalize_east_edge(
(row, col), env::CTMRGEnv, P_left, P_right, network::InfiniteSquareNetwork
(row, col), env::AbstractCTMRGEnv, P_left, P_right, network::InfiniteSquareNetwork
)
return renormalize_east_edge(
edge(env, EAST, row, col + 1),
Expand Down Expand Up @@ -152,7 +152,7 @@ environment tensors.
```
"""
function renormalize_south_edge(
(row, col), env::CTMRGEnv, P_left, P_right, network::InfiniteSquareNetwork
(row, col), env::AbstractCTMRGEnv, P_left, P_right, network::InfiniteSquareNetwork
)
return renormalize_south_edge(
edge(env, SOUTH, row + 1, col),
Expand Down Expand Up @@ -222,7 +222,7 @@ environment tensors.
```
"""
function renormalize_west_edge( # For simultaneous CTMRG scheme
(row, col), env::CTMRGEnv, P_left, P_right, network::InfiniteSquareNetwork,
(row, col), env::AbstractCTMRGEnv, P_left, P_right, network::InfiniteSquareNetwork,
)
return renormalize_west_edge(
edge(env, WEST, row, col - 1),
Expand All @@ -232,7 +232,7 @@ function renormalize_west_edge( # For simultaneous CTMRG scheme
)
end
function renormalize_west_edge( # For sequential CTMRG scheme
(row, col), env::CTMRGEnv, projectors, network::InfiniteSquareNetwork,
(row, col), env::AbstractCTMRGEnv, projectors, network::InfiniteSquareNetwork,
)
return renormalize_west_edge(
edge(env, WEST, row, col - 1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Keep contraction order but try to optimize intermediate permutations:
# EE_SWA is largest object so keep largest legs to the front there
function reduced_densitymatrix1x1(
inds::CartesianIndex{2}, ket::InfinitePEPS, bra::InfinitePEPS, env::CTMRGEnv
inds::CartesianIndex{2}, ket::InfinitePEPS, bra::InfinitePEPS, env::AbstractCTMRGEnv
)
row, col = Tuple(inds)

Expand Down Expand Up @@ -45,7 +45,7 @@ end
# Special case 2x1 density matrix:
# Keep contraction order but try to optimize intermediate permutations:
function reduced_densitymatrix2x1(
ind::CartesianIndex, ket::InfinitePEPS, bra::InfinitePEPS, env::CTMRGEnv
ind::CartesianIndex, ket::InfinitePEPS, bra::InfinitePEPS, env::AbstractCTMRGEnv
)
row, col = Tuple(ind)

Expand Down Expand Up @@ -95,7 +95,7 @@ function reduced_densitymatrix2x1(
end

function reduced_densitymatrix1x2(
ind::CartesianIndex, ket::InfinitePEPS, bra::InfinitePEPS, env::CTMRGEnv
ind::CartesianIndex, ket::InfinitePEPS, bra::InfinitePEPS, env::AbstractCTMRGEnv
)
row, col = Tuple(ind)

Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/contractions/local_patch/network_expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ boundary_contraction_expr(env::Type, rowrange, colrange) = throw(
)

function boundary_contraction_expr(
::Type{<:CTMRGEnv{C, T}}, rowrange, colrange
::Type{<:AbstractCTMRGEnv{C, T}}, rowrange, colrange
) where {C, T}
# the edges carry one virtual leg per layer of the sandwich, on top of the two environment
# indices threading the ring, so the height follows from the edge tensor type
Expand Down
Loading
Loading