├── examples
├── README.md
└── example01_geomprep_usage.ipynb
├── gallery
├── header.png
├── header3.png
├── profiles.png
├── model_plot.png
├── results_compare.png
├── synthwave-heatpinn.png
├── heat_pinn_doughnotts.png
├── 2023-11-08-19-00-36_EDIT.org.png
├── 2023-11-08-19-00-39_EDIT.org.png
├── 2023-11-08-19-07-16_EDIT.org.png
└── 2023-11-08-19-09-09_EDIT.org.png
├── model
└── heat-man.h5
├── LICENSE
├── codes
└── pinn-nn-comparison
│ └── README.md
├── README.md
└── utils
└── geomprep.py
/examples/README.md:
--------------------------------------------------------------------------------
1 | # Examples
2 | ## Example 01: Usage of the `geomprep.py`
--------------------------------------------------------------------------------
/gallery/header.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/314arhaam/heat-pinn/HEAD/gallery/header.png
--------------------------------------------------------------------------------
/gallery/header3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/314arhaam/heat-pinn/HEAD/gallery/header3.png
--------------------------------------------------------------------------------
/model/heat-man.h5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/314arhaam/heat-pinn/HEAD/model/heat-man.h5
--------------------------------------------------------------------------------
/gallery/profiles.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/314arhaam/heat-pinn/HEAD/gallery/profiles.png
--------------------------------------------------------------------------------
/gallery/model_plot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/314arhaam/heat-pinn/HEAD/gallery/model_plot.png
--------------------------------------------------------------------------------
/gallery/results_compare.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/314arhaam/heat-pinn/HEAD/gallery/results_compare.png
--------------------------------------------------------------------------------
/gallery/synthwave-heatpinn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/314arhaam/heat-pinn/HEAD/gallery/synthwave-heatpinn.png
--------------------------------------------------------------------------------
/gallery/heat_pinn_doughnotts.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/314arhaam/heat-pinn/HEAD/gallery/heat_pinn_doughnotts.png
--------------------------------------------------------------------------------
/gallery/2023-11-08-19-00-36_EDIT.org.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/314arhaam/heat-pinn/HEAD/gallery/2023-11-08-19-00-36_EDIT.org.png
--------------------------------------------------------------------------------
/gallery/2023-11-08-19-00-39_EDIT.org.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/314arhaam/heat-pinn/HEAD/gallery/2023-11-08-19-00-39_EDIT.org.png
--------------------------------------------------------------------------------
/gallery/2023-11-08-19-07-16_EDIT.org.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/314arhaam/heat-pinn/HEAD/gallery/2023-11-08-19-07-16_EDIT.org.png
--------------------------------------------------------------------------------
/gallery/2023-11-08-19-09-09_EDIT.org.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/314arhaam/heat-pinn/HEAD/gallery/2023-11-08-19-09-09_EDIT.org.png
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Parham Abbasi
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/examples/example01_geomprep_usage.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": null,
6 | "metadata": {},
7 | "outputs": [],
8 | "source": [
9 | "from utils.geomprep import Geometry2D\n",
10 | "from shapely import Polygon, Point"
11 | ]
12 | },
13 | {
14 | "cell_type": "code",
15 | "execution_count": null,
16 | "metadata": {},
17 | "outputs": [],
18 | "source": [
19 | "# create a polygon\n",
20 | "p1 = Polygon([[-1, -1], [-1, +1], [+1, +1], [+1, -1], [-1, -1]])\n",
21 | "# create a circle\n",
22 | "c1 = Point(0, -0.5).buffer(0.3)\n",
23 | "# bore the circle inside the polygon\n",
24 | "geom = p1.difference(c1)\n",
25 | "# show the *.svg\n",
26 | "geom\n",
27 | "# create Geometry2D object\n",
28 | "G = Geometry2D(geom)\n",
29 | "# make boundary; 100 points\n",
30 | "G.makeBoundary(100)\n",
31 | "# make domain; 500 points\n",
32 | "G.makeDomain(500)\n",
33 | "# show scatter plot\n",
34 | "G.plot()"
35 | ]
36 | }
37 | ],
38 | "metadata": {
39 | "language_info": {
40 | "name": "python"
41 | }
42 | },
43 | "nbformat": 4,
44 | "nbformat_minor": 2
45 | }
46 |
--------------------------------------------------------------------------------
/codes/pinn-nn-comparison/README.md:
--------------------------------------------------------------------------------
1 | # PINN and simple NN performance comparison
2 | ## Introduction
3 | In this work, 2 neural networks with the same architectures, one with pysics-informed loss functions and the other using simple MSE loss were compared. The model properties for the simple neural network (SNN) and physics-informed neural network (PINN) are presented in the following table:
4 | |Model|Loss functions|Data|
5 | |-|-|-|
6 | |**PINN**|Physics-Informed & MSE|(x, y, T) for BCs
(x, y) for Colloc.|
7 | |**SNN**|MSE|(x, y, T)|
8 | ## Performance
9 | Performance comparison between PINN and a simple NN (a neural network without MSE loss) are presented in the following table:
10 | |Method|Training time|Loss|Data Size|
11 | |-|-|-|-|
12 | |**PINN**|66.35 (s)|0.019|BC points: (100, 3)
Colloc. points: (10000, 2)|
13 | |**SNN**|21.0 (min.)|0.020 (noisy)|Training data: (7000, 3)
Test data: (1800, 3)
Val. data: (1200, 3)|
14 |
15 | ## Conclusion
16 | 1. SNN takes a relatively long time to be trained with comparable loss. This makes SNN unfeasible compared to both of the FDM solver and the PINN.
17 | 2. For a 100*100 grid, 7000 data points was used and the computed loss value for the test data, was 0.25 which means poor performance for the unseen data. Also, 7000 data points simply means the grid is almost solved by the FDM method. With fewer training data, the performance becomes worse.
18 | 3. Unlike the data required for the SNN, there is no need to have the value of dependent variable (T) in collocation points used in PINNs. It could be said that these points indicate the domain in which the equation is solved and the non-homogenous terms.
19 |
20 | In summary, not only it is not feasible to use SNNs instead of PINNs for this example, it is not reasonable as a huge amount of data is needed for the SNN to be trained.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
A Physics-Informed Neural Network, to solve 2D steady-state heat equation based on the methodology, introduced in: Physics Informed Deep Learning (Part I): Data-driven Solutions of Nonlinear Partial Differential Equations.
8 | 9 | ## **Table of Contents** 10 | - [Introduction](#intro) 11 | - [Results](#res) 12 | 13 | 14 | ## Introduction 15 | In this project, a PINN is trained to solve a 2D heat equation and the final results is compared to a solution based on FDM method. 16 | For more detailts about the project read [this](https://github.com/314arhaam/burger-pinn). 17 | ### Problem 18 | The governing equation: 19 | 20 | $$ 21 | \Theta = \frac{T - T_{\textbf{min}}}{T_{\textbf{max}}-T_{\textbf{min}}} 22 | $$ 23 | 24 | $$ 25 | \nabla^2{\Theta} = (\partial_{xx}+\partial_{yy})\Theta=0 26 | $$ 27 | 28 | in the following domain: 29 | 30 | 31 | $$ 32 | D = \\{ (x, y)|-1\le x \le +1 \land -1\le y \le +1 \\} 33 | $$ 34 | 35 | With the following boundary conditions: 36 | 37 | 38 | $$ 39 | \begin{equation} 40 | \begin{cases} 41 | T(-1, y) = 75.0 \degree{C}\\ 42 | T(+1, y) = 0.0 \degree{C}\\ 43 | T(x, -1) = 50.0 \degree{C}\\ 44 | T(x, +1) = 0.0 \degree{C}\\ 45 | \end{cases} 46 | \end{equation} 47 | $$ 48 | 49 | When normalized: 50 | 51 | $$ 52 | \begin{equation} 53 | \begin{cases} 54 | \Theta(-1, y) = 1\\ 55 | \Theta(+1, y) = 0\\ 56 | \Theta(x, -1) = \frac{2}{3}\\ 57 | \Theta(x, +1) = 0\\ 58 | \end{cases} 59 | \end{equation} 60 | $$ 61 | 62 | ## Results 63 | 64 | ### Square geometry 65 |
66 |
67 |
70 |
71 |
75 |
76 |