File:QHO-Fockstate1+2squeezed-animation.gif
From Wikimedia Commons, the free media repository
Jump to navigation
Jump to search
QHO-Fockstate1+2squeezed-animation.gif (300 × 200 pixels, file size: 93 KB, MIME type: image/gif, looped, 60 frames, 3.0 s)
File information
Structured data
Captions
Captions
Add a one-line explanation of what this file represents
Summary
[edit]DescriptionQHO-Fockstate1+2squeezed-animation.gif |
English: Animation of the probability distribution of the quantum wave function of a squeezed state in a Quantum harmonic oscillator consisting only of the first two energy eigenstates. The best squeezing reached is a reduction in standard deviation by a factor of |
Date | |
Source |
Own work![]() This plot was created with Matplotlib. |
Author | Geek3 |
Other versions | QHO-Fockstate1+2squeezed-animation-color.gif (with colored phase) |
Source Code
[edit]The plot was generated with Matplotlib.
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
from numpy.polynomial.hermite import Hermite
import os, sys
# image settings
fname = 'QHO-Fockstate1+2squeezed-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 = 60
fps = 20
def animate(nframe):
print str(nframe) + ' ',; sys.stdout.flush()
t = float(nframe) / nframes * 1.0
ax.cla()
ax.grid(True)
ax.axis((x0, x1, y0, y1))
# Definition of Fock-states in terms of Hermite functions:
# https://en.wikipedia.org/wiki/Quantum_harmonic_oscillator
# maximum squeezing is reached for phi=pi/6
psi_fock = np.array([cos(pi/6), sin(pi/6)])
a_hermite = [a * pi**-0.25 / sqrt(2.**n*factorial(n))
* e**(-1j * 2*pi * (n+0.5) * t) for n, a in enumerate(psi_fock)]
# doc: http://docs.scipy.org/doc/numpy/reference/generated/numpy.polynomial.hermite.Hermite.html
H = Hermite(a_hermite)
x = np.linspace(x0, x1, int(ceil(1+w_px)))
psi_x = np.exp(-x**2 / 2.0) * H(x)
y = np.abs(psi_x)**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
[edit]I, 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 | 16:42, 17 October 2015 | ![]() | 300 × 200 (93 KB) | Geek3 (talk | contribs) | {{Information |Description ={{en|1=Animation of the probability distribution of the quantum wave function of a squeezed state in a [[:en:Quantum harmonic oscillator|Quantu... |
You cannot overwrite this file.
File usage on Commons
The following page uses this file: