Skip to content

4.5

A numerical solver for custom potentials

Package last section's method into a general-purpose solver: feed in any potential curve, get back levels and wavefunctions — then commission it on the double well, explaining the ammonia maser along the way.

Recommended first

After this section you should be able to

  • Wrap the finite difference method into a solver usable for any V(x), and handle the unit conversions
  • Sign off numerical results against a checklist: node counts, parity, orthogonality, double convergence
  • Solve the double well with the solver, read off the tunneling splitting, and explain its exponential sensitivity
  • Deduce the period of left-right oscillation from a split pair of levels, connecting to the ammonia maser and the chemical bond

Last section we walked the finite difference method through, end to end, on the harmonic oscillator. But fiddling afresh with grid, units, and checks at every change of potential is no way to live. This section does two things: package the method into a solver you can grab whenever you need it; then use it to chew through a bone analytic methods cannot crack — the double well — and read genuine physics out of the numbers: the ammonia molecule’s microwave maser, and the embryo of the chemical bond.

The solver itself

The code is almost a reprint of last section’s; the one new idea is passing the potential in as a parameter — any function that can evaluate on an array will do:

import numpy as np
from scipy.linalg import eigh_tridiagonal

def solve(V, L, N, k=6):
    """Solve -psi''/2 + V(x) psi = E psi (dimensionless units hbar = m = 1).

    V : potential function, accepts a numpy array
    L : width of the solution interval [-L/2, L/2] (both ends treated as infinitely high walls)
    N : number of interior grid points
    k : number of lowest levels requested
    Returns: grid x, levels E[0..k-1], wavefunctions psi[:, i] (normalised)
    """
    x = np.linspace(-L/2, L/2, N + 2)[1:-1]
    h = x[1] - x[0]
    diag = 1.0 / h**2 + V(x)
    off  = -0.5 / h**2 * np.ones(N - 1)
    E, psi = eigh_tridiagonal(diag, off, select='i', select_range=(0, k - 1))
    return x, E, psi / np.sqrt(h)

First run it on a known answer to make sure nothing was miscopied:

x, E, psi = solve(lambda x: 0.5 * x**2, L=16, N=1000)
print(np.round(E, 4))    # [0.5  1.5  2.4999  3.4998  4.4997  5.4995]

The oscillator levels n+12n+\frac12 arrive on schedule.

What about units? The code runs in dimensionless units with =m=1\hbar=m=1 — not laziness but standard numerical practice: it keeps numbers of order 103410^{-34} from rampaging through the floating-point arithmetic. The conversion rule fits in one sentence: pick a length unit L0L_0, and the energy unit is automatically ε0=2/(mL02)\varepsilon_0=\hbar^2/(mL_0^2). For an electron with L0=1L_0=1 nm:

ε0=(c)2mc2L02=197.32511000×120.0762 eV(4.5.1)\varepsilon_0=\frac{(\hbar c)^2}{mc^2\,L_0^2}=\frac{197.3^2}{511000\times1^2}\approx0.0762\ \text{eV}\tag{4.5.1}

Scale the real potential by ε0\varepsilon_0 into dimensionless numbers before feeding it in, multiply the computed EE back by ε0\varepsilon_0, and you have eV.

Commissioning trial: the double well

Now the main course. Take

V(x)=V0(x21)2(4.5.2)V(x)=V_0\,(x^2-1)^2\tag{4.5.2}

Two minima at x=±1x=\pm1, separated by a hump of height V0V_0. This is a graveyard for analytic methods — no closed-form solution — but a gold mine for physics: the nitrogen atom of ammonia flipping between the two sides of its hydrogen plane, the shared electron of a chemical bond, the double-well circuit of a superconducting qubit — all are variations on it.

To the solver it is nothing special. Change one line:

x, E, psi = solve(lambda x: 20.0 * (x**2 - 1)**2, L=8, N=2000)
print(np.round(E, 3))    # [6.036  6.056  16.23  17.111  23.379  27.933]

