Inefficient photon detection: Mixing stochastic and deterministic master equations

Copyright (C) 2011 and later, Paul D. Nation & Robert J. Johansson


In [1]:
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [2]:
from qutip import *

In [3]:
from matplotlib import rcParams
rcParams['font.family'] = 'STIXGeneral'
rcParams['mathtext.fontset'] = 'stix'
rcParams['font.size'] = '14'

Direct photo-detection

Here we follow an example from Wiseman and Milburn, Quantum measurement and control, section. 4.8.1.

Consider cavity that leaks photons with a rate $\kappa$. The dissipated photons are detected with an inefficient photon detector, with photon-detection efficiency $\eta$. The master equation describing this scenario, where a separate dissipation channel has been added for detections and missed detections, is

$\dot\rho = -i[H, \rho] + \mathcal{D}[\sqrt{1-\eta} \sqrt{\kappa} a] + \mathcal{D}[\sqrt{\eta} \sqrt{\kappa}a]$

To describe the photon measurement stochastically, we can unravelling only the dissipation term that corresponds to detections, and leaving the missed detections as a deterministic dissipation term, we obtain [Eq. (4.235) in W&M]

$d\rho = \mathcal{H}[-iH -\eta\frac{1}{2}a^\dagger a] \rho dt + \mathcal{D}[\sqrt{1-\eta} a] \rho dt + \mathcal{G}[\sqrt{\eta}a] \rho dN(t)$

or

$d\rho = -i[H, \rho] dt + \mathcal{D}[\sqrt{1-\eta} a] \rho dt -\mathcal{H}[\eta\frac{1}{2}a^\dagger a] \rho dt + \mathcal{G}[\sqrt{\eta}a] \rho dN(t)$

where

$\displaystyle \mathcal{G}[A] \rho = \frac{A\rho A^\dagger}{\mathrm{Tr}[A\rho A^\dagger]} - \rho$

$\displaystyle \mathcal{H}[A] \rho = A\rho + \rho A^\dagger - \mathrm{Tr}[A\rho + \rho A^\dagger] \rho $

and $dN(t)$ is a Poisson distributed increment with $E[dN(t)] = \eta \langle a^\dagger a\rangle (t)$.

Formulation in QuTiP

In QuTiP we write the stochastic master equation on the form:

$\displaystyle d\rho(t) = -i[H, \rho] dt + \mathcal{D}[B] \rho dt + D_{1}[A]\rho(t) dt + D_{2}[A]\rho(t) d\xi$

where the first two term gives the deterministic master equation (Lindblad form with collapse operator $B$). Here $A = \sqrt{\eta\gamma} a$ and $B = \sqrt{(1-\eta)\gamma} $a.

We can identify

$\displaystyle D_{1}[A]\rho(t) = - \frac{1}{2}\eta\gamma \mathcal{H}[a^\dagger a] \rho(t) = - \frac{1}{2}\mathcal{H}[A^\dagger A] \rho(t) = -\frac{1}{2}\left( A^\dagger A\rho + \rho A^\dagger A - \mathrm{Tr}[A^\dagger A\rho + \rho A^\dagger A] \rho \right)$

$\displaystyle D_{2}[A]\rho(t) = \mathcal{G}[\sqrt{\eta\gamma}a] \rho = \mathcal{G}[A] \rho = \frac{A\rho A^\dagger}{\mathrm{Tr}[A\rho A^\dagger]} - \rho$

and $d\xi = dN(t)$ with a Poisson distribution.


In [4]:
N = 15
w0 = 0.5 * 2 * pi
times = linspace(0, 15, 150)
dt = times[1] - times[0]
gamma = 0.1

In [5]:
a = destroy(N)

In [6]:
H = w0 * a.dag() * a

In [7]:
rho0 = fock(N, 5)

In [8]:
e_ops = [a.dag() * a, a + a.dag()]

Define the stochastic terms


In [9]:
# The argument A in the d1 and d2 callback functions is a list with the following
# precomputed superoperators, where c is the stochastic collapse operator given
# to the solver (called once for each operator, if more than one is given)
#
#     A[0] = spre(c)
#     A[1] = spost(c)
#     A[2] = spre(c.dag())
#     A[3] = spost(c.dag())
#     A[4] = spre(n)
#     A[5] = spost(n)
#     A[6] = (spre(c) * spost(c.dag())
#     A[7] = lindblad_dissipator(c)

