Cubic_Spline replaced by Spline

29 views
Skip to first unread message

Manish J. Thapa

unread,
Apr 19, 2024, 4:20:07 AMApr 19
to QuTiP: Quantum Toolbox in Python
Hi,

Cubic_Spline has been replaced by Spline in v5. 
This was the use case before:

Cubic_Spline(time_array[0], time_array[-1], f(time_array))
Where f is the function you want to interpolate.

How does it look with Spline now that Cubic_Spline is gone? I could not do that implementation with Spline since I cannot find how to call this Spline method. Any idea?

Éric Giguère

unread,
Apr 19, 2024, 10:01:16 AMApr 19
to QuTiP: Quantum Toolbox in Python

There are no equivalent stand alone class.
You could use scipy's CubicSpline instead.

Scipy's CubicSpline can be used as coefficient of QobjEvo:

These all create equivalent QobjEvo:
```
H = qutip.QobjEvo([H0, scipy.interpolate.CubicSpline(x, y, bc_type=bc_type)])
H = qutip.QobjEvo([H0, np.array(y)], tlist=x, boundary_conditions=bc_type)
H = H0 * qutip.coefficient(np.array(y), tlist=x, boundary_conditions=bc_type)
```

Manish J. Thapa

unread,
Apr 19, 2024, 2:28:29 PMApr 19
to qu...@googlegroups.com
Hi,

Thanks for your answer. It helps me a bit.

but I get some another error:

../src/ABC/solver/mesolver.py:64: in solve
    res = qt.mesolve(
../../../opt/miniconda3/envs/abclib/python3.11/site-packages/qutip/solver/mesolve.py:131: in mesolve
    H = QobjEvo(H, args=args, tlist=tlist)
qutip/core/cy/qobjevo.pyx:223: in qutip.core.cy.qobjevo.QobjEvo.__init__
    ???
qutip/core/cy/qobjevo.pyx:272: in qutip.core.cy.qobjevo.QobjEvo._read_element
    ???
../../../opt/miniconda3/envs/abc/lib/python3.11/site-packages/qutip/core/coefficient.py:175: in coefficient
    return coefficient_builders[type_](base, **kwargs)
qutip/core/cy/coefficient.pyx:520: in qutip.core.cy.coefficient.InterCoefficient.from_PPoly
    ???
qutip/core/cy/coefficient.pyx:515: in qutip.core.cy.coefficient.InterCoefficient.restore
    ???

Any idea what this could be?

--
You received this message because you are subscribed to a topic in the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/qutip/MS0r6YNFkd8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to qutip+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qutip/5f5a6d37-5002-43d6-bd91-8a5a7e4fdde6n%40googlegroups.com.

Éric Giguère

unread,
Apr 19, 2024, 4:14:39 PMApr 19
to QuTiP: Quantum Toolbox in Python
The `y` passed to CubicSpline must be complex.
This is an oversight in QuTiP...

Éric Giguère

unread,
Apr 19, 2024, 5:13:08 PMApr 19
to QuTiP: Quantum Toolbox in Python
I made a quick patch (https://github.com/qutip/qutip/pull/2397). It should work in the next release.
Reply all
Reply to author
Forward
0 new messages