Physics Forums Insights
  • Physics
    • Physics Articles
    • Physics Tutorials
    • Physics Guides
    • Physics FAQs
  • Math
    • Math Articles
    • Math Tutorials
    • Math Guides
    • Math FAQs
  • Bio/Chem/Tech
    • Bio/Chem Articles
    • Computer Science Tutorials
    • Technology Guides
  • Education
    • Education Articles
    • Education Guides
  • Interviews
  • Quizzes
  • Forums
  • Click to open the search input field Click to open the search input field Search
  • Menu Menu
2D Animation

Particle in a Box: 1D & 2D Quantum Visualizations

May 4, 2015/11 Comments/in Physics Tutorials/by Josh Meyer
📖Read Time: 4 minutes
📊Readability: Moderate (Standard complexity)
🔖Core Topics: particletimeboxenergylx

Table of Contents

  • Introduction
  • Why classical intuition fails
    • Key quantum results
  • The Schrödinger equation and separation of variables
  • The 1-D wavefunction and boundary conditions
    • Normalized stationary state
  • Simulating the 1-D solution
  • The 2-D particle in a box
  • Simulating the 2-D solution
  • Feedback
  • Learn More
    • More Related Articles

Introduction

The particle in a box is a staple of entry-level quantum mechanics courses because it provides a clear contrast between classical and quantum dynamics. It is one of the few problems that can be solved exactly, without approximations. I suspect most readers solved only the 1-D particle-in-a-box in class and did not explore the larger picture, visualizing solutions, or higher-dimensional examples. Others reading this may work in a scientific field other than physics but are curious about the peculiarities of quantum mechanics.

In this Insight I briefly outline why the particle-in-a-box problem is important, what the solutions mean, and what the solutions look like in higher dimensions (2-D). Along the way you can pick up MATLAB code for making your own visualizations.

Why classical intuition fails

In the 1-D model the particle is free to move (potential energy V = 0) along a line of length Lx. No forces act on the particle inside the box; the walls are treated as impenetrable because the region outside the box has infinitely large potential (V = ∞).

Classical mechanics says that a particle in a 1 m box can have any speed and is equally likely to be found at any position along the line. That prediction changes dramatically when the box length is on the order of a nanometer (1×10-9 m), where quantum mechanics applies. The quantum solution gives several nonintuitive results:

Key quantum results

  1. The particle is more likely to be found in certain positions than others, depending on its energy.
  2. There are nodes—positions where the probability density is always zero.
  3. The particle’s energy is restricted to a discrete set of allowed energy levels (quantization).
  4. The particle cannot have zero energy; it always has nonzero motion (zero-point energy).

The Schrödinger equation and separation of variables

We solve the problem using the time-dependent Schrödinger equation. I omit many mathematical steps; the references below fill in details.

i ħ ∂Ψ(x,t)/∂t = −(ħ² / 2m) ∂²Ψ(x,t)/∂x² + V(x) Ψ(x,t)

Here the variables are:

  • Ψ — the wave function (encodes position, momentum, and energy information)
  • V — potential energy
  • x — position
  • t — time
  • ħ — reduced Planck’s constant
  • m — particle mass
  • i — imaginary unit

With a time-independent potential we use separation of variables, assuming Ψ(x,t) = ψ(x) φ(t). Substituting and separating gives a spatial eigenvalue equation and a time equation, both equal to the same constant E (the energy):

−(ħ² / 2m) d²ψ(x)/dx² + V(x) ψ(x) = E ψ(x)

i ħ dφ(t)/dt = E φ(t)

The spatial solutions are time-independent and are therefore called stationary states; each corresponds to a definite energy.

The 1-D wavefunction and boundary conditions

Solving the spatial equation in a region of zero potential yields a general solution:

ψ(x) = A sin(kx) + B cos(kx)

Impenetrable walls impose boundary conditions ψ(0) = ψ(Lx) = 0, which forces B = 0 and restricts the wavenumber to k = n π / Lx for integer n = 1, 2, 3, …. Thus

ψn(x) = A sin(n π x / Lx)

The corresponding energy levels are

En = ħ ω = (ħ² k²) / (2 m) = (n² π² ħ²) / (2 m Lx²)

Normalized stationary state

Choosing normalization constant A = sqrt(2 / Lx) gives the full time-dependent wavefunction for mode n:

Ψn(x,t) = sqrt(2 / Lx) sin(n π x / Lx) e−i ω t

Simulating the 1-D solution

For visualization you can assign unit values to constants (for clarity) and plot the real part of Ψ(x,t) as it evolves in time. See the MATLAB code and animation below.

View the code for the 1-D time simulation


1D Particle Animation
Figure: Real part of Ψ(x,t) for a 1-D particle (example mode). Note the nodes where the wave function is always zero.

The 2-D particle in a box

In 2-D the particle is confined to a rectangle of width Lx and height Ly. The 2-D time-independent Schrödinger equation becomes

