Enhancing Equations

- add init file
- add docs
- fixing bug System of equation, replace torch.stack with torch.hstack
- add tests
This commit is contained in:
Dario Coscia
2023-06-28 11:49:14 +02:00
committed by Nicola Demo
parent 09f04008b5
commit b9ddea827b
6 changed files with 234 additions and 11 deletions

View File

@@ -4,7 +4,29 @@ from .equation_interface import EquationInterface
class Equation(EquationInterface):
def __init__(self, equation):
"""
Equation class for specifing any equation in PINA.
Each ``equation`` passed to a ``Condition`` object
must be an ``Equation`` or ``SystemEquation``.
:param equation: A ``torch`` callable equation to
evaluate the residual.
:type equation: callable
"""
if not callable(equation):
raise ValueError('equation must be a callable function.'
'Expected a callable function, got '
f'{equation}')
self.__equation = equation
def residual(self, input_, output_):
"""
Residual computation of the equation.
:param LabelTensor input_: Input points to evaluate the equation.
:param LabelTensor output_: Output vectors given my a model (e.g,
a ``FeedForward`` model).
:return: The residual evaluation of the specified equation.
:rtype: LabelTensor
"""
return self.__equation(input_, output_)