$\displaystyle D_{1}[A]\rho(t) = -\frac{1}{2}\left( A^\dagger A\rho + \rho A^\dagger A - \mathrm{Tr}[A^\dagger A\rho + \rho A^\dagger A] \rho \right)$


In [10]:
def d1_rho_func(A, rho_vec):
    n_sum = A[4] + A[5]
    return 0.5 * (- n_sum * rho_vec + expect_rho_vec(n_sum, rho_vec, False) * rho_vec)

$\displaystyle D_{2}[A]\rho(t) = \frac{A\rho A^\dagger}{\mathrm{Tr}[A\rho A^\dagger]} - \rho$


In [11]:
def d2_rho_func(A, rho_vec):
    e1 = expect_rho_vec(A[6], rho_vec, False) + 1e-16  # add a small number to avoid division by zero
    return [(A[6] * rho_vec) / e1 - rho_vec]

Highly efficient detection


In [12]:
eta = 0.7
c_ops = [sqrt(1-eta) * sqrt(gamma) * a]  # collapse operator B
sc_ops = [sqrt(eta) * sqrt(gamma) * a]   # stochastic collapse operator A

In [13]:
result_ref = mesolve(H, rho0, times, c_ops+sc_ops, e_ops)

In [14]:
result1 = smesolve(H, rho0, times, c_ops=c_ops, sc_ops=sc_ops, e_ops=e_ops, 
                   ntraj=1, nsubsteps=100, d1=d1_rho_func, d2=d2_rho_func,
                   distribution='poisson', store_measurement=True)


Total run time:   6.84s

In [15]:
result2 = smesolve(H, rho0, times, c_ops=c_ops, sc_ops=sc_ops, e_ops=e_ops, 
                  ntraj=10, nsubsteps=100, d1=d1_rho_func, d2=d2_rho_func,
                  distribution='poisson', store_measurement=True)


10.0%. Run time:   6.73s. Est. time left: 00:00:01:00
20.0%. Run time:  13.53s. Est. time left: 00:00:00:54
30.0%. Run time:  20.37s. Est. time left: 00:00:00:47
40.0%. Run time:  27.20s. Est. time left: 00:00:00:40
50.0%. Run time:  34.02s. Est. time left: 00:00:00:34
60.0%. Run time:  40.90s. Est. time left: 00:00:00:27
70.0%. Run time:  47.77s. Est. time left: 00:00:00:20
80.0%. Run time:  54.60s. Est. time left: 00:00:00:13
90.0%. Run time:  61.55s. Est. time left: 00:00:00:06
Total run time:  68.39s

In [16]:
fig, axes = subplots(2,2, figsize=(12,8), sharex=True)

axes[0,0].plot(times, result1.expect[0], label=r'Stochastic ME (ntraj = 1)', lw=2)
axes[0,0].plot(times, result_ref.expect[0], label=r'Lindblad ME', lw=2)
axes[0,0].set_title("Cavity photon number (ntraj = 1)")
axes[0,0].legend()

axes[0,1].plot(times, result2.expect[0], label=r'Stochatic ME (ntraj = 10)', lw=2)
axes[0,1].plot(times, result_ref.expect[0], label=r'Lindblad ME', lw=2)
axes[0,1].set_title("Cavity photon number (ntraj = 10)")
axes[0,1].legend()

axes[1,0].step(times, dt * np.cumsum(result1.measurement[0].real), lw=2)
axes[1,0].set_title("Cummulative photon detections (ntraj = 1)")
axes[1,1].step(times, dt * np.cumsum(array(result2.measurement).sum(axis=0).real) / 10, lw=2)
axes[1,1].set_title("Cummulative avg. photon detections (ntraj = 10)")

fig.tight_layout()


Highly inefficient photon detection


In [17]:
eta = 0.1
c_ops = [sqrt(1-eta) * sqrt(gamma) * a]  # collapse operator B
sc_ops = [sqrt(eta) * sqrt(gamma) * a]   # stochastic collapse operator A

In [18]:
result_ref = mesolve(H, rho0, times, c_ops+sc_ops, e_ops)

In [19]:
result1 = smesolve(H, rho0, times, c_ops=c_ops, sc_ops=sc_ops, e_ops=e_ops, 
                  ntraj=1, nsubsteps=100, d1=d1_rho_func, d2=d2_rho_func,
                  distribution='poisson', store_measurement=True)


Total run time:   6.86s

