sesolve where H1 function is unknown explicitly but know at t_list values t_i

33 views
Skip to first unread message

Ryan Vogt

unread,
Jul 3, 2021, 1:39:14 PM7/3/21
to QuTiP: Quantum Toolbox in Python
Hello,

So I have H1(t) on values of t_list

a = destroy(levels)
adag = a.dag()
H0 = fa*(adag*a) - (xa/2)*(adag*adag*a*a)
H1 = i_num*(a-adag)
H = [H0,[H1, h1_coff]]
Results = sesolve(H, Qeye, t_list, args=args_dic)

def h1_coff(t,args):
return args["output"][str(t)]



I thought I could work around by just making a dictionary that would map each t_i to the value I have for it, but it seems the numerical solver is evaluating at t values other than the t_list I prescribed.

Is it possible to just past the values of the discretized function at every t_i rather than having a function for any t?

Thank you.


Simon Cross

unread,
Jul 19, 2021, 5:02:22 PM7/19/21
to qu...@googlegroups.com
Hi Ryan,

Yes, as you have discovered, coefficient functions are evaluated at times other than those in t_list. This makes sense -- t_list is the list of times to report the state of the system in the result, but the solver needs to evaluate H at many small time steps in order to accurately H along the way.

QuTiP has built in support for what you are looking for though!

If you set H to ``[H0, [H1, coeff_values]]`` where ``coeff_values`` is a numpy array of float or complex values with one value for each time in t_list, it will do what you want.

This and all the other ways of specifying coefficients are documented in the QobjEvo documentation -- https://qutip.org/docs/latest/apidoc/classes.html#qutip.QobjEvo.

The QobjEvo documentation is referenced from the ``sesolve`` documentation -- https://qutip.org/docs/latest/apidoc/functions.html#module-qutip.sesolve -- but there isn't a nice link and it's easy to miss.

I've attached a small silly reworked version of your example showing now the numpy array coefficients work. Hopefully the list doesn't eat it.

Yours sincerely,
Simon Cross
np-coeff.py

Simon Cross

unread,
Jul 19, 2021, 5:05:24 PM7/19/21
to qu...@googlegroups.com
P.S. By default the values in ``coeff_values`` are interpolated using a cubic spline. You can select step interpolation by passing ``args = {"_step_func_coeff": True}``. If you want some other interpolation, it's probably easiest to write a coefficient function that does the interpolation for you.
Reply all
Reply to author
Forward
0 new messages