Overview
The flow decomposition module allows you to decompose power flows on transmission lines into their constituent components: commercial flow, loop flow from different zones, PST flow, and internal flow. This is useful for cross-border capacity calculation and congestion management.Main Classes
FlowDecomposition
Main class for configuring and running flow decomposition analysis.Methods
Add a contingency with a single element (1 N-1 state).Parameters:
element_id(str): ID of the elementcontingency_id(str, optional): ID of the contingency. Defaults to element_id
Add a contingency for each element (n N-1 states).Parameters:
element_ids(List[str]): List of element IDscontingency_id_provider(Callable, optional): Function to transform element ID to contingency ID
Add a contingency with multiple elements (1 N-k state).Parameters:
elements_ids(List[str]): List of element IDscontingency_id(str, optional): ID of the contingency. Defaults to concatenation of element IDs
Add branches to be monitored by the flow decomposition.Creates a XNEC for each valid pair of branch and state.Parameters:
branch_ids(List[str] or str): List of branches to monitorcontingency_ids(List[str] or str, optional): List of contingenciescontingency_context_type(ContingencyContextType): Type of states to monitor (ALL, NONE, or SPECIFIC)
Add branches to be monitored on precontingency state (XNE).Parameters:
branch_ids(List[str] or str): List of branches to monitor
Add branches to be monitored on postcontingency states (XNEC).Creates a XNEC for each valid pair of branch and contingency. A pair is valid if the contingency does not contain the branch.Parameters:
branch_ids(List[str] or str): List of branches to monitorcontingency_ids(List[str] or str): List of contingencies
Add branches with zone-to-zone PTDF > 5% or interconnections as monitored elements.Returns: FlowDecomposition
Add all interconnection branches as monitored elements.Returns: FlowDecomposition
Add all network branches as monitored elements.Returns: FlowDecomposition
Run the flow decomposition.Parameters:
network(Network): Network on which to compute flow decompositionflow_decomposition_parameters(Parameters, optional): Flow decomposition parametersload_flow_parameters(loadflow.Parameters, optional): Load flow parameters
branch_id: Branch IDcontingency_id: Contingency IDcountry1: Country ID of terminal 1country2: Country ID of terminal 2ac_reference_flow: AC reference flow (MW)dc_reference_flow: DC reference flow (MW)commercial_flow: Commercial/allocated flow (MW)x_node_flow: Flow from unmerged XNodes (MW)pst_flow: PST flow (MW)internal_flow: Internal flow (MW)loop_flow_from_XX: Loop flow from zone XX (MW), one column per country
xnec_idParameters
Parameters for flow decomposition execution.Enable AC losses compensation on the DC network
Filter loads from losses compensation. Loads with absolute active power below this threshold will not be connected. Use -1 to disable filtering.
Filter sensitivity values. Absolute small sensitivity values below this threshold will be ignored. Use -1 to disable filtering.
Rescale the flow decomposition to the AC reference.Enum Values:
RescaleMode.NONE: No rescalingRescaleMode.ACER_NTCF: ACER NTCF rescaling
Fallback behavior after AC divergence. If True, run DC loadflow if AC loadflow diverges. If False, throw exception on AC divergence.
Chunk size for sensitivity analysis. Reduces memory footprint but increases computation time.
ContingencyContextType
Enum defining contingency context types.Utility Functions
Create a flow decomposition object.Returns: FlowDecompositionExample:
Complete Example
Notes
- Flow decomposition creates XNECs (cross-border network elements with contingencies) and XNEs (without contingencies)
- A valid XNEC pair requires that the contingency does not contain the monitored branch
- The resulting dataframe is indexed on
xnec_id - Loop flow columns are dynamically generated based on the countries in the network
