Skip to content

Connection

The Connection class models bidirectional power flow between elements. It composes ordered segments that apply efficiency, limits, and pricing to the flow.

Overview

Connection is the primary model for power flow:

  • Composable: Ordered segment chain defines behavior.
  • Lossless by default: A passthrough segment is created when no segments are provided.
  • Extensible: Segment outputs are exposed for adapters and diagnostics.

Segments are provided as an ordered mapping. The mapping keys become segment names and drive the nested segments output.

Segment types

Model formulation

Decision variables

For each time step \(t \in \{0, 1, \ldots, T-1\}\):

Variable Domain Description
\(P_{s \rightarrow t}\) \(\mathbb{R}_{\geq 0}\) Power flow from source to target
\(P_{t \rightarrow s}\) \(\mathbb{R}_{\geq 0}\) Power flow from target to source

These variables represent the input to the first segment in the chain. Each segment may transform the flow before passing it to the next segment.

Parameters

Parameter Description
source Name of the source element
target Name of the target element
periods Time period durations (hours)
segments Ordered mapping of segment names to segment specifications

If segments is omitted or empty, a passthrough segment is created automatically. Segment parameters can be scalars or per-period arrays. Scalar values are broadcast across all periods.

Constraints

Connection adds linking constraints between adjacent segments. Each segment contributes its own constraints, such as power limits or time-slice coupling.

Power balance interface

Connections provide power_into_source and power_into_target properties that elements use for power balance. These use the first segment inputs and last segment outputs:

\[ P_{\text{into\_source}}(t) = P^{\text{out}}_{t \rightarrow s,\text{last}}(t) - P^{\text{in}}_{s \rightarrow t,\text{first}}(t) \]
\[ P_{\text{into\_target}}(t) = P^{\text{out}}_{s \rightarrow t,\text{last}}(t) - P^{\text{in}}_{t \rightarrow s,\text{first}}(t) \]

Efficiency losses are applied inside the segment chain. Elements do not need to account for them directly.

Cost contribution

Connection aggregates cost expressions from all segments. PricingSegment instances contribute directional energy costs.

Outputs

Connection exposes power flow and segment outputs:

  • connection_power_source_target
  • connection_power_target_source
  • segments (nested map of segment names to constraint shadow outputs)

The segments output groups segment outputs using the segment names provided in the configuration. Adapters use this map to surface segment-specific shadow prices (for example power_limit.source_target).

When to use

Use Connection for all power-flow paths. Select the segment chain that matches the physical behavior you need.

Next Steps