update ReadMe (#32)

Simple Update of the  Example
This commit is contained in:
Dario Coscia
2022-11-21 14:32:34 +01:00
committed by GitHub
parent bb1efe44bc
commit f51e826132

View File

@@ -50,23 +50,25 @@ PINN is a novel approach that involves neural networks to solve supervised learn
#### Problem definition #### Problem definition
First step is formalization of the problem in the PINA framework. We take as example here a simple Poisson problem, but PINA is already able to deal with **multi-dimensional**, **parametric**, **time-dependent** problems. First step is formalization of the problem in the PINA framework. We take as example here a simple Poisson problem, but PINA is already able to deal with **multi-dimensional**, **parametric**, **time-dependent** problems.
Consider: Consider:
$$\begin{cases}\Delta u = \sin(\pi x)\sin(\pi y)\quad& \text{in}\\,D,\\\\u = 0& \text{on}\\,\partial D,\end{cases}$$
where $D = [0, 1]^2$ is a square domain and $u$ the unknown field. The translation in PINA code becomes a new class containing all the information about the domain, about the `conditions` and nothing more: $$\begin{cases} \Delta u = \sin(\pi x)\sin(\pi y)\quad& \text{in} \\ D \\\\ u = 0& \text{on} \\ \partial D \end{cases}$$
where $D = [0, 1]^2$ is a square domain, $u$ the unknown field, and $\partial D = \Gamma_1 \cup \Gamma_2 \cup \Gamma_3 \cup \Gamma_4$, where $\Gamma_i$ are the boundaries of the square for $i=1,\cdots,4$. The translation in PINA code becomes a new class containing all the information about the domain, about the `conditions` and nothing more:
```python ```python
class Poisson(SpatialProblem): class Poisson(SpatialProblem):
spatial_variables = ['x', 'y']
output_variables = ['u'] output_variables = ['u']
domain = Span({'x': [0, 1], 'y': [0, 1]}) spatial_domain = Span({'x': [0, 1], 'y': [0, 1]})
def laplace_equation(input_, output_): def laplace_equation(input_, output_):
force_term = (torch.sin(input_['x']*torch.pi) * force_term = (torch.sin(input_.extract(['x'])*torch.pi) *
torch.sin(input_['y']*torch.pi)) torch.sin(input_.extract(['y'])*torch.pi))
return nabla(output_['u'], input_).flatten() - force_term nabla_u = nabla(output_.extract(['u']), input_)
return nabla_u - force_term
def nil_dirichlet(input_, output_): def nil_dirichlet(input_, output_):
value = 0.0 value = 0.0
return output_['u'] - value return output_.extract(['u']) - value
conditions = { conditions = {
'gamma1': Condition(Span({'x': [-1, 1], 'y': 1}), nil_dirichlet), 'gamma1': Condition(Span({'x': [-1, 1], 'y': 1}), nil_dirichlet),