I run into the issue that calling expectation_value for a LocalOperator containing one-site terms, fails. Only when calling it with two-site operators, does it give a result.
Underlying is a minimal breaking example.
using PEPSKit, TensorKit, TensorKitTensors
T = ComplexF64
pspace = ℂ^2
vspace = ℂ^3
envspace = ℂ^10
ctm_alg = SimultaneousCTMRG()
ψ = InfinitePEPS(randn(T, pspace, vspace ⊗ vspace ⊗ vspace' ⊗ vspace'))
env, = leading_boundary(CTMRGEnv(ψ, envspace), ψ, ctm_alg)
(Nr, Nc) = (1, 1)
lattice = InfiniteSquare(Nr, Nc)
spaces = fill(pspace, Nr, Nc)
op_twosite = PEPSKit.LocalOperator(
spaces,
(neighbor => SpinOperators.S_x() ⊗ SpinOperators.S_x() for neighbor in nearest_neighbours(lattice))...,
)
op_onesite = PEPSKit.LocalOperator(
spaces,
([idx,] => SpinOperators.S_x() for idx in vertices(lattice))...,
)
op_combination = PEPSKit.LocalOperator(
spaces,
(neighbor => SpinOperators.S_x() ⊗ SpinOperators.S_x() for neighbor in nearest_neighbours(lattice))...,
([idx,] => SpinOperators.S_x() for idx in vertices(lattice))...,
)
E1 = expectation_value(ψ, op_twosite, env) # this works
E2 = expectation_value(ψ, op_onesite, env) # this does not work
E3 = expectation_value(ψ, op_combination, env) # this does not work
with stacktrace
ERROR: MethodError: no method matching reduced_densitymatrix(::Vector{…}, ::InfinitePEPS{…}, ::InfinitePEPS{…}, ::CTMRGEnv{…})
The function `reduced_densitymatrix` exists, but no method is defined for this combination of argument types.
Closest candidates are:
reduced_densitymatrix(::Tuple{CartesianIndex{2}, CartesianIndex{2}}, ::InfinitePEPS, ::InfinitePEPS, ::CTMRGEnv)
@ PEPSKit ~/.julia/packages/PEPSKit/zz9BS/src/algorithms/contractions/localoperator.jl:394
reduced_densitymatrix(::Tuple{CartesianIndex{2}}, ::InfinitePEPS, ::InfinitePEPS, ::CTMRGEnv)
@ PEPSKit ~/.julia/packages/PEPSKit/zz9BS/src/algorithms/contractions/localoperator.jl:355
reduced_densitymatrix(::NTuple{N, CartesianIndex{2}}, ::InfinitePEPS, ::InfinitePEPS, ::CTMRGEnv) where N
@ PEPSKit ~/.julia/packages/PEPSKit/zz9BS/src/algorithms/contractions/localoperator.jl:312
...
Stacktrace:
[1] (::PEPSKit.var"#560#561"{InfinitePEPS{…}, InfinitePEPS{…}, CTMRGEnv{…}})(::Pair{Any, TensorMap{…} where {…}})
@ PEPSKit ~/.julia/packages/PEPSKit/zz9BS/src/algorithms/toolbox.jl:16
[2] iterate
@ ./generator.jl:48 [inlined]
[3] collect_to!(dest::Vector{ComplexF64}, itr::Base.Generator{Vector{…}, PEPSKit.var"#560#561"{…}}, offs::Int64, st::Int64)
@ Base ./array.jl:849
[4] collect_to_with_first!(dest::Vector{…}, v1::ComplexF64, itr::Base.Generator{…}, st::Int64)
@ Base ./array.jl:827
[5] _collect(c::Vector{…}, itr::Base.Generator{…}, ::Base.EltypeUnknown, isz::Base.HasShape{…})
@ Base ./array.jl:821
[6] collect_similar(cont::Vector{Pair{…}}, itr::Base.Generator{Vector{…}, PEPSKit.var"#560#561"{…}})
@ Base ./array.jl:720
[7] map(f::Function, A::Vector{Pair{Any, TensorMap{ComplexF64, ComplexSpace, N₁, N₂, Vector{ComplexF64}} where {N₁, N₂}}})
@ Base ./abstractarray.jl:3371
[8] #tmap#108
@ ~/.julia/packages/OhMyThreads/qVAdL/src/implementation.jl:453 [inlined]
[9] dtmap(::Function, ::Vararg{Any}; scheduler::OhMyThreads.Schedulers.SerialScheduler)
@ PEPSKit ~/.julia/packages/PEPSKit/zz9BS/src/utility/diffable_threads.jl:9
[10] expectation_value(bra::InfinitePEPS{…}, O::LocalOperator{…}, ket::InfinitePEPS{…}, env::CTMRGEnv{…})
@ PEPSKit ~/.julia/packages/PEPSKit/zz9BS/src/algorithms/toolbox.jl:15
[11] expectation_value(peps::InfinitePEPS{…}, O::LocalOperator{…}, env::CTMRGEnv{…})
@ PEPSKit ~/.julia/packages/PEPSKit/zz9BS/src/algorithms/toolbox.jl:21
[12] top-level scope
@ ~/Documents/Doctoraat/ExcitationsKit.jl/test/bugtest.jl:34
Some type information was truncated. Use `show(err)` to see complete types.
I run into the issue that calling
expectation_valuefor aLocalOperatorcontaining one-site terms, fails. Only when calling it with two-site operators, does it give a result.Underlying is a minimal breaking example.
with stacktrace