Skip to content

Commit 984a2d3

Browse files
committed
Merge branch 'lb/contractible_networks' into lb/pepo_ctmrg
2 parents 845db60 + f923875 commit 984a2d3

File tree

5 files changed

+93
-101
lines changed

5 files changed

+93
-101
lines changed

src/algorithms/contractions/ctmrg_contractions.jl

Lines changed: 52 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,10 @@ function enlarge_northwest_corner(
3737
E_west::CTMRG_PF_EdgeTensor,
3838
C_northwest::CTMRGCornerTensor,
3939
E_north::CTMRG_PF_EdgeTensor,
40-
A::PFSandwich,
40+
A::PFTensor,
4141
)
4242
return @autoopt @tensor corner[χ_S D_S; χ_E D_E] :=
43-
E_west[χ_S D1; χ1] *
44-
C_northwest[χ1; χ2] *
45-
E_north[χ2 D2; χ_E] *
46-
tensor(A)[D1 D_S; D2 D_E]
43+
E_west[χ_S D1; χ1] * C_northwest[χ1; χ2] * E_north[χ2 D2; χ_E] * A[D1 D_S; D2 D_E]
4744
end
4845

4946
"""
@@ -77,13 +74,10 @@ function enlarge_northeast_corner(
7774
E_north::CTMRG_PF_EdgeTensor,
7875
C_northeast::CTMRGCornerTensor,
7976
E_east::CTMRG_PF_EdgeTensor,
80-
A::PFSandwich,
77+
A::PFTensor,
8178
)
8279
return @autoopt @tensor corner[χ_W D_W; χ_S D_S] :=
83-
E_north[χ_W D1; χ1] *
84-
C_northeast[χ1; χ2] *
85-
E_east[χ2 D2; χ_S] *
86-
tensor(A)[D_W D_S; D1 D2]
80+
E_north[χ_W D1; χ1] * C_northeast[χ1; χ2] * E_east[χ2 D2; χ_S] * A[D_W D_S; D1 D2]
8781
end
8882

8983
"""
@@ -117,13 +111,10 @@ function enlarge_southeast_corner(
117111
E_east::CTMRG_PF_EdgeTensor,
118112
C_southeast::CTMRGCornerTensor,
119113
E_south::CTMRG_PF_EdgeTensor,
120-
A::PFSandwich,
114+
A::PFTensor,
121115
)
122116
return @autoopt @tensor corner[χ_N D_N; χ_W D_W] :=
123-
E_east[χ_N D1; χ1] *
124-
C_southeast[χ1; χ2] *
125-
E_south[χ2 D2; χ_W] *
126-
tensor(A)[D_W D2; D_N D1]
117+
E_east[χ_N D1; χ1] * C_southeast[χ1; χ2] * E_south[χ2 D2; χ_W] * A[D_W D2; D_N D1]
127118
end
128119

