Set Up Conditions for a PINA Problem
[!IMPORTANT] Read RULES.md before using this skill — it applies to all skills. This is a sub-skill of create-problem. Load the entry-point skill first.
Use this skill to define Condition objects that bind data, equations, or
time-series windows to the problem.
Step 1 — Determine the condition type
Three kinds of conditions exist in PINA:
| Kind | When to use |
|---|---|
| Physics-on-domain | PDE/ODE residual on a sampled domain |
| Data-driven | Input→target mapping (supervised) |
| Time series | Rolling-window forecasting |
Step 2 — Data types (data-driven only)
If the problem is data-driven, ask:
What data type are you using?
Available data types for Condition(input=..., target=...):
LabelTensor/torch.Tensor— standard tensor data (most common)Graph— PINA's built-in graph structure (frompina import Graph)Data— PyTorch GeometricDataobject (fromtorch_geometric.data import Data)
All three types are accepted directly as input/target.
Step 3 — Build conditions
Physics-on-domain
Conditions map domain names (sampled later via discretise_domain) or explicit
point tensors to equations:
from pina import Condition
# Option 1: reference a domain by name (sampled later)
conditions = {
"boundary": Condition(domain="boundary", equation=FixedValue(0.0)),
"interior": Condition(domain="D", equation=Equation(my_pde)),
}
# Option 2: provide explicit points
conditions = {
"data_pde": Condition(input=points_tensor, equation=Equation(my_pde)),
}
Data-driven (supervised)
conditions = {
"data": Condition(input=input_tensor, target=target_tensor),
}
Time series forecasting
If the user has time series data, ask whether they want standard supervised or time-series conditions:
from pina import Condition
# Standard supervised
Condition(input=ts_tensor, target=target_tensor)
# Time series (input is 3D: [batch, n_windows, features])
Condition(
input=ts_tensor,
n_windows=10,
unroll_length=5,
randomize=True,
)
# Graph time series
Condition(
input=graph_ts_data,
n_windows=10,
unroll_length=5,
key="some_key",
)
Parameters:
n_windows— number of rolling windowsunroll_length— prediction horizon per windowrandomize— shuffle window orderkey— key for graph time series data
Step 4 — Integrate with the problem class
Conditions become a class-level dict on the problem:
class MyProblem(SpatialProblem):
output_variables = ["u"]
spatial_domain = CartesianDomain({"x": [0, 1]})
domains = {
"D": spatial_domain,
"boundary": spatial_domain.partial(),
}
conditions = {
"boundary": Condition(domain="boundary", equation=FixedValue(0.0)),
"D": Condition(domain="D", equation=Equation(my_pde)),
}
Checklist
- For data-driven: confirmed data type (
LabelTensor,torch.Tensor,Graph, or PyGData) - For data-driven:
input_variablesis alist[str]naming the inputs - For time series:
n_windows,unroll_length, and optionalkeyare set correctly - Each
Conditionuses valid keyword arguments:Condition(domain=..., equation=...)for physics-on-domainCondition(input=..., equation=...)for physics-on-pointsCondition(input=..., target=...)for data-drivenCondition(input=..., n_windows=..., unroll_length=...)for time series
-
domainsdict has an entry for every domain name used in conditions