.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples_gallery/simple_pdes/laplace_eq_2d.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_laplace_eq_2d.py: Solving Laplace's equation in 2d ================================ This example shows how to solve a 2d Laplace equation with spatially varying boundary conditions. .. GENERATED FROM PYTHON SOURCE LINES 8-18 .. image-sg:: /examples_gallery/simple_pdes/images/sphx_glr_laplace_eq_2d_001.png :alt: Solution to Laplace's equation :srcset: /examples_gallery/simple_pdes/images/sphx_glr_laplace_eq_2d_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np from pde import CartesianGrid, solve_laplace_equation grid = CartesianGrid([[0, 2 * np.pi], [0, 2 * np.pi]], 64) bcs = {"x": {"value": "sin(y)"}, "y": {"value": "sin(x)"}} res = solve_laplace_equation(grid, bcs) res.plot() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.543 seconds) .. _sphx_glr_download_examples_gallery_simple_pdes_laplace_eq_2d.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: laplace_eq_2d.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: laplace_eq_2d.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: laplace_eq_2d.zip `