129120
"""
@@ -157,13 +148,10 @@ function enlarge_southwest_corner(
157148
E_south::CTMRG_PF_EdgeTensor,
158149
C_southwest::CTMRGCornerTensor,
159150
E_west::CTMRG_PF_EdgeTensor,
160-
A::PFSandwich,
151+
A::PFTensor,
161152
)
162153
return @autoopt @tensor corner[χ_E D_E; χ_N D_N] :=
163-
E_south[χ_E D1; χ1] *
164-
C_southwest[χ1; χ2] *
165-
E_west[χ2 D2; χ_N] *
166-
tensor(A)[D2 D1; D_N D_E]
154+
E_south[χ_E D1; χ1] * C_southwest[χ1; χ2] * E_west[χ2 D2; χ_N] * A[D2 D1; D_N D_E]
167155
end
168156

169157
# Projector contractions
@@ -191,12 +179,12 @@ function left_projector(E_1, C, E_2, V, isqS, A::PEPSSandwich)
191179
conj(V[χ4; χ3 D5 D6]) *
192180
isqS[χ4; χ_out]
193181
end
194-
function left_projector(E_1, C, E_2, V, isqS, A::PFSandwich)
182+
function left_projector(E_1, C, E_2, V, isqS, A::PFTensor)
195183
return @autoopt @tensor P_left[χ_in D_in; χ_out] :=
196184
E_1[χ_in D1; χ1] *
197185
C[χ1; χ2] *
198186
E_2[χ2 D2; χ3] *
199-
tensor(A)[D1 D_in; D2 D3] *
187+
A[D1 D_in; D2 D3] *
200188
conj(V[χ4; χ3 D3]) *
201189
isqS[χ4; χ_out]
202190
end
@@ -223,11 +211,11 @@ function right_projector(E_1, C, E_2, U, isqS, A::PEPSSandwich)
223211
C[χ3; χ4] *
224212
E_1[χ4 D5 D6; χ_out]
225213
end
226-
function right_projector(E_1, C, E_2, U, isqS, A::PFSandwich)
214+
function right_projector(E_1, C, E_2, U, isqS, A::PFTensor)
227215
return @autoopt @tensor P_right[χ_in; χ_out D_out] :=
228216
isqS[χ_in; χ1] *
229217
conj(U[χ1; χ2 D1]) *
230-
tensor(A)[D1 D_out; D2 D3] *
218+
A[D1 D_out; D2 D3] *
231219
E_2[χ2 D2; χ3] *
232220
C[χ3; χ4] *
233221
E_1[χ4 D3; χ_out]
@@ -367,41 +355,41 @@ function half_infinite_environment(
367355
end
368356
function half_infinite_environment(
369357
C_1, C_2, E_1, E_2, E_3, E_4, A_1::P, A_2::P
370-
) where {P<:PFSandwich}
358+
) where {P<:PFTensor}
371359
return @autoopt @tensor env[χ_in D_in; χ_out D_out] :=
372360
E_1[χ_in D1; χ1] *
373361
C_1[χ1; χ2] *
374362
E_2[χ2 D3; χ3] *
375-
tensor(A_1)[D1 D_in; D3 D9] *
376-
tensor(A_2)[D9 D_out; D5 D7] *
363+
A_1[D1 D_in; D3 D9] *
364+
A_2[D9 D_out; D5 D7] *
377365
E_3[χ3 D5; χ4] *
378366
C_2[χ4; χ5] *
379367
E_4[χ5 D7; χ_out]
380368
end
381369
function half_infinite_environment(
382370
C_1, C_2, E_1, E_2, E_3, E_4, x::AbstractTensor{T,S,2}, A_1::P, A::P
383-
) where {T,S,P<:PFSandwich}
371+
) where {T,S,P<:PFTensor}
384372
return @autoopt @tensor env_x[χ_in D_in] :=
385373
E_1[χ_in D1; χ1] *
386374
C_1[χ1; χ2] *
387375
E_2[χ2 D3; χ3] *
388-
tensor(A_1)[D1 D_in; D3 D9] *
389-
tensor(A_2)[D9 D11; D5 D7] *
376+
A_1[D1 D_in; D3 D9] *
377+
A_2[D9 D11; D5 D7] *
390378
E_3[χ3 D5; χ4] *
391379
C_2[χ4; χ5] *
392380
E_4[χ5 D7; χ6] *
393381
x[χ6 D11]
394382
end
395383
function half_infinite_environment(
396384
x::AbstractTensor{T,S,2}, C_1, C_2, E_1, E_2, E_3, E_4, A_1::P, A_2::P
397-
) where {T,S,P<:PFSandwich}
385+
) where {T,S,P<:PFTensor}
398386
return @autoopt @tensor env_x[χ_in D_in] :=
399387
x[χ1 D1 D2] *
400388
conj(E_1[χ1 D3; χ2]) *
401389
conj(C_1[χ2; χ3]) *
402390
conj(E_2[χ3 D5; χ4]) *
403-
conj(tensor(A_1)[D3 D1; D5 D11]) *
404-
conj(tensor(A_2)[D11 D_in; D7 D9]) *
391+
conj(A_1[D3 D1; D5 D11]) *
392+
conj(A_2[D11 D_in; D7 D9]) *
405393
conj(E_3[χ4 D7; χ5]) *
406394
conj(C_2[χ5; χ6]) *
407395
conj(E_4[χ6 D9; χ_in])
@@ -666,21 +654,21 @@ function full_infinite_environment(
666654
A_2::P,
667655
A_3::P,
668656
A_4::P,
669-
) where {P<:PFSandwich}
657+
) where {P<:PFTensor}
670658
return @autoopt @tensor env[χ_in D_in; χ_out D_out] :=
671659
E_1[χ_in D1; χ1] *
672660
C_1[χ1; χ2] *
673661
E_2[χ2 D3; χ3] *
674-
tensor(A_1)[D1 D_in; D3 D11] *
675-
tensor(A_2)[D11 D9; D5 D7] *
662+
A_1[D1 D_in; D3 D11] *
663+
A_2[D11 D9; D5 D7] *
676664
E_3[χ3 D5; χ4] *
677665
C_2[χ4; χ5] *
678666
E_4[χ5 D7; χ6] *
679667
E_5[χ6 D13; χ7] *
680668
C_3[χ7; χ8] *
681669
E_6[χ8 D15; χ9] *
682-
tensor(A_3)[D17 D15; D9 D13] *
683-
tensor(A_4)[D21 D19; D_out D17] *
670+
A_3[D17 D15; D9 D13] *
671+
A_4[D21 D19; D_out D17] *
684672
E_7[χ9 D19; χ10] *
685673
C_4[χ10; χ11] *
686674
E_8[χ11 D21; χ_out]
@@ -703,21 +691,21 @@ function full_infinite_environment(
703691
A_2::P,
704692
A_3::P,
705693
A_4::P,
706-
) where {T,S,P<:PFSandwich}
694+
) where {T,S,P<:PFTensor}
707695
return @autoopt @tensor env_x[χ_in D_in] :=
708696
E_1[χ_in D1; χ1] *
709697
C_1[χ1; χ2] *
710698
E_2[χ2 D3; χ3] *
711-
tensor(A_1)[D1 D_in; D3 D11] *
712-
tensor(A_2)[D11 D9; D5 D7] *
699+
A_1[D1 D_in; D3 D11] *
700+
A_2[D11 D9; D5 D7] *
713701
E_3[χ3 D5; χ4] *
714702
C_2[χ4; χ5] *
715703
E_4[χ5 D7; χ6] *
716704
E_5[χ6 D13; χ7] *
717705
C_3[χ7; χ8] *
718706
E_6[χ8 D15; χ9] *
719-
tensor(A_3)[D17 D15; D9 D13] *
720-
tensor(A_4)[D21 D19; D_x D17] *
707+
A_3[D17 D15; D9 D13] *
708+
A_4[D21 D19; D_x D17] *
721709
E_7[χ9 D19; χ10] *
722710
C_4[χ10; χ11] *
723711
E_8[χ11 D21; χ_x] *
@@ -741,22 +729,22 @@ function full_infinite_environment(
741729
A_2::P,
742730
A_3::P,
743731
A_4::P,
744-
) where {T,S,P<:PFSandwich}
732+
) where {T,S,P<:PFTensor}
745733
return @autoopt @tensor x_env[χ_in D_in] :=
746734
x[χ_x D_x] *
747735
E_1[χ_x D1; χ1] *
748736
C_1[χ1; χ2] *
749737
E_2[χ2 D3; χ3] *
750-
tensor(A_1)[D1 D_x; D3 D11] *
751-
tensor(A_2)[D11 D9; D5 D7] *
738+
A_1[D1 D_x; D3 D11] *
739+
A_2[D11 D9; D5 D7] *
752740
E_3[χ3 D5; χ4] *
753741
C_2[χ4; χ5] *
754742
E_4[χ5 D7; χ6] *
755743
E_5[χ6 D13; χ7] *
756744
C_3[χ7; χ8] *
757745
E_6[χ8 D15; χ9] *
758-
tensor(A_3)[D17 D15; D9 D13] *
759-
tensor(A_4)[D21 D19; D_in D17] *
746+
A_3[D17 D15; D9 D13] *
747+
A_4[D21 D19; D_in D17] *
760748
E_7[χ9 D19; χ10] *
761749
C_4[χ10; χ11] *
762750
E_8[χ11 D21; χ_in]
@@ -849,14 +837,14 @@ function renormalize_northwest_corner(
849837
P_left[χ4 D7 D8; χ_out]
850838
end
851839
function renormalize_northwest_corner(
852-
E_west, C_northwest, E_north, P_left, P_right, A::PFSandwich
840+
E_west, C_northwest, E_north, P_left, P_right, A::PFTensor
853841
)
854842
return @autoopt @tensor corner[χ_in; χ_out] :=
855843
P_right[χ_in; χ1 D1] *
856844
E_west[χ1 D3; χ2] *
857845
C_northwest[χ2; χ3] *
858846
E_north[χ3 D5; χ4] *
859-
tensor(A)[D3 D1; D5 D7] *
847+
A[D3 D1; D5 D7] *
860848
P_left[χ4 D7; χ_out]
861849
end
862850

@@ -904,14 +892,14 @@ function renormalize_northeast_corner(
904892
P_left[χ4 D7 D8; χ_out]
905893
end
906894
function renormalize_northeast_corner(
907-
E_north, C_northeast, E_east, P_left, P_right, A::PFSandwich
895+
E_north, C_northeast, E_east, P_left, P_right, A::PFTensor
908896
)
909897
return @autoopt @tensor corner[χ_in; χ_out] :=
910898
P_right[χ_in; χ1 D1] *
911899
E_north[χ1 D3; χ2] *
912900
C_northeast[χ2; χ3] *
913901
E_east[χ3 D5; χ4] *
914-
tensor(A)[D1 D7; D3 D5] *
902+
A[D1 D7; D3 D5] *
915903
P_left[χ4 D7; χ_out]
916904
end
917905

@@ -957,14 +945,14 @@ function renormalize_southeast_corner(
957945
P_left[χ4 D7 D8; χ_out]
958946
end
959947
function renormalize_southeast_corner(
960-
E_east, C_southeast, E_south, P_left, P_right, A::PFSandwich
948+
E_east, C_southeast, E_south, P_left, P_right, A::PFTensor
961949
)
962950
return @autoopt @tensor corner[χ_in; χ_out] :=
963951
P_right[χ_in; χ1 D1] *
964952
E_east[χ1 D3; χ2] *
965953
C_southeast[χ2; χ3] *
966954
E_south[χ3 D5; χ4] *
967-
tensor(A)[D7 D5; D1 D3] *
955+
A[D7 D5; D1 D3] *
968956
P_left[χ4 D7; χ_out]
969957
end
970958

@@ -1010,14 +998,14 @@ function renormalize_southwest_corner(
1010998
P_left[χ4 D7 D8; χ_out]
1011999
end
10121000
function renormalize_southwest_corner(
1013-
E_south, C_southwest, E_west, P_left, P_right, A::PFSandwich
1001+
E_south, C_southwest, E_west, P_left, P_right, A::PFTensor
10141002
)
10151003
return @autoopt @tensor corner[χ_in; χ_out] :=
10161004
P_right[χ_in; χ1 D1] *
10171005
E_south[χ1 D3; χ2] *
10181006
C_southwest[χ2; χ3] *
10191007
E_west[χ3 D5; χ4] *
1020-
tensor(A)[D5 D3; D7 D1] *
1008+
A[D5 D3; D7 D1] *
10211009
P_left[χ4 D7; χ_out]
10221010
end
10231011

@@ -1130,14 +1118,9 @@ function renormalize_north_edge(
11301118
P_right[χ_W; χ1 D5 D6]
11311119
return out
11321120
end
1133-
function renormalize_north_edge(
1134-
E_north::CTMRG_PF_EdgeTensor, P_left, P_right, A::PFSandwich
1135-
)
1121+
function renormalize_north_edge(E_north::CTMRG_PF_EdgeTensor, P_left, P_right, A::PFTensor)
11361122
return @autoopt @tensor edge[χ_W D_S; χ_E] :=
1137-
E_north[χ1 D1; χ2] *
1138-
tensor(A)[D5 D_S; D1 D3] *
1139-
P_left[χ2 D3; χ_E] *
1140-
P_right[χ_W; χ1 D5]
1123+
E_north[χ1 D1; χ2] * A[D5 D_S; D1 D3] * P_left[χ2 D3; χ_E] * P_right[χ_W; χ1 D5]
11411124
end
11421125

11431126
"""
@@ -1177,12 +1160,9 @@ function renormalize_east_edge(
11771160
P_bottom[χ2 D3 D4; χ_S] *
11781161
P_top[χ_N; χ1 D5 D6]
11791162
end
1180-
function renormalize_east_edge(E_east::CTMRG_PF_EdgeTensor, P_bottom, P_top, A::PFSandwich)
1163+
function renormalize_east_edge(E_east::CTMRG_PF_EdgeTensor, P_bottom, P_top, A::PFTensor)
11811164
return @autoopt @tensor edge[χ_N D_W; χ_S] :=
1182-
E_east[χ1 D1; χ2] *
1183-
tensor(A)[D_W D3; D5 D1] *
1184-
P_bottom[χ2 D3; χ_S] *
1185-
P_top[χ_N; χ1 D5]
1165+
E_east[χ1 D1; χ2] * A[D_W D3; D5 D1] * P_bottom[χ2 D3; χ_S] * P_top[χ_N; χ1 D5]
11861166
end
11871167

11881168
"""
@@ -1220,14 +1200,9 @@ function renormalize_south_edge(
12201200
P_left[χ2 D3 D4; χ_W] *
12211201
P_right[χ_E; χ1 D5 D6]
12221202
end
1223-
function renormalize_south_edge(
1224-
E_south::CTMRG_PF_EdgeTensor, P_left, P_right, A::PFSandwich
1225-
)
1203+
function renormalize_south_edge(E_south::CTMRG_PF_EdgeTensor, P_left, P_right, A::PFTensor)
12261204
return @autoopt @tensor edge[χ_E D_N; χ_W] :=
1227-
E_south[χ1 D1; χ2] *
1228-
tensor(A)[D3 D1; D_N D5] *
1229-
P_left[χ2 D3; χ_W] *
1230-
P_right[χ_E; χ1 D5]
1205+
E_south[χ1 D1; χ2] * A[D3 D1; D_N D5] * P_left[χ2 D3; χ_W] * P_right[χ_E; χ1 D5]
12311206
end
12321207

12331208
"""
@@ -1284,12 +1259,9 @@ function renormalize_west_edge(
12841259
P_bottom[χ2 D3 D4; χ_N] *
12851260
P_top[χ_S; χ1 D5 D6]
12861261
end
1287-
function renormalize_west_edge(E_west::CTMRG_PF_EdgeTensor, P_bottom, P_top, A::PFSandwich)
1262+
function renormalize_west_edge(E_west::CTMRG_PF_EdgeTensor, P_bottom, P_top, A::PFTensor)
12881263
return @autoopt @tensor edge[χ_S D_E; χ_N] :=
1289-
E_west[χ1 D1; χ2] *
1290-
tensor(A)[D1 D5; D3 D_E] *
1291-
P_bottom[χ2 D3; χ_N] *
1292-
P_top[χ_S; χ1 D5]
1264+
E_west[χ1 D1; χ2] * A[D1 D5; D3 D_E] * P_bottom[χ2 D3; χ_N] * P_top[χ_S; χ1 D5]
12931265
end
12941266

12951267
# Gauge fixing contractions

src/algorithms/toolbox.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function _contract_site(
121121
E_east::CTMRG_PF_EdgeTensor,
122122
E_south::CTMRG_PF_EdgeTensor,
123123
E_west::CTMRG_PF_EdgeTensor,
124-
O::PFSandwich,
124+
O::PFTensor,
125125
)
126126
return @autoopt @tensor E_west[χ_WSW D_W; χ_WNW] *
127127
C_northwest[χ_WNW; χ_NNW] *
@@ -131,7 +131,7 @@ function _contract_site(
131131
C_southeast[χ_ESE; χ_SSE] *
132132
E_south[χ_SSE D_S; χ_SSW] *
133133
C_southwest[χ_SSW; χ_WSW] *
134-
tensor(O)[D_W D_S; D_N D_E]
134+
O[D_W D_S; D_N D_E]
135135
end
136136

137137
"""

0 commit comments

Comments
 (0)