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

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

Open Krastanov opened 2 months ago

Krastanov commented 2 months ago

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.

gfq960906 commented 2 months ago

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.