Skip to content

Switch animations to |ψ|² (probability density) instead of Re/Im of ψ#2

Open
sgaofen wants to merge 3 commits into
qcrash:mainfrom
sgaofen:viz-default-psi2
Open

Switch animations to |ψ|² (probability density) instead of Re/Im of ψ#2
sgaofen wants to merge 3 commits into
qcrash:mainfrom
sgaofen:viz-default-psi2

Conversation

@sgaofen

@sgaofen sgaofen commented May 23, 2026

Copy link
Copy Markdown

Summary

Two related fixes — both make the animation output show the physically observable quantity |ψ|² instead of components of the complex wavefunction:

  • viz/index.html — default the position-space panel to |ψ|² only; hide Re(ψ) and Im(ψ) by default and expose them as legend-checkbox toggles. Dynamics, observables, and Wigner panel unchanged.
  • mp4gen.bash — the gnuplot command was using using 2:3 w l, which plots a curve in the (Re ψ, Im ψ) complex plane parameterized by x. Switch to using 1:($2**2+$3**2) so the generated out.mp4 shows the probability density |ψ(x,t)|² against position. Also tighten axis ranges to the box [-1, 1] and add axis labels.

Why

Re(ψ) and Im(ψ) are mathematical components of the complex wavefunction, not directly observable. With nontrivial momentum and the hard walls of the box, they oscillate at the de Broglie wavelength λ = 2π/|p|, which visually drowns out the |ψ|² structure — in particular the reflection-induced interference fringes that the demo is meant to highlight. |ψ|² carries the physical content (probability density), so it should be the default output of every animation pipeline in this repo.

In the interactive page the Re/Im checkboxes still let you opt in for teaching purposes (showing the relation between ψ and |ψ|²).

Test plan

viz/index.html:

  • Open in browser; confirm only the teal |ψ|² curve + walls render by default
  • Tick Re(ψ) / Im(ψ) checkboxes → curves overlay; untick → they disappear
  • Disabled checkboxes show dimmed/struck-through legend swatches
  • Wigner panel, stats panel, and language toggle unchanged

mp4gen.bash:

  • Run the Fortran solver to produce psi_* files, then bash mp4gen.bash
  • Confirm out.mp4 shows a positive-valued curve over x ∈ [-1, 1] (probability density) rather than a closed Lissajous-style loop in the complex plane
  • Y-axis label reads |psi|^2

🤖 Generated with Claude Code

sgaofen and others added 3 commits May 15, 2026 15:27
Single-file HTML visualization aligned with the Fortran solver:
analytic eigenstate expansion on (-1, 1), Wigner phase space
matching wigner.f90, bilingual (EN/中文) walkthrough.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Re(psi) and Im(psi) are components of the complex wavefunction,
not directly observable. They oscillate at the de Broglie wavelength
and drown out |psi|^2 structure (e.g. wall-reflection interference
fringes) when p0 is large. Default the position panel to |psi|^2
only; add legend-checkbox toggles to overlay Re/Im on demand.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The original `using 2:3` plotted a curve in the (Re psi, Im psi) complex
plane parameterized by x, which is not a physical observable. Switch to
`using 1:($2**2+$3**2)` so the animation shows the probability density
|psi|^2 against position x. Also tighten the axis ranges to the box
[-1, 1] and a positive y-range, and label the axes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sgaofen sgaofen changed the title viz: default position panel to |ψ|², make Re/Im opt-in Switch animations to |ψ|² (probability density) instead of Re/Im of ψ May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant