QuantumOptics.jl icon indicating copy to clipboard operation
QuantumOptics.jl copied to clipboard

better error message when the Hamiltonian or Lindblad function are not of the necessary output type (currently we just get an confusing assert error)

Open Krastanov opened this issue 1 year ago • 1 comments

See https://discourse.julialang.org/t/quantumoptics-jl-time-dependent-hamiltonian-cannot-run/113448/9?u=krastanov

When we have H(t,rho) -> matrix, an assert fails in master_dynamic. We can have a better error message there.

Krastanov avatar Apr 25 '24 14:04 Krastanov

Provide some examples to supplement this issue:

psi_0 = (tensor(plus,s0) + tensor(plus,s1) + tensor(minus,s0) + tensor(minus,s1))/sqrt(4)
psi_f = (tensor(plus,s0) + tensor(plus,sr) + tensor(sr,s0) + tensor(minus,s1))/sqrt(4)
function Hami(t,rho)
    detuning = Delta_0*t + (2*delta*sin((omega_0*t)/2)^2)/omega_0

    H1 = Omega/2*exp(-1im*(beta*pi/2-alpha-pi/2))*exp(-1im*detuning)*sr⊗dagger(minus) + Omega/2*exp(1im*(beta*pi/2-alpha-pi/2))*exp(1im*detuning)*minus⊗dagger(sr)
    H2 = Omega/2*exp(-1im*(beta*pi/2-alpha-pi/2))*exp(-1im*detuning)*sr⊗dagger(s1) + Omega/2*exp(1im*(beta*pi/2-alpha-pi/2))*exp(1im*detuning)*s1⊗dagger(sr)

    return tensor(H1, eye4) + tensor(eye4, H2) + Urr*tensor(sr⊗dagger(sr), sr⊗dagger(sr))
end

tout, pops = timeevolution.schroedinger_dynamic(tlist, psi_0, Hami)

Because the Initial value psi_0 is Bra type, we need to use the command schroedinger_dynamic.

gfq960906 avatar Apr 29 '24 10:04 gfq960906