GRAPE calculation of control fields for cnot 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 = 2 * np.pi 
times = np.linspace(0, T, 500)
In [4]:
U = cnot()
R = 500
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_{1y}$', r'$u_{2z}$',
            r'$u_{xx}$',
            r'$u_{yy}$',
            r'$u_{zz}$',
        ]
In [5]:
H0 = 0 * np.pi * (tensor(sigmax(), identity(2)) + tensor(identity(2), sigmax()))

c_ops = []

# This is the analytical result in the absense of single-qubit tunnelling
#g = pi/(4 * T)
#H = g * (tensor(sigmax(), sigmax()) + tensor(sigmay(), sigmay()))

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 * 0.05 for _ in range(len(H_ops))])

u0 = [np.convolve(np.ones(10)/10, u0[idx,:], mode='same') for idx in range(len(H_ops))]

u_limits = None #[0, 1 * 2 * pi]
alpha = None
In [9]:
result = cy_grape_unitary(U, H0, H_ops, R, times, u_start=u0, u_limits=u_limits,
                          eps=2*np.pi*1, alpha=alpha, phase_sensitive=False,
                          progress_bar=TextProgressBar())
10.0%. Run time: 366.95s. Est. time left: 00:00:55:02
20.0%. Run time: 735.78s. Est. time left: 00:00:49:03
30.0%. Run time: 1103.50s. Est. time left: 00:00:42:54
40.0%. Run time: 1483.28s. Est. time left: 00:00:37:04
50.0%. Run time: 1849.76s. Est. time left: 00:00:30:49
60.0%. Run time: 2216.15s. Est. time left: 00:00:24:37
70.0%. Run time: 2578.35s. Est. time left: 00:00:18:25
80.0%. Run time: 2950.03s. Est. time left: 00:00:12:17
90.0%. Run time: 3321.43s. Est. time left: 00:00:06:09
Total run time: 3678.78s
U_f, H_list_func, u = grape_unitary_adaptive(U, H0, H_ops, R, times, u_start=u0, u_limits=u_limits, eps=2*pi*1, alpha=alpha, phase_sensitive=False, overlap_terminate=0.9999, progress_bar=TextProgressBar())

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

In [10]:
plot_grape_control_fields(times, result.u / (2 * np.pi), H_labels, uniform_axes=True);

Fidelity/overlap

In [11]:
U
Out[11]:
Quantum object: dims = [[2, 2], [2, 2]], shape = [4, 4], type = oper, isherm = True\begin{equation*}\left(\begin{array}{*{11}c}1.0 & 0.0 & 0.0 & 0.0\\0.0 & 1.0 & 0.0 & 0.0\\0.0 & 0.0 & 0.0 & 1.0\\0.0 & 0.0 & 1.0 & 0.0\\\end{array}\right)\end{equation*}
In [12]:
result.U_f
Out[12]:
Quantum object: dims = [[2, 2], [2, 2]], shape = [4, 4], type = oper, isherm = False\begin{equation*}\left(\begin{array}{*{11}c}(0.707+0.707j) & (4.482\times10^{-10}+4.647\times10^{-10}j) & (1.326\times10^{-09}+1.651\times10^{-09}j) & (1.650\times10^{-09}+1.323\times10^{-09}j)\\(-4.647\times10^{-10}-4.482\times10^{-10}j) & (0.707+0.707j) & (-9.126\times10^{-10}-1.242\times10^{-09}j) & (-1.262\times10^{-09}-8.967\times10^{-10}j)\\(-1.323\times10^{-09}-1.650\times10^{-09}j) & (8.967\times10^{-10}+1.262\times10^{-09}j) & (1.749\times10^{-11}+4.312\times10^{-12}j) & (0.707+0.707j)\\(-1.651\times10^{-09}-1.326\times10^{-09}j) & (1.242\times10^{-09}+9.126\times10^{-10}j) & (0.707+0.707j) & (-4.310\times10^{-12}-1.749\times10^{-11}j)\\\end{array}\right)\end{equation*}
In [13]:
result.U_f/result.U_f[0,0]
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 & (6.455\times10^{-10}+1.164\times10^{-11}j) & (2.105\times10^{-09}+2.303\times10^{-10}j) & (2.102\times10^{-09}-2.311\times10^{-10}j)\\(-6.455\times10^{-10}+1.165\times10^{-11}j) & (1.000+3.009\times10^{-11}j) & (-1.523\times10^{-09}-2.327\times10^{-10}j) & (-1.527\times10^{-09}+2.585\times10^{-10}j)\\(-2.102\times10^{-09}-2.311\times10^{-10}j) & (1.527\times10^{-09}+2.585\times10^{-10}j) & (1.542\times10^{-11}-9.318\times10^{-12}j) & (1.000+4.603\times10^{-10}j)\\(-2.105\times10^{-09}+2.303\times10^{-10}j) & (1.523\times10^{-09}-2.327\times10^{-10}j) & (1.000-4.244\times10^{-10}j) & (-1.541\times10^{-11}-9.320\times10^{-12}j)\\\end{array}\right)\end{equation*}
In [14]:
_overlap(U, result.U_f).real, abs(_overlap(U, result.U_f)) ** 2
Out[14]:
(0.7071067811865461, 0.9999999999999973)

Test numerical integration of GRAPE pulse

In [15]:
U_f_numerical = propagator(result.H_t, times[-1], [], options=Odeoptions(nsteps=5000), args={})
U_f_numerical
Out[15]:
Quantum object: dims = [[2, 2], [2, 2]], shape = [4, 4], type = oper, isherm = False\begin{equation*}\left(\begin{array}{*{11}c}(0.783-0.233j) & (0.532+0.113j) & (-0.002-0.152j) & (-0.018+0.113j)\\(-0.073+0.135j) & (0.067-0.322j) & (0.645-0.662j) & (0.094-0.075j)\\(-0.182+0.493j) & (0.582-0.342j) & (-0.341+0.066j) & (0.384+0.024j)\\(-0.114-0.140j) & (0.225+0.301j) & (-0.020-0.043j) & (0.099-0.902j)\\\end{array}\right)\end{equation*}
In [16]:
U_f_numerical / U_f_numerical[0,0]
Out[16]:
Quantum object: dims = [[2, 2], [2, 2]], shape = [4, 4], type = oper, isherm = False\begin{equation*}\left(\begin{array}{*{11}c}1.000 & (0.584+0.318j) & (0.051-0.179j) & (-0.060+0.126j)\\(-0.133+0.133j) & (0.191-0.354j) & (0.987-0.552j) & (0.137-0.055j)\\(-0.385+0.515j) & (0.801-0.199j) & (-0.423-0.042j) & (0.442+0.162j)\\(-0.085-0.204j) & (0.159+0.431j) & (-0.008-0.057j) & (0.431-1.024j)\\\end{array}\right)\end{equation*}
In [17]:
_overlap(result.U_f, U_f_numerical).real, abs(_overlap(result.U_f, U_f_numerical))**2
Out[17]:
(0.11355125771393167, 0.1127464011373238)

Process tomography

Ideal cnot gate

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

U_i_s = to_super(U)

chi = qpt(U_i_s, op_basis)

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

cnot gate calculated using GRAPE

In [20]:
fig = plt.figure(figsize=(12,6))

U_f_s = to_super(result.U_f)

chi = qpt(U_f_s, op_basis)

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

Versions

In [21]:
from qutip.ipynbtools import version_table

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