.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/fields/quantum_fields/plot_nls_self_focusing_collapse.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_fields_quantum_fields_plot_nls_self_focusing_collapse.py: Self-focusing collapse of an attractive condensate ======================================================== Vladimir Zakharov showed in "Collapse of Langmuir Waves" (1972) that the focusing nonlinear Schrodinger equation has a regime with no shape-preserving soliton at all: a sufficiently intense, narrow wave packet can self-focus so strongly that it contracts toward a genuine singularity in finite time, rather than settling into a stable envelope. :func:`~physicskit.fields.quantum_fields.gpe_evolve` solves the 2D Gross-Pitaevskii / cubic NLS equation .. math:: i\partial_t\psi = \Big[-\tfrac12\nabla^2 + V(\mathbf{r}) + g|\psi|^2\Big]\psi \qquad (\hbar = m = 1), and, run here with no trapping potential (:math:`V=0`) and an attractive interaction (:math:`g<0`, opposite sign convention from the 1D ``nls_evolve`` solver), reproduces exactly the runaway contraction of a sufficiently tall, narrow initial packet -- the numerical, finite-grid stand-in for approaching (never reaching) Zakharov's collapse; the calculation is stopped once the peak density is still visibly growing, not carried through the unresolvable blow-up itself. .. GENERATED FROM PYTHON SOURCE LINES 26-32 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from physicskit.fields import animate_density_2d, gpe_evolve, harmonic_trap_grid .. GENERATED FROM PYTHON SOURCE LINES 33-35 A tall, narrow packet with attractive interactions and no trap -------------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 35-41 .. code-block:: Python n, length = 64, 16.0 X, Y, KX, KY, K2 = harmonic_trap_grid(n, length) V = np.zeros((n, n)) psi0 = 3.0 * np.exp(-0.5 * (X**2 + Y**2) / 0.5**2).astype(complex) .. GENERATED FROM PYTHON SOURCE LINES 42-44 Real-time propagation under the attractive (g < 0) nonlinearity -------------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 44-48 .. code-block:: Python dt, steps, stride = 2e-4, 400, 40 frames, times = gpe_evolve(psi0, V, g=-2.0, dt=dt, steps=steps, K2=K2, snapshot_stride=stride) .. GENERATED FROM PYTHON SOURCE LINES 49-52 Peak density grows monotonically -- self-focusing collapse, not a stable soliton, which would instead hold its peak density fixed as it propagates. .. GENERATED FROM PYTHON SOURCE LINES 52-59 .. code-block:: Python peak_density = np.max(np.abs(frames) ** 2, axis=(1, 2)) extent = (X.min(), X.max(), Y.min(), Y.max()) anim = animate_density_2d(frames, extent=extent, times=times) plt.show() .. container:: sphx-glr-animation .. raw:: html .. GENERATED FROM PYTHON SOURCE LINES 60-64 To save the animation to a file instead of (or in addition to) displaying it interactively, use e.g.:: anim.save("self_focusing_collapse.gif", writer="pillow", fps=15) .. GENERATED FROM PYTHON SOURCE LINES 64-68 .. code-block:: Python print(f"peak density: t=0 -> {peak_density[0]:.3f}, t={times[-1]:.3f} -> {peak_density[-1]:.3f}") print(f"density growth factor: {peak_density[-1] / peak_density[0]:.2f}x (a stable soliton would stay near 1.0x)") .. rst-class:: sphx-glr-script-out .. code-block:: none peak density: t=0 -> 9.000, t=0.080 -> 21.743 density growth factor: 2.42x (a stable soliton would stay near 1.0x) .. GENERATED FROM PYTHON SOURCE LINES 69-76 Peak density over the whole run: runaway growth, not a plateau ------------------------------------------------------------------ The animation shows the packet visibly narrowing frame by frame, but plotting the already-recorded peak density against time directly shows the collapse *accelerating* -- an ever-steepening curve, not the flat line a stable soliton (or the saturating curve of a process approaching some finite peak) would trace out. .. GENERATED FROM PYTHON SOURCE LINES 76-83 .. code-block:: Python fig2, ax2 = plt.subplots() ax2.plot(times, peak_density, "o-") ax2.set_xlabel("t") ax2.set_ylabel(r"peak $|\psi|^2$") ax2.set_title("Self-focusing collapse: peak density accelerating, not saturating") fig2.tight_layout() .. image-sg:: /api/gallery/fields/quantum_fields/images/sphx_glr_plot_nls_self_focusing_collapse_002.png :alt: Self-focusing collapse: peak density accelerating, not saturating :srcset: /api/gallery/fields/quantum_fields/images/sphx_glr_plot_nls_self_focusing_collapse_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.764 seconds) .. _sphx_glr_download_api_gallery_fields_quantum_fields_plot_nls_self_focusing_collapse.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_nls_self_focusing_collapse.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_nls_self_focusing_collapse.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_nls_self_focusing_collapse.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_