In [20]:
result2 = smesolve(H, rho0, times, c_ops=c_ops, sc_ops=sc_ops, e_ops=e_ops, 
                  ntraj=10, nsubsteps=100, d1=d1_rho_func, d2=d2_rho_func,
                  distribution='poisson', store_measurement=True)


10.0%. Run time:   7.03s. Est. time left: 00:00:01:03
20.0%. Run time:  14.02s. Est. time left: 00:00:00:56
30.0%. Run time:  20.99s. Est. time left: 00:00:00:48
40.0%. Run time:  27.95s. Est. time left: 00:00:00:41
50.0%. Run time:  34.90s. Est. time left: 00:00:00:34
60.0%. Run time:  41.89s. Est. time left: 00:00:00:27
70.0%. Run time:  48.97s. Est. time left: 00:00:00:20
80.0%. Run time:  56.01s. Est. time left: 00:00:00:14
90.0%. Run time:  63.13s. Est. time left: 00:00:00:07
Total run time:  70.34s

In [21]:
fig, axes = subplots(2,2, figsize=(12,8), sharex=True)

axes[0,0].plot(times, result1.expect[0], label=r'Stochastic ME (ntraj = 1)', lw=2)
axes[0,0].plot(times, result_ref.expect[0], label=r'Lindblad ME', lw=2)
axes[0,0].set_title("Cavity photon number (ntraj = 1)")
axes[0,0].legend()

axes[0,1].plot(times, result2.expect[0], label=r'Stochatic ME (ntraj = 10)', lw=2)
axes[0,1].plot(times, result_ref.expect[0], label=r'Lindblad ME', lw=2)
axes[0,1].set_title("Cavity photon number (ntraj = 10)")
axes[0,1].legend()

axes[1,0].step(times, dt * np.cumsum(result1.measurement[0].real), lw=2)
axes[1,0].set_title("Cummulative photon detections (ntraj = 1)")
axes[1,1].step(times, dt * np.cumsum(array(result2.measurement).sum(axis=0).real) / 10, lw=2)
axes[1,1].set_title("Cummulative avg. photon detections (ntraj = 10)")

fig.tight_layout()


Efficient homodyne detection

The stochastic master equation for inefficient homodyne detection, when unravaling the detection part of the master equation

$\dot\rho = -i[H, \rho] + \mathcal{D}[\sqrt{1-\eta} \sqrt{\kappa} a] + \mathcal{D}[\sqrt{\eta} \sqrt{\kappa}a]$,

is given in W&M as

$d\rho = -i[H, \rho]dt + \mathcal{D}[\sqrt{1-\eta} \sqrt{\kappa} a] \rho dt + \mathcal{D}[\sqrt{\eta} \sqrt{\kappa}a] \rho dt + \mathcal{H}[\sqrt{\eta} \sqrt{\kappa}a] \rho d\xi$

where $d\xi$ is the Wiener increment. This can be described as a standard homodyne detection with efficiency $\eta$ together with a stochastic dissipation process with collapse operator $\sqrt{(1-\eta)\kappa} a$. Alternatively we can combine the two deterministic terms on standard Lindblad for and obtain the stochastic equation (which is the form given in W&M)

$d\rho = -i[H, \rho]dt + \mathcal{D}[\sqrt{\kappa} a]\rho dt + \sqrt{\eta}\mathcal{H}[\sqrt{\kappa}a] \rho d\xi$

Below we solve these two equivalent equations with QuTiP


In [22]:
rho0 = coherent(N, sqrt(5))

Form 1: Standard homodyne with deterministic dissipation on Lindblad form


In [23]:
eta = 0.95
c_ops = [sqrt(1-eta) * sqrt(gamma) * a]  # collapse operator B
sc_ops = [sqrt(eta) * sqrt(gamma) * a]   # stochastic collapse operator A

In [24]:
result_ref = mesolve(H, rho0, times, c_ops+sc_ops, e_ops)

In [25]:
result = smesolve(H, rho0, times, c_ops, sc_ops, e_ops, ntraj=125, nsubsteps=100,
                  method='homodyne', store_measurement=True)


