.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/quantum/wave_packets/plot_wave_packet_dynamics.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_quantum_wave_packets_plot_wave_packet_dynamics.py: Dispersion, twin-slit interference, and quantum revivals ============================================================ Three non-stationary phenomena governed by the time-dependent Schrodinger equation, each solved via its own exact analytic route rather than direct numerical propagation. A free Gaussian wavepacket keeps its Gaussian shape but spreads as it travels, its width growing as .. math:: \sigma(t) = \sigma_0\sqrt{1 + \left(\frac{\hbar t}{2m\sigma_0^2}\right)^2}. A matter-wave analogue of Young's experiment sends the same kind of packet through two coherent point sources (slits) separated by a fixed distance; the two paraxially-propagated contributions interfere on a downstream screen, building up the intensity :math:`\lvert\psi_1+\psi_2\rvert^2`. Finally, a wavepacket confined to an infinite square well of width :math:`L` -- whose eigenenergies :math:`E_n=n^2\pi^2\hbar^2/(2mL^2)` grow quadratically in :math:`n` -- disperses into an apparently chaotic superposition yet exactly reassembles into a replica of its initial shape at the revival time :math:`t_\text{rev}=4mL^2/(\pi\hbar)` (with a mirror-image replica at :math:`t_\text{rev}/2`), a purely quantum consequence of the discrete, quadratically-spaced spectrum. .. GENERATED FROM PYTHON SOURCE LINES 26-33 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from physicskit.quantum.chapters.wave_packets import GaussianDispersion, QuantumRevival, TwinSlit from physicskit.quantum.visualizers.wavefunctions import animate_density .. GENERATED FROM PYTHON SOURCE LINES 34-36 Free dispersion, twin-slit interference, and quantum revivals ------------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 36-79 .. code-block:: Python fig, axes = plt.subplots(1, 3, figsize=(15, 4.5)) # Free-particle dispersion: width grows, exact analytic solution gd = GaussianDispersion(x0=0.0, sigma0=1.0, k0=3.0) x1 = np.linspace(-20, 40, 1000) for t in [0, 2, 5, 10]: axes[0].plot(x1, gd.density(x1, t), label=f"t={t}") axes[0].set_title("Free wavepacket dispersion\n(width grows, exact analytic solution)") axes[0].set_xlabel("x") axes[0].legend(fontsize=8) # Twin-slit interference: the matter-wave analogue of Young's experiment ts = TwinSlit(slit_separation=4.0, slit_width=0.4, k0=10.0) x2 = np.linspace(-10, 10, 2000) I = ts.intensity(x2, screen_distance=50) axes[1].plot(x2, I) axes[1].set_title("Twin-slit interference\n(matter-wave analogue of Young's experiment)") axes[1].set_xlabel("screen position") # Quantum revivals in the infinite square well: dispersion -> exact self-reassembly qr = QuantumRevival(L=1.0, n_max=300) x3 = np.linspace(0, qr.L, 1500) psi0_func = qr.gaussian_initial_state(x0=0.3, sigma=0.03) psi0 = psi0_func(x3) coeffs = qr.eigenbasis_coefficients(psi0_func) t_rev = qr.revival_time fractions = [0.0, 0.25, 0.5, 1.0] offset = 0 for frac in fractions: density = np.abs(qr.wavefunction(x3, frac * t_rev, coeffs)) ** 2 axes[2].plot(x3, density + offset, label=f"t={frac:.2f} t_rev") offset += density.max() * 1.3 # infinite walls of the box, for reference axes[2].axvline(0.0, color="black", lw=1.2) axes[2].axvline(qr.L, color="black", lw=1.2) axes[2].set_title("Quantum revivals in an infinite well [0,L]\n(dispersion -> exact self-reassembly)") axes[2].set_xlabel("x") axes[2].legend(fontsize=7) fig.tight_layout() .. image-sg:: /api/gallery/quantum/wave_packets/images/sphx_glr_plot_wave_packet_dynamics_001.png :alt: Free wavepacket dispersion (width grows, exact analytic solution), Twin-slit interference (matter-wave analogue of Young's experiment), Quantum revivals in an infinite well [0,L] (dispersion -> exact self-reassembly) :srcset: /api/gallery/quantum/wave_packets/images/sphx_glr_plot_wave_packet_dynamics_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 80-81 Fidelity to the initial state approaches 1 at (fractional) revival times. .. GENERATED FROM PYTHON SOURCE LINES 81-86 .. code-block:: Python for frac in fractions: fid = qr.fidelity_to_initial(x3, frac * t_rev, coeffs, psi0) print(f"fidelity to initial state at t={frac} t_rev: {fid:.4f}") .. rst-class:: sphx-glr-script-out .. code-block:: none fidelity to initial state at t=0.0 t_rev: 1.0000 fidelity to initial state at t=0.25 t_rev: 0.5000 fidelity to initial state at t=0.5 t_rev: 0.0000 fidelity to initial state at t=1.0 t_rev: 1.0000 .. GENERATED FROM PYTHON SOURCE LINES 87-97 An animated view of free dispersion -------------------------------------- The static snapshots of ``gd.density`` above come from :meth:`~physicskit.quantum.chapters.wave_packets.GaussianDispersion.trajectory`, the same exact analytic free-particle solution stacked over a time grid, shaped for :func:`~physicskit.quantum.visualizers.wavefunctions.animate_density` -- here rendered phase-colored, so the de Broglie phase :math:`e^{ik_0x}` riding along the ballistically advancing center is directly visible while the envelope spreads. .. GENERATED FROM PYTHON SOURCE LINES 97-104 .. code-block:: Python t_anim = np.linspace(0, 6.0, 120) x_anim = np.linspace(-20, 40, 600) frames = gd.trajectory(x_anim, t_anim) anim = animate_density(x_anim, frames, times=t_anim) # anim.save("wave_packet_dispersion.gif", writer="pillow", fps=15) .. container:: sphx-glr-animation .. raw:: html .. GENERATED FROM PYTHON SOURCE LINES 105-114 A "quantum carpet": the full space-time revival pattern -------------------------------------------------------------- The four discrete snapshots above sample :meth:`~physicskit.quantum.chapters.wave_packets.QuantumRevival.wavefunction` at isolated fractions of :math:`t_\text{rev}`; evaluating it on a full :math:`(x,t)` grid instead reveals the famous "quantum carpet" -- a web of diagonal fractional-revival ridges that the discrete snapshots only hint at, converging back to sharp replicas of the initial state exactly at :math:`t=0`, :math:`t_\text{rev}/2`, and :math:`t_\text{rev}`. .. GENERATED FROM PYTHON SOURCE LINES 114-128 .. code-block:: Python t_carpet = np.linspace(0, t_rev, 500) x_carpet = np.linspace(0, qr.L, 700) carpet = np.array([np.abs(qr.wavefunction(x_carpet, t, coeffs)) ** 2 for t in t_carpet]) fig2, ax4 = plt.subplots(figsize=(7, 5.5)) im = ax4.pcolormesh(x_carpet, t_carpet, carpet, shading="auto", cmap="inferno") for frac in fractions: ax4.axhline(frac * t_rev, color="cyan", ls="--", lw=0.6) ax4.set_xlabel("x") ax4.set_ylabel("t") ax4.set_title(r"Quantum carpet: $|\psi(x,t)|^2$ in the infinite well") fig2.colorbar(im, ax=ax4, label=r"$|\psi(x,t)|^2$") fig2.tight_layout() .. image-sg:: /api/gallery/quantum/wave_packets/images/sphx_glr_plot_wave_packet_dynamics_003.png :alt: Quantum carpet: $|\psi(x,t)|^2$ in the infinite well :srcset: /api/gallery/quantum/wave_packets/images/sphx_glr_plot_wave_packet_dynamics_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (1 minutes 28.068 seconds) .. _sphx_glr_download_api_gallery_quantum_wave_packets_plot_wave_packet_dynamics.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_wave_packet_dynamics.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_wave_packet_dynamics.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_wave_packet_dynamics.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_