File:QHO-Fockstate0123.png

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

QHO-Fockstate0123.png(300 × 300 pixels, file size: 23 KB, MIME type: image/png)

Captions

Captions

Add a one-line explanation of what this file represents

Summary[edit]

Description
Date
Source Own work
 
This plot was created with Matplotlib.
Author Geek3
Other versions QHO-Fockstate0123-animation-color.gif

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
import numpy as np
from numpy.polynomial.hermite import Hermite

plt.rc('path', snap=False)
plt.rc('mathtext', default='regular')

# image settings
fname = 'QHO-Fockstate0123'
width, height = 300, 300
ml, mr, mt, mb = 35, 8, 22, 45
x0, x1 = -4, 4
y0, y1 = 0.0, 0.7

def plot():
    for nfock in range(4):
        ax = axi[3-nfock]
        ax.cla()
        ax.axis((x0, x1, y0, y1))
        ax.grid(True)
        plt.yticks([0.0, 0.2, 0.4, 0.6], ['0.0', '0.2', '0.4', ''])
        if nfock != 0:
            ax.set_xticklabels([])
        ax.plot(0, 0, color=(1,1,1,0), label=r'$\vert{}\rangle$'.format(nfock))
        
        psi_fock = np.eye(1, nfock+1, nfock).flatten()
        # Definition of Fock-states in terms of Hermite functions:
        # https://en.wikipedia.org/wiki/Quantum_harmonic_oscillator
        a_hermite = [psi_fock[n] * pi**-0.25 / sqrt(2.**n*factorial(n))
                     for n in range(1+nfock)]
        # doc: http://docs.scipy.org/doc/numpy/reference/generated/numpy.polynomial.hermite.Hermite.html
        H = Hermite(a_hermite)
        
        x = np.linspace(x0, x1, 2 * width)
        psi_x = np.exp(-x**2 / 2.0) * H(x)
        y = np.abs(psi_x)**2
        
        ax.plot(x, y, lw=2, color='#0000cc')
        leg = ax.legend(handlelength=0, handletextpad=0, borderpad=0.1,
                  borderaxespad=0.45, loc='upper left', fontsize=17)
        leg.get_frame().set_linewidth(0.0)

plt.close('all')
fig, axi = plt.subplots(4, sharey=True, 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)

# 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')

plot()
plt.savefig(fname + '.png')

# compress with optipng
from os import system
cmd = 'optipng -o9 "' + fname + '.png"'
if system(cmd) != 0:
    print 'warning: optipng not found!'

Licensing[edit]

I, the copyright holder of this work, hereby publish it under the following licenses:
GNU head 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.
w:en:Creative Commons
attribution
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/TimeThumbnailDimensionsUserComment
current13:30, 4 October 2015Thumbnail for version as of 13:30, 4 October 2015300 × 300 (23 KB)Geek3 (talk | contribs)legend added
22:29, 20 September 2015Thumbnail for version as of 22:29, 20 September 2015300 × 300 (24 KB)Geek3 (talk | contribs){{Information |Description ={{en|1=Probability distribution of the quantum wave functions of the Fock states with n=0..3 in a [[:en:Quantum harmonic oscillator|Quantum harmoni...

File usage on other wikis

The following other wikis use this file:

Metadata