|
| 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 |
0 commit comments