−(ħ² / 2m) (∂²ψ(x,y)/∂x² + ∂²ψ(x,y)/∂y²) + V(x,y) ψ(x,y) = E ψ(x,y)

Using separation of variables again, set ψ(x,y) = f(x) g(y). Each factor satisfies a 1-D-type equation, so the spatial eigenfunctions are products of sines:

Ψn_x,n_y(x,y,t) = sqrt(4 / (Lx Ly)) sin(kx x) sin(ky y) e−i ω t

Here kx = nx π / Lx, ky = ny π / Ly, and nx, ny = 1, 2, 3, …. The probability density has more nodes in 2-D, forming a grid of nodal lines depending on the two quantum numbers.

Simulating the 2-D solution

You can extend the 1-D MATLAB code to 2-D by evaluating the product sin(kx x) sin(ky y) on a grid and animating the real part in time.

View the code for the 2-D time-simulation for (nx, ny) = (4,4)


2D Particle Animation (4,4)
Figure: Time evolution for the 2-D mode (nx, ny) = (4,4). Nodes form a grid of lines where the particle cannot be found.

For multiple mode combinations see the full simulation code and the combined animation below.

View code for the full 2-D time-simulation


2D Particle Multiple Modes Animation
Figure: Animation showing several (nx,ny) mode combinations.

Feedback

Please leave comments or send me a message with any feedback so I can improve future posts.

Learn More

  1. 2-D wells — University of Virginia
  2. Particle in a box — Wikipedia
  3. HyperPhysics: Particle in a box
  4. Short video demonstration
  5. Supplementary notes: Particle in a Box (2-D)
Josh Meyer

Josh received a BA in Physics from Clark University in 2009, and an MS in Physics from SUNY Albany in 2012. He currently works as a technical writer for MathWorks, where he writes documentation for MATLAB.

More Related Articles

  • What are Virtual Particles? A 10 Minute Introduction
  • Understanding Superposition Physically and Mathematically
  • Struggles with the Continuum – Relativity and Quantum
  • Exploring the Anatomy of Compton Scattering
  • Explore Some Sins in Physics Didactics
  • Quantum Mechanics and the Famous Double-slit Experiment
Tags: MATLAB, quantum mechanics
Share this entry
  • Share on Facebook
  • Share on X
  • Share on WhatsApp
  • Share on LinkedIn
  • Share on Reddit
  • Share by Mail
