qojulia / QuantumOptics.jl

Library for the numerical simulation of closed as well as open quantum systems.
http://qojulia.org
Other
518 stars 101 forks source link

Different behavior of schroedinger() and master() for sum basis. #377

Closed kimkyngt closed 6 months ago

kimkyngt commented 6 months ago

I was trying some simple rabi oscillation with sum basis and found different behavior for schroedinger() and master(). If I understand what I am doing, the following script shows two identical plots (as printed value is true), but it does not.

using QuantumOptics
using Plots

spins = [1//2, 1//2]

bases = [SpinBasis(spin) for spin in spins]

rho0 = directsum(
    diagonaloperator(SpinBasis(spins[1]), ComplexF64[1.0, 0.0]),
    diagonaloperator(SpinBasis(spins[2]), ComplexF64[0.0, 0.0]),
)

psi0 = directsum(
    Ket(SpinBasis(spins[1]), ComplexF64[1.0, 0.0]),
    Ket(SpinBasis(spins[2])),
)

println(psi0⊗dagger(psi0) == rho0)

H = (spinup(bases[1]) ⊕ Ket(bases[2])) ⊗ dagger(Ket(bases[1]) ⊕ spindown(bases[2]))
H = 2π*(H + H')/2

tspan = range(0.0, 3.0, step=1e-2)

t_master, rho_master = timeevolution.master(tspan, rho0, H, [])
t_sch, rho_sch = timeevolution.schroedinger(tspan, rho0, H)

fig1 = plot()
fig2 = plot()
id_ops = [one(bases[ii]) for ii in eachindex(spins)]
for indx in eachindex(spins)
    id_vec = zeros(length(spins))
    id_vec[1] = 1
    id_vec = circshift(id_vec, indx - 1)

    plot!(fig1, tspan, real.(expect(directsum([id_vec[ii] * id_ops[ii] for ii in eachindex(spins)]...), rho_master)), label="Tr(ρ$indx) master",)
    plot!(fig2, tspan, real.(expect(directsum([id_vec[ii] * id_ops[ii] for ii in eachindex(spins)]...), rho_sch)), label="Tr(ρ$indx) schroedinger",)

end
plot!(fig1, tspan, real.(expect(directsum([id_ops[ii] for ii in eachindex(spins)]...), rho_master)), label="Tr(ρ) master",)
plot!(fig2, tspan, real.(expect(directsum([id_ops[ii] for ii in eachindex(spins)]...), rho_sch)), label="Tr(ρ) schroedinger",)

fig = plot(fig1, fig2, layout=(2, 1))
display(fig)
image
amilsted commented 6 months ago

When you supply a density matrix to schroedinger you are computing the action of the propagator exp(-itH) * rho, whereas master performs exp(-itH) * rho * exp(itH).

You should see the same results if you apply schroedinger to psi0 to get pure state outputs.

kimkyngt commented 6 months ago

When you supply a density matrix to schroedinger you are computing the action of the propagator exp(-itH) * rho, whereas master performs exp(-itH) * rho * exp(itH).

You should see the same results if you apply schroedinger to psi0 to get pure state outputs.

Thank you. I guess it is not a sum basis thing then. If I am interested in a coherent evolution of a mixed state , I should use master without the jump operators.

amilsted commented 6 months ago

Yes, that's right.