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.
In [1]:
%pylab inline
In [2]:
from qutip import *
In [3]:
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
In [4]:
steadystate_fock_distribution(250, 0);
In [5]:
steadystate_fock_distribution(250, 150);
In [1]:
%pylab inline
In [2]:
from qutip import *
In [3]:
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)
Out[3]:
In [4]:
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)
Out[4]:
In [12]:
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)
Out[12]:
In [14]:
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)
Out[14]:
In [6]:
from qutip.ipynbtools import version_table; version_table()
Out[6]: