Copyright (C) 2013, Paul D. Nation & Robert J. Johansson
When we work with harmonic oscillator operators in the number state representation we always need to truncate the number of basis states at a finite number. Usually we pick an upper limit for the number state and use all the number states below this cut off. However, in some problems it can also be useful with a number basis representation that does not start with the zero number state, but rather at some lower cut off. This notebook demonstrates how to do this in QuTiP using the optional offset
argument to oscillator operator functions.
%pylab inline
Populating the interactive namespace from numpy and matplotlib
from qutip import *
def steadystate_fock_distribution(N, offset):
"""
Solve for the steady state of a driven dissipative cavity, given
the upper (N) and lower (offset) cut offs for the number states in
in the basis. Calculate the average photon number in the steady
state and plot the fock state distribution.
"""
N = N - offset
Omega = 1.0 * 2 * pi
kappa = 0.9
a = destroy(N, offset)
n = num(N, offset)
H = Omega * (a + a.dag())
c_ops = [sqrt(kappa) * a]
rho_ss = steadystate(H, c_ops)
title = "Steady state avg. photon number = %.2f" % expect(rho_ss, n)
fig, ax = fock_distribution(rho_ss, offset=offset, unit_y_range=False, title=title)
return fig, ax
steadystate_fock_distribution(250, 0);
steadystate_fock_distribution(250, 150);
%pylab inline
Populating the interactive namespace from numpy and matplotlib
from qutip import *
N = 10
offset = 0
n = num(N, offset=offset)
psi = (basis(N, 2, offset=offset) + basis(N, 4, offset=offset) + basis(N, 6, offset=offset)).unit()
fock_distribution(psi, offset=offset, unit_y_range=False, figsize=(4,3))
expect(n, psi)
4.000000000000001
N = 5
offset = 2
n = num(N, offset=offset)
psi = (basis(N, 2, offset=offset) + basis(N, 4, offset=offset) + basis(N, 6, offset=offset)).unit()
fock_distribution(psi, offset=offset, unit_y_range=False, figsize=(4,3))
expect(n, psi)
4.000000000000001
N = 75
offset = 0
n = num(N, offset=offset)
psi = coherent(N, 6.5, offset=offset)
fock_distribution(psi, offset=offset, unit_y_range=False, figsize=(4,3))
expect(n, psi)
42.24999120237548
N = 50
offset = 20
n = num(N, offset=offset)
psi = coherent(N, 6.5, offset=offset)
fock_distribution(psi, offset=offset, unit_y_range=False, figsize=(4,3))
expect(n, psi)
42.244955490644436
from qutip.ipynbtools import version_table; version_table()
Software | Version |
---|---|
Cython | 0.19.1 |
QuTiP | 2.3.0.dev-15c5f51 |
SciPy | 0.13.0.dev-7c6d92e |
Python | 3.3.1 (default, Apr 17 2013, 22:30:32) [GCC 4.7.3] |
Numpy | 1.8.0.dev-b307a8a |
matplotlib | 1.4.x |
IPython | 2.0.0-dev |
OS | posix [linux] |
Fri Aug 30 15:46:41 2013 JST |