huangboming / PDEs-PINN-Examples-Using-Tensorflow2

Some examples of using PINN to solve PDEs numerically
13 stars 2 forks source link

PDEs-PINN-Examples-Using-Tensorflow2

Some examples of using PINN to solve PDEs numerically.

PINN official implementation: https://github.com/maziarraissi/PINNs

SA-PINN official implementation: https://github.com/levimcclenny/SA-PINNs

Update:


Poisson 1D example

Poisson 1D with boundary condition:

$$\left{ \begin{array}{l} -u^{''}(x) = f(x) \quad \textrm{for } \, x \in [-1, 1] \newline u(-1) = u(1) = 0 \end{array} \right.$$

where $f(x) = \pi^2 \sin(\pi x)$.

The exact solution is: $u(x) = \sin(\pi x)$

PINN solution and the exact solution: PINN_Poisson_1D


Poisson 2D example

Poisson 2D with boundary condition:

$$ \left{ \begin{array}{l} -\Delta u(x, y) = f(x, y) \quad \textrm{for } \, (x, y) \in \Omega = [-1, 1] \times [-1, 1] \newline u|_{\partial \Omega} = 0 \end{array} \right. $$

where $f(x, y) = 2\pi^2 \sin(\pi x)\sin(\pi y)$.

The exact solution is: $u(x, y) = \sin(\pi x) \sin(\pi y)$

PINN solution: PINN_Poisson_2D

The exact solution: Exact_Poisson_2D


Diffusion Equation example

(Example from Juan Diego Toscano's Leaning PIML in Python, example 4: diffusion equation)

Diffusion equation with initial condition and boundary conditions:

$$ \left{ \begin{array}{l} ut = u{xx} - e^{-t}(\sin(\pi x) - \pi^2\sin(\pi x)) \quad x \in [-1, 1], t\in [0, 1] \newline u(x, 0) = \sin(\pi x) \newline u(-1, t) = u(1, t) = 0 \end{array} \right. $$

The exact solution is: $u(x, t) = e^{-t}\sin(\pi x)$.

PINN solution v.s. the exact solution: pinn solution 2d real solution 2d

pinn solution 3d real solution 3d


Poisson 1D (Inverse Problem) example

Poisson 1D (Inverse Problem) with boundary condition:

PDE: $$\left{\begin{array}{l} -\lambda u^{''}(x) = f(x) \quad x \in (-1, 1) \ u(-1) = u(1) = 0 \end{array}\right.$$

where $f(x) = \pi^2 \sin(\pi x)$.

Exact solution(for generating training set) is: $u(x) = \sin(\pi x)$.

We're going to train a DNN to approximate $\lambda$. (The exact result is $\lambda = 1$)

PINN solution:

Poisson 1D results Poisson 1D lambda history


Burgers Equation example

I learned how to use PINN to solve burgers equation from omniscientoctopus' code. Much of my code is same as omniscientoctopus' code, but I add some comments and my ideas in my code.

Here's omniscientoctopus' GitHub repo: https://github.com/omniscientoctopus/Physics-Informed-Neural-Networks

The data I used is also from omniscientoctopus' GitHub repo.

Burgers equation: $$\left{ \begin{array}{l} u_t + uux = \nu u{xx} \quad x \in [-1, 1], t \in [0, 1] \newline u(x, 0) = u_0(x) \newline u(-1, t) = u(1, t) = 0 \end{array} \right.$$

where $u_0(x) = -\sin(\pi x)$, $\nu = \frac{0.01}{\pi}$

PINN results:

real and pinn solution

SA-PINN results:

real solution sa-pinn solution real v.s sa-pinn solution


Allen-Cahn Equation(2D) example

(Example from https://youtu.be/UTC6cccEEnM?t=267)

Allen-Cahn equation for two-phase microstructrue evolution:

$$\left{\begin{array}{l}ut - 0.00001u{xx} + 5u^3 - 5u = 0 \quad x\in[-1,1], t \in [0,1] \newline u(x, 0) = x^2 \cos(\pi x) \newline u(-1, t) = u(1, t) \newline u_x(-1, t) = u_x(1, t) \end{array} \right.$$

SA-PINN results:

real solution 2d sapinn solution 2d

real solution 3d sapinn solution 3d

t=0s t=0.25s t=0.50s t=0.75s