|
| 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