Expectation value of an operator after dmrg using ground state.

@shuklavaibhav
Again, please use markdowns, you can find instructions on how to use them here (Please Read: Make It Easier to Help You)

Anyway, are you sure you actually have to compute them? What you are attempting to do is compute the mean value of a the matrix Sy over a real state, this is always going to be zero (this is also true for the non diagonal elements of the correlation matrix C_{i,j}=\langle S_i^yS_j^y\rangle, while the diagonal elements would be the identity since (S_i^y)^2 = 1).

Mathematical demonstration

The mean value of S_y in the computational basis is represented as:

\begin{pmatrix} \alpha^* & \beta^* \end{pmatrix} \begin{pmatrix} 0 & -i\\ i & 0 \end{pmatrix} \begin{pmatrix} \alpha \\ \beta \end{pmatrix}

By performing the multiplications you arrive that this is equal to 2 Re(i\beta^* \alpha), if both \alpha and \beta are real, than i\beta^*\alpha is a purely imaginary number, so its real part is zero.

So if you know that your state is real (and you know that because the S=1/2 Heisenberg Hamiltonian is real and symmetric) you already know that this mean value is zero.

If you still want to do it numerically, you have to convert the state to a complex one

psi = convert_leaf_eltype(ComplexF64, psi)

To compute the correlations the function to use is correlation_matrix(psi, "Sy", "Sy"), please refer to the example (MPS and MPO Examples · ITensors.jl) and to the documentation of the function (MPS and MPO · ITensors.jl)