Expectation value of 2-site operators for a given MPS

Hi,

I have a system of spin-1/2 XXZ of length L. I want to compute the expectation value of the bond energy defined as

H_{i,i+1} = \frac{1}{2}(S^+_i S^-_{i+1} + S^-_i S^+_{i+1}) + \Delta S^z_iS^z_{i+1}.

I can use the expect function for a single site operator. Is there a way to implement this for a 2-site operator like the one described above? I could think about 2 different ways of doing it naively -

  1. Define a two-site operator using ITensors.op(::OpName"E12", ::SiteType"S=1/2") = Matrix, where Matrix is the (2,2,2,2) tensor for the above 2 site operator. Then use the apply(gate,psi) function to act this gate on the MPS and compute its inner product with psi using inner.
ITensors.op(::OpName"E12", ::SiteType"S=1/2") = Matrix
gates = ITensor[]
push!(gates,op("E12",s[1],s[2]))
E12_psi = apply(gates, psi)
E12_val = inner(psi',E12_psi)
  1. Another way of doing it would be following what is suggested in the ITensor documentation
orthogonalize!(psi,1)
E12_psi = deepcopy(psi)
ITensors.op(::OpName"E12", ::SiteType"S=1/2") = Matrix
G = op("E12",s[1],s[2])
wf = (E12_psi[1]*E12_psi[2])*G
inds3 = uniqueinds(E12_psi[1],E12_psi[2])
U,S,V = svd(wf,inds3,cutoff=1E-8)
E12_psi[1] = U
E12_psi[2] = S*V
E12_val = inner(psi',E12_psi)

The first method works, but is it possible to use the operator “E12” with the function expect? Something similar was suggested in this discussion, but I could not understand how to use it and would appreciate any help regarding this.

The second method gives me an error about matching indices. It would be very helpful if someone could help me understand where I am going wrong in the second approach.

Finally, I would like to know which is the best method to compute this expectation value.

Thanks.

Just make H_{i,i+1} into an MPO using OpSum() defined only over the pair of sites (i,i+1) and take its expectation value with inner(\psi',H_{i,i+1},\psi).

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.

Hi @tamoghnaRay ,
It’s a good question since the documentation doesn’t show explicitly how to compute a two-site expectation value. Note that while the tutorial you linked is pretty close to the steps needed, you don’t need to do the SVD part for an expectation value, since the SVD is about putting a modified wavefunction back into an MPS.

Here is a code pattern you can use for generically measuring two-site expectation values:

  i = 3
  operator = op("TwoSite",sites[i],sites[i+1]) # make the operator
 
  orthogonalize!(psi,i)  # shift the orthogonality to i, so that the other tensors cancel
  wf = psi[i]*psi[i+1] # form the two-site wavefunction tensor

  # contract the bra and ket versions of the wavefunction 
  # around the operator
  # the prime(...,"Site") makes sure the indices on the bra 
  # match the top of the operator
  expectation = scalar(dag(prime(wf,"Site"))*operator*wf)

Here is a diagram showing the contraction on the final line above:

Finally, while the OpSum and MPO approach certainly is fine for a “quick and convenient” approach, it’s worth pointing out that it would do significantly more operations and also scale linearly with system size, whereas the approach I wrote above can be much faster, especially when measuring multiple two-site operators. So just mentioning that if you have to measure operators in a way that affects performance (such as multiple times inside a loop).

1 Like