.. 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_gpe_ground_state_relaxation.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_gpe_ground_state_relaxation.py: Relaxing to the Gross-Pitaevskii interacting ground state ================================================================ Eugene Gross and Lev Pitaevskii independently derived, in 1961, a mean-field equation for the macroscopic wavefunction of a dilute Bose-Einstein condensate: a nonlinear Schrodinger equation with a cubic self-interaction term, :math:`i\hbar\partial_t\psi = [-\tfrac{\hbar^2}{2m}\nabla^2 + V + g|\psi|^2]\psi`. Decades before a real BEC existed in a laboratory, this gave theorists a concrete tool for its structure. In the natural units used here (:math:`\hbar=m=1`) for a condensate held in a 2D harmonic trap :math:`V(\mathbf{r})=\tfrac12(x^2+y^2)`, .. math:: i\partial_t\psi = \Big[-\tfrac12\nabla^2 + V(\mathbf{r}) + g|\psi|^2\Big]\psi, :func:`~physicskit.fields.quantum_fields.gpe_relax` solves exactly this equation via imaginary-time propagation (:math:`\tau=it`, renormalizing the norm after every step): substituting :math:`\tau=it` turns the oscillatory Schrodinger-like evolution into a gradient-flow relaxation that drains energy from any initial state and settles it into a stationary point of the energy, starting here from a noninteracting Gaussian cloud. Repulsive interactions (:math:`g>0`) visibly broaden the relaxed cloud past that starting Gaussian. .. GENERATED FROM PYTHON SOURCE LINES 27-33 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from physicskit.fields import gpe_energy, gpe_relax, harmonic_trap_grid, plot_bec_density .. GENERATED FROM PYTHON SOURCE LINES 34-36 A harmonically trapped condensate with repulsive interactions g > 0 -------------------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 36-42 .. code-block:: Python n, length, g = 64, 12.0, 4.0 X, Y, KX, KY, K2 = harmonic_trap_grid(n, length) V = 0.5 * (X**2 + Y**2) psi0 = np.exp(-0.5 * (X**2 + Y**2)).astype(complex) .. GENERATED FROM PYTHON SOURCE LINES 43-45 Imaginary-time propagation relaxes psi0 to the interacting ground state -------------------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 45-48 .. code-block:: Python psi = gpe_relax(psi0, V, g, dtau=5e-4, steps=2000, X=X, Y=Y, K2=K2) .. GENERATED FROM PYTHON SOURCE LINES 49-53 Repulsion broadens the cloud past the noninteracting Gaussian -- the mean-field density profile Gross and Pitaevskii predicted, verified here by comparing the relaxed cloud's radius against the trivial noninteracting case. .. GENERATED FROM PYTHON SOURCE LINES 53-66 .. code-block:: Python E = gpe_energy(psi, V, g, X, Y, K2) dx = X[1, 0] - X[0, 0] r2_interacting = np.sum((X**2 + Y**2) * np.abs(psi) ** 2) * dx * dx r2_noninteracting = np.sum((X**2 + Y**2) * np.abs(psi0) ** 2) * dx * dx / (np.sum(np.abs(psi0) ** 2) * dx * dx) fig, ax = plot_bec_density(X, Y, psi) ax.set_title(f"interaction energy = {E['interaction']:.3f}") fig.tight_layout() print(f"interaction energy: {E['interaction']:.4f} (0 would mean no broadening)") print(f": noninteracting Gaussian = {r2_noninteracting:.4f}, relaxed g={g} cloud = {r2_interacting:.4f}") .. image-sg:: /api/gallery/fields/quantum_fields/images/sphx_glr_plot_gpe_ground_state_relaxation_001.png :alt: interaction energy = 0.247 :srcset: /api/gallery/fields/quantum_fields/images/sphx_glr_plot_gpe_ground_state_relaxation_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none interaction energy: 0.2471 (0 would mean no broadening) : noninteracting Gaussian = 1.0000, relaxed g=4.0 cloud = 1.2451 .. GENERATED FROM PYTHON SOURCE LINES 67-76 A radial cross-section makes the broadening directly visible ------------------------------------------------------------------ The 2D heatmap above shows the relaxed cloud's shape, but only a cross-section through the trap center puts the interacting and noninteracting density profiles on the same axes, side by side, so the broadening summarized by ```` above is visible directly as a wider, flatter-topped profile -- the Thomas-Fermi-like flattening repulsive interactions produce, in place of the noninteracting cloud's pure Gaussian peak. .. GENERATED FROM PYTHON SOURCE LINES 76-89 .. code-block:: Python mid = n // 2 density_interacting = np.abs(psi[:, mid]) ** 2 density_noninteracting = np.abs(psi0[:, mid]) ** 2 / (np.sum(np.abs(psi0) ** 2) * dx * dx) fig2, ax2 = plt.subplots() ax2.plot(X[:, mid], density_noninteracting, "--", label="noninteracting Gaussian") ax2.plot(X[:, mid], density_interacting, label=f"relaxed, g={g}") ax2.set_xlabel("x") ax2.set_ylabel(r"$|\psi(x, 0)|^2$") ax2.set_title("Radial cross-section: repulsion broadens and flattens the cloud") ax2.legend() fig2.tight_layout() .. image-sg:: /api/gallery/fields/quantum_fields/images/sphx_glr_plot_gpe_ground_state_relaxation_002.png :alt: Radial cross-section: repulsion broadens and flattens the cloud :srcset: /api/gallery/fields/quantum_fields/images/sphx_glr_plot_gpe_ground_state_relaxation_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.251 seconds) .. _sphx_glr_download_api_gallery_fields_quantum_fields_plot_gpe_ground_state_relaxation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_gpe_ground_state_relaxation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_gpe_ground_state_relaxation.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_gpe_ground_state_relaxation.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_