Domain Equation Condition#
- class DomainEquationCondition(**kwargs)[source]#
Bases:
BaseConditionThe class
DomainEquationConditiondefines a condition based on adomainand anequation. This condition is typically used in physics-informed problems, where the model is trained to satisfy a givenequationover a specifieddomain. Thedomainis used to sample points where theequationresidual is evaluated and minimized during training.- Example:
>>> from pina.domain import CartesianDomain >>> from pina.equation import Equation >>> from pina import Condition
>>> # Equation to be satisfied over the domain: # x^2 + y^2 - 1 = 0 >>> def dummy_equation(pts): ... return pts["x"]**2 + pts["y"]**2 - 1
>>> domain = CartesianDomain({"x": [0, 1], "y": [0, 1]}) >>> condition = Condition(domain=domain, equation=Equation(dummy_equation))
Initialization of the
BaseConditionclass.- Parameters:
kwargs (dict) – The keyword arguments representing the data to be stored in the condition.
- store_data(**kwargs)[source]#
Store the domain and the equation for the condition. It sets the attributes
domainandequationof the condition instance based on the provided keyword arguments.- Parameters:
kwargs (dict) – The keyword arguments containing the data to be stored.
- evaluate(batch, solver)[source]#
Evaluate the residual of the condition on the given batch using the solver.
This method computes the non-aggregated, element-wise residual of the condition. A forward pass of the solver’s model is performed on the input samples, and the condition residual is evaluated accordingly.
The returned tensor is not reduced, preserving the per-sample residual values.
- Parameters:
batch (dict) – The batch containing the data required by the condition evaluation.
solver (BaseSolver) – The solver used to perform the forward pass and compute the residual. The solver provides access to the model and its parameters, which may be necessary for evaluating the condition residual.
- Raises:
NotImplementedError – Always raised since any domain-equation condition is transformed into an input-equation condition before evaluation, and the residual is computed using the input-equation condition’s evaluation method.
- property equation#
The equation associated with the condition.
- Returns:
The equation.
- Return type:
- property domain#
The domain associated with the condition.
- Returns:
The domain.
- Return type: