Making Quantum Mechanics Visible: A Browser-Native Laboratory for Pakistani Classrooms
Quantum mechanics is usually taught through equations and static diagrams, while the phenomena it describes — interference, quantised energy, and the uncertainty trade-off — are intrinsically dynamic. This note describes a small, open, browser-native laboratory that makes three of those phenomena directly manipulable. The simulations are evaluated from closed-form expressions in real time, require no installation, and run on the low-cost hardware available to most students in Pakistan. I document the physical models, the numerical choices that keep them honest, the educational design rationale, and the limitations that remain before classroom evaluation.
1Motivation
A double-slit apparatus, a tunable monochromatic source and a photodetector are not exotic equipment, but they are not available in most intermediate and undergraduate laboratories in Pakistan either. Where apparatus does exist, a class of forty students usually watches one demonstration. The result is that students can state d sin θ = mλ in an examination while holding no intuition for how the fringe spacing responds to the geometry.
The alternative is not a better animation. A video shows one trajectory through parameter space; a simulation lets a student choose the trajectory. The hypothesis behind this project is narrow and testable: if the independent variables of an experiment are exposed as physical controls, students will form a quantitative intuition faster than they do from diagrams, and they will ask better questions about the model itself.
2Design constraints
Four constraints shaped every decision. First, zero installation: the artefact must open on a shared lab machine, a phone, or a borrowed laptop with no administrator rights. Second, zero infrastructure cost: a static build with no server, database or paid API. Third, physical fidelity over visual polish: when the two conflict, the equation wins. Fourth, readable source: the code should be a teaching object in its own right, not a black box, because the project is also a demonstration of research practice.
3Physics models
3.1 Fraunhofer interference from two finite slits
The screen intensity is modelled in the Fraunhofer limit, where the slit-to-screen distance is much larger than the slit separation. Each slit contributes a diffraction envelope and the pair contributes an interference term:
The slit width a is fixed at 22% of d, so the envelope is visible without adding a fourth control. Bright fringes sit at d sin θ = mλ, and for small angles the on-screen spacing reduces to Δy = λL/d, which is displayed live beside the graph. The screen window is fixed at ±4 mm so that the fringe count changes visibly as d, λ and L are varied.
3.2 Exact evolution in an infinite square well
The second simulation solves the time-dependent Schrödinger equation analytically rather than numerically integrating it. For a well of width L, the eigenfunctions and energies are known, so any superposition evolves exactly:
Working in units where ħ = 2m = L = 1 gives Eₖ = k², so the phase of each term advances at a rate proportional to k². The coefficients cₖ are Gaussian in k, centred on the chosen level and normalised. A single eigenstate would be stationary — visually unhelpful — whereas the narrow mixture used here produces genuine back-and-forth motion with a well-defined mean energy ⟨E⟩ = Σ |cₖ|²Eₖ. The expectation value ⟨x⟩ is obtained by Simpson integration of x|ψ|² over 240 intervals, which is exact to well below a pixel for these smooth integrands.
3.3 The uncertainty frontier
The third experiment treats position and momentum as Fourier partners. For a Gaussian state the relation is saturated:
The plot exposes the full (Δx, Δp) plane. Dragging the state point below the hyperbola is impossible: the solver clamps it back to the boundary, so the forbidden region is enforced by the interaction rather than merely shaded. Points above the curve are permitted and correspond to non-minimum states; the product readout and the two inset Gaussians let a student see that the widths are coupled even when the bound is not saturated.
4Numerical implementation
- Sampling. Curves are sampled at one point per device-independent pixel (capped at 420 samples), which keeps the cost linear in width while avoiding visible polygonal artefacts on high-density displays.
- Time stepping. Each frame advances the phase by Δt read from the animation clock and clamped to 50 ms, so a background tab cannot teleport the wave function when it regains focus.
- Rendering budget. Canvas backing stores are scaled by the device pixel ratio, capped at 2. Loops are suspended by an IntersectionObserver when a canvas leaves the viewport and restored on entry.
- Accessibility. Every slider is a native range input with an accessible value text; canvases carry descriptive labels; motion is disabled under prefers-reduced-motion while state changes still repaint.
- Delivery. The site is a static Next.js export served from the edge, so physics runs entirely on the client and the classroom copy has no backend dependency.
5Educational design
Each experiment is presented as a claim, a control panel, and a consequence. The claim is the governing formula; the controls are only the independent variables of that formula; the consequence is rendered twice — once as a physical picture and once as a graph. Presenting both views is deliberate. Students often accept a pattern without connecting it to the quantity being plotted, and the pairing forces the mapping between geometry and intensity to become explicit.
The plain-English explanation and the “Explain with AI” panel are written and reviewed by hand for this version. The panel is intentionally a placeholder: a language model can restate a concept, but it can also hallucinate, so the interface is designed to accept a model later while the shipped text remains deterministic. The wording avoids the two most common classroom misconceptions — that the pattern is painted on the screen, and that uncertainty reflects instrument error. In both cases the simulation itself carries the correction: photons are shown arriving one at a time in the accompanying description, and the uncertainty solver refuses to enter the forbidden region regardless of how carefully the point is dragged.
6Limitations
The apparatus simulated here is idealised. The double-slit model is scalar and Fraunhofer; it ignores polarisation, partial coherence, finite source size and detector resolution. The well is one-dimensional and infinite; there is no tunnelling, no continuum and no decoherence, and the wave function never collapses because no measurement model is implemented. The uncertainty explorer enforces the Robertson bound for conjugate variables but does not model the state preparation that would produce a given pair of spreads. These omissions are deliberate: each one would add controls without adding to the specific intuition the page targets.
There is also no formal evaluation yet. Claims about learning gains should be treated as a hypothesis, not a result. The next stage is a small pre/post study with intermediate students, using the same instrument for a control group taught from diagrams and a group given ten minutes with the sliders.
7Next steps
Three extensions are queued. A single-photon mode that accumulates detections dot by dot would make the measurement postulate visible. A finite-well solver with an adjustable barrier would open tunnelling, the phenomenon most often described but least often seen. And an Urdu interface would remove a language barrier for exactly the students this project is meant to reach. Each is a self-contained module in the existing architecture, which is the practical argument for keeping the physics core separate from the rendering layer.
8References
- [1] Griffiths, D. J. & Schroeter, D. F. (2018). Introduction to Quantum Mechanics, 3rd ed. Cambridge University Press.
- [2] Feynman, R. P., Leighton, R. B. & Sands, M. (1965). The Feynman Lectures on Physics, Vol. III. Addison-Wesley.
- [3] Halliday, D., Resnick, R. & Walker, J. (2021). Fundamentals of Physics, 12th ed. Wiley.
- [4] Heisenberg, W. (1927). Über den anschaulichen Inhalt der quantentheoretischen Kinematik und Mechanik. Zeitschrift für Physik, 43, 172–198.
- [5] Robertson, H. P. (1929). The uncertainty principle. Physical Review, 34(1), 163–164.
- [6] p5.js Reference. Processing Foundation. p5js.org/reference
Rehman, S. U. (2026). Making Quantum Mechanics Visible: A Browser-Native Laboratory for Pakistani Classrooms. Quantum Visual Lab, v1.0.