Apply quantum channel to MPO

Hi, apologies for the spate of questions. This will hopefully be the last for a while.

My goal is to apply a quantum channel to a density matrix represented as an MPO. Now, ordinarily, I would simply use apply() here. However, in this case the number of input and output indices is different. For example, you could think of this as a (non-unitary) quantum channel that ties together 4 sites into 1. Here is my best guess for how something like that might work:

function apply_channel(ρ::MPO, Ψ::ITensor)
    ρ̃ = copy(ρ)

    # extract the common indices where we will be applying the channel 
    common_inds = findall(x -> hascommoninds(Ψ, ρ[x]), collect(1:length(ρ)))

    # Apply the channel 
    wf = ρ̃[common_inds[1]] * Ψ
    for v in common_inds[2:end]
        wf *= ρ̃[v] 
    end

    # Update the MPO
    new_data = vcat(ρ̃[1:common_inds[1]-1], wf, ρ̃[common_inds[end]+1:length(ρ̃)])
    ρ̃.data = new_data

    return ρ̃
end

I have no real reason to believe that this is wrong, save for the fact that my code as a whole is not working and I am trying to pinpoint the location of my bug. Please let me know if you have any thoughts! And thank you again for all the help.

What is the error message you are getting?

Hi Miles,

This part of the code does not actually throw an error message – I am just not getting the results I expect from the script as a whole, and was wondering whether that might be because I am making some mistake in applying the quantum channel to the MPO. But if this looks fine to you, then I will have to look for my bug elsewhere…

Thanks so much! (Also happy to provide more information here or via email if you think that would be helpful)

I see - however, I’m not sure if the code you posted has a bug or not, but the question wasn’t really specific enough for me to know what might be the issue you were asking about. If you have a more specific or narrowly tailored question, please ask, otherwise I encourage you to try out various parts of your code on small examples where you know what the correct result should be and/or print out intermediate values of your code as it is running to verify if it’s working correctly.

Best,
Miles

1 Like