.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples_gallery/simple_pdes/pde_schroedinger.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_examples_gallery_simple_pdes_pde_schroedinger.py: Schrödinger's Equation ====================== This example implements a complex PDE using the :class:`~pde.pdes.pde.PDE`. We here chose the `Schrödinger equation `_ without a spatial potential in non-dimensional form: .. math:: i \partial_t \psi = -\nabla^2 \psi Note that the example imposes Neumann conditions at the wall, so the wave packet is expected to reflect off the wall. .. GENERATED FROM PYTHON SOURCE LINES 15-34 .. image-sg:: /examples_gallery/simple_pdes/images/sphx_glr_pde_schroedinger_001.png :alt: pde schroedinger :srcset: /examples_gallery/simple_pdes/images/sphx_glr_pde_schroedinger_001.png :class: sphx-glr-single-img .. code-block:: Python from math import sqrt from pde import PDE, CartesianGrid, MemoryStorage, ScalarField, plot_kymograph grid = CartesianGrid([[0, 20]], 128, periodic=False) # generate grid # create a (normalized) wave packet with a certain form as an initial condition initial_state = ScalarField.from_expression(grid, "exp(I * 5 * x) * exp(-(x - 10)**2)") initial_state /= sqrt(initial_state.to_scalar("norm_squared").integral.real) eq = PDE({"ψ": "I * laplace(ψ)"}) # define the pde # solve the pde and store intermediate data storage = MemoryStorage() eq.solve(initial_state, t_range=2.5, dt=1e-5, tracker=[storage.tracker(0.02)]) # visualize the results as a space-time plot plot_kymograph(storage, scalar="norm_squared") .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 8.055 seconds) .. _sphx_glr_download_examples_gallery_simple_pdes_pde_schroedinger.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: pde_schroedinger.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: pde_schroedinger.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: pde_schroedinger.zip `