J.R. Johansson and P.D. Nation
For more information about QuTiP see http://qutip.org
In [1]:
%pylab inline
In [2]:
from qutip import *
import time
from mpl_toolkits.mplot3d import Axes3D
In [3]:
def compute(N, wc, wa, glist, use_rwa):
# Pre-compute operators for the hamiltonian
a = tensor(destroy(N), qeye(2))
sm = tensor(qeye(N), destroy(2))
nc = a.dag() * a
na = sm.dag() * sm
idx = 0
na_expt = zeros(shape(glist))
nc_expt = zeros(shape(glist))
for g in glist:
# recalculate the hamiltonian for each value of g
if use_rwa:
H = wc * nc + wa * na + g * (a.dag() * sm + a * sm.dag())
else:
H = wc * nc + wa * na + g * (a.dag() + a) * (sm + sm.dag())
# find the groundstate of the composite system
evals, ekets = H.eigenstates()
psi_gnd = ekets[0]
na_expt[idx] = expect(na, psi_gnd)
nc_expt[idx] = expect(nc, psi_gnd)
idx += 1
return nc_expt, na_expt, ket2dm(psi_gnd)
#
# set up the calculation
#
wc = 1.0 * 2 * pi # cavity frequency
wa = 1.0 * 2 * pi # atom frequency
N = 20 # number of cavity fock states
use_rwa = False # Set to True to see that non-RWA is necessary in this regime
glist = linspace(0, 2.5, 50) * 2 * pi # coupling strength vector
start_time = time.time()
nc, na, rhoss_final = compute(N, wc, wa, glist, use_rwa)
print('time elapsed = ' + str(time.time() - start_time))
In [4]:
#
# plot the cavity and atom occupation numbers as a function of
#
figure(1)
plot(glist/(2*pi), nc)
plot(glist/(2*pi), na)
legend(("Cavity", "Atom excited state"))
xlabel('g - coupling strength')
ylabel('Occupation probability')
title('# photons in the groundstate');
In [5]:
#
# plot the cavity wigner function for the cavity state (final coupling strenght)
#
fig = plt.figure(2, figsize=(9, 6))
rho_cavity = ptrace(rhoss_final, 0)
xvec = linspace(-7.5,7.5,100)
X,Y = meshgrid(xvec, xvec)
W = wigner(rho_cavity, xvec, xvec)
ax = Axes3D(fig, azim=-107, elev=49)
surf=ax.plot_surface(X, Y, W, rstride=1, cstride=1, cmap=cm.jet, alpha=1.0, linewidth=0.05, vmax=0.25, vmin=-0.25)
ax.set_xlim3d(-7.5, 7.5)
ax.set_ylim3d(-7.5, 7.5)
fig.colorbar(surf, shrink=0.65, aspect=20)
title("Wigner function for the cavity groundstate\n(ultra-strong coupling to a qubit)");
In [6]:
from qutip.ipynbtools import version_table
version_table()
Out[6]: