Robert Johansson (robert@riken.jp)
%matplotlib inline
import matplotlib.pyplot as plt
import time
import numpy as np
from qutip import *
from qutip.control import *
T = 2 * np.pi
times = np.linspace(0, T, 500)
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}$',
]
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()))
from qutip.control.grape import plot_grape_control_fields, _overlap, grape_unitary_adaptive, cy_grape_unitary
from scipy.interpolate import interp1d
from qutip.ui.progressbar import TextProgressBar
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
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
plot_grape_control_fields(times, result.u / (2 * np.pi), H_labels, uniform_axes=True);
U
result.U_f
result.U_f/result.U_f[0,0]
_overlap(U, result.U_f).real, abs(_overlap(U, result.U_f)) ** 2
(0.7071067811865461, 0.9999999999999973)
U_f_numerical = propagator(result.H_t, times[-1], [], options=Odeoptions(nsteps=5000), args={})
U_f_numerical
U_f_numerical / U_f_numerical[0,0]
_overlap(result.U_f, U_f_numerical).real, abs(_overlap(result.U_f, U_f_numerical))**2
(0.11355125771393167, 0.1127464011373238)
op_basis = [[qeye(2), sigmax(), sigmay(), sigmaz()]] * 2
op_label = [["i", "x", "y", "z"]] * 2
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)
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)
from qutip.ipynbtools import version_table
version_table()
Software | Version |
---|---|
IPython | 2.3.1 |
OS | posix [linux] |
SciPy | 0.14.1 |
Cython | 0.21.2 |
Python | 3.4.0 (default, Apr 11 2014, 13:05:11) [GCC 4.8.2] |
matplotlib | 1.4.2 |
QuTiP | 3.1.0 |
Numpy | 1.9.1 |
Tue Jan 13 14:11:48 2015 JST |