Stare at that string of numbers — it is telling a story:

  • E0=6.036E_0=6.036 and E1=6.056E_1=6.056 are squeezed into a pair, split by only ΔE=0.019\Delta E=0.019, while E1E_1 to E2E_2 is a full 10.210.2 apart. The levels no longer spread out evenly: they come in pairs, nearly degenerate within each pair.
  • Check the wavefunctions: ψ0\psi_0 is even — one bump over each well, joined with the same sign; ψ1\psi_1 is odd — the same two bumps, the right one flipped, crossing zero in the middle. Checklist item 3 passes: symmetric potential, even-odd alternation.
  • The oscillator limit checks out too (item 5): near a single well bottom V(±1)=8V0=160V''(\pm1)=8V_0=160, effective frequency ω=16012.6\omega=\sqrt{160}\approx12.6, zero-point energy about ω/26.3\omega/2\approx6.3 — consistent with E06.0E_0\approx6.0, the shortfall being exactly the anharmonic correction.

Why squeezed into a pair? Imagine the hump infinitely high: the left and right wells are two sealed-off worlds, each with a ground state at exactly the same energy — strict two-fold degeneracy. With the hump finite, the two wells’ wavefunction tails meet under the peak by tunneling, the degeneracy breaks, and one level splits into two. ΔE\Delta E is the tunneling splitting, a direct gauge of how easily the wells “visit each other”.

The numerics can verify this interpretation on the spot: lower the hump from V0=20V_0=20 to 1010, and the splitting jumps from 0.0190.019 to 0.1250.125 — halve the hump, and the splitting grows more than sixfold. This wildly disproportionate response is the fingerprint of section 2.11’s tunneling exponential e2κa\ee^{-2\kappa a}: the splitting is exponentially sensitive to the barrier parameters.

From a pair of levels to a back-and-forth oscillation

A nearly degenerate pair of levels is not just decoration on the spectrum — it hides a clock.

Make it your own instrument

From here on, this solver is your laboratory bench. A few potentials worth running by hand (remember the sign-off checklist for each):

  • The asymmetric double well V0(x21)2+λxV_0(x^2-1)^2+\lambda x: add a tiny tilt λ\lambda and watch the nearly degenerate pair get prised apart, each wavefunction retreating into its own well — the numerical edition of section 4.1’s “no symmetry, no parity”.
  • The tilted-floor well V=αxV=\alpha x (for x>0x>0, wall at the left end): the triangular well, the real predicament of electrons at a semiconductor heterojunction interface.
  • The truncated oscillator: flatten x2/2x^2/2 above some height, count how many bound states survive, and compare with section 4.1’s z0z_0 counting rule.

Publication-grade code adds two more items: the Numerov method to lift the accuracy from O(h2)O(h^2) to O(h4)O(h^4), and imaginary-time evolution for two and three dimensions — but the skeleton never changes: discretise, diagonalise, sign off.

End of chapter

Take stock of what this chapter has added to the toolkit: parity used one commutator to sort the bound states into even-odd alternation, striking out a batch of integrals for free; the phase shift condensed scattering into a single angle, with resonances and bound states shaking hands in Levinson’s theorem; the transfer matrix turned multilayer structures into 2×22\times2 multiplication, delivering resonant tunneling and energy bands; finite differences landed “operators are matrices” as running code, making any one-dimensional potential a ten-line program. The one-dimensional world, it is fair to say, is now firmly in hand.

But real atoms are not one-dimensional. The electron in hydrogen lives in a three-dimensional Coulomb potential, and three dimensions bring a character one dimension simply lacks: rotation. A particle can orbit the nucleus, and rotation has speed and direction — angular momentum takes the stage. The good news: every one of your tools carries over. For a central potential, the 3D equation separates into a radial equation that lives exactly on the half-axis — precisely the “wall plus potential” stage of section 4.2. The bad news (really the most exciting news): the angular part is a world of its own. The three components of angular momentum fail to commute pairwise, [L^x,L^y]=iL^z[\hat L_x,\hat L_y]=\ii\hbar\hat L_z — and chapter 3’s commutator algebra will no longer be a mere test of “can they be measured sharply together”, but the very tool that builds the allowed values of angular momentum, one rung at a time.

Chapter 5 — it begins with rotation.

Section 35 of 106 · use to turn the page