Qutip and the Numpy Gradient

466 views
Skip to first unread message

Sahra Kulmiya

unread,
Mar 5, 2022, 12:05:24 PM3/5/22
to QuTiP: Quantum Toolbox in Python
Hello,

   I have a time dependent hamiltionian with a simple polynomial function, whose gradient I find using Numpy's gradient function. I also specify the step size that the gradient function should use.

However, when passing the function and its gradient to Qutips mesolve function, i get the error:

ValueError: Shape of array too small to calculate a numerical gradient, at least (edge_order + 1) elements are required.

I think this is because usually you would pass the whole array of time which Numpy would calculate the gradient of, but in the case of mesolve in qutip, we are passing a float instead of an array, i.e. calculating 1 time point which numpy cannot use.

Does anyone know how i can get around this?

Kind Regards
Sahra

Simon Cross

unread,
Mar 6, 2022, 1:57:37 AM3/6/22
to qu...@googlegroups.com
Hi Sahra,

Could you give an code example showing how you are trying to call mesolve?

It doesn't accept a gradient parameter, or at least not directly
(https://qutip.org/docs/latest/apidoc/functions.html?#module-qutip.mesolve).

Regards,
Simon

Sahra Kulmiya

unread,
Mar 6, 2022, 8:09:28 AM3/6/22
to QuTiP: Quantum Toolbox in Python
Hello

Thank you for your reply,
   I have attached my code,

Kind Regards
Sahra
forced_qho.py
Reply all
Reply to author
Forward
Message has been deleted
0 new messages