converting a mps in the double Hilbert space to mpo

I am studying open quantum system using itensor, and I wonder how to convert the density matrix in the double Hilbert space (a MPS) to the corresponding mpdo for the density matrix, e.g., any functions in itensor.

The setup is:
for a N-site system, the density matrix is represented as \rho\rightarrow |\rho\rangle\rangle, with |\rho\rangle\rangle a 2N physical site MPS, i.e.,
|\rho\rangle\rangle=\text{tr}\left(\prod_{i_{1},\ j_{1}}^{i_{N},\ j_{N}}M^{s_{i}\ s_{j}}\right)|i_{1},\ i_{2},\ \dots\rangle\otimes|j_{1},\ \dots j_{N}\rangle".

Are there any function in itensor to reshape it to a mpo, i.e.,
\hat{\rho}=\text{tr}\left(\prod_{i_{1},\ j_{1}}^{i_{N},\ j_{N}}M^{s_{i}\ s_{j}}\right)|i_{1},\ i_{2},\ \dots\rangle\langle j_{1},\ \dots j_{N}|.

Thanks for your help!

I’m not sure if I fully understood your question, but if you have a normalized state \ket \psi in the form of an MPS and want to get the density matrix \rho = \ket\psi\!\!\bra\psi in the form of an MPO, the function that does that is outer

thanks for the quick reply: The setup is, for a N-site system, I have \rho\rightarrow |\rho\rangle\rangle, with |\rho\rangle\rangle a 2N physical site MPS. Now, I want to reconstruct the MPDO for \rho.

Assuming that “|\rho\rangle\rangle=\text{tr}\left(\prod_{i_{1},\ j_{1}}^{i_{N},\ j_{N}}M^{s_{i}\ s_{j}}\right)|i_{1},\ i_{2},\ \dots\rangle\otimes|j_{1},\ \dots j_{N}\rangle”, are there any function in itensor to reshape it to a mpo, i.e., “\hat{\rho}=\text{tr}\left(\prod_{i_{1},\ j_{1}}^{i_{N},\ j_{N}}M^{s_{i}\ s_{j}}\right)|i_{1},\ i_{2},\ \dots\rangle\langle j_{1},\ \dots j_{N}|”.

Thanks for your help!

For what I know, MPDO and MPO are different, for this reason I’m a bit confused. In ITensor there is no support for MPDO that I know of. About MPO instead, I don’t think there is an already implemented way to do it, but all you should do is split the site index present in the MPS into 2 and you can do that using the combiner function , so you could implement it with something like:

function mps_to_mpo(mps::MPS)
    N = length(mps)
    double_sites = siteinds(mps) 
    sites = siteinds("S=1/2", N) #change this line as needed
    mpo = MPO([
        let 
            C = combiner(s', dag(s))
            c = combinedind(C)
            dag(C) * (delta(ds, c) * mps_ten)
        end 
        for (ds, s, mps_ten) in zip(double_sites, sites, mps)
        ])
    return mpo
end

hi, Vince. Thanks for your reply! Sorry, I am new to itensor, and some explanation would be helpful! To be more specific, my density matrix is,
|\rho\rangle\rangle=\text{tr}\left\{ \prod_{i_{1},\ j_{1}}^{i_{N},\ j_{N}}\left[\left(A^{s_{i_{1}}}B^{s_{j_{1}}}\right)\dots\right]\right\} |i_{1},\ i_{2},\ \dots\rangle\otimes|j_{1},\ \dots j_{N}\rangle”, with A, B for the ket and bra state.

And, I would like to have the following MPO,
\hat{\rho}=\text{tr}\left\{ \prod_{i_{1},\ j_{1}}^{i_{N},\ j_{N}}\left[\left(A^{s_{i_{1}}}B^{s_{j_{1}}}\right)\dots\right]\right\} |i_{1},\ i_{2},\ \dots\rangle\langle j_{1},\ \dots j_{N}|”, or by fusing A B,
\hat{\rho}=\text{tr}\left(\prod_{i_{1},\ j_{1}}^{i_{N},\ j_{N}}M^{s_{i_{1}}\ s_{j_{1}}}\right)|i_{1},\ i_{2},\ \dots\rangle\langle j_{1},\ \dots j_{N}|”.