fix examples (#21)
This commit is contained in:
@@ -8,10 +8,9 @@ from pina.span import Span
|
||||
|
||||
class Burgers1D(TimeDependentProblem, SpatialProblem):
|
||||
|
||||
spatial_variables = ['x']
|
||||
temporal_variable = ['t']
|
||||
output_variables = ['u']
|
||||
domain = Span({'x': [-1, 1], 't': [0, 1]})
|
||||
spatial_domain = Span({'x': [-1, 1]})
|
||||
temporal_domain = Span({'t': [0, 1]})
|
||||
|
||||
def burger_equation(input_, output_):
|
||||
du = grad(output_, input_)
|
||||
|
||||
@@ -16,11 +16,9 @@ class ParametricEllipticOptimalControl(SpatialProblem, ParametricProblem):
|
||||
x_range = [xmin, xmax]
|
||||
y_range = [ymin, ymax]
|
||||
|
||||
spatial_variables = ['x1', 'x2']
|
||||
parameters = ['mu', 'alpha']
|
||||
output_variables = ['u', 'p', 'y']
|
||||
domain = Span({
|
||||
'x1': x_range, 'x2': y_range, 'mu': mu_range, 'alpha': a_range})
|
||||
spatial_domain = Span({'x1': x_range, 'x2': y_range})
|
||||
parameter_domain = Span({'mu': mu_range, 'alpha': a_range})
|
||||
|
||||
|
||||
def term1(input_, output_):
|
||||
|
||||
@@ -7,10 +7,9 @@ from pina import Span, Condition
|
||||
|
||||
class ParametricPoisson(SpatialProblem, ParametricProblem):
|
||||
|
||||
spatial_variables = ['x', 'y']
|
||||
parameters = ['mu1', 'mu2']
|
||||
output_variables = ['u']
|
||||
domain = Span({'x': [-1, 1], 'y': [-1, 1]})
|
||||
spatial_domain = Span({'x': [-1, 1], 'y': [-1, 1]})
|
||||
parameter_domain = Span({'mu1': [-1, 1], 'mu2': [-1, 1]})
|
||||
|
||||
def laplace_equation(input_, output_):
|
||||
force_term = torch.exp(
|
||||
|
||||
@@ -8,9 +8,8 @@ from pina import Condition, Span
|
||||
|
||||
class Poisson(SpatialProblem):
|
||||
|
||||
spatial_variables = ['x', 'y']
|
||||
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_):
|
||||
force_term = (torch.sin(input_.extract(['x'])*torch.pi) *
|
||||
@@ -30,7 +29,11 @@ class Poisson(SpatialProblem):
|
||||
'D': Condition(Span({'x': [0, 1], 'y': [0, 1]}), laplace_equation),
|
||||
}
|
||||
|
||||
def poisson_sol(self, x, y):
|
||||
return -(np.sin(x*np.pi)*np.sin(y*np.pi))/(2*np.pi**2)
|
||||
def poisson_sol(self, pts):
|
||||
return -(
|
||||
torch.sin(pts.extract(['x'])*torch.pi)*
|
||||
torch.sin(pts.extract(['y'])*torch.pi)
|
||||
)/(2*torch.pi**2)
|
||||
#return -(np.sin(x*np.pi)*np.sin(y*np.pi))/(2*np.pi**2)
|
||||
|
||||
truth_solution = poisson_sol
|
||||
|
||||
@@ -8,9 +8,8 @@ from pina import Condition, Span, LabelTensor
|
||||
|
||||
class Stokes(SpatialProblem):
|
||||
|
||||
spatial_variables = ['x', 'y']
|
||||
output_variables = ['ux', 'uy', 'p']
|
||||
domain = Span({'x': [-2, 2], 'y': [-1, 1]})
|
||||
spatial_domain = Span({'x': [-2, 2], 'y': [-1, 1]})
|
||||
|
||||
def momentum(input_, output_):
|
||||
nabla_ = torch.hstack((LabelTensor(nabla(output_.extract(['ux']), input_), ['x']),
|
||||
|
||||
Reference in New Issue
Block a user