1
#This file is part of QuTIP.
3
# QuTIP is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation, either version 3 of the License, or
6
# (at your option) any later version.
8
# QuTIP is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with QuTIP. If not, see <http://www.gnu.org/licenses/>.
15
###########################################################################
18
# XSQUEEZE illustrates the operator exponential and its use in making a squeezed state
20
# Derived from xsqueeze.m from the Quantum Optics toolbox by Sze M. Tan
24
from mpl_toolkits.mplot3d import Axes3D
25
from matplotlib import cm
28
#-----------------------------------------------------------------------------
29
# XSQUEEZE illustrates the operator exponential and its use in making a squeezed state
30
#-----------------------------------------------------------------------------
32
alpha = -1.0; # Coherent amplitude of field
33
epsilon = 0.5j; # Squeezing parameter
35
#-----------------------------------------------------------------------------
36
# Define displacement and squeeze operators
37
#-----------------------------------------------------------------------------
38
D = qexpm(alpha*trans(a)-conj(alpha)*a); # Displacement
39
S = qexpm(0.5*conj(epsilon)*a*a-0.5*epsilon*trans(a)*trans(a)); # Squeezing
40
psi = D*S*basis(N,0); # Apply to vacuum state
44
#-----------------------------------------------------------------------------
45
#pause # Press [Enter] to calculate Wigner function
46
#-----------------------------------------------------------------------------
47
xvec = arange(-40.,40.)*5./40
48
X,Y = meshgrid(xvec, xvec)
50
W=wigner(psi,xvec,xvec)
56
ax.plot_surface(X, Y, W, rstride=2, cstride=2, cmap=cm.jet, alpha=0.7)
57
ax.contour(X, Y, W, 15,zdir='x', offset=-6)
58
ax.contour(X, Y, W, 15,zdir='y', offset=6)
59
ax.contour(X, Y, W, 15,zdir='z', offset=-0.3)
62
ax.set_zlim3d(-0.3,0.4)
66
#title('Wigner function of squeezed state');
67
#-----------------------------------------------------------------------------
68
#pause # Press [Enter] to calculate Q function
69
#-----------------------------------------------------------------------------
70
Q = qfunc(psi,xvec,xvec,g);
76
ax.plot_surface(X, Y, Q, rstride=2, cstride=2, cmap=cm.jet, alpha=0.7)
77
ax.contour(X, Y, Q,zdir='x', offset=-6)
78
ax.contour(X, Y, Q,zdir='y', offset=6)
79
ax.contour(X, Y, Q, 15,zdir='z', offset=-0.4)
82
ax.set_zlim3d(-0.3,0.4)
86
#f2 = figure(2); pcolor(xvec,yvec,real(Q));
88
#title('Q function of squeezed state');
89
#-----------------------------------------------------------------------------
90
#pause # Press [Enter] to end demonstration
91
#-----------------------------------------------------------------------------
92
#delete(f1); delete(f2);