ITensors.jl icon indicating copy to clipboard operation
ITensors.jl copied to clipboard

Define `expect(::MPS,::String,::Int)` for measuring a single site?

Open emstoudenmire opened this issue 4 years ago • 2 comments

It can be useful to measure expected values on only a single site or a small number of sites. Currently the notation for measuring "Sz" on a site j is:

expect(psi,"Sz";site_range=j:j)

so an alternate notation for this could be

expect(psi,"Sz",j)

with the option to pass more operators such as expect(psi,"Sz",j,"Sx",j,"Sz",k) for which the return value would be a vector.

emstoudenmire avatar Jul 17 '21 18:07 emstoudenmire

Sounds good. However with the multi-operator notation:

expect(psi,"Sz",j,"Sx",j,"Sz",k)

my first reaction was that it looks like it would be calculating a correlation function <Sz_j Sx_j Sz_k>.

I would suggest something more verbose like expect(psi, [("Sz",i), ("Sx",j), ("Sz",k)]). But honestly in that case I would lean towards someone just calling expect multiple times, such as:

[expect(psi, op...) for op in [("Sz",i), ("Sx",j), ("Sz",k)]]

EDIT: I just realized that iterating over it in multiple calls may mean certain optimization can't be done, like caching work that needs to be done calculating multiple operators on the same site, so maybe expect(psi, [("Sz",i), ("Sx",j), ("Sz",k)]) is better.

mtfishman avatar Jul 19 '21 19:07 mtfishman

Agreed - this does need some more thought about the design.

emstoudenmire avatar Aug 09 '21 16:08 emstoudenmire