Solving technical problems in using QuTiP solver for CircuitProcessor
Now we have the main ingredients for this project: CircuitProcessor as the simulator and CircuitNoise representing noise, it's time to go back and fix some technical issues. There were two unsolved problems discussed in the posts before:
- QuTiP solver interprets the array-like coefficients as smooth function and uses a cubic spline interpolation by default. However, as mentioned in the previous blog, in CircuitProcessor we use the coefficients as a step function, i.e. coeff = [1,2,3] means that the pulse amplitude is 1 during t=[0,1), 2 during t=[1,2) and so on. This causes a mismatch in the result and was only solved temporarily by using Python function as coefficients.
- The solver requires that all the coefficients have the same tlist, which makes it difficult to add noise to the processor since the noise might have a different frequency. This was mentioned at the end of the last post.
To solve the first problem we need to modify the solvers. Fortunately, the recent update of QuTiP offers a very convenient interface for it: the QobjEvo class. It is used to unify the representation of time-dependent Hamiltonian and thus offers a convenient way to adapt the solver to our problem. The only thing we need to do is to modify QobjEvo so that it interprets the time dependence in the desired way. As all solvers in QuTiP take/will take it as the input, the problems solved.
In QobjEvo, each pair of Hamiltonian and coefficient is saved in an object called EvoElement, when called by the solver, its attributes get_coeff is used. For array-like coefficients, we need to change the definition of this attribute in both Python and Cython version. The Python version can be easily replaced by scipy.interpolate.interp1d, which offers an option for step function. For the Cython version, new methods are defined to replace the cubic spline interpolation. The use of this step function coefficients is controlled by an argument "_step_func_coeff".
For the second problem, I implemented a method that combines two coefficients with different tlist. It creates a longer tlist containing all the time step in both original tlist as well as two new coefficients array. With this, we can easily create noise with a much finer frequency, an example is shown below, where Gaussian white noise is created and added to a pulse with much lower frequency (The details can be found at Combining two coefficients with different tlist):
This method is not only useful in the noise object, but it should also be possible to integrate it into QobjEvo to allow the addition of two QobjEvos with different tlist such as
QobjEvo([...], tlist=[0., 1., 2.]) + QobjEvo([...],tlist=[0., 1., 1.5, 2.])
In QobjEvo, each pair of Hamiltonian and coefficient is saved in an object called EvoElement, when called by the solver, its attributes get_coeff is used. For array-like coefficients, we need to change the definition of this attribute in both Python and Cython version. The Python version can be easily replaced by scipy.interpolate.interp1d, which offers an option for step function. For the Cython version, new methods are defined to replace the cubic spline interpolation. The use of this step function coefficients is controlled by an argument "_step_func_coeff".
For the second problem, I implemented a method that combines two coefficients with different tlist. It creates a longer tlist containing all the time step in both original tlist as well as two new coefficients array. With this, we can easily create noise with a much finer frequency, an example is shown below, where Gaussian white noise is created and added to a pulse with much lower frequency (The details can be found at Combining two coefficients with different tlist):
This method is not only useful in the noise object, but it should also be possible to integrate it into QobjEvo to allow the addition of two QobjEvos with different tlist such as
QobjEvo([...], tlist=[0., 1., 2.]) + QobjEvo([...],tlist=[0., 1., 1.5, 2.])
Really good description of the problems. Your solutions are very good. I am extra pleased that the solutions also extend the capabilities of QuTiP generally, that is beyond the confines of this project, by enabling the merging of QobjEvo with different `tlist`. Excellent work, thank you.
ReplyDelete