https://www.physicsforums.com/insights/wp-content/uploads/2015/05/2danimation.png 135 240 Josh Meyer https://www.physicsforums.com/insights/wp-content/uploads/2019/02/Physics_Forums_Insights_logo.png Josh Meyer2015-05-04 14:01:352026-02-16 10:19:07Particle in a Box: 1D & 2D Quantum Visualizations
You might also like
arrowoftime Retrocausality: How Fundamental is the Arrow of Time?
virtualparticlesmyths Top Misconceptions about Virtual Particles
quantum mechanics is incomplete 9 Reasons Quantum Mechanics is Incomplete
qm_interpretations The Fundamental Difference in Interpretations of Quantum Mechanics
entanglement_entropy Learn Entanglement Entropy in Quantum Mechanics
vaccummyth Explore The Vacuum Fluctuation Myth in Quantum Theory
11 replies
  1. jtbell says:
    May 19, 2016 at 3:55 pm

    Sure, for a rectangular 3D “particle in a box.”

    Log in to Reply
  2. Jimster41 says:
    May 19, 2016 at 3:55 pm

    I think I made (or am working on) a connection that I hadn’t made, and I hope it is “not wrong”, but please tell me if it is.

    The periodic shape of wavefunction (the wavenumber?) for the given box “size” and the given energy, is dictated by way(s) that energy is divided by h (which, like the size dimension x of the box, is a “size”). The result is discrete scale invariant, is that correct?

    Sorry for treating the insights as a regular old thread, but they are little bit like a class where you would love to be able to raise your hand. o_O and get yourself squared up. Moreso IMHO than regular question threads which can be pretty chaotic and often you are just trying to figure out what the conversation is about. Or you are having to frame a question without such lucid context, and are not even sure if your terms are right.

    Log in to Reply
  3. jtbell says:
    May 19, 2016 at 3:55 pm

    “Trying to picture what happens if you suddenly increase the size of the box.”

    This is actually a fairly common exercise for students studying the one-dimensional particle in a box. Basically you start by assuming that the wave function ##Psi(x,t)## does not change at the instant the box increases in size. If it was originally in the ground state, it goes from this:

    [ATTACH=full]83125[/ATTACH]

    to something like this:

    [ATTACH=full]83126[/ATTACH]

    Which doesn’t look very interesting, does it? But, just let some time elapse!

    In the original box, ##Psi## is an energy eigenstate ##psi_k(x) e^{-iE_k t / hbar}## with a fixed energy. The probability distribution ##|Psi|^2## maintains the same shape, so we call it a “stationary state”.

    In the new box, ##Psi## is a superposition (linear combination) of the new energy eigenstates, e.g. :

    [ATTACH=full]83127[/ATTACH]

    for the new ground state and first excited state. Each of these eigenstates oscillates at a different frequency, so the probability distribution of the superposition does not maintain the same shape, that is, it is not a “stationary state.” The probability distribution “sloshes” around inside the new box as time passes, starting from the probability distribution of the original wave function.

    To see what this actually looks like for a specific case, you have to work out the coefficients A[SUB]k[/SUB] of the linear combination that expresses the spatial part of the original ##psi(x)## in terms of the spatial part of the new energy eigenstates: $$psi(x) = Sigma {A_k psi_k^prime(x)}$$ Then you can find the new time-dependent wave function $$Psi(x,t) = Sigma A_k psi_k^prime(x) e^{-iE_k t / hbar}$$ and the new probability distribution $$P(x,t) = |Psi(x,t)|^2$$

    Log in to Reply
  4. Greg Bernhardt says:
    May 19, 2016 at 3:55 pm

    Great first entry kreil!

    Log in to Reply
  5. Atlas3 says:
    May 7, 2015 at 3:54 am

    Can the plot above labeled by "Here is the time-simulation for (nx,ny)=(4,4). In this case, the spots where the wave function is always zero are more numerous, and form a grid."  fill a volume if stacked in another dimension?

    Log in to Reply
  6. Jimster41 says:
    May 6, 2015 at 4:49 pm

    No,no, sorry, it's just plain periodic.

    Log in to Reply
  7. Jimster41 says:
    May 6, 2015 at 12:39 pm

    Re-reading after thinking about it. I’d like to ask questions in context, but I don’t want to distract from a great, clear tutorial. Trying to picture what happens if you suddenly increase the size of the box. My guess was that the response is sort of quantized (or harmonic) due to the periodicity of the wave equation, that there would be no noticeable change until a new peak, or a new coherent wave frequency or pattern across the whole box was accommodated. Is that threshold Planck size? Also, was picturing the overall energy density probability going down, which seems naively consistent with thermodynamic expectation? At the moment when a new wave function suddenly “fits” the “expectation” wave spontaneously re-forms instantaneously everywhere to take this new shape? What if the box is huge?

    Log in to Reply
  8. Josh Meyer says:
    May 6, 2015 at 1:18 am

    Thanks guys, glad it was clear enough for non-physicists to follow! If you have any suggestions for future topics please let me know.

    Log in to Reply
  9. PWiz says:
    May 4, 2015 at 3:06 pm

    Nice! The blog’s mathematical presentation is pretty simple and easy to understand as well. Gotta have one of these in the starting chapters of every introductory QM book ;)

    Log in to Reply
  10. Fooality says:
    May 4, 2015 at 2:48 pm

    Absolutely excellent. I am not a physicist, but have an interest in understanding QM and this article was perfect: The visualizations and instructions for computer simulation relate the ideas better than anything I’ve read.

    Log in to Reply
  11. Jimster41 says:
    May 4, 2015 at 2:15 pm

    cool. Thanks for the lucid tutorial!

    Log in to Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply Cancel reply

You must be logged in to post a comment.

Trending Articles

  • Explosion-Generated Collapsing Vacuum Bubbles Reach 20,000 Kelvin
  • Explore Some Sins in Physics Didactics
  • It’s Elemental! The Periodic Table Quiz
  • Do Black Holes Really Exist?
  • Grab Bag Science Quiz and Trivia

Physics Forums

  • Classical Physics
  • Atomic and Condensed Matter
  • Quantum Physics
  • Special and General Relativity
  • Beyond the Standard Model
  • High Energy, Nuclear, Particle Physics
  • Astronomy and Astrophysics
  • Cosmology
  • Other Physics Topics

Receive Insights Articles to Your Inbox

Enter your email address:

Blog Information

  • Become a Member!
  • Write for Us!
  • Table of Contents
  • Blog Author List

Popular Topics

astronomy (17) black holes (17) classical physics (35) cosmology (16) education (23) electromagnetism (19) general relativity (19) gravity (24) interview (21) mathematics (39) mathematics self-study (21) Physicist (26) programming (18) Quantum Field Theory (31) quantum mechanics (36) quantum physics (24) relativity (40) Special Relativity (16) technology (19) universe (21)
2026 © Physics Forums, ALL RIGHTS RESERVED - Contact Us - Privacy Policy - About PF Insights
  • Link to X
  • Link to Facebook
  • Link to LinkedIn
  • Link to Youtube
Link to: LHC Part 2: Commissioning Link to: LHC Part 2: Commissioning LHC Part 2: CommissioningLink to: Overcoming Challenges of Self-Studying Number Theory Link to: Overcoming Challenges of Self-Studying Number Theory ADHD studyingOvercoming Challenges of Self-Studying Number Theory
Scroll to top Scroll to top Scroll to top