Equation#
Module for the Equation.
- class Equation(equation)[source]#
Bases:
BaseEquationImplementation of the Equation class, representing a single mathematical equation to be satisfied by the model outputs.
It can be passed to a
Conditionobject to define the conditions under which the model is trained.- Example:
>>> from pina.equation import Equation >>> eq = Equation(lambda x, u: u - x) >>> # Use within a Condition: >>> # condition = Condition(domain=domain, equation=eq)
Initialization of the
Equationclass.- Parameters:
equation (Callable) – A callable function used to compute the residual of a mathematical equation.
- Raises:
ValueError – If the equation is not a callable function.
- residual(input_, output_, params_=None)[source]#
Evaluate the equation residual at the given inputs.
- Parameters:
input (LabelTensor) – The input points where the residual is computed.
output (LabelTensor) – The output tensor, potentially produced by a
torch.nn.Moduleinstance.params (dict) – An optional dictionary of unknown parameters, used in
InverseProblemsettings. If the equation is not related to an inverse problem, this should be set toNone. Default isNone.
- Raises:
RuntimeError – If the underlying equation signature is neither of length 2 for direct problems nor of length 3 for inverse problems.
- Returns:
The residual values of the equation.
- Return type: