QuTiP example: Quantum process tomography

J.R. Johansson and P.D. Nation

For more information about QuTiP see http://qutip.org


In [1]:
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [2]:
from qutip import *
from qutip.quantum_info import *

In [3]:
"""
Plot the process tomography matrices for some 1, 2, and 3-qubit qubit gates.
"""
gates = [['C-NOT', cnot()],
         ['SWAP', swap()],
         ['$i$SWAP', iswap()],
         ['$\sqrt{i\mathrm{SWAP}}$', sqrtiswap()],
         ['S-NOT', snot()],
         ['$\pi/2$ phase gate', phasegate(pi/2)],
         ['Toffoli', toffoli()],
         ['Fredkin', fredkin()]]

In [4]:
def plt_qpt_gate(gate, figsize=(8,6)):

    name  = gate[0]
    U_psi = gate[1]
    
    N = len(U_psi.dims[0]) # number of qubits

    # create a superoperator for the density matrix
    # transformation rho = U_psi * rho_0 * U_psi.dag()
    U_rho = spre(U_psi) * spost(U_psi.dag())

    # operator basis for the process tomography
    op_basis = [[qeye(2), sigmax(), sigmay(), sigmaz()] for i in range(N)]

    # labels for operator basis
    op_label = [["$i$", "$x$", "$y$", "$z$"] for i in range(N)]

    # calculate the chi matrix
    chi = qpt(U_rho, op_basis)

    # visualize the chi matrix
    fig, ax = qpt_plot_combined(chi, op_label, name, figsize=figsize)
    
    ax.set_title(name)
    
    return fig, ax

In [5]:
plt_qpt_gate(gates[0]);


/usr/local/lib/python2.7/dist-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/mpl_toolkits/mplot3d/axes3d.py:1673: RuntimeWarning: invalid value encountered in divide
  for n in normals])
/usr/local/lib/python2.7/dist-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/colors.py:394: RuntimeWarning: invalid value encountered in greater
  if (c.ravel() > 1).any() or (c.ravel() < 0).any():
/usr/local/lib/python2.7/dist-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/colors.py:394: RuntimeWarning: invalid value encountered in less
  if (c.ravel() > 1).any() or (c.ravel() < 0).any():

In [6]:
plt_qpt_gate(gates[1]);



In [7]:
plt_qpt_gate(gates[2]);



In [8]:
plt_qpt_gate(gates[3]);



In [9]:
plt_qpt_gate(gates[4]);



In [10]:
plt_qpt_gate(gates[5]);



In [11]:
fig, ax = plt_qpt_gate(gates[6], figsize=(16,12))
ax.axis('tight');



In [12]:
fig, ax = plt_qpt_gate(gates[7], figsize=(16,12))
ax.axis('tight');


Versions


In [13]:
from qutip.ipynbtools import version_table

version_table()


Out[13]:
SoftwareVersion
Cython0.19
SciPy0.14.0.dev-2a4ba40
QuTiP2.3.0.dev-35120ca
Python2.7.4 (default, Apr 19 2013, 18:28:01) [GCC 4.7.3]
IPython2.0.0-dev
OSposix [linux2]
Numpy1.8.0.dev-928289b
matplotlib1.4.x
Sun Sep 29 22:18:18 2013 JST