10.4%. Run time:  66.80s. Est. time left: 00:00:09:35
20.0%. Run time: 129.37s. Est. time left: 00:00:08:37
30.4%. Run time: 196.66s. Est. time left: 00:00:07:30
40.0%. Run time: 259.49s. Est. time left: 00:00:06:29
50.4%. Run time: 326.79s. Est. time left: 00:00:05:21
60.0%. Run time: 388.63s. Est. time left: 00:00:04:19
70.4%. Run time: 456.23s. Est. time left: 00:00:03:11
80.0%. Run time: 518.94s. Est. time left: 00:00:02:09
90.4%. Run time: 585.64s. Est. time left: 00:00:01:02
Total run time: 648.09s

In [26]:
plot_expectation_values([result, result_ref]);



In [27]:
fig, ax = subplots(figsize=(8,4))

M = sqrt(eta) * sqrt(gamma)

for m in result.measurement:
    ax.plot(times, m[:, 0].real / M, 'b', alpha=0.025)

ax.plot(times, result_ref.expect[1], 'k', lw=2);

ax.set_ylim(-25, 25)
ax.set_xlim(0, times.max())
ax.set_xlabel('time', fontsize=12)
ax.plot(times, array(result.measurement).mean(axis=0)[:,0].real / M, 'b', lw=2);


Form 2: Combined homodyne with deterministic dissipation for missed detection events

$\displaystyle D_{1}[A]\rho(t) = \mathcal{D}[\kappa a]\rho(t) = \mathcal{D}[A]\rho(t)$


In [28]:
def d1_rho_func(A, rho_vec):
    return A[7] * rho_vec

$\displaystyle D_{2}[A]\rho(t) = \sqrt{\eta} \mathcal{H}[\sqrt{\kappa} a]\rho(t) = \sqrt{\eta} \mathcal{H}[A]\rho(t) = \sqrt{\eta}(A\rho + \rho A^\dagger - \mathrm{Tr}[A\rho + \rho A^\dagger] \rho) \rightarrow \sqrt{\eta} \left((A_L + A_R^\dagger)\rho_v - \mathrm{Tr}[(A_L + A_R^\dagger)\rho_v] \rho_v\right)$


In [29]:
def d2_rho_func(A, rho_vec):
    n_sum = A[0] + A[3]
    e1 = expect_rho_vec(n_sum, rho_vec, False)
    return [sqrt(eta) * (n_sum * rho_vec - e1 * rho_vec)]

In [30]:
c_ops = []
sc_ops = [sqrt(gamma) * a]

In [31]:
result_ref = mesolve(H, rho0, times, c_ops+sc_ops, e_ops)

In [32]:
result = smesolve(H, rho0, times, [], sc_ops, e_ops, 
                  ntraj=125, nsubsteps=100, d1=d1_rho_func, d2=d2_rho_func,
                  m_ops=[[a + a.dag()]], dW_factors=[1/sqrt(gamma * eta)],
                  distribution='normal', store_measurement=True)


10.4%. Run time:  71.73s. Est. time left: 00:00:10:17
20.0%. Run time: 139.12s. Est. time left: 00:00:09:16
30.4%. Run time: 212.34s. Est. time left: 00:00:08:06
40.0%. Run time: 278.35s. Est. time left: 00:00:06:57
50.4%. Run time: 349.04s. Est. time left: 00:00:05:43
60.0%. Run time: 412.66s. Est. time left: 00:00:04:35
70.4%. Run time: 484.11s. Est. time left: 00:00:03:23
80.0%. Run time: 548.44s. Est. time left: 00:00:02:17
90.4%. Run time: 617.82s. Est. time left: 00:00:01:05
Total run time: 681.04s

In [33]:
plot_expectation_values([result, result_ref]);



In [34]:
fig, ax = subplots(figsize=(8,4))

for m in result.measurement:
    ax.plot(times, m[:, 0].real, 'b', alpha=0.025)

ax.plot(times, result_ref.expect[1], 'k', lw=2);

ax.set_ylim(-25, 25)
ax.set_xlim(0, times.max())
ax.set_xlabel('time', fontsize=12)
ax.plot(times, array(result.measurement).mean(axis=0)[:,0].real, 'b', lw=2);


Versions


In [35]:
from qutip.ipynbtools import version_table

version_table()


Out[35]:
SoftwareVersion
QuTiP3.0.0.dev-ae1db71
OSposix [linux]
Python3.3.2+ (default, Oct 9 2013, 14:50:09) [GCC 4.8.1]
Numpy1.9.0.dev-d4c7c3a
matplotlib1.4.x
Cython0.20.post0
IPython2.0.0-dev
SciPy0.15.0.dev-c04c506
Fri Mar 07 15:50:53 2014 JST