Tracking the expectation value of an MPO during DMRG with DMRGObserver

Hello,

What would be the syntax if I have an MPO and want to track its expectation value using the DMRGObserver in Julia?

The syntax that I have found so far I believe is only suitable for single site operators whereas I would like to apply a whole MPO which is more general.

Thanks in advance!

Hi, good question. So the way I would do this is:

  • when defining your custom observer type, add a data field that holds an MPO
  • when constructing your observer, pass the MPO that you want to measure to your observer object so it can store it
  • in the measure! function, the first argument passed is the observer, so you can access the MPO you want to measure and also the current wavefunction is passed through the psi keyword argument (as noted in the docs here).
  • you can then use the code inner(psi',M,psi) where M is your MPO to get the expectation value and print it