Skip to content

Commit 6999fd9

Browse files
committed
Add tests
1 parent deba165 commit 6999fd9

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

.github/workflows/Tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
- utility
3434
- bondenv
3535
- timeevol
36+
- toolbox
3637
os:
3738
- ubuntu-latest
3839
- macOS-latest

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ end
6565
include("timeevol/sitedep_truncation.jl")
6666
end
6767
end
68+
if GROUP == "ALL" || GROUP == "TOOLBOX"
69+
@time @safetestset "Cluster truncation with projectors" begin
70+
include("toolbox/densitymatrices.jl")
71+
end
72+
end
6873
if GROUP == "ALL" || GROUP == "UTILITY"
6974
@time @safetestset "LocalOperator" begin
7075
include("utility/localoperator.jl")

test/toolbox/densitymatrices.jl

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using TensorKit
2+
using PEPSKit
3+
using Test
4+
using TestExtras
5+
6+
ds = Dict(Trivial =>^2, U1Irrep => U1Space(i => 1 for i in -1:1), FermionParity => Vect[FermionParity](0 => 1, 1 => 1))
7+
Ds = Dict(Trivial =>^3, U1Irrep => U1Space(i => 2 for i in -1:1), FermionParity => Vect[FermionParity](0 => 2, 1 => 2))
8+
χs = Dict(Trivial =>^4, U1Irrep => U1Space(i => 3 for i in -2:2), FermionParity => Vect[FermionParity](0 => 4, 1 => 4))
9+
10+
@testset "Double-layer densitymatrix contractions ($I)" for I in keys(ds)
11+
d = ds[I]
12+
D = Ds[I]
13+
χ = χs[I]
14+
15+
ρ = InfinitePEPO(d, D)
16+
17+
ρ_peps = @constinferred InfinitePEPS(ρ)
18+
env = CTMRGEnv(ρ_peps, χ)
19+
20+
O = rand(d, d)
21+
O += O'
22+
F = isomorphism(fuse(d ⊗ d'), d d')
23+
@tensor O_doubled[-1; -2] := F[-1; 1 2] * O[1; 3] * twist(F', 2)[3 2; -2]
24+
25+
# Single site
26+
O_singlesite = LocalOperator(reshape(physicalspace(ρ), 1, 1), ((1, 1),) => O)
27+
E1 = expectation_value(ρ, O_singlesite, ρ, env)
28+
O_doubled_singlesite = LocalOperator(physicalspace(ρ_peps), ((1, 1),) => O_doubled)
29+
E2 = expectation_value(ρ_peps, O_doubled_singlesite, ρ_peps, env)
30+
@test E1 E2
31+
32+
# two sites
33+
for inds in zip(
34+
[(1, 1), (1, 1), (1, 1), (1, 2), (1, 1)],
35+
[(2, 1), (1, 2), (2, 2), (2, 1), (3, 1)]
36+
)
37+
O_twosite = LocalOperator(reshape(physicalspace(ρ), 1, 1), inds => O O)
38+
E1 = expectation_value(ρ, O_twosite, ρ, env)
39+
O_doubled_twosite = LocalOperator(physicalspace(ρ_peps), inds => O_doubled O_doubled)
40+
E2 = expectation_value(ρ_peps, O_doubled_twosite, ρ_peps, env)
41+
@test E1 E2
42+
end
43+
end

0 commit comments

Comments
 (0)