Constructing MPOs manually

Hi,

I was wondering if it is possible to build MPOs without using OpSum. It seems that this is possible in the C++ version of ITensor (Constructing MPO manually - ITensor Support Q&A) but I cannot see how this could be done in the Julia version.

Alternatively, it seems like ITensorInfiniteMPS might support something like this (eg, https://github.com/ITensor/ITensorInfiniteMPS.jl/blob/main/src/infinitempomatrix.jl#L62), but if I am not mistaken it seems to assume a very particular form for the MPO. For example, as written, it wouldn’t support the MPO specified in the previous link:

H^{\sigma'_i, \sigma_i} = \begin{bmatrix} I & 0 & 0 \\ S^z_i & e^{-1} I & 0 \\ 0 & J S^z_i & I \end{bmatrix}.

Is there a recommended way to build MPOs manually?

You should be able to use opsum to get all of H except the center element. And then assign the center afterwards. I can make some sample code for you, but I don’t understand the e^{-1} element, it is a scalar, we need an operator there. Did you mean I*e^{-1} ?

Ah yes, the center element should be proportional to the identity.

Ok here is the code:

using ITensors

let
    N,J=5,1.0
    s=siteinds("S=1/2",N)
    # Build the NN Ising portion of H using OpSum for convenience
    os=OpSum()
    for i in 1:N-1
        os += J,"Sz",i,"Sz",i+1
    end
    H=MPO(os,s) #Convert to MPO, H[1] and H[N] are row and column vectors
    ils=linkinds(H) #Get all N-1 linkindices
    H[2]+=exp(-1.0)*op(s[2],"Id")*onehot(ils[1]=>2,ils[2]=>2)
    @show H[2]
end

I hope this helps.
Regards
Jan

Thank you!