ITensor / ITensors.jl

A Julia library for efficient tensor computations and tensor network calculations
https://itensor.org
Apache License 2.0
509 stars 119 forks source link

Generalize `expect` and `correlation_matrix` to MPOs #730

Open mtfishman opened 2 years ago

mtfishman commented 2 years ago

Generalize expect and correlation_matrix to MPOs.

This comes up here: http://itensor.org/support/3350/calculating-observables-from-density-matrices and is needed in PastaQ.

A conceptually simple approach would be something like:

function expect(M::MPO, x::String, n::Int)
  s = dag.(siteinds(first, M; plev=0))
  O = op(x, s, n)
  return tr(apply([O], M))
end

used like:

expect(M, "Sx", 3)  # Compute `tr(Sx_3 * M)`

where of course we would want to handle moving the orthogonality center around efficiently when computing ranges of local expectation values.

emstoudenmire commented 2 years ago

Yes, that forum question also made me realize we should have this.