.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_ch7\ch7_heat_eq.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_auto_ch7_ch7_heat_eq.py: ==================================== 7.03 Heat Equation ==================================== We reproduce here the figure 7.4 & 7.5 of the book. Utilitary functions can be found next to this file. Here, we only define codpy-related functions. .. GENERATED FROM PYTHON SOURCE LINES 10-12 Necessary Imports ------------------------ .. GENERATED FROM PYTHON SOURCE LINES 12-27 .. code-block:: Python import os import sys import matplotlib.pyplot as plt try: CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) except NameError: CURRENT_DIR = os.getcwd() data_path = os.path.join(CURRENT_DIR, "data") PARENT_DIR = os.path.abspath(os.path.join(CURRENT_DIR, "..")) sys.path.insert(0, PARENT_DIR) from utils.ch7.ch7_utils import PDE3, PDE4 .. GENERATED FROM PYTHON SOURCE LINES 28-36 Problem statement ------------------------ let's consider the heat equation in a fixed geometry $\Omega$ with null Dirichlet conditions: $$\partial_t u(t,x) = \Delta u(t,x), \quad u(0,x)=u_0(x),\quad x \in \Omega, \quad u_{\partial \Omega}=0$$ To approximate this equation, we follow the following steps: Select a mesh $X \in \mathbb{R}^{N_x,D}$ for the domain $\Omega$. Pick up a kernel $k$ generating a space of vanishing trace functions. We represent this equation as $\frac{d}{dt} u(t) = \Delta_k u(t)$, with evolution operator $u^{n+1} = B(\Delta_k,u^{n},dt,\theta)$ and $\theta = 1$. This corresponds to the fully implicit case .. GENERATED FROM PYTHON SOURCE LINES 39-42 Regular mesh ------------------------ This image provides a 3-D representation of the initial condition and time evolution of the heat equation on a fixed square. .. GENERATED FROM PYTHON SOURCE LINES 42-45 .. code-block:: Python PDE3() plt.show() .. image-sg:: /auto_ch7/images/sphx_glr_ch7_heat_eq_001.png :alt: initial condition, time evolution :srcset: /auto_ch7/images/sphx_glr_ch7_heat_eq_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 46-49 Irregular mesh ------------------------ This image shows the heat equation on an irregular mesh generated by a bimodal Gaussian process. .. GENERATED FROM PYTHON SOURCE LINES 49-51 .. code-block:: Python PDE4() plt.show() pass .. image-sg:: /auto_ch7/images/sphx_glr_ch7_heat_eq_002.png :alt: initial condition, time evolution :srcset: /auto_ch7/images/sphx_glr_ch7_heat_eq_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.404 seconds) .. _sphx_glr_download_auto_ch7_ch7_heat_eq.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: ch7_heat_eq.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: ch7_heat_eq.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: ch7_heat_eq.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_