GRAPE calculation of control fields for iSWAP implementation

Robert Johansson ([email protected])

In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import time
import numpy as np
In [2]:
from qutip import *
from qutip.control import *
In [3]:
T = 1
times = np.linspace(0, T, 100)
In [4]:
U = iswap()
R = 50
H_ops = [#tensor(sigmax(), identity(2)),
         #tensor(sigmay(), identity(2)),
         #tensor(sigmaz(), identity(2)),
         #tensor(identity(2), sigmax()),
         #tensor(identity(2), sigmay()),
         #tensor(identity(2), sigmaz()),
         tensor(sigmax(), sigmax()),
         tensor(sigmay(), sigmay()),
         tensor(sigmaz(), sigmaz())]

H_labels = [#r'$u_{1x}$',
            #r'$u_{1y}$',
            #r'$u_{1z}$',
            #r'$u_{2x}$',
            #r'$u_{2y}$',
            #r'$u_{2z}$',
            r'$u_{xx}$',
            r'$u_{yy}$',
            r'$u_{zz}$',
        ]
In [5]:
H0 = 0 * np.pi * (tensor(sigmaz(), identity(2)) + tensor(identity(2), sigmaz()))

GRAPE

In [6]:
from qutip.control.grape import plot_grape_control_fields, _overlap, grape_unitary_adaptive, cy_grape_unitary
In [7]:
from scipy.interpolate import interp1d
from qutip.ui.progressbar import TextProgressBar
In [8]:
u0 = np.array([np.random.rand(len(times)) * (2 * np.pi / T) * 0.01 for _ in range(len(H_ops))])

u0 = [np.convolve(np.ones(10)/10, u0[idx, :], mode='same') for idx in range(len(H_ops))]
In [9]:
result = cy_grape_unitary(U, H0, H_ops, R, times, u_start=u0, eps=2*np.pi/T,
                          progress_bar=TextProgressBar())
10.0%. Run time:   3.90s. Est. time left: 00:00:00:35
20.0%. Run time:   7.49s. Est. time left: 00:00:00:29
30.0%. Run time:  11.07s. Est. time left: 00:00:00:25
40.0%. Run time:  14.66s. Est. time left: 00:00:00:21
50.0%. Run time:  18.23s. Est. time left: 00:00:00:18
60.0%. Run time:  21.79s. Est. time left: 00:00:00:14
70.0%. Run time:  25.35s. Est. time left: 00:00:00:10
80.0%. Run time:  28.97s. Est. time left: 00:00:00:07
90.0%. Run time:  32.54s. Est. time left: 00:00:00:03
Total run time:  35.46s
In [10]:
#result = grape_unitary(U, H0, H_ops, R, times, u_start=u0, eps=2*np.pi/T,
#                       progress_bar=TextProgressBar())

Plot control fields for iSWAP gate in the presense of single-qubit tunnelling

In [11]:
plot_grape_control_fields(times, result.u / (2 * np.pi), H_labels, uniform_axes=True);
In [12]:
# compare to the analytical results
np.mean(result.u[-1,0,:]), np.mean(result.u[-1,1,:]), np.pi/(4 * T)
Out[12]:
(-0.74176269364089276, -0.74159807970319103, 0.7853981633974483)

Fidelity

In [13]:
U
Out[13]:
Quantum object: dims = [[2, 2], [2, 2]], shape = [4, 4], type = oper, isherm = False\begin{equation*}\left(\begin{array}{*{11}c}1.0 & 0.0 & 0.0 & 0.0\\0.0 & 0.0 & 1.0j & 0.0\\0.0 & 1.0j & 0.0 & 0.0\\0.0 & 0.0 & 0.0 & 1.0\\\end{array}\right)\end{equation*}
In [14]:
result.U_f.tidyup(1e-2)
Out[14]:
Quantum object: dims = [[2, 2], [2, 2]], shape = [4, 4], type = oper, isherm = False\begin{equation*}\left(\begin{array}{*{11}c}1.000 & 0.0 & 0.0 & 0.0\\0.0 & 0.093 & 0.996j & 0.0\\0.0 & 0.996j & 0.093 & 0.0\\0.0 & 0.0 & 0.0 & 1.000\\\end{array}\right)\end{equation*}
In [15]:
_overlap(U, result.U_f).real
Out[15]:
0.9978153151159737

Test numerical integration of GRAPE pulse

In [16]:
c_ops = []
In [17]:
U_f_numerical = propagator(result.H_t, times[-1], c_ops, args={})
In [18]:
U_f_numerical
Out[18]:
Quantum object: dims = [[2, 2], [2, 2]], shape = [4, 4], type = oper, isherm = False\begin{equation*}\left(\begin{array}{*{11}c}(1.000+0.014j) & 0.0 & 0.0 & (-1.462\times10^{-04}+0.010j)\\0.0 & (0.059-8.591\times10^{-04}j) & (0.014+0.998j) & 0.0\\0.0 & (0.014+0.998j) & (0.059-8.591\times10^{-04}j) & 0.0\\(-1.462\times10^{-04}+0.010j) & 0.0 & 0.0 & (1.000+0.014j)\\\end{array}\right)\end{equation*}
In [19]:
_overlap(U, U_f_numerical).real
Out[19]:
0.9989882532493792

Process tomography

Ideal iSWAP gate

In [20]:
op_basis = [[qeye(2), sigmax(), sigmay(), sigmaz()]] * 2
op_label = [["i", "x", "y", "z"]] * 2
In [21]:
fig = plt.figure(figsize=(8,6))

U_ideal = spre(U) * spost(U.dag())

chi = qpt(U_ideal, op_basis)

fig = qpt_plot_combined(chi, op_label, fig=fig, threshold=0.001)

iSWAP gate calculated using GRAPE

In [22]:
fig = plt.figure(figsize=(8,6))

U_ideal = to_super(result.U_f)

chi = qpt(U_ideal, op_basis)

fig = qpt_plot_combined(chi, op_label, fig=fig, threshold=0.001)

Versions

In [23]:
from qutip.ipynbtools import version_table

version_table()
Out[23]:
SoftwareVersion
Cython0.21.2
Numpy1.9.1
OSposix [linux]
SciPy0.14.1
matplotlib1.4.2
QuTiP3.1.0
Python3.4.0 (default, Apr 11 2014, 13:05:11) [GCC 4.8.2]
IPython2.3.1
Tue Jan 13 13:44:55 2015 JST