Conditions#

class Condition(*args, **kwargs)[source]#

Bases: object

Represents constraints (such as physical equations, boundary conditions, etc.) that must be satisfied in a given problem. Condition objects are used to formulate the PINA AbstractProblem object.

There are different types of conditions:

  • InputTargetCondition: Defined by specifying both the input and the target of the condition. In this case, the model is trained to produce the target given the input. The input and output data must be one of the torch.Tensor, LabelTensor, Data, or Graph. Different implementations exist depending on the type of input and target. For more details, see InputTargetCondition.

  • DomainEquationCondition : Defined by specifying both the domain and the equation of the condition. Here, the model is trained to minimize the equation residual by evaluating it at sampled points within the domain.

  • InputEquationCondition: Defined by specifying the input and the equation of the condition. In this case, the model is trained to minimize the equation residual by evaluating it at the provided input. The input must be either a LabelTensor or a Graph. Different implementations exist depending on the type of input. For more details, see InputEquationCondition.

  • DataCondition: Defined by specifying only the input. In this case, the model is trained with an unsupervised custom loss while using the provided data during training. The input data must be one of torch.Tensor, LabelTensor, Data, or Graph. Additionally, conditional variables can be provided when the model depends on extra parameters. These conditional variables must be either torch.Tensor or LabelTensor. Different implementations exist depending on the type of input. For more details, see DataCondition.

Example:

>>> from pina import Condition
>>> condition = Condition(
...     input=input,
...     target=target
... )
>>> condition = Condition(
...     domain=location,
...     equation=equation
... )
>>> condition = Condition(
...     input=input,
...     equation=equation
... )
>>> condition = Condition(
...     input=data,
...     conditional_variables=conditional_variables
... )

Instantiate the appropriate Condition object based on the keyword arguments passed.

Raises:
  • ValueError – If no keyword arguments are passed.

  • ValueError – If the keyword arguments are invalid.

Returns:

The appropriate Condition object.

Return type:

ConditionInterface