Pulser
Pulser copied to clipboard
Cubic spline extrapolation of the Hamiltonian by QuTip
When building the Hamiltonian QobjEvo, the entire list of samples of a Sequence is given to QuTip. QuTip will then extrapolate (with Cubic spline) the values of the coefficients in between. This leads to artifacts when defining a piecewise constant pulse, at the transitions between plateaus. One way to correct that would be to split the Sequence into constant and time-dependant parts and tell QuTip about it. From QuTip documentation :
The times of the tlist do not need to be equidistant, but must be sorted. By default, a cubic spline interpolation will be used for the coefficient at time t. If the coefficients are to be treated as step functions, use the arguments
args = {"_step_func_coeff": True}
.
One way to edit build_coeffs_ops
would be to split qobj_list
into the list of objects to be extrapolated (say qobj_list_spline
) and the list to be kept piecewise constant (say qobj_list_pwcst
) and replace
ham = qutip.QobjEvo(qobj_list, tlist=self._times)
by
ham_spline = qutip.QobjEvo(qobj_list_spline, tlist=self._times)
ham_pwcst = qutip.QobjEvo(qobj_list_pwcst, tlist=self._times, args = {"_step_func_coeff": True})
ham = ham_spline + ham_pwcst
Now that I'm thinking about it. Another way to solve this issue would be to discard the sampling times altogether and to build the Hamiltonian QobjEvo by giving the functional dependence of the coefficients. This way Qutip doesn't do any interpolating
Using the _step_func_coeff
argument in sesolve
only gives a ~20% speedup when the Pulse is completely piecewise constant. Otherwise, it only gives a small increase in accuracy, at the expanse of a large slowing down of the computation.
Here is a short notebook illustrating the effect : pwc.ipynb.zip