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

Simulating cascaded formalism #304

Closed Physis21 closed 3 years ago

Physis21 commented 3 years ago

Hello,

I would like to simulate cascade formalism such as the one in this master equation: image

The fourth term in the right side of the equation cannot be modeled by a Hamiltonian or a Linblad operator. Do you know if there currently exists a way to either simulate this directly, or to create custom additionnal terms in a Master equation, which are different than [H,p] or Linblad terms?

Good day, Physis

david-pl commented 3 years ago

One thing you could do (as of v0.8.8) is to define the right-hand-side of your equation as a superoperator (using spre and spost) and then pass it to timeevolution.master. Note that this only works for constant operators though.

From your equation i presume that the fk (and hence the operators on the RHS) change over time. Is that right? That will be a bit more tricky. You can still build up the super-operator on the right-hand-side in the same way. But then you have to rewrite it as a regular Operator and multiply it by im. Then you can reshape your initial state density operator into a Ket. The solution of the equation above is then the same as solving a Schrödinger equation with the super-operator as Hamiltonian and the density operator as the state. You can use schroedinger_dynamic to take care of the time-dependence.

Physis21 commented 3 years ago

Thanks for the reply! Thankfully my case is easier, as the cascade term is independant of time: image

I don't see in the documentation how to implement superoperators into timeevolution.master() . Is it something I should put in kwargs?

david-pl commented 3 years ago

Okay great!

I don't see in the documentation how to implement superoperators into timeevolution.master() . Is it something I should put in kwargs?

Yes it was just added recently. I need to update the documentation. The method is just timeevolution.master(tspan, rho0, L::SuperOperator).

Physis21 commented 3 years ago

I tried a basic code to test out the method you indicate, but it returns an error to me:

using QuantumOptics N=4 basis = FockBasis(N) Na = number(basis) ϕ0 = fockstate(basis,1) H = 5 Na tspan = LinRange(0,30,300) L = -im spre(H) + im * spost(H) tout,states = timeevolution.master(tspan,ϕ0,L)

the error message is "LoadError: MethodError: no method matching master(::LinRange{Float64}, ::Ket{FockBasis{Int64},Array{Complex{Float64},1}}, ::SuperOperator{Tuple{FockBasis{Int64},FockBasis{Int64}},Tuple{FockBasis{Int64},FockBasis{Int64}},SparseArrays.SparseMatrixCSC{Complex{Float64},Int64}}) "

did I specify something wrong?

david-pl commented 3 years ago

Hm your code works for me. You may need to update, this feature is only available as of v0.8.8. Which version are you on?

Physis21 commented 3 years ago

you're right, I just updated my version and it worked. Thanks for helping me out!