Equation#

Module for the Equation.

class Equation(equation)[source]#

Bases: BaseEquation

Implementation of the Equation class, representing a single mathematical equation to be satisfied by the model outputs.

It can be passed to a Condition object 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 Equation class.

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.Module instance.

  • params (dict) – An optional dictionary of unknown parameters, used in InverseProblem settings. If the equation is not related to an inverse problem, this should be set to None. Default is None.

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:

LabelTensor