Skip to content

Commit 71e6e31

Browse files
committed
Merge remote-tracking branch 'upstream/master' into bondenv-ntu
2 parents f9d029a + 2171fb1 commit 71e6e31

5 files changed

Lines changed: 133 additions & 6 deletions

File tree

src/algorithms/contractions/ctmrg/renormalize_corner.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ Alternatively, provide the constituent tensors and perform the complete contract
336336
```
337337
"""
338338
function renormalize_southwest_corner((row, col), enlarged_env, P_left, P_right)
339-
return renormalize_corner(
339+
return renormalize_southwest_corner(
340340
enlarged_env[SOUTHWEST, row, col],
341341
P_left[WEST, row, col],
342342
P_right[SOUTH, row, _next(col, end)],
@@ -345,7 +345,7 @@ end
345345
function renormalize_southwest_corner(
346346
quadrant::AbstractTensorMap{T, S, N, N}, P_left, P_right
347347
) where {T, S, N}
348-
return renormalize_southwest_corner(quadrant, P_left, P_right)
348+
return renormalize_corner(quadrant, P_left, P_right)
349349
end
350350
function renormalize_southwest_corner(
351351
E_south, C_southwest, E_west, P_left, P_right, A::PEPSSandwich

test/ctmrg/contractions.jl

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
using Test
2+
using Random
3+
using PEPSKit
4+
using TensorKit
5+
6+
using PEPSKit: eachcoordinate
7+
using PEPSKit: EnlargedCorner, simultaneous_projectors
8+
using PEPSKit: renormalize_northwest_corner, renormalize_northeast_corner, renormalize_southeast_corner, renormalize_southwest_corner
9+
10+
# settings
11+
Random.seed!(91283219347)
12+
stype = ComplexF64
13+
ctm_alg = SimultaneousCTMRG(; projector_alg = :halfinfinite)
14+
15+
function test_contractions(
16+
Pspaces, Nspaces, Espaces, chis_north, chis_east, chis_south, chis_west,
17+
)
18+
peps = InfinitePEPS(randn, stype, Pspaces, Nspaces, Espaces)
19+
env = CTMRGEnv(randn, stype, peps, chis_north, chis_east, chis_south, chis_west)
20+
21+
n = InfiniteSquareNetwork(peps)
22+
coordinates = eachcoordinate(n)
23+
dirs_and_coordinates = eachcoordinate(n, 1:4)
24+
25+
# initialize dense and sparse enlarged corners
26+
sparse_enlarged_corners = map(dirs_and_coordinates) do co
27+
return EnlargedCorner(n, env, co)
28+
end
29+
dense_enlarged_corners = map(TensorMap, sparse_enlarged_corners)
30+
31+
# compute projectors (doesn't matter how)
32+
(P_left, P_right), info = simultaneous_projectors(
33+
dense_enlarged_corners, env, ctm_alg.projector_alg
34+
)
35+
36+
# test corner renormalization
37+
return foreach(coordinates) do (r, c)
38+
for renormalize_f in (
39+
renormalize_northwest_corner, renormalize_northeast_corner,
40+
renormalize_southeast_corner, renormalize_southwest_corner,
41+
)
42+
C_sparse = renormalize_f((r, c), sparse_enlarged_corners, P_left, P_right)
43+
C_dense = renormalize_f((r, c), dense_enlarged_corners, P_left, P_right)
44+
@test C_sparse C_dense
45+
end
46+
end
47+
48+
# TODO: test all other uncovered contracitions
49+
end
50+
51+
@testset "Random Cartesian spaces" begin
52+
unitcell = (3, 3)
53+
54+
Pspaces = ComplexSpace.(rand(2:3, unitcell...))
55+
Nspaces = ComplexSpace.(rand(2:4, unitcell...))
56+
Espaces = ComplexSpace.(rand(2:4, unitcell...))
57+
chis_north = ComplexSpace.(rand(5:10, unitcell...))
58+
chis_east = ComplexSpace.(rand(5:10, unitcell...))
59+
chis_south = ComplexSpace.(rand(5:10, unitcell...))
60+
chis_west = ComplexSpace.(rand(5:10, unitcell...))
61+
62+
test_contractions(
63+
Pspaces, Nspaces, Espaces, chis_north, chis_east, chis_south, chis_west,
64+
)
65+
end
66+
67+
@testset "Specific U1 spaces" begin
68+
unitcell = (2, 2)
69+
70+
PA = U1Space(-1 => 1, 0 => 1)
71+
PB = U1Space(0 => 1, 1 => 1)
72+
Vpeps = U1Space(-1 => 2, 0 => 1, 1 => 2)
73+
Venv = U1Space(-2 => 2, -1 => 3, 0 => 4, 1 => 3, 2 => 2)
74+
75+
Pspaces = [PA PB; PB PA]
76+
Nspaces = [Vpeps Vpeps'; Vpeps' Vpeps]
77+
chis = [Venv Venv; Venv Venv]
78+
79+
test_contractions(Pspaces, Nspaces, Nspaces, chis, chis, chis, chis)
80+
81+
# 4x4 unit cell with all 32 inequivalent bonds
82+
#
83+
# 10 4 7 32
84+
# | | | |
85+
# 3--A--1--B--5--C--8--D--3
86+
# | | | |
87+
# 2 6 9 11
88+
# | | | |
89+
# 14--E-12--F-15--G-17--H-14
90+
# | | | |
91+
# 13 16 18 19
92+
# | | | |
93+
# 22--I-20--J-23--K-25--L-22
94+
# | | | |
95+
# 21 24 26 27
96+
# | | | |
97+
# 29--M-28--N-30--O-31--P-29
98+
# | | | |
99+
# 10 4 7 32
100+
101+
phys_space = Vect[U1Irrep](1 => 1, -1 => 1)
102+
corner_space = Vect[U1Irrep](0 => 1, 1 => 1, -1 => 1)
103+
vspaces = map(i -> Vect[U1Irrep](0 => 1 + i % 4, 1 => i ÷ 4 % 4, -2 => i ÷ 16), 1:32)
104+
@test length(Set(vspaces)) == 32
105+
106+
Espaces = [
107+
vspaces[1] vspaces[5] vspaces[8] vspaces[3]
108+
vspaces[12] vspaces[15] vspaces[17] vspaces[14]
109+
vspaces[20] vspaces[23] vspaces[25] vspaces[22]
110+
vspaces[28] vspaces[30] vspaces[31] vspaces[29]
111+
]
112+
113+
Nspaces = [
114+
vspaces[10] vspaces[4] vspaces[7] vspaces[32]
115+
vspaces[2] vspaces[6] vspaces[9] vspaces[11]
116+
vspaces[13] vspaces[16] vspaces[18] vspaces[19]
117+
vspaces[21] vspaces[24] vspaces[26] vspaces[27]
118+
]
119+
Pspaces = fill(phys_space, (4, 4))
120+
chis = fill(corner_space, (4, 4))
121+
122+
test_contractions(Pspaces, Nspaces, Nspaces, chis, chis, chis, chis)
123+
end

test/examples/heisenberg.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ end
5555
@testset "C4v AD optimization with scalartype T=$T and projector_alg=$projector_alg" for (T, projector_alg) in
5656
Iterators.product([Float64, ComplexF64], [:c4v_eigh, :c4v_qr])
5757
# initialize symmetric states
58-
Random.seed!(1234567)
58+
Random.seed!(123456789)
5959
symm = RotateReflect()
6060
H′ = heisenberg_XYZ_c4v(InfiniteSquare())
6161
H = T <: Real ? real(H′) : H′

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ end
5555
@time @safetestset "correlation length" begin
5656
include("ctmrg/correlation_length.jl")
5757
end
58+
@time @safetestset "Contractions" begin
59+
include("ctmrg/contractions.jl")
60+
end
5861
end
5962
if GROUP == "ALL" || GROUP == "BP"
6063
@time @safetestset "Unit cell bond matching" begin

test/timeevol/tf_ising_finiteT.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ dt, nstep = 1.0e-3, 400
4444
β = dt * nstep
4545

4646
# when g = 2, β = 0.4 and 2β = 0.8 belong to two phases (without and with nonzero σᶻ)
47-
@testset "Finite-T SU (bipartite = $(bipartite))" for bipartite in (true, false)
47+
@testset "Finite-T SU (force_mpo = $(force_mpo))" for force_mpo in (false, true)
4848
# use second order Trotter decomposition
4949
symmetrize_gates = true
50+
bipartite = true
5051

5152
# PEPO approach: results at β, or T = 2.5
52-
alg = SimpleUpdate(; trunc = trunc_pepo, purified = false, bipartite)
53+
alg = SimpleUpdate(; trunc = trunc_pepo, purified = false, bipartite, force_mpo)
5354
pepo, wts, info = time_evolve(pepo0, ham, dt, nstep, alg, wts0; symmetrize_gates)
5455

5556
## BP gauge fixing
@@ -72,7 +73,7 @@ dt, nstep = 1.0e-3, 400
7273
@test isapprox(abs.(result_2β), bm_2β, rtol = 1.0e-4)
7374

7475
# Purification approach: results at 2β, or T = 1.25
75-
alg = SimpleUpdate(; trunc = trunc_pepo, purified = true, bipartite)
76+
alg = SimpleUpdate(; trunc = trunc_pepo, purified = true, bipartite, force_mpo)
7677
pepo, wts, info = time_evolve(pepo0, ham, dt, 2 * nstep, alg, wts0; symmetrize_gates)
7778
env = converge_env(InfinitePEPS(pepo), 8)
7879
result_2β′ = measure_mag(pepo, env; purified = true)

0 commit comments

Comments
 (0)