MPO construction from multi-site OpSum

I am interested in creating Hamiltonians built from multi-site terms which are not easily expressed as sums of (tensor products of) single-site basis operators. OpSum() supports multisite operators, but I am not sure about how to turn the resulting OpSum into an MPO, as the naive method—as in the following code—fails:

sites = siteinds("Qubit",2)
opsum = OpSum()
add!(opsum,"CNOT",1,2) 
H = MPO(opsum,sites)

with the last line producing an error. What is the correct syntax here?

That’s not currently supported, probably the best approach is expanding the operator into the Pauli basis.

Ah, I see, thanks! Would be nice to have in future versions–if straightforward to implement–since the system I am interested in has some large-ish onsite Hilbert space dimension and a Hamiltonian with large-ish range of terms, so doing the appropriate decomposition is rather painful – but will just deal with it for now :slight_smile: