Skip to content

Commit 685e429

Browse files
committed
fix contractinos
1 parent 94db950 commit 685e429

2 files changed

Lines changed: 35 additions & 15 deletions

File tree

src/algorithms/contractions/ctmrg_contractions.jl

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -947,18 +947,28 @@ environment tensors.
947947
```
948948
"""
949949
function renormalize_north_edge(
950-
(row, col), env::CTMRGEnv, P_left, P_right, network::InfiniteSquareNetwork
950+
(row, col), env::CTMRGEnv, P_right, P_left, network::InfiniteSquareNetwork
951951
)
952952
return renormalize_north_edge(
953953
env.edges[NORTH, _prev(row, end), col],
954-
P_left[NORTH, row, col],
955-
P_right[NORTH, row, _prev(col, end)],
954+
P_right[NORTH, row, col],
955+
P_left[NORTH, row, _prev(col, end)],
956956
network[row, col], # so here it's fine
957957
)
958958
end
959-
function renormalize_north_edge(E_north, P_left, P_right, A)
959+
function renormalize_north_edge(E_north, P_right, P_left, A)
960960
A_west = _rotl90_localsandwich(A)
961-
return renormalize_west_edge(E_north, P_left, P_right, A_west)
961+
return renormalize_west_edge(E_north, P_right, P_left, A_west)
962+
end
963+
# specialize PartitionFunction to avoid permute(A)
964+
function renormalize_north_edge(E_north::CTMRG_PF_EdgeTensor, P_right, P_left, A::PFTensor)
965+
return @tensor begin
966+
temp = permute(E_north, ((2, 1), (3,))) # impose D_N as 1st leg
967+
PE[D_N D_E; χNW χ_E] := temp[D_N χNW; χNE] * P_right[χNE D_E; χ_E]
968+
PEA[D_W χNW; D_S χ_E] := A[D_W D_S; D_N D_E] * PE[D_N D_E; χNW χ_E]
969+
P_leftp = permute(P_left, ((1,), (3, 2)))
970+
edge[χ_W D_S; χ_E] := P_leftp[χ_W; D_W χNW] * PEA[D_W χNW; D_S χ_E]
971+
end
962972
end
963973

964974
"""
@@ -992,6 +1002,15 @@ function renormalize_east_edge(E_east, P_bottom, P_top, A)
9921002
A_west = _rot180_localsandwich(A)
9931003
return renormalize_west_edge(E_east, P_bottom, P_top, A_west)
9941004
end
1005+
# specialize PartitionFunction to avoid permute(A)
1006+
function renormalize_east_edge(E_east::CTMRG_PF_EdgeTensor, P_bottom, P_top, A::PFTensor)
1007+
return @tensor begin
1008+
temp = permute(P_top, ((3, 1), (2,))) # impose D_N as 1st leg
1009+
PE[D_N D_E; χN χSE] := temp[D_N χN; χNE] * E_east[χNE D_E; χSE]
1010+
PEA[D_W χN; χSE D_S] := A[D_W D_S; D_N D_E] * PE[D_N D_E; χN χSE]
1011+
edge[χ_N D_W; χ_S] := PEA[D_W χ_N; χSE D_S] * P_bottom[χSE D_S; χ_S]
1012+
end
1013+
end
9951014

9961015
"""
9971016
renormalize_south_edge((row, col), env, P_left, P_right, network::InfiniteSquareNetwork{P})
@@ -1052,12 +1071,12 @@ environment tensors.
10521071
```
10531072
"""
10541073
function renormalize_west_edge( # For simultaneous CTMRG scheme
1055-
(row, col), env::CTMRGEnv, P_bottom::Array{Pb, 3}, P_top::Array{Pt, 3}, network::InfiniteSquareNetwork,
1074+
(row, col), env::CTMRGEnv, P_top::Array{Pt, 3}, P_bottom::Array{Pb, 3}, network::InfiniteSquareNetwork,
10561075
) where {Pt, Pb}
10571076
return renormalize_west_edge(
10581077
env.edges[WEST, row, _prev(col, end)],
1059-
P_bottom[WEST, row, col],
1060-
P_top[WEST, _next(row, end), col],
1078+
P_top[WEST, row, col],
1079+
P_bottom[WEST, _next(row, end), col],
10611080
network[row, col],
10621081
)
10631082
end
@@ -1072,27 +1091,27 @@ function renormalize_west_edge( # For sequential CTMRG scheme
10721091
)
10731092
end
10741093
function renormalize_west_edge(
1075-
E_west::CTMRG_PEPS_EdgeTensor, P_bottom, P_top, A::PEPSSandwich
1094+
E_west::CTMRG_PEPS_EdgeTensor, P_top, P_bottom, A::PEPSSandwich
10761095
)
1077-
# starting with P_top to save one permute in the end
1096+
# starting with P_bottom to save one permute in the end
10781097
return @tensor begin
10791098
# already putting χE in front here to make next permute cheaper
1080-
PE[χS χNW DSb DWb; DSt DWt] := P_top[χS; χSW DSt DSb] * E_west[χSW DWt DWb; χNW]
1099+
PE[χS χNW DSb DWb; DSt DWt] := P_bottom[χS; χSW DSt DSb] * E_west[χSW DWt DWb; χNW]
10811100

10821101
PEket[χS χNW DNt DEt; DSb DWb d] :=
10831102
PE[χS χNW DSb DWb; DSt DWt] * ket(A)[d; DNt DEt DSt DWt]
10841103

10851104
corner[χS DEt DEb; χNW DNt DNb] :=
10861105
PEket[χS χNW DNt DEt; DSb DWb d] * conj(bra(A)[d; DNb DEb DSb DWb])
10871106

1088-
edge[χS DEt DEb; χN] := corner[χS DEt DEb; χNW DNt DNb] * P_bottom[χNW DNt DNb; χN]
1107+
edge[χS DEt DEb; χN] := corner[χS DEt DEb; χNW DNt DNb] * P_top[χNW DNt DNb; χN]
10891108
end
10901109
end
1091-
function renormalize_west_edge(E_west::CTMRG_PF_EdgeTensor, P_bottom, P_top, A::PFTensor)
1110+
function renormalize_west_edge(E_west::CTMRG_PF_EdgeTensor, P_top, P_bottom, A::PFTensor)
10921111
return @tensor begin
1093-
PE[χ_S χNW; D_W D_S] := P_top[χ_S; χSW D_S] * E_west[χSW D_W; χNW]
1112+
PE[χ_S χNW; D_W D_S] := P_bottom[χ_S; χSW D_S] * E_west[χSW D_W; χNW]
10941113
PEA[χ_S D_E; χNW D_N] := PE[χ_S χNW; D_W D_S] * A[D_W D_S; D_N D_E]
1095-
edge[χ_S D_E; χ_N] := PEA[χ_S D_E; χNW D_N] * P_bottom[χNW D_N; χ_N]
1114+
edge[χ_S D_E; χ_N] := PEA[χ_S D_E; χNW D_N] * P_top[χNW D_N; χ_N]
10961115
end
10971116
end
10981117

src/algorithms/ctmrg/simultaneous.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ function ctmrg_iteration(network, env::CTMRGEnv, alg::SimultaneousCTMRG)
4747
return TensorMap(EnlargedCorner(network, env, idx))
4848
end # expand environment
4949
projectors, info = simultaneous_projectors(enlarged_corners, env, alg.projector_alg) # compute projectors on all coordinates
50+
@show typeof(projectors)
5051
env′ = renormalize_simultaneously(enlarged_corners, projectors, network, env) # renormalize enlarged corners
5152
return env′, info
5253
end

0 commit comments

Comments
 (0)