Hi there,
I find the function measurelocalops!()
in the function function measure!(obs::DMRGObserver; kwargs...)
in the source code \src\ITensorMPS\observer.jl
.
I redefined this function as
function ITensors.measurelocalops!(obs::ObserverDemo, wf::ITensor, i::Int)
for o in obs.onsite_ITensor_ops
# Moves to GPU if needed
# @show o
oⱼ = ITensors.adapt(ITensors.datatype(wf), ITensors.op(obs.sites, o, i))
m = ITensors.dot(wf, ITensors.apply(oⱼ, wf))
imag(m) > 1e-8 && (@warn "encountered finite imaginary part when measuring $o")
obs.measurements[o][end][i] = real(m)
end
end
in my own code with the version of ITensors v0.3.35, and it works much more efficiently than inner(psi', MPO(onsite_mpo, obs.sites), psi)
. However, when I update ITensors to version v0.3.68, this redefined function breaks down, while the source code does not change much.
How can I still use the more efficient way to calculate averages of the onsite operator with the updated version of ITensors?
Thank you so much for your time!
Best wishes.