import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D
from qutip import *
from qutip.ipynbtools import version_table
%matplotlib inline
delta = 0.5 * 2 * np.pi
v = 2.0 * 2 * np.pi # sweep rate
H0 = delta/2.0 * sigmax()
H1 = v/2.0 * sigmaz()
H = [H0, [H1, 't']]
psi0 = basis(2,0)
sm = destroy(2)
sx=sigmax();
sy=sigmay()
sz=sigmaz()
expt_ops = [sm.dag() * sm,sx,sy,sz]
tlist = np.linspace(-10.0, 10.0, 1500)
expt_list = sesolve(H, psi0, tlist, expt_ops).expect
Note that I need to call b.show
here so that I can grab a Figure instance later
b = Bloch()
## normalize colors to times in tlist ##
nrm = mpl.colors.Normalize(-2,10)
colors = cm.cool(nrm(tlist))
## add data points from expectation values ##
b.add_points([expt_list[1],
expt_list[2],
-expt_list[3]],'m')
## customize sphere properties ##
b.point_color = list(colors)
b.point_marker = ['o']
b.point_size = [20]
b.zlpos = [1.1,-1.2]
b.show()
left, bottom, width, height = [0.98, 0.05, 0.05, 0.9]
ax2 = b.fig.add_axes([left, bottom, width, height])
mpl.colorbar.ColorbarBase(ax2, cmap=cm.cool,
norm=nrm,
orientation='vertical');
Currently I need to call b.fig
as replotting figures in a notebook is a bit tricky. However, this is likely to be improved in the future.
b.fig
version_table()
Software | Version |
---|---|
QuTiP | 4.3.0.dev0+4a9c6fd1 |
Numpy | 1.13.1 |
SciPy | 0.19.1 |
matplotlib | 2.0.2 |
Cython | 0.26.1 |
Number of CPUs | 2 |
BLAS Info | INTEL MKL |
IPython | 6.1.0 |
Python | 3.6.2 |Anaconda, Inc.| (default, Sep 21 2017, 18:29:43) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] |
OS | posix [darwin] |
Mon Oct 09 11:24:04 2017 MDT |