tmp commit - toward 0.0.1

This commit is contained in:
Your Name
2021-11-29 15:29:00 +01:00
parent beae301a58
commit fb16fc7f3a
38 changed files with 2790 additions and 1 deletions

View File

@@ -0,0 +1,29 @@
import numpy as np
import torch
from pina.problem import Problem
from pina.segment import Segment
from pina.parametricproblem2d import ParametricProblem2D
bc = (
(Segment((-1, -1), ( 1, -1)), lambda x: torch.zeros(x.shape[0], 1)),
(Segment(( 1, -1), ( 1, 1)), lambda x: torch.zeros(x.shape[0], 1)),
(Segment(( 1, 1), (-1, 1)), lambda x: torch.zeros(x.shape[0], 1)),
(Segment((-1, 1), (-1, -1)), lambda x: torch.zeros(x.shape[0], 1)),
)
params_domain = np.array([
[-1.0, 1.0],
[-1.0, 1.0]])
def equation(x, fx):
grad_x, grad_y = Problem.grad(fx, x)[:, :2].T
grad_xx = Problem.grad(grad_x, x)[:, 0]
grad_yy = Problem.grad(grad_y, x)[:, 1]
a = grad_xx + grad_yy - torch.exp(- 2*(x[:, 0] - x[:, 2])**2 - 2*(x[:, 1] - x[:, 3])**2)
return a
laplace = ParametricProblem2D(bc=bc, domain_bound=params_domain, params_bound=params_domain)
laplace.equation = equation