File:QHO-squeezed-vacuum1dB-animation.gif
QHO-squeezed-vacuum1dB-animation.gif (300 × 200 pixels, file size: 48 KB, MIME type: image/gif, looped, 30 frames, 1.5 s)
File information
Structured data
Captions
Captions
Add a one-line explanation of what this file represents
Summary
editDescriptionQHO-squeezed-vacuum1dB-animation.gif |
English: Animation of the probability distribution of the quantum wave function of a squeezed vacuum state in a Quantum harmonic oscillator with 1dB of squeezing. The gaussian wave packet oscillates between a squeezed and an anti-squeezed state. |
Date | |
Source |
Own work![]() This plot was created with Matplotlib. |
Author | Geek3 |
Other versions | QHO-squeezed-vacuum1dB-animation-color.gif |
Python Matplotlib source code |
---|
#!/usr/bin/python
# -*- coding: utf8 -*-
from math import *
import matplotlib.pyplot as plt
from matplotlib import animation
import numpy as np
import os, sys
# image settings
fname = 'QHO-squeezed-vacuum1dB-animation'
plt.rc('path', snap=False)
plt.rc('mathtext', default='regular')
width, height = 300, 200
ml, mr, mt, mb = 35, 8, 22, 45
x0, x1 = -3.5, 3.5
y0, y1 = 0.0, 0.8
nframes = 30
fps = 20
# physics settings
omega = 2 * pi
xi0 = -0.1 * log(10) # 1dB of squeezing
def squeezed(xi0, x, omega_t):
# Definition of squeezed states
xi = xi0 * e**(-2j * omega_t)
r = np.abs(xi)
tr = tanh(r)
kk = (r - tr * xi) / (r + tr * xi)
psi = (kk.real/pi)**0.25 * np.exp(-0.5j * omega_t - 0.5 * x**2 * kk)
return psi
def animate(nframe):
print str(nframe) + ' ',; sys.stdout.flush()
t = float(nframe) / nframes * 0.5 # animation repeats after t=0.5
ax.cla()
ax.grid(True)
ax.axis((x0, x1, y0, y1))
x = np.linspace(x0, x1, int(ceil(1+w_px)))
psi = squeezed(xi0, x, omega*t)
y = np.abs(psi)**2
plt.plot(x, y, lw=2, color='#0000cc')
ax.set_yticks(ax.get_yticks()[:-1])
ax.set_yticklabels([l for l in ax.get_yticks() if l < y0+0.9*(y1-y0)])
# create figure and axes
plt.close('all')
fig, ax = plt.subplots(1, figsize=(width/100., height/100.))
bounds = [float(ml)/width, float(mb)/height,
1.0 - float(mr)/width, 1.0 - float(mt)/height]
fig.subplots_adjust(left=bounds[0], bottom=bounds[1],
right=bounds[2], top=bounds[3], hspace=0)
w_px = width - (ml+mr) # plot width in pixels
# axes labels
fig.text(0.5 + 0.5 * float(ml-mr)/width, 4./height,
r'$x\ \ [(\hbar/(m\omega))^{1/2}]$', ha='center')
fig.text(5./width, 1.0, '$|\psi|^2$', va='top')
# start animation
if 0 != os.system('convert -version > ' + os.devnull):
print 'imagemagick not installed!'
# warning: imagemagick produces somewhat jagged and therefore large gifs
anim = animation.FuncAnimation(fig, animate, frames=nframes)
anim.save(fname + '.gif', writer='imagemagick', fps=fps)
else:
# unfortunately the matplotlib imagemagick backend does not support
# options which are necessary to generate high quality output without
# framewise color palettes. Therefore save all frames and convert then.
if not os.path.isdir(fname):
os.mkdir(fname)
fnames = []
for frame in range(nframes):
animate(frame)
imgname = os.path.join(fname, fname + '{:03d}'.format(frame) + '.png')
fig.savefig(imgname)
fnames.append(imgname)
# compile optimized animation with ImageMagick
cmd = 'convert -loop 0 -delay ' + str(100 / fps) + ' '
cmd += ' '.join(fnames) # now create optimized palette from all frames
cmd += r' \( -clone 0--1 \( -clone 0--1 -fill black -colorize 100% \) '
cmd += '-append +dither -colors 63 -unique-colors '
cmd += '-write mpr:colormap +delete \) +dither -map mpr:colormap '
cmd += '-alpha activate -layers OptimizeTransparency '
cmd += fname + '.gif'
os.system(cmd)
for fnamei in fnames:
os.remove(fnamei)
os.rmdir(fname)
|
Licensing
editI, the copyright holder of this work, hereby publish it under the following licenses:
![]() |
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.http://www.gnu.org/copyleft/fdl.htmlGFDLGNU Free Documentation Licensetruetrue |
![w:en:Creative Commons](https://upload.wikimedia.org/wikipedia/commons/thumb/7/79/CC_some_rights_reserved.svg/90px-CC_some_rights_reserved.svg.png)
![attribution](https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Cc-by_new_white.svg/24px-Cc-by_new_white.svg.png)
This file is licensed under the Creative Commons Attribution 3.0 Unported license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
You may select the license of your choice.
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 21:06, 10 October 2015 | ![]() | 300 × 200 (48 KB) | Geek3 (talk | contribs) | smaller filesize |
21:03, 10 October 2015 | ![]() | 300 × 200 (178 KB) | Geek3 (talk | contribs) | {{Information |Description ={{en|1=Animation of the probability distribution of the quantum wave function of a squeezed vacuum state in a [[:en:Quantum harmonic oscillato... |
You cannot overwrite this file.
File usage on Commons
The following page uses this file: