Hi
It is possible to solve this type of problem with mesolve, but it takes a few tricks.. The best solution would be if the c_ops argument could be a callback function that generates the collapse operators or the liouvillian for a given time step, in the same way as the H argument can be a callback function. However, this is not implemented in the latest qutip release, but I'll create an issue for it on github and we'll try to make implement it before next release.
The way you can solve this problem with mesolve in qutip 2.2 is to work with callback function for the Hamiltonian, which actually should return the Hamiltonian in superoperator form. Since the Hamiltonian callback function return a superoperator, this can equally well be the entire system Liouvillian. For example, the following are all equivalent
1)
result = mesolve(H, rho0, tlist, c_ops, e_ops)
2)
L = liouvillian(H, c_ops)
result = mesolve(L, rho0, tlist, [], e_ops)
3)
L = liouvillian(H, c_ops)
def L_func(t, args):
""" This callback function is supposed to return the data of a superoperator, hence the L.data """
return L.data
result = mesolve(L_func, rho0, tlist, [], e_ops)
In option 3) you have a callback function that is called for each time step and which constructs the system Liouvillian Here you are free to construct the collapse operators or Liouvillian in whichever way you want, so going back to your question, you could do something like
def f(t):
return .... # return a Qobj operator
def g(t):
return .... # return a C-number coefficient
def L_func(t, args):
""" This callback function is supposed to return the data of a superoperator, hence the L.data """
L = liouvillian_fast(H, [[f(t),g(t)],[h(t),k(t)]])
return L.data
result = mesolve(L_func, ket2dm(psi0), tlist, [], e_ops)
Rob