A Byte of PhysicsLogo

Energy levels

Bound quantum systems permit particular stationary states rather than every energy a classical particle could have. In code, an energy-level calculation is an eigenvalue problem: turn a Hamiltonian into a matrix, solve for eigenpairs, normalize the returned state vectors, and check the residual before you label a level as physical.

Think like a programmer

Do not call an array entry an energy level merely because an eigensolver returned it. Keep the spatial grid, potential, boundary conditions, mass convention, eigenvalue, eigenvector, normalization error, and residual together as one result object.

Model checklist

Inputs
A potential-energy function, spatial interval, grid resolution, mass, boundary conditions, and number of levels requested.
State
The discretized Hamiltonian and its eigenpairs.
Rule
Solve Hψ = Eψ, sort E values, and normalize each ψ with the grid spacing.
Output
Allowed energies, wavefunctions, energy gaps, and residual diagnostics.
Check
For every retained eigenpair, the norm is one within tolerance and Hψ − Eψ is small.

Discretize the model, then test it

For a one-dimensional stationary problem,

\[\hat H\psi(x)=\left[-\frac{\hbar^2}{2m}\frac{d^2}{dx^2}+V(x)\right]\psi(x)=E\psi(x)\]

On an evenly spaced grid with spacing dx, replace the second derivative with a finite difference. That produces a tridiagonal matrix whose diagonal includes the potential and whose neighboring entries represent kinetic coupling. The approximation improves only when the interval, grid, and boundary condition are appropriate for the state being studied.

const norm = Math.sqrt(psi.reduce((sum, value) => sum + value * value * dx, 0));
const normalized = psi.map((value) => value / norm);
const residual = maxAbs(matVec(H, normalized).map((value, i) => value - energy * normalized[i]));

The normalization condition is

\[\int |\psi(x)|^2\,dx=1\]

It gives the displayed wavefunction a stable scale and makes |ψ|² interpretable as a probability density after the model's assumptions are stated. A low residual catches a different class of error: the vector may be normalized but still fail to be an eigenvector of the matrix you actually constructed.

A known answer is a test fixture

For an ideal infinite square well of width L, the analytic levels are

\[E_n=\frac{n^2\pi^2\hbar^2}{2mL^2},\qquad n=1,2,3,\ldots\]

Use that case as a regression fixture before interpreting a custom potential. Refine dx and verify that low-lying numerical energies approach the analytic values. Sorting eigenvalues, fixing an eigenvector sign convention for plots, and reporting the grid make repeated runs comparable.

Try this experiment

Prediction: Halving the ideal well width raises every fixed-n energy by a factor of four.

Evaluate the analytic expression for a chosen n at width L and L/2. Predict the ratio before calculating it, then explain which input in your discretized model needs to change with the physical width.

Where this model breaks

A finite grid can miss narrow features, truncate extended states, and add boundary artifacts. This stationary, nonrelativistic one-particle model omits spin, interactions, measurement dynamics, and relativistic effects. Never present a low residual as evidence that the physical model itself is complete.

Summary

Energy levels are checked eigenpairs, not decorative horizontal lines. Normalize the state, inspect the residual, compare a known potential with an analytic answer, and record the numerical choices that control error.

Glossary

Self-check

  1. Why are normalization and residual separate checks?
  2. What analytic problem is a useful first regression fixture?
  3. How does halving an infinite well's width change a fixed-n energy?

Sources

Model contract

Treat the lesson as a small function before treating it as a fact to memorize. Give every value a unit, keep only the state needed for the next step, and make the output easy to inspect.

\[\text{observable output} = f(\text{inputs},\,\text{state})\]
Inputs
Quantities you set or measure, with units and useful bounds.
State
Values the program must retain to reproduce the next result.
Rule
The relationship or update that turns inputs and state into a result.
Check
A known limit, unit check, invariant, or measured result that can expose a bad model.

Implement the idea as a model

For Energy Levels, write down the quantities you can control, the values your program must retain, and the result a reader could inspect. In Atoms and Solids, the useful program is not the drawing: it is the smallest explicit model that makes a prediction you can test.

Guided experiment

Prediction: changing one declared input while holding the others fixed should change only the outputs that the model connects to that input. Choose one input, predict the direction of change, then check a limiting case such as zero, a symmetric arrangement, or a familiar low-speed or small-change approximation.

Where this model breaks

This lesson is a teaching model, not a complete simulator. Before using it outside the stated question, check which interactions, scales, uncertainties, boundary conditions, and measurement limits it leaves out.

Summary

Treat Energy Levels as a contract: named inputs and units enter a rule, the rule produces an observable result, and a known limit or invariant checks whether the implementation deserves trust.

Glossary

  • Input: a measured value or chosen parameter supplied to a model.
  • State: the smallest set of values needed to continue or reproduce a model.
  • Validation: comparing an output with a known result, limit, invariant, or measurement.

Self-check

  1. Which values are inputs, and which values must remain state?
  2. What observable result would tell you the model is behaving as expected?
  3. Which assumption would you test first before applying the model to a real system?

Model review: turn Energy Levels into a test

Compute bound-state eigenpairs with normalization, sorting, and residual checks.

  1. Name the inputs and units that the atoms and solids model needs.
  2. Separate the state you must keep from values you can calculate when needed.
  3. Write one rule that maps the current state and inputs to an observable result.
  4. Choose a limiting case, unit check, invariant, or known result before trusting an output.
  5. State one assumption you would change before using this simplified model for a real decision.

Share to: