In [1]:
%pylab inline
In [2]:
from qutip import *
In [3]:
N = 4 # number of cavity fock states
wc = wa = 1.0 * 2 * pi # cavity and atom frequency
g = 0.1 * 2 * pi # coupling strength
kappa = 0.75 # cavity dissipation rate
gamma = 0.25 # atom dissipation rate
# Jaynes-Cummings Hamiltonian
a = tensor(destroy(N), qeye(2))
sm = tensor(qeye(N), destroy(2))
H = wc * a.dag() * a + wa * sm.dag() * sm + g * (a.dag() * sm + a * sm.dag())
# collapse operators
n_th = 0.01
c_ops = [sqrt(kappa * (1 + n_th)) * a, sqrt(kappa * n_th) * a.dag(), sqrt(gamma) * sm]
In [4]:
# calculate the correlation function using the mesolve
# solver, and then fft to obtain the power spectrum
tlist = linspace(0, 100, 2500)
corr = correlation_ss(H, tlist, c_ops, a.dag(), a)
wlist1, spec1 = spectrum_correlation_fft(tlist, corr)
# calculate the power spectrum using spectrum_ss, which
# uses essolve to solve for the dynamics
wlist2 = linspace(0.25, 1.75, 500) * 2 * pi
spec2 = spectrum_ss(H, wlist2, c_ops, a.dag(), a)
In [5]:
# plot the correlation function
fig, ax = plt.subplots(1, 1, figsize=(10,4))
ax.plot(tlist, real(corr), 'b', lw=1, label='real')
ax.plot(tlist, imag(corr), 'r', lw=1, label='imag')
ax.legend(loc=1)
ax.set_xlabel('Time')
ax.set_ylabel('Correlation')
Out[5]:
In [6]:
# plot the spectra given by the two methods
fig, ax = plt.subplots(1, 1, figsize=(10,4))
ax.plot(wlist1/(2*pi), spec1, 'b', lw=2, label='eseries method')
ax.plot(wlist2/(2*pi), spec2, 'r--', lw=2, label='me+fft method')
ax.legend(loc=1)
ax.set_xlabel('Frequency')
ax.set_ylabel('Power spectrum')
ax.set_title('Vacuum Rabi splitting')
ax.set_xlim(wlist2[0]/(2*pi), wlist2[-1]/(2*pi));
In [7]:
from qutip.ipynbtools import version_table
version_table()
Out[7]: