Interfaces#
toop_engine_interfaces
#
toop_engine_interfaces.folder_structure
#
Defines constants for the folder structure.
File: folder_structure.py Author: Benjamin Petrick Created: 2024-09-12
PREPROCESSING_PATHS
module-attribute
#
PREPROCESSING_PATHS = {
"grid_file_path_powsybl": "grid.xiidm",
"grid_file_path_pandapower": "grid.json",
"masks_path": "masks",
"static_information_file_path": "static_information.hdf5",
"importer_auxiliary_file_path": "importer_auxiliary_data.json",
"initial_topology_path": "initial_topology",
"LF_CA_path": "initial_topology/LF_CA",
"single_line_diagram_path": "initial_topology/single_line_diagram",
"asset_topology_file_path": "initial_topology/asset_topology.json",
"asset_topology_runtime_file_path": "initial_topology/asset_topology_runtime.json",
"asset_topology_master_file_path": "initial_topology/asset_topology_master_data.json",
"asset_topology_master_data_file_path": "initial_topology/asset_topology_master_data.json",
"original_gridfile_path": "initial_topology/original_gridfile",
"logs_path": "logs",
"start_datetime_info_file_path": "logs/start_datetime.info",
"chronics_path": "chronics",
"action_set_file_path": "action_set.json",
"action_set_diff_path": "action_set_diffs.hdf5",
"nminus1_definition_file_path": "nminus1_definition.json",
"ignore_file_path": "ignore_elements.csv",
"contingency_list_file_path": "contingency_list.csv",
"static_information_stats_file_path": "static_information_stats.json",
"loadflow_parameters_file_path": "loadflow_parameters.json",
}
POSTPROCESSING_PATHS
module-attribute
#
POSTPROCESSING_PATHS = {
"optimizer_snapshots_path": "optimizer_snapshots",
"dc_optimizer_snapshots_path": "optimizer_snapshots/dc",
"ac_optimizer_snapshots_path": "optimizer_snapshots/ac",
"dc_plus_optimizer_snapshots_path": "optimizer_snapshots/dc_plus",
"LF_CA_ac_path": "optimizer_snapshots/ac/LF_CA",
"single_line_diagram_ac_path": "optimizer_snapshots/ac/single_line_diagram",
"logs_path": "logs",
"orao_summary": "orao_summary",
}
NETWORK_MASK_NAMES
module-attribute
#
NETWORK_MASK_NAMES = {
"relevant_subs": "relevant_subs.npy",
"line_for_nminus1": "line_for_nminus1.npy",
"line_for_reward": "line_for_reward.npy",
"line_overload_weight": "line_overload_weight.npy",
"line_disconnectable": "line_disconnectable.npy",
"line_tso_border": "line_tso_border.npy",
"line_blacklisted": "line_blacklisted.npy",
"trafo_for_nminus1": "trafo_for_nminus1.npy",
"trafo_for_reward": "trafo_for_reward.npy",
"trafo_overload_weight": "trafo_overload_weight.npy",
"trafo_disconnectable": "trafo_disconnectable.npy",
"trafo_controllable": "trafo_controllable.npy",
"trafo_dso_border": "trafo_dso_border.npy",
"trafo_n0_n1_max_diff_factor": "trafo_n0_n1_max_diff_factor.npy",
"trafo_blacklisted": "trafo_blacklisted.npy",
"trafo3w_for_nminus1": "trafo3w_for_nminus1.npy",
"trafo3w_for_reward": "trafo3w_for_reward.npy",
"trafo3w_overload_weight": "trafo3w_overload_weight.npy",
"trafo3w_disconnectable": "trafo3w_disconnectable.npy",
"trafo3w_n0_n1_max_diff_factor": "trafo3w_n0_n1_max_diff_factor.npy",
"tie_line_for_reward": "tie_line_for_reward.npy",
"tie_line_for_nminus1": "tie_line_for_nminus1.npy",
"tie_line_overload_weight": "tie_line_overload_weight.npy",
"tie_line_disconnectable": "tie_line_disconnectable.npy",
"tie_line_tso_border": "tie_line_tso_border.npy",
"boundary_line_for_nminus1": "boundary_line_for_nminus1.npy",
"generator_for_nminus1": "generator_for_nminus1.npy",
"load_for_nminus1": "load_for_nminus1.npy",
"switch_for_nminus1": "switch_for_nminus1.npy",
"switch_for_reward": "switch_for_reward.npy",
"cross_coupler_limits": "cross_coupler_limits.npy",
"sgen_for_nminus1": "sgen_for_nminus1.npy",
"busbar_for_nminus1": "busbar_for_nminus1.npy",
}
OUTPUT_FILE_NAMES
module-attribute
#
OUTPUT_FILE_NAMES = {
"multiple_topologies": "repertoire.json",
"realized_asset_topology": "asset_topology.json",
"postprocessed_topology": "topology.json",
"loadflows_ac": "loadflows_ac.hdf5",
"loadflows_dc": "loadflows_dc.hdf5",
"loadflows_ac_cross_coupler": "loadflows_ac_cross_coupler.hdf5",
"loadflows_dc_cross_coupler": "loadflows_dc_cross_coupler.hdf5",
}
CHRONICS_FILE_NAMES
module-attribute
#
CHRONICS_FILE_NAMES = {
"load_p": "load_p.npy",
"gen_p": "gen_p.npy",
"sgen_p": "sgen_p.npy",
"dcline_p": "dcline_p.npy",
}
toop_engine_interfaces.backend
#
The abstract interface definition for accessing data from pandapower/powerfactory/...
BackendInterface
#
Bases: ABC
Interface for the backend.
The task of this interface is to provide routines for accessing data from the grid modelling software (pandapower/powerfactory/...)
Specifically not task of this interface is to perform any validations or processing of the data
This assume a node-branch model, hence busbars would be nodes and lines, trafos, etc would be branches. Injections inject onto a node and represent both generators, loads, sgens, ...
get_ptdf
#
Get the PTDF matrix, if it was computed already
For the relevant substations it is important that only node A is given as a column in the reference topology. This is to ensure node A and B are treated properly by the algorithm.
If None is returned, the PTDF matrix will be computed by the solver based on from_node, to_node and susceptance.
| RETURNS | DESCRIPTION |
|---|---|
Float[ndarray, ' n_branch n_node']
|
The unextended PTDF matrix, not including second nodes for the relevant substations, and not including the PSDF. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_psdf
#
Get the PSDF matrix, if it was computed already
If None is returned, the PSDF matrix will be computed by the solver based on shift_angle and susceptance.
This refers to the already reduced PSDF matrix, i.e. without elements that will never have a shift angle. See get_phase_shifters for more information.
| RETURNS | DESCRIPTION |
|---|---|
Float[ndarray, ' n_branch n_phaseshifters']
|
The PSDF matrix, not including the PTDF. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_slack
abstractmethod
#
Get the index of the slack node
Note that the solver does not support distributed slack nodes, if you have a distributed slack, replace all but one slack node by their injections or create a virtual slack node that is connected with same-impendance lines to the other slack nodes.
| RETURNS | DESCRIPTION |
|---|---|
int
|
The index of the slack node |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_ac_dc_mismatch
#
Get the AC-DC mismatch for each branch
This is the difference between the AC and DC flow on each branch, i.e. the difference between the AC and DC loadflow results.
This is used in the solver to adjust the DC flow to match the AC flow in the N-0 case. If all zeros are returned, the solver will return pure DC flows.
Positive values mean the AC flow is higher than the DC flow, negative values mean the AC flow is lower than the DC flow.
| RETURNS | DESCRIPTION |
|---|---|
Float[ndarray, ' n_timestep n_branch']
|
The AC-DC mismatch for each branch and per timestep |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_basecase_dc_branch_flows
abstractmethod
#
Return base-case DC branch flows in the solver's branch orientation.
Positive values flow from get_from_nodes() to get_to_nodes(). The returned
values must be ordered consistently with get_branch_ids() and contain one row per
timestep.
| RETURNS | DESCRIPTION |
|---|---|
Float[ndarray, ' n_timestep n_branch']
|
Base-case DC active branch flows in MW. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_max_mw_flows
abstractmethod
#
Get the maximum flow per branch
The timestep dimension is added to represent temperature-dependent capacity limits. If the capacity limits are not temperature-dependent, the same value should be returned for all timesteps.
| RETURNS | DESCRIPTION |
|---|---|
Float[ndarray, ' n_timestep n_branch']
|
The maximum flow per branch and per timestep |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_max_mw_flows_n_1
#
Get a varying max flow for N-1 if there is a difference or NaN.
In some circumstances, a higher N-1 load is allowed than N-0 as N-1 leaves some time to address an overload in practice - a line won't melt right away if it's overloaded for a few seconds until the operators can react.
If not overloaded, returns all NaNs and hence the values from get_max_mw_flows will be used.
| RETURNS | DESCRIPTION |
|---|---|
Float[ndarray, ' n_timestep n_branch']
|
The maximum flow per branch and per timestep if overridden, else NaN |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_overload_weights
#
Get a factor that the overloads are multiplied with for each branch
This can be used to penalize overloads on certain branches more than on others.
If this funcion is not overloaded, returns all ones.
| RETURNS | DESCRIPTION |
|---|---|
Float[ndarray, ' n_branch']
|
The overload weights for each branch |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_n0_n1_max_diff_factors
#
Get limits for the relative difference between N-0 and N-1 flows.
This is an array of factors to the base case flows. Negative factors or NaN values mean the branch will be ignored and always have a penalty of 0. For example if a branch has a 20 MW diff between N-0 and N-1 in the base case (in the unsplit configuration) and the factor is 2, then the maximum allowed diff for the n0_n1_delta penalty would be 40 MW. If a negative factor is used, this branch has no N-0 to N-1 maximum delta and will always incur a penalty of 0. See dc_solver.jax.aggregate_results.compute_n0_n1_max_diff for how these factors are used
If this function is not overloaded, returns all minus ones (i.e. no branch has a limit).
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_cross_coupler_limits
#
Get the cross-coupler limits for each relevant substation.
Returns over all buses to match conventions and if relevant substations are modified independently of the cross-coupler limits.
The limits are a P[MW] Value for each coupler.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_susceptances
abstractmethod
#
Get the susceptances of the branches
| RETURNS | DESCRIPTION |
|---|---|
Float[ndarray, ' n_branch']
|
The susceptances of the branches |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_from_nodes
abstractmethod
#
Get the from nodes of the branches
| RETURNS | DESCRIPTION |
|---|---|
Int[ndarray, ' n_branch']
|
The from nodes of the branches |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_to_nodes
abstractmethod
#
Get the to nodes of the branches
| RETURNS | DESCRIPTION |
|---|---|
Int[ndarray, ' n_branch']
|
The to nodes of the branches |
get_controllable_pst_node_mask
#
Get the mask of controllable phase shifters over nodes
True means a node is (bogus node and) a controllable phase shifter, i.e. is connected to a branch that is a controllable phase shifter. False means it normal node.
| RETURNS | DESCRIPTION |
|---|---|
Bool[ndarray, ' n_node']
|
The mask of controllable phase shifters over nodes |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_shift_angles
abstractmethod
#
Get the shift angles of the branches in degree
The timestep dimension is added to represent time-varying phase shift angles. If the phase shift angles are not time-varying, the same value should be returned for all timesteps.
| RETURNS | DESCRIPTION |
|---|---|
Float[ndarray, ' n_timestep n_branch']
|
The shift angles of the branches |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_phase_shift_mask
abstractmethod
#
Get the mask of phase shifters
True means a branch is a phase shifter, i.e. can have shift_degree != 0 False means it is not a phase shifter. Note that the controllable phase shifters are a subset of this, i.e. not every phase shifter is controllable.
| RETURNS | DESCRIPTION |
|---|---|
Bool[ndarray, ' n_branch']
|
The mask of phase shifters |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_controllable_phase_shift_mask
#
Which of the phase shifters are controllable
This must be a subset of get_phase_shift_mask()
| RETURNS | DESCRIPTION |
|---|---|
Bool[ndarray, ' n_branch']
|
The mask of controllable phase shifters |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_phase_shift_linearity
#
Which of the phase shifters have linear shift behavior
| RETURNS | DESCRIPTION |
|---|---|
Bool[ndarray, ' n_controllable_psts']
|
The mask of phase shifters with linear shift behavior |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_phase_shift_taps
#
Return the possible tap positions of each controllable PST.
The outer list has as many entries as there are controllable PSTs (see controllable_phase_shift_mask). The inner np array has as many entries as there are taps for the given PST with each value representing the angle shift for the given tap position. The taps are ordered smallest to largest angle shift. Each controllable PST must have at least one tap position.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_phase_shift_susceptance_taps
#
Return the effective branch susceptance at every controllable PST tap.
The returned lists must align with get_phase_shift_taps() and get_controllable_phase_shift_mask(). By default, repeat the current branch susceptance for every tap, which is correct for PSTs whose effective branch parameters do not vary with the tap.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_phase_shift_starting_taps
#
Get the starting tap position for each controllable PST, given as an integer index into pst_tap_values.
Note that taps in the original grid model might not start at zero, while in our optimization we assume taps to always be zero terminated. To translate back into original grid model, add get_phase_shift_low_taps.
The outer list has as many entries as there are controllable PSTs (see controllable_phase_shift_mask). The inner np array has as many entries as there are taps for the given PST with each value representing the angle shift for the given tap position. The taps are ordered smallest to largest angle shift.
If this function is not overloaded, it is assumed that all controllable PSTs start at their lowest tap position (i.e. index 0).
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_phase_shift_low_taps
#
Get the lowest tap position in the original grid model
Original taps are needed so taps as integer indices into tap values can be converted back to the original tap positions by tap + low_tap
If this function is not overloaded, it is assumed that all controllable PSTs have a low tap of 0.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_controllable_phase_shift_ids
#
Get branch ids of controllable PSTs aligned with controllable PST arrays.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_parallel_pst_group_mask
abstractmethod
#
Get a PST group mask aligned with the controllable PST arrays.
| RETURNS | DESCRIPTION |
|---|---|
Optional[Bool[np.ndarray, " n_parallel_pst_groups n_controllable_pst"]
|
The mask for parallel PST groups, or None if no explicit grouping metadata is available. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_parallel_pst_group_ids
abstractmethod
#
Get PST group identifiers aligned with rows of get_parallel_pst_group_mask().
| RETURNS | DESCRIPTION |
|---|---|
Optional[list[str]]
|
The identifiers for parallel PST groups, or None if no explicit grouping metadata is available. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_relevant_node_mask
abstractmethod
#
Get true if a node is part of the relevant nodes
This refers to the node A (the node that is present in the un-extended PTDF) of the relevant substations. The relevant nodes are those that can be split later on in the solver.
| RETURNS | DESCRIPTION |
|---|---|
Bool[ndarray, ' n_node']
|
The mask over nodes, indicating if they are relevant (splittable) |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_monitored_branch_mask
abstractmethod
#
Get the mask of monitored branches for the reward calculation
True means a branch is monitored, False means it is not monitored
| RETURNS | DESCRIPTION |
|---|---|
Bool[ndarray, ' n_branch']
|
The mask of monitored branches |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_branches_in_maintenance
abstractmethod
#
Get the mask of branches in maintenance
True means a branch is in maintenance, False means it is not in maintenance
The timestep dimension is added to represent time-varying maintenance schedules. If the maintenance schedules are not time-varying, the same value should be returned for all timesteps.
| RETURNS | DESCRIPTION |
|---|---|
Bool[ndarray, ' n_timestep n_branch']
|
The mask of branches in maintenance |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_disconnectable_branch_mask
abstractmethod
#
Get the mask of disconnectable branches
True means a branch is disconnectable as a remedial action, False means it must stay online
| RETURNS | DESCRIPTION |
|---|---|
Bool[ndarray, ' n_branch']
|
The mask of disconnectable branches |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_outaged_branch_mask
abstractmethod
#
Get the mask of outaged branches for the N-1 computation
True means a branch is outaged, False means it is not outaged
| RETURNS | DESCRIPTION |
|---|---|
Bool[ndarray, ' n_branch']
|
The mask of outaged branches |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_outaged_injection_mask
abstractmethod
#
Get the mask of outaged injections for the N-1 computation
True means an injection is outaged, False means it is not outaged
| RETURNS | DESCRIPTION |
|---|---|
Bool[ndarray, ' n_injection']
|
The mask of outaged injections |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_multi_outage_branches
abstractmethod
#
Get the mask of outaged branches for potential multi-outages
True means a branch is outaged, False means it is not outaged.
get_multi_outage_branches, get_multi_outage_nodes and get_multi_outage_names have to return the same first dimension, i.e. the same number of multi-outages.
| RETURNS | DESCRIPTION |
|---|---|
Bool[ndarray, ' n_multi_outages n_branch']
|
The mask of outaged branches for every multi-outage |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_multi_outage_nodes
abstractmethod
#
Get the mask of outaged nodes for potential multi-outages
True means a node is outaged, False means it is not outaged.
get_multi_outage_branches, get_multi_outage_nodes and get_multi_outage_names have to return the same first dimension, i.e. the same number of multi-outages.
| RETURNS | DESCRIPTION |
|---|---|
Bool[ndarray, ' n_multi_outages n_node']
|
The mask of outaged nodes for every multi-outage |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_injection_nodes
abstractmethod
#
Get the node index of the injections
| RETURNS | DESCRIPTION |
|---|---|
Int[ndarray, ' n_injection']
|
The node index that the injection injects onto |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_mw_injections
abstractmethod
#
Get the MW injections of the injections
The timestep dimension is added to represent time-varying injections. If the injections are not time-varying, the same value should be returned for all timesteps.
| RETURNS | DESCRIPTION |
|---|---|
Float[ndarray, ' n_timestep n_injection']
|
The MW injections of the injections |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_base_mva
abstractmethod
#
Get the baseMVA of the grid
| RETURNS | DESCRIPTION |
|---|---|
float
|
The base MVA of the grid |
get_master_asset_topology
#
Get canonical asset-topology master data for the grid, if available.
get_runtime_asset_topology
#
Get live runtime-enriched topology payloads for the current grid, if available.
get_node_ids
abstractmethod
#
Get the ids of the nodes as a Sequence of length N_node
| RETURNS | DESCRIPTION |
|---|---|
Union[Sequence[str], Sequence[int]]
|
The ids of the nodes |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_branch_ids
abstractmethod
#
Get the ids of the branches as a Sequence of length N_branch
| RETURNS | DESCRIPTION |
|---|---|
Union[Sequence[str], Sequence[int]]
|
The ids of the branches |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_injection_ids
abstractmethod
#
Get the ids of the injections as a Sequence of length N_injection
| RETURNS | DESCRIPTION |
|---|---|
Union[Sequence[str], Sequence[int]]
|
The ids of the injections |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_multi_outage_ids
abstractmethod
#
Get the ids of the multi-outages as a Sequence of length N_multi_outages
| RETURNS | DESCRIPTION |
|---|---|
Union[Sequence[str], Sequence[int]]
|
The ids of the multi-outages |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_node_names
abstractmethod
#
Get the names of the nodes as a Sequence of length N_node
| RETURNS | DESCRIPTION |
|---|---|
Sequence[str]
|
The names of the nodes |
get_branch_names
abstractmethod
#
Get the names of the branches as a Sequence of length N_branch
| RETURNS | DESCRIPTION |
|---|---|
Sequence[str]
|
The names of the branches |
get_injection_names
abstractmethod
#
Get the names of the injections
| RETURNS | DESCRIPTION |
|---|---|
Sequence[str]
|
The names of the injections |
get_multi_outage_names
abstractmethod
#
Get the names of the multi-outages as a Sequence of length N_multi_outages
If more than one element are involved in a multi-outage you can return a concatenated name
| RETURNS | DESCRIPTION |
|---|---|
Sequence[str]
|
The names of the multi-outages |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_branch_types
abstractmethod
#
Get the type of the branches
| RETURNS | DESCRIPTION |
|---|---|
Sequence[str]
|
The type of the branches |
get_node_types
abstractmethod
#
Get the type of the nodes
| RETURNS | DESCRIPTION |
|---|---|
Sequence[str]
|
The type of the nodes |
get_injection_types
abstractmethod
#
Get the type of the injections
| RETURNS | DESCRIPTION |
|---|---|
Sequence[str]
|
The type of the injections |
get_multi_outage_types
abstractmethod
#
Get the type of the multi-outages as a Sequence of length N_multi_outages
| RETURNS | DESCRIPTION |
|---|---|
Sequence[str]
|
The type of the multi-outages |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_metadata
abstractmethod
#
Can be used to return metadata or additional information about the grid.
This is not used by the solver but rather to easy postprocessing and validation. You can return an empty dict if you don't want to use this field.
| RETURNS | DESCRIPTION |
|---|---|
dict
|
The metadata of the grid |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
get_busbar_outage_map
#
Get the mapping of stations to busbars for the busbar-outages
The key of the dict is the station's bus_group_id and the value is a list of grid_model_ids of the busbars that have to be outaged. If this method is not overloaded, all the physical busbars of the relevant stations will be outaged.
| RETURNS | DESCRIPTION |
|---|---|
Optional[dict[str, Sequence[str]]]
|
The mapping of busbar-outages to the relevant nodes |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/backend.py
toop_engine_interfaces.types
#
Define global type aliases.
Currently this holds only the MetricType, a Literal of all possible metrics.
The meaning of the metrics is documented in metrics.md in the docs folder.
MatrixMetric
module-attribute
#
MatrixMetric = Literal[
"max_flow_n_0",
"median_flow_n_0",
"overload_energy_n_0",
"underload_energy_n_0",
"overload_energy_limited_n_0",
"exponential_overload_energy_n_0",
"exponential_overload_energy_limited_n_0",
"critical_branch_count_n_0",
"critical_branch_count_limited_n_0",
"max_flow_n_1",
"median_flow_n_1",
"overload_energy_n_1",
"underload_energy_n_1",
"overload_energy_limited_n_1",
"exponential_overload_energy_n_1",
"exponential_overload_energy_limited_n_1",
"critical_branch_count_n_1",
"critical_branch_count_limited_n_1",
"top_k_overloads_n_1",
"cumulative_overload_n_0",
"cumulative_overload_n_1",
"transport_n_0",
"transport_n_1",
]
OperationMetric
module-attribute
#
OperationMetric = Literal[
"switching_distance",
"split_subs",
"disconnected_branches",
"fitness",
"pst_switching_distance",
"pst_switching_distance_squared",
"pst_activated",
]
OtherMetric
module-attribute
#
OtherMetric = Literal[
"n0_n1_delta",
"cross_coupler_flow",
"bb_outage_penalty",
"bb_outage_overload",
"bb_outage_grid_splits",
"max_va_diff_n_0",
"max_va_diff_n_1",
"critical_va_diff_count_n_0",
"critical_va_diff_count_n_1",
"overload_current_n_0",
"overload_current_n_1",
"voltage_jump_count_n_1",
"non_converging_loadflows",
"fitness_dc",
]
toop_engine_interfaces.status_update
#
The in-process progress reporting of the preprocessing routines.
This holds the callback that preprocessing routines invoke to report their progress, along with the statistics they report next to a stage. Both are an internal interface between the routines and whoever drives them, and the statistics only ever end up in the logs. They live here rather than in a package of their own so that the importer and the DC solver can depend on them without depending on each other.
The stages themselves are user-facing and are therefore defined alongside the heartbeat message in toop_engine_interfaces.messages.preprocess.preprocess_heartbeat.
StatusUpdateFn
#
Bases: Protocol
The callback used to report progress through the preprocessing pipeline.
__call__
#
Report that a preprocessing stage was entered.
| PARAMETER | DESCRIPTION |
|---|---|
stage
|
The stage that is being entered
TYPE:
|
message
|
An optional message with more detail on the stage
TYPE:
|
stats
|
Size statistics of the network data as it looks when entering the stage, if available. Only stages that operate on network data report these.
TYPE:
|
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/status_update.py
empty_status_update_fn
#
Log an empty status update to logging.
Use this function when no status_update_fn is provided.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/status_update.py
toop_engine_interfaces.stored_action_set
#
Holds a format for storing the action set for later use in postprocessing.
This is different from the jax-internal action set as defined in jax/types.py where only jax-relevant information is stored, but is instead aimed at use in postprocessing and visualization. Instead of just storing the electrical switching state, this bases on the asset topology to store physical switchings to make a translation to .dgs or other formats easier.
One of the decisions to take was was whether to use a single action set for all timesteps or a different one for each timestep. As the jax part currently also only supports one action set for all timesteps, we decide to mirror this for the time being, i.e. we do not store strategies but topologies in the action set.
Furthermore, it should also be possible to use a global action set if necessary. Meaning, by default an action is substation-local, but it it can span multiple substations as well. Using a format that is suitable for both options is desirable for easier collaboration.
Another question was whether to store the switching distance and busbar information in the action set, but the switching distance can be trivially recomputed by using the bus-group diff between the starting topology and the bus group in the action set. BB outage information can also be retrieved from the asset topology.
There is a slim hope of storing the action set independent of the grid state but based on the master grid, however right now there is a fundamental way that 'binds' an action set to the specific grid it has been computed on: During the enumerations, all electrical actions are enumerated and then physical realizations are found for it based on heuristics. These heuristics take the grid state into account, so it could be that an electrical action can not be realized the same way if maintenances are active. Hence, for the moment, it is no problem to tie the initial topology into the action set.
PSTRange
#
Bases: GridElement
Phase shifting transformers can be set within the scope of non-costly optimization.
A PST has a list of taps, each with an angle shift.
starting_tap
instance-attribute
#
The tap the PST was set to before optimization. To filter out actions that do not change anything in the UI, this is required.
pst_group
class-attribute
instance-attribute
#
The optimization group of the PST.
When omitted in serialized action sets, this defaults to the PST id for backward compatibility.
id
instance-attribute
#
The id of the element. For powsybl grids this is the global string id, for pandapower this is the integer index into the dataframe
name
class-attribute
instance-attribute
#
The name of the element. This is optional, but can be used to provide a more human-readable name for the element.
type
instance-attribute
#
For pandapower, we need to further specify a type which corresponds to the table pandapower stores the information in. Valid tables are 'line', 'trafo', 'ext_grid', 'gen', 'load', 'shunt', ... For powsybl, this is not strictly needed to identify the element however it makes it easier. In that case, type will be something like TIE_LINE, LINE, TWO_WINDING_TRANSFORMER, GENERATOR, etc.
kind
instance-attribute
#
The kind of the element. Usually these are handled differently in the grid modelling software, so it can make assembling an N-1 analysis easier if it is known if the element is a branch, bus or injection. This could be inferred from the type, however for conveniece it is stored separately.
For the bus type there is some potential confusion in powsybl. In pandapower, this always refers to the net.bus df. In powsybl in a bus/branch model, there are no busbar sections in powsybl, i.e. net.get_node_breaker_topology does not deliver busbar sections. Meaning, the "bus" type refers to the net.get_bus_breaker_topology buses if it's a bus/breaker topology bus. If it's a node/breaker topology, then "bus" refers to the busbar section.
HVDCRange
#
Bases: GridElement
High voltage direct current lines can be set within the scope of non-costly optimization.
An HVDC has a minimum and maximum power setpoint
id
instance-attribute
#
The id of the element. For powsybl grids this is the global string id, for pandapower this is the integer index into the dataframe
name
class-attribute
instance-attribute
#
The name of the element. This is optional, but can be used to provide a more human-readable name for the element.
type
instance-attribute
#
For pandapower, we need to further specify a type which corresponds to the table pandapower stores the information in. Valid tables are 'line', 'trafo', 'ext_grid', 'gen', 'load', 'shunt', ... For powsybl, this is not strictly needed to identify the element however it makes it easier. In that case, type will be something like TIE_LINE, LINE, TWO_WINDING_TRANSFORMER, GENERATOR, etc.
kind
instance-attribute
#
The kind of the element. Usually these are handled differently in the grid modelling software, so it can make assembling an N-1 analysis easier if it is known if the element is a branch, bus or injection. This could be inferred from the type, however for conveniece it is stored separately.
For the bus type there is some potential confusion in powsybl. In pandapower, this always refers to the net.bus df. In powsybl in a bus/branch model, there are no busbar sections in powsybl, i.e. net.get_node_breaker_topology does not deliver busbar sections. Meaning, the "bus" type refers to the net.get_bus_breaker_topology buses if it's a bus/breaker topology bus. If it's a node/breaker topology, then "bus" refers to the busbar section.
ActionSet
#
Bases: BaseModel
A collection of actions available to the optimizer in readable form.
All actions are also stored directly in jax, but without IDs, names or other useful information to introspect them.
starting_bus_groups
instance-attribute
#
Runtime-aware bus-group snapshots for the starting grid state. These are used to get to the switches of disconnectable branches. In the future this will be handled differently via the circuit groups.
simplified_starting_bus_groups
instance-attribute
#
Runtime-aware bus-group snapshots for the simplified starting grid state.
These snapshots define the bus-group and asset ordering contract for local_actions.
They are still runtime snapshots, but projected to the reduced DC-solver asset view rather than
the full physical bus-group view.
These are used to apply the split topology.
connectable_branches
instance-attribute
#
A list of assets that can be connected as a remedial action.
disconnectable_branches
instance-attribute
#
A list of assets that can be disconnected as a remedial action. Currently the DC solver supports only branches.
pst_ranges
instance-attribute
#
A list of phase shifting transformers that can be set as a remedial action.
hvdc_ranges
instance-attribute
#
A list of high voltage direct current lines that can be set as a remedial action. This is currently not implemented yet in the solver.
local_actions
instance-attribute
#
A list of split/reconfiguration actions that affect exactly one electrical bus group.
Actions affecting the same bus group are adjacent. The bus_group_id identifies the affected
bus group, and asset ordering matches the corresponding entry in
simplified_starting_bus_groups.
get_starting_bus_groups
#
Return normalized runtime-aware bus-group snapshots for the starting topology.
get_simplified_starting_bus_groups
#
Return normalized runtime-aware bus-group snapshots for the simplified starting topology.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/stored_action_set.py
BusGroupDiffArray
#
Bases: BaseModel
A difference between copies of a bus group in the local action set and the starting topology.
So that the action set does not have to store copies of the full bus group with all associated information, we only store the changes in the bus group that are typical for the actions in the action set, i.e. the switching table and coupler states. Furthermore, we store them in array form for the entire action set, so that we can potentially store them in parquet format.
A full action set consists of bus-group diffs for every switchable bus group in the grid.
model_config
class-attribute
instance-attribute
#
coupler_open
instance-attribute
#
The state of the "open" field for every coupler in the bus group. The array dimension n_couplers is equivalent to
bus_group.couplers in length and order and the entries correspond to open (True) and closed (False). The n_actions
dimension provides an entry per action in the action set.
branch_switching_table
instance-attribute
#
Branch switching tables for the bus-group actions.
The busbar and branch-asset dimensions match bus_group.branch_switching_table.
injection_switching_table
instance-attribute
#
Injection switching tables for the bus-group actions.
The busbar and injection-asset dimensions match bus_group.injection_switching_table.
validate_actions_grouped
#
Validate that actions are grouped by bus-group grid model id.
| PARAMETER | DESCRIPTION |
|---|---|
actions
|
Action bus groups to validate.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If a bus-group grid model id appears in multiple non-contiguous groups. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/stored_action_set.py
store_bus_group_diff_fs
#
Store bus-group diffs to an HDF5 file, using a different group for every bus group.
Use load_bus_group_diff_fs to load it again
| PARAMETER | DESCRIPTION |
|---|---|
filesystem
|
A filesystem to store the bus-group diffs in.
TYPE:
|
bus_group_diffs
|
A list of bus-group diffs to store.
TYPE:
|
diff_file_path
|
The file path to store the bus-group diffs in.
TYPE:
|
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/stored_action_set.py
load_bus_group_diff_fs
#
Load bus-group diffs from an HDF5 file, using a different group for every bus group.
Use store_station_diff_io to store it.
| PARAMETER | DESCRIPTION |
|---|---|
filesystem
|
A filesystem to load the bus-group diffs from.
TYPE:
|
diff_file_path
|
The file path to load the bus-group diffs from.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[BusGroupDiffArray]
|
A list of bus-group diffs loaded from the file. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/stored_action_set.py
expand_single_bus_group_diff_to_actions
#
Expand one densely stored bus-group diff to action bus groups.
| PARAMETER | DESCRIPTION |
|---|---|
starting_busgroup
|
The starting bus group. Its static fields are copied while coupler states and switching tables are replaced.
TYPE:
|
bus_group_diff
|
The bus-group diff to expand.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[SimplifiedBusGroup]
|
Action bus groups represented by the diff action dimension. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/stored_action_set.py
expand_bus_group_diffs_from_starting_bus_groups
#
Expand densely stored bus-group diffs from reference runtime bus groups.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/stored_action_set.py
compress_actions_to_bus_group_diffs_from_starting_bus_groups
#
compress_actions_to_bus_group_diffs_from_starting_bus_groups(
starting_bus_groups,
actions,
validate_diff_hypothesis=False,
)
Compress action bus groups to bus-group diffs using reference runtime bus groups.
This is the inverse of expand_bus_group_diffs_from_starting_bus_groups and keeps only the
state that actually varies across local actions: coupler openness and the two switching tables.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/stored_action_set.py
load_action_set_fs
#
Load an action set from a file system.
| PARAMETER | DESCRIPTION |
|---|---|
filesystem
|
The file system to use to load the action set.
TYPE:
|
json_file_path
|
The path to the JSON file containing the action set without local actions.
TYPE:
|
diff_file_path
|
The path to the HDF5 file containing the station diffs to expand to local actions. If this is none, the local_actions field will not be filled and be the empty list.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ActionSet
|
The action set loaded from the file. When |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/stored_action_set.py
load_action_set
#
Load an action set from a file.
| PARAMETER | DESCRIPTION |
|---|---|
json_file_path
|
The path to the JSON file containing the action set without local actions.
TYPE:
|
diff_file_path
|
The path to the HDF5 file containing the station diffs to expand to local actions. If this is none, the local_actions field will not be filled and be the empty list.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ActionSet
|
The action set loaded from the file. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/stored_action_set.py
save_action_set_fs
#
save_action_set_fs(
filesystem,
json_file_path,
diff_file_path,
action_set,
validate_diff_hypothesis=False,
revalidate_action_set=True,
)
Save an action set to a file system.
| PARAMETER | DESCRIPTION |
|---|---|
filesystem
|
The file system to use to save the action set.
TYPE:
|
json_file_path
|
The path to the JSON file to save the pydantic payload.
TYPE:
|
diff_file_path
|
The path to the HDF5 file to save the station diffs.
TYPE:
|
action_set
|
The action set to save.
TYPE:
|
validate_diff_hypothesis
|
Whether to validate that local action changes only affect coupler open states and switching tables. This is intended for debugging and can make saving slower.
TYPE:
|
revalidate_action_set
|
Whether to round-trip the action set through Pydantic validation before saving.
Disable this in hot paths when the caller already constructed a validated
TYPE:
|
Notes
The JSON payload stores only the reference stations and scalar metadata. local_actions are
serialized separately as dense station diffs in HDF5 to avoid repeating unchanged station payloads.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/stored_action_set.py
save_action_set
#
save_action_set(
json_file_path,
diff_file_path,
action_set,
validate_diff_hypothesis=False,
revalidate_action_set=True,
)
Save an action set to a file.
| PARAMETER | DESCRIPTION |
|---|---|
json_file_path
|
The path to the JSON file to save the pydantic payload.
TYPE:
|
diff_file_path
|
The path to the HDF5 file to save the station diffs.
TYPE:
|
action_set
|
The action set to save.
TYPE:
|
validate_diff_hypothesis
|
Whether to validate that local action changes only affect coupler open states and switching tables. This is intended for debugging and can make saving slower.
TYPE:
|
revalidate_action_set
|
Whether to round-trip the action set through Pydantic validation before saving.
TYPE:
|
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/stored_action_set.py
random_actions
#
Sample a random topology from the action set.
Makes sure to sample each substation at most once.
| PARAMETER | DESCRIPTION |
|---|---|
action_set
|
The action set to sample the random topology from.
TYPE:
|
rng
|
The random number generator to use.
TYPE:
|
n_split_subs
|
The number of substations to split. If this is more than total number of substations, all substations are split. (i.e. will be clipped to the number of substations)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[int]
|
A list of indices of the action set with substations to split. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/stored_action_set.py
Messages#
toop_engine_interfaces.messages.preprocess
#
toop_engine_interfaces.messages.lf_service
#
toop_engine_interfaces.messages.lf_service.loadflow_commands
#
Describes the interfaces for a loadflow service providing N-1 computations in AC or DC to customers.
The communication follows a 2 step pattern:
- Grid load - Load a grid file into the engine and potentially perform some preprocessing. The engine should return a grid reference upon this call, which is used in the job to reference the grid. Multiple grids can be loaded at the same time, it is the responsibility of the engine to perform memory management (i.e. swap out a grid to disk if memory is full).
- Execute jobs - Run a loadflow job on the engine. The job references the grid that was loaded in step 2. A call to this can contain multiple jobs, allowing the engine to parallelize over jobs in addition to parallelizing over timesteps/outages.
The LoadflowEngine protocol describes this two step process in detail.
BaseFilter
#
Bases: BaseModel, ABC
A base class for filters.
The idea behind filters is to implement logics that can not be implemented with the monitored elements directly but that are dependent on the loadflow results
This is not to be used directly, but to be subclassed.
WorstContingencyBranchFilter
#
Bases: BaseFilter
If this filter is applied, it will reduce the branch results to only the worst N-1 case/side per branch and timestep.
Worst is determined with respect to the loading value. Branches that don't have a rating will never be returned.
If there are multiple worst N-1 cases/sides that produce a tie, one will be chosen at random. This filtering happens on a per-timestep basis, meaning for every timestep there should be as many results as monitored branches, but they can refer to different N-1 cases.
VoltageBandFilter
#
Bases: BaseFilter
If this filter is applied, it will reduce the node results to only the results that are outside of a specified band.
The band is defined by a minimum and maximum p.u. value for all nodes
return_basecase
class-attribute
instance-attribute
#
Whether to return the basecase at all times. If this is set to True, the basecase will always be returned even if it is inside the band and hence should be filtered out.
filter_type
class-attribute
instance-attribute
#
An identifier for the discriminated union
PercentCutoffBranchFilter
#
Bases: BaseFilter
Filter, if applied returns only branch results that are above a loading threshold.
Elements for which no loading could be computed (e.g. due to missing ratings) are never returned. This filtering happens on a per-timestep basis, i.e. if a branch/contingency is above the threshold in one timestep, it will be returned in exactly that timestep.
Job
#
Bases: BaseModel
A job constitutes a single workload and will produce a LoadflowResults object.
There are different types of jobs based on the workload, the simple being a base job with no changes to the base grid.
id
instance-attribute
#
A unique identifier for the job. This is used to reference the job in the results.
branch_filter
class-attribute
instance-attribute
#
Filters for the branch results table. Exactly one filter can be active per table and job
node_filter
class-attribute
instance-attribute
#
Filters for the node results table. Exactly one filter can be active per table and job
job_type
class-attribute
instance-attribute
#
An identifier for the discriminated union
timestep_subselection
class-attribute
instance-attribute
#
If this is set, only the timesteps in this list are computed. If this is not set, all timesteps are computed. Timesteps are referenced by their index in the grid file, starting at 0.
JobWithCGMESChanges
#
Bases: Job
A job that includes changes in CGMES format. This is only applicable if the grid is a CGMES grid
tp_files
instance-attribute
#
The file including the topology changes that shall be applied.
There must be as many entries as timesteps in the grid, but the same file can be referenced multiple times.
ssh_files
instance-attribute
#
The file including the state/injection changes that shall be applied.
There must be as many entries as timesteps in the grid, but the same file can be referenced multiple times.
job_type
class-attribute
instance-attribute
#
An identifier for the discriminated union
id
instance-attribute
#
A unique identifier for the job. This is used to reference the job in the results.
branch_filter
class-attribute
instance-attribute
#
Filters for the branch results table. Exactly one filter can be active per table and job
node_filter
class-attribute
instance-attribute
#
Filters for the node results table. Exactly one filter can be active per table and job
timestep_subselection
class-attribute
instance-attribute
#
If this is set, only the timesteps in this list are computed. If this is not set, all timesteps are computed. Timesteps are referenced by their index in the grid file, starting at 0.
InjectionAddition
#
Bases: BaseModel
A single addition of an injection at a node.
This feature only support PQ nodes, if attempted to apply to a branch, pv node or slack node, the engine should ignore this addition and log a warning.
Positive values shall have the same effect as sgens, i.e. power is produced, while negative values will have the same effect as loads, i.e. power is consumed.
timestep_subselection
class-attribute
instance-attribute
#
If this is given, the addition only happens in the timesteps that are in this list. If this is not given, the addition happens in all timesteps.
JobWithInjectionAdditions
#
Bases: Job
Adds a constant injection to a node in the grid.
This feature assumes all injections are added to PQ nodes - otherwise they will be ignored.
Positive values shall have the same effect as sgens, i.e. power is produced, while negative values will have the same effect as loads, i.e. power is consumed.
job_type
class-attribute
instance-attribute
#
An identifier for the discriminated union
id
instance-attribute
#
A unique identifier for the job. This is used to reference the job in the results.
branch_filter
class-attribute
instance-attribute
#
Filters for the branch results table. Exactly one filter can be active per table and job
node_filter
class-attribute
instance-attribute
#
Filters for the node results table. Exactly one filter can be active per table and job
timestep_subselection
class-attribute
instance-attribute
#
If this is set, only the timesteps in this list are computed. If this is not set, all timesteps are computed. Timesteps are referenced by their index in the grid file, starting at 0.
BaseGrid
#
Bases: BaseModel, ABC
A base class for grid files. This is not to be used directly, but to be subclassed
n_1_definition
class-attribute
instance-attribute
#
The N-1 cases that are to be computed. If this is provided, this shall overwrite the N-1 cases that are defined in the grid files if the format supports such definition. If this is not provided, the N-1 cases that are defined in the grid files shall be used. If neither is provided, the engine should throw an error.
grid_type
instance-attribute
#
An identifier for the discriminated union, to be set by the subclasses
CGMESGrid
#
Bases: BaseGrid
A CGMES grid file does not need to store much additional information
grid_files
instance-attribute
#
A list of paths to grid files. This can include multiple .tp and .ssh files which are to be interpreted as multiple timesteps. If a .tp and a .ssh file have the same filename or the same timestep metadata inside the file, they correspond to the same timestep. Timesteps should be sorted by the timestep information inside the CGMES files.
grid_type
class-attribute
instance-attribute
#
An identifier for the discriminated union
n_1_definition
class-attribute
instance-attribute
#
The N-1 cases that are to be computed. If this is provided, this shall overwrite the N-1 cases that are defined in the grid files if the format supports such definition. If this is not provided, the N-1 cases that are defined in the grid files shall be used. If neither is provided, the engine should throw an error.
UCTEGrid
#
Bases: BaseGrid
A list of UCTE files that are to be loaded into the engine
grid_files
instance-attribute
#
A list of paths to grid files. This can include multiple .ucte files which are to be interpreted as multiple timesteps. Timesteps should be interpreted in the order of this list
grid_type
class-attribute
instance-attribute
#
An identifier for the discriminated union
n_1_definition
class-attribute
instance-attribute
#
The N-1 cases that are to be computed. If this is provided, this shall overwrite the N-1 cases that are defined in the grid files if the format supports such definition. If this is not provided, the N-1 cases that are defined in the grid files shall be used. If neither is provided, the engine should throw an error.
PowsyblGrid
#
Bases: BaseGrid
A list of powsybl xiidm files that are to be loaded into the engine
grid_files
instance-attribute
#
A list of xiidm files that represent the timesteps. Timesteps should be interpreted in the order of this list
n_1_definition
class-attribute
instance-attribute
#
The N-1 cases that are to be computed. If this is provided, this shall overwrite the N-1 cases that are defined in the grid files if the format supports such definition. If this is not provided, the N-1 cases that are defined in the grid files shall be used. If neither is provided, the engine should throw an error.
PandapowerGrid
#
Bases: BaseGrid
A list of pandapower json files that are to be loaded into the engine
grid_files
instance-attribute
#
A list of pandapower files that represent the timesteps. Timesteps should be interpreted in the order of this list
n_1_definition
class-attribute
instance-attribute
#
The N-1 cases that are to be computed. If this is provided, this shall overwrite the N-1 cases that are defined in the grid files if the format supports such definition. If this is not provided, the N-1 cases that are defined in the grid files shall be used. If neither is provided, the engine should throw an error.
StartCalculationCommand
#
Bases: BaseModel
A command to run a list of jobs on the engine.
This can involve multiple N-1 computations with different changes to the base grid, but a job must share the same grid file.
loadflow_id
instance-attribute
#
A unique identifier for the loadflow run. This is used to identify the result
grid_data
class-attribute
instance-attribute
#
The string that was returned by load_grid, identifying the grid file that this job collection shall run on
method
instance-attribute
#
The method that is to be used for the loadflow computations. This can be either AC or DC. This must be the same for all jobs in the list
LoadflowEngine
#
Bases: Protocol
A protocol for a loadflow engine.
Roughly, an engine shall be able to load grids and execute jobs on them. There is some memory management that the engine needs to perform internally, i.e. it could happen that two users want to use the same engine in parallel. In that case, the engine should swap out grids to disk if memory is full.
run_job
#
Run a job on the engine.
This can involve multiple N-1 computations with different changes to the base grid, identified through multiple jobs in the BatchJob. The engine should return the results of the jobs as in-memory dataframes.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/messages/lf_service/loadflow_commands.py
ShutdownCommand
#
Bases: BaseModel
A command to shut down the preprocessing worker
toop_engine_interfaces.messages.lf_service.loadflow_heartbeat
#
Loadflow Heartbeat Commands for the kafka worker.
LoadflowStatusInfo
#
Bases: BaseModel
A status info to inform about an ongoint Loadflow solving action.
toop_engine_interfaces.messages.lf_service.stored_loadflow_reference
#
A reference to a stored loadflow, in a separate file because many locations started to reference it.
Also, we might add helper functions in the future like load/save to azure bucket.
StoredLoadflowReference
#
Bases: BaseModel
A reference to a stored loadflow result on disk or in an object store.
Loadflow results are too large to be sent directly over kafka, so they need to be stored somewhere and referenced.
They are stored and written using the functions in loadflow_result_helpers_new.py, which use the fsspec library
to abstract away the filesystem. Hence, these can write to local disk, Azure bucket, ...
The reference contains the filename relative to the base path or bucket defined in the filesystem, i.e. if a DirFileSystem is used with base_path="/path/to/base" and the filename is "loadflows" then the full path is "/path/to/base/loadflows/node_results.parquet", "/path/to/base/loadflows/branch_results.parquet", ...
relative_path
instance-attribute
#
The folder of the loadflow result relative to the base path or bucket in the filesystem. This points to a directory under which the files "node_results.parquet", "branch_results.parquet", "metadata.json", ... are stored.
toop_engine_interfaces.messages.protobuf_message_factory
#
Module: protobuf_message_factory
This module provides utility functions for serializing and deserializing messages using the MessageWrapper protobuf schema. It enables conversion between string messages and their protobuf-encoded byte representations for efficient message exchange.
| FUNCTION | DESCRIPTION |
|---|---|
- serialize_message |
Serializes a string message into bytes using the MessageWrapper protobuf schema. |
- deserialize_message |
Deserializes bytes into a string message using the MessageWrapper protobuf schema. |
serialize_message
#
Serialize a message string into bytes using MessageWrapper.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
The message to be serialized.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bytes
|
The serialized message as a bytes object. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/messages/protobuf_message_factory.py
deserialize_message
#
Deserializes a protobuf message from bytes and returns its string representation.
| PARAMETER | DESCRIPTION |
|---|---|
msg_bytes
|
The serialized protobuf message as a byte string.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The deserialized message as a string. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/messages/protobuf_message_factory.py
toop_engine_interfaces.messages.preprocess.preprocess_results
#
Contains the result classes for the preprocessing process.
ImportResult
#
Bases: BaseModel
Statistics and results from an import process of UCTE data
data_folder
instance-attribute
#
The path where the entry point where the timestep data folder structure starts. The folder structure is defined in dc_solver.interfaces.folder_structure. Can be on a temp dir
n_relevant_subs
class-attribute
instance-attribute
#
The number of relevant substations
n_low_impedance_lines
class-attribute
instance-attribute
#
The number of low impedance lines that have been converted to a switch
n_branch_across_switch
class-attribute
instance-attribute
#
The number of branches across a switch that have been removed
n_line_for_nminus1
class-attribute
instance-attribute
#
The number of lines in the N-1 definition
n_line_for_reward
class-attribute
instance-attribute
#
The number of lines that are observed
n_line_disconnectable
class-attribute
instance-attribute
#
The number of lines that are disconnectable
n_trafo_for_nminus1
class-attribute
instance-attribute
#
The number of trafos in the N-1 definition
n_trafo_for_reward
class-attribute
instance-attribute
#
The number of trafos that are observed
n_trafo_disconnectable
class-attribute
instance-attribute
#
The number of trafos in the N-1 definition
n_tie_line_for_reward
class-attribute
instance-attribute
#
The number of tie lines that are observed
n_tie_line_for_nminus1
class-attribute
instance-attribute
#
The number of tie lines in the N-1 definition
n_tie_line_disconnectable
class-attribute
instance-attribute
#
The number of tie lines that are disconnectable
n_boundary_line_for_nminus1
class-attribute
instance-attribute
#
The number of boundary lines in the N-1 definition
n_generator_for_nminus1
class-attribute
instance-attribute
#
The number of generators in the N-1 definition
n_load_for_nminus1
class-attribute
instance-attribute
#
The number of loads in the N-1 definition
n_switch_for_nminus1
class-attribute
instance-attribute
#
The number of switches in the N-1 definition
n_switch_for_reward
class-attribute
instance-attribute
#
The number of switches that are observed
n_white_list
class-attribute
instance-attribute
#
The number of elements in the whitelist in total
n_white_list_applied
class-attribute
instance-attribute
#
The number of elements in the whitelist that were successfully matched and applied
n_black_list
class-attribute
instance-attribute
#
The number of elements in the blacklist in total
n_black_list_applied
class-attribute
instance-attribute
#
The number of elements in the blacklist that were successfully matched and applied
grid_type
class-attribute
instance-attribute
#
The type of grid that was imported, e.g. ucte or cgmes
DynamicInformationStats
#
Bases: BaseModel
Stats about the static information class
fp_dtype
class-attribute
instance-attribute
#
A string representation of the floating point type used in the static informations, e.g. 'float32' or 'float64'.
device
class-attribute
instance-attribute
#
A string representation of the device(s) the static information arrays are placed on, e.g. 'TFRT_CPU_0' or 'cuda:0'. If the arrays are replicated or sharded across multiple devices, all of them are listed comma-separated.
total_size_bytes
class-attribute
instance-attribute
#
The total storage space of all arrays in the dynamic information, in bytes. This is the logical size of the arrays, so a replicated array is counted once and not once per device.
ptdf_size_bytes
class-attribute
instance-attribute
#
The storage space of the PTDF matrix alone, in bytes. Part of total_size_bytes.
action_set_size_bytes
class-attribute
instance-attribute
#
The storage space of the action set, in bytes, excluding the busbar outage data that is stored within it. Part of total_size_bytes and disjoint from bb_outage_size_bytes.
bb_outage_size_bytes
class-attribute
instance-attribute
#
The storage space of all busbar outage data, in bytes. This covers the rel_bb_outage_data inside the action set, the non_rel_bb_outage_data and the bb_outage_baseline_analysis. It is 0 if the static information was preprocessed without busbar outages. Part of total_size_bytes.
has_double_limits
class-attribute
instance-attribute
#
Whether the static information has max_mw_flow_limited set or not
n_branches
class-attribute
instance-attribute
#
The number of branches in the PTDF matrix
n_branch_outages
class-attribute
instance-attribute
#
How many branch outages are part of the N-1 computation
n_multi_outages
class-attribute
instance-attribute
#
How many multi-outages are part of the N-1 computation
n_injection_outages
class-attribute
instance-attribute
#
How many injection outages are part of the N-1 computation
n_busbar_outages
class-attribute
instance-attribute
#
How many busbar outages are part of the N-1 computation
n_nminus1_cases
class-attribute
instance-attribute
#
How many N-1 cases are there in total
n_controllable_psts
class-attribute
instance-attribute
#
How many controllable phase shifting transformers are in the grid
n_monitored_branches
class-attribute
instance-attribute
#
How many branches are monitored
n_timesteps
class-attribute
instance-attribute
#
How many timesteps are optimized at the same time
n_relevant_subs
class-attribute
instance-attribute
#
How many relevant substations are in the grid
n_disc_branches
class-attribute
instance-attribute
#
How many disconnectable branches are in the definition
overload_energy_n0
class-attribute
instance-attribute
#
What is the N-0 overload energy of the unsplit configuration
overload_energy_n1
class-attribute
instance-attribute
#
What is the N-1 overload energy of the unsplit configuration
n_actions
class-attribute
instance-attribute
#
How many actions have been precomputed in the action set. This is the size of the branch action set, note that combinations of actions within that set are possible (product set wise) if multiple substations are split
max_station_branch_degree
class-attribute
instance-attribute
#
The maximum number of branches connected to any station in the grid
max_station_injection_degree
class-attribute
instance-attribute
#
The maximum number of injections connected to any station in the grid
max_reassignment_distance
class-attribute
instance-attribute
#
The maximum reassignment distance associated with any action
PreprocessingSuccessResult
#
Bases: BaseModel
Results of a preprocessing run, mainly including the static_information and network_data files.
data_folder
instance-attribute
#
The path where the entry point where the timestep data folder structure starts. The folder structure is defined in dc_solver.interfaces.folder_structure. Can be on a temp dir
initial_loadflow
instance-attribute
#
The initial AC loadflow results, i.e. the N-1 analysis without any actions applied to the grid.
initial_metrics
instance-attribute
#
The initial metrics computed for the loadflow results
static_information_stats
instance-attribute
#
Statistics about the static information file that was produced
result_type
class-attribute
instance-attribute
#
The discriminator for the Result Union
PreprocessingStartedResult
#
Bases: BaseModel
A message that is sent when the preprocessing process has started
result_type
class-attribute
instance-attribute
#
The discriminator for the Result Union
ErrorResult
#
Result
#
Bases: BaseModel
A generic class for result, holding either a successful or an unsuccessful result
preprocess_id
instance-attribute
#
The preprocess_id that was sent in the preprocess_command, used to identify the result
instance_id
class-attribute
instance-attribute
#
The instance id of the importer worker that created this result
runtime
instance-attribute
#
The runtime in seconds that the preprocessing took until the result
result
class-attribute
instance-attribute
#
The actual result data in a discriminated union
uuid
class-attribute
instance-attribute
#
uuid = Field(default_factory=lambda: str(uuid.uuid4()))
A unique identifier for this result message, used to avoid duplicates during processing
timestamp
class-attribute
instance-attribute
#
When the result was sent
toop_engine_interfaces.messages.preprocess.preprocess_commands
#
Defines the commands that can be sent to a preprocessing worker.
UCTERegionType
module-attribute
#
UCTERegionType = Literal[
"A",
"B",
"C",
"D",
"D1",
"D2",
"D4",
"D6",
"D7",
"D8",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
"0",
"2",
"_",
]
CGMESRegionType
module-attribute
#
CGMESRegionType = Literal[
"AL",
"AD",
"AM",
"AT",
"AZ",
"BY",
"BE",
"BA",
"BG",
"HR",
"CY",
"CZ",
"DK",
"EE",
"FI",
"FR",
"GE",
"DE",
"GR",
"HU",
"IS",
"IE",
"IT",
"LV",
"LI",
"LT",
"LU",
"MT",
"MD",
"MC",
"ME",
"NL",
"MK",
"NO",
"PL",
"PT",
"RO",
"RU",
"SM",
"RS",
"SK",
"SI",
"ES",
"SE",
"CH",
"TR",
"UA",
"GB",
"VA",
"HK",
]
RegionType
module-attribute
#
RegionType = Union[
UCTERegionType,
CGMESRegionType,
AllCountriesRegionType,
CustomRegionType,
]
LimitAdjustmentParameters
#
Bases: BaseModel
Parameters for the adjustment of limits of special branches.
The new operational limits will be created like this: 1) Compute AC Loadflow 2) new_limit = current_flow * n_0_factor (or n_1_factor) 3) If new_limit > min_increase (=old_limit * n_0_min_increase) new_limit = min_increase 4) If new_limit > old_limit new_limit = old_limit
n_0_factor
class-attribute
instance-attribute
#
The factor for the N-0 current limit. Default is 1.2
n_1_factor
class-attribute
instance-attribute
#
The factor for the N-1 current limit. Default is 1.4
n_0_min_increase
class-attribute
instance-attribute
#
The minimal allowed load increase in percent for the n-0 case. This value multiplied with the current limit gives a lower border for the new limit. This makes sure, that lines that currently are barely loaded can be used at all Default is 5%.
n_1_min_increase
class-attribute
instance-attribute
#
The minimal allowed load increase in percent for the n-1 case. This value multiplied with the current limit gives a lower border for the new limit. This makes sure, that lines that currently are barely loaded can be used at all Default is 5%.
get_parameters_for_case
#
Get the factors for the specific case
| PARAMETER | DESCRIPTION |
|---|---|
case
|
Which case should be returned
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[PositiveFloat, PositiveFloat]
|
The factor and the minimal increase |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/messages/preprocess/preprocess_commands.py
AreaSettings
#
Bases: BaseModel
Setting related to the areas that are imported
control_area
instance-attribute
#
The area in which switching can take place. Substations from this area will automatically become relevant substations (switchable) except they are below the cutoff voltage. Also lines in this area will become disconnectable.
view_area
instance-attribute
#
The areas in which branches shall be part of the overload computation, i.e. for which regions shall line flows be computed.
nminus1_area
instance-attribute
#
The areas where elements shall be part of the N-1 computation, i.e. which elements to fail.
cutoff_voltage
class-attribute
instance-attribute
#
The cutoff voltage under which to ignore equipment. Equipment that doesn't have at least one end equal or above this nominal voltage will not be part of the reward/nminus1 computation
dso_trafo_factors
class-attribute
instance-attribute
#
If given, the N-0 and N-1 flows across the dso trafos in the specied region will be limited to the current N-0 flows in the unsplit configuration. For each case (n0 or n1) a new operational limit with the name "border_limit_n0"/"border_limit_n1" is added.
dso_trafo_weight
class-attribute
instance-attribute
#
A weight that is used for trafos that leave the n-1 area, to underlying DSOs
border_line_factors
class-attribute
instance-attribute
#
If given, the N-0 and N-1 flows across the border lines leaving or entering the specied region will be limited to the current N-0 flows in the unsplit configuration. For each case (n0 or n1) a new operational limit with the name "border_limit_n0"/"border_limit_n1" is added.
border_line_weight
class-attribute
instance-attribute
#
A weight that is used for lines that leave the n-1 area, to neighbouring TSOs
RelevantStationRules
#
Bases: BaseModel
Rules to determine whether a substation is relevant or not.
min_busbars
class-attribute
instance-attribute
#
The minimum number of busbars a substation must have to be considered relevant.
min_connected_branches
class-attribute
instance-attribute
#
The minimum number of connected branches a substation must have to be considered relevant. This only counts branches (lines, transformers, tie-lines), not injections (generators, loads, shunts, etc.).
min_connected_elements
class-attribute
instance-attribute
#
The minimum number of connected elements a substation must have to be considered relevant. This includes branches and injections (generators, loads, shunts, etc.).
BaseImporterParameters
#
Bases: BaseModel
Parameters that are required to import any data format.
area_settings
instance-attribute
#
Which areas of the grid are to be imported and how to handle boundaries
fail_on_non_convergence
class-attribute
instance-attribute
#
Whether to raise an error if the loadflow does not converge in the basecase. If set to False, the preprocessing will continue and dc-optimization can still happen. Mostly for debugging purposes
data_folder
instance-attribute
#
The path where the entry point where the timestep data folder structure starts.
The folder structure is defined in interfaces.folder_structure. This folder is relative to the processed_grid_folder that is configured in the backend/importer. A typical default would be grid_model_file.stem
grid_model_file
instance-attribute
#
The path to the input grid model file.
This file should contain the grid model in the format defined by the data_type. For instance a .uct for UCTE data or a .zip for CGMES data.
data_type
instance-attribute
#
The type of data that is being imported.
This will determine the importer that is used to load the data.
white_list_file
class-attribute
instance-attribute
#
The path to the white lists if present
black_list_file
class-attribute
instance-attribute
#
The path to the balck lists if present
ignore_list_file
class-attribute
instance-attribute
#
The path to the ignore lists if present
A csv file with the following columns: grid_model_id, reason
The implementation is expected to ignore all elements that are in the ignore list.
select_by_voltage_level_id_list
class-attribute
instance-attribute
#
If given, only the voltage levels in this list will be imported. Note: not all voltage levels in this list might be considered relevant after preprocessing. This can happen if the requirements for relevant substations are not met. E.g. minimum number of busbars, connected branches or missing busbar couplers.
ingress_id
class-attribute
instance-attribute
#
An optional id that is used to identify the source of the data. This can be used to track where the data came from, e.g. if it was imported from a specific database or a specific user.
contingency_list_file
class-attribute
instance-attribute
#
The path to the contingency lists if present expected format see: importer/contingency_from_power_factory/PF_data_class.py
schema_format
class-attribute
instance-attribute
#
The schema format of the contingency list file if present. This can be either "ContingencyImportSchemaPowerFactory" or "ContingencyImportSchema". found in: - importer/contingency_from_power_factory/PF_data_class.py - importer/pypowsybl_import/contingency_from_file/contingency_file_models.py
relevant_station_rules
class-attribute
instance-attribute
#
relevant_station_rules = RelevantStationRules()
Rules to determine whether a substation is relevant or not.
loadflow_parameters_file
class-attribute
instance-attribute
#
The path to the loadflow parameters file if present. This file should contain the loadflow parameters in the format defined by the data_type.
network_reduction_voltage_level_range
class-attribute
instance-attribute
#
The range of the network reduction to be applied, based on AreaSettings.view_area. If set to -1, no reduction is applied. The range defines how many voltage levels away from the view_area should be included in the reduction.
UcteImporterParameters
#
Bases: BaseImporterParameters
Parameters that are required to import the data from a UCTE file.
This will utilize powsybl and the powsybl backend to the loadflow solver
area_settings
class-attribute
instance-attribute
#
area_settings = AreaSettings(
control_area=["D8"],
view_area=["D2", "D4", "D7", "D8"],
nminus1_area=["D2", "D4", "D7", "D8"],
)
By default the D8 is controllable and the german grid is viewable
grid_model_file
instance-attribute
#
The path to the UCTE file to load. Note that only a single timestep, i.e. only a single UCTE file will be loaded in one import/preprocessing run. For multiple timesteps, the preprocessing is triggered multiple times.
data_type
class-attribute
instance-attribute
#
A constant field to indicate that this is a UCTE importer
fail_on_non_convergence
class-attribute
instance-attribute
#
Whether to raise an error if the loadflow does not converge in the basecase. If set to False, the preprocessing will continue and dc-optimization can still happen. Mostly for debugging purposes
data_folder
instance-attribute
#
The path where the entry point where the timestep data folder structure starts.
The folder structure is defined in interfaces.folder_structure. This folder is relative to the processed_grid_folder that is configured in the backend/importer. A typical default would be grid_model_file.stem
white_list_file
class-attribute
instance-attribute
#
The path to the white lists if present
black_list_file
class-attribute
instance-attribute
#
The path to the balck lists if present
ignore_list_file
class-attribute
instance-attribute
#
The path to the ignore lists if present
A csv file with the following columns: grid_model_id, reason
The implementation is expected to ignore all elements that are in the ignore list.
select_by_voltage_level_id_list
class-attribute
instance-attribute
#
If given, only the voltage levels in this list will be imported. Note: not all voltage levels in this list might be considered relevant after preprocessing. This can happen if the requirements for relevant substations are not met. E.g. minimum number of busbars, connected branches or missing busbar couplers.
ingress_id
class-attribute
instance-attribute
#
An optional id that is used to identify the source of the data. This can be used to track where the data came from, e.g. if it was imported from a specific database or a specific user.
contingency_list_file
class-attribute
instance-attribute
#
The path to the contingency lists if present expected format see: importer/contingency_from_power_factory/PF_data_class.py
schema_format
class-attribute
instance-attribute
#
The schema format of the contingency list file if present. This can be either "ContingencyImportSchemaPowerFactory" or "ContingencyImportSchema". found in: - importer/contingency_from_power_factory/PF_data_class.py - importer/pypowsybl_import/contingency_from_file/contingency_file_models.py
relevant_station_rules
class-attribute
instance-attribute
#
relevant_station_rules = RelevantStationRules()
Rules to determine whether a substation is relevant or not.
loadflow_parameters_file
class-attribute
instance-attribute
#
The path to the loadflow parameters file if present. This file should contain the loadflow parameters in the format defined by the data_type.
network_reduction_voltage_level_range
class-attribute
instance-attribute
#
The range of the network reduction to be applied, based on AreaSettings.view_area. If set to -1, no reduction is applied. The range defines how many voltage levels away from the view_area should be included in the reduction.
CgmesImporterParameters
#
Bases: BaseImporterParameters
Parameters to start an import data from a CGMES file.
This will utilize powsybl and the powsybl backend to the loadflow solver.
area_settings
class-attribute
instance-attribute
#
area_settings = AreaSettings(
control_area=["BE"],
view_area=["BE", "LU", "D4", "D2", "NL", "FR"],
nminus1_area=["BE"],
cutoff_voltage=220,
)
The area settings for the CGMES importer
grid_model_file
instance-attribute
#
The path to the CGMES .zip file to load.
Note that only a single timestep, i.e. only a single CGMES .zip file will be loaded in one import/preprocessing run. For multiple timesteps, the preprocessing is triggered multiple times. Note: the .zip file must contain all xml files in the same root folder, i.e. the following files: - EQ.xml - SSH.xml - SV.xml - TP.xml - EQBD.xml - TPBD.xml
data_type
class-attribute
instance-attribute
#
A constant field to indicate that this is a CGMES importer
fail_on_non_convergence
class-attribute
instance-attribute
#
Whether to raise an error if the loadflow does not converge in the basecase. If set to False, the preprocessing will continue and dc-optimization can still happen. Mostly for debugging purposes
data_folder
instance-attribute
#
The path where the entry point where the timestep data folder structure starts.
The folder structure is defined in interfaces.folder_structure. This folder is relative to the processed_grid_folder that is configured in the backend/importer. A typical default would be grid_model_file.stem
white_list_file
class-attribute
instance-attribute
#
The path to the white lists if present
black_list_file
class-attribute
instance-attribute
#
The path to the balck lists if present
ignore_list_file
class-attribute
instance-attribute
#
The path to the ignore lists if present
A csv file with the following columns: grid_model_id, reason
The implementation is expected to ignore all elements that are in the ignore list.
select_by_voltage_level_id_list
class-attribute
instance-attribute
#
If given, only the voltage levels in this list will be imported. Note: not all voltage levels in this list might be considered relevant after preprocessing. This can happen if the requirements for relevant substations are not met. E.g. minimum number of busbars, connected branches or missing busbar couplers.
ingress_id
class-attribute
instance-attribute
#
An optional id that is used to identify the source of the data. This can be used to track where the data came from, e.g. if it was imported from a specific database or a specific user.
contingency_list_file
class-attribute
instance-attribute
#
The path to the contingency lists if present expected format see: importer/contingency_from_power_factory/PF_data_class.py
schema_format
class-attribute
instance-attribute
#
The schema format of the contingency list file if present. This can be either "ContingencyImportSchemaPowerFactory" or "ContingencyImportSchema". found in: - importer/contingency_from_power_factory/PF_data_class.py - importer/pypowsybl_import/contingency_from_file/contingency_file_models.py
relevant_station_rules
class-attribute
instance-attribute
#
relevant_station_rules = RelevantStationRules()
Rules to determine whether a substation is relevant or not.
loadflow_parameters_file
class-attribute
instance-attribute
#
The path to the loadflow parameters file if present. This file should contain the loadflow parameters in the format defined by the data_type.
network_reduction_voltage_level_range
class-attribute
instance-attribute
#
The range of the network reduction to be applied, based on AreaSettings.view_area. If set to -1, no reduction is applied. The range defines how many voltage levels away from the view_area should be included in the reduction.
ReassignmentLimits
#
Bases: BaseModel
Reassignment limits for electrical reconfiguration at substations.
max_reassignments_per_sub
class-attribute
instance-attribute
#
The maximum number of reassignments to perform during the electrical reconfiguration. Gets overriden by station_specific_limits if a voltage level id is given.
station_specific_limits
class-attribute
instance-attribute
#
Specific reassignment limits per station to override the global reassignment limit. Expects a voltage level id as key and the maximum number of reassignments as value. Note: the key must match the runtime station voltage_level_id used during preprocessing.
PreprocessParameters
#
Bases: BaseModel
Parameters for the preprocessing procedure which is independent of the data source
filter_disconnectable_branches_processes
class-attribute
instance-attribute
#
When checking for disconnectable branches, multiple worker processes can be used as it is a costly operation.
action_set_filter_bridge_lookup
class-attribute
instance-attribute
#
Whether to filter the action set using bridge lookups. This will remove all assignments that have less than two non-bridges on every side
action_set_filter_bsdf_lodf
class-attribute
instance-attribute
#
Whether to filter the action set using a consecutive BSDF/LODF application. This will filter out all actions that are also filtered by bridge lookup and additionally all actions that split the grid under N-1 branch outages, i.e. all assignments that created a new bridge in the graph. This is a relatively costly process to run, only set to true if you can afford the extra preprocessing time.
action_set_filter_bsdf_lodf_batch_size
class-attribute
instance-attribute
#
If filtering with bsdf/lodf - which batch size to use. Larger will use more memory but be faster.
action_set_clip
class-attribute
instance-attribute
#
After which size to randomly subselect actions at a substation. If a substations has a lot of branches, the action space will explode exponentially and a safe-guard is to clip after a certain number of actions.
asset_topo_close_couplers
class-attribute
instance-attribute
#
Whether to close open couplers in all stations in the asset topology. This might accidentally cancel a maintenance
separation_set_clip_hamming_distance
class-attribute
instance-attribute
#
If a large configuration table comes out of a substation, the table size can be reduced by removing configurations that are close to each other. This parameter sets the definition of close in terms of hamming distance, by default 0 (no reduction).
separation_set_clip_at_size
class-attribute
instance-attribute
#
By what size a table is considered large. If the table is larger than this size, the clip_hamming_distance will be used to reduce the table size, by default 100. If a table is smaller, no reduction will be applied.
realise_station_busbar_choice_heuristic
class-attribute
instance-attribute
#
The heuristic to use when there are multiple physical busbars available for an asset. The options are: - "first": Use the first busbar in the list of busbars (fastest preprocessing) - "least_connected_busbar": Use the busbar with the least number of connections to other assets (best results)
The "least_connected_busbar" heuristic is the default and is recommended for most cases, trying to spread the assets evenly across the busbars in a station.
electrical_reassignment_limits
class-attribute
instance-attribute
#
If given, limits for the electrical reassignment at substations.
physical_reassignment_limits
class-attribute
instance-attribute
#
If given, limits for the physical reassignment at substations.
ac_dc_interpolation
class-attribute
instance-attribute
#
Whether to use the DC loadflow as the base loadflow (0) or the AC loadflow (1). Can also be anything in between.
preprocess_bb_outages
class-attribute
instance-attribute
#
Whether to preprocess and persist busbar outage data into the grid file. This does not decide whether the optimizer will eventually include busbar outage effects.
double_limit_n0
class-attribute
instance-attribute
#
If passed, then double limits will be computed for the N-0 flows. Lines that are below double_limit_n0 relative load in the unsplit configuration will have their capacity multiplied by double_limit_n0 to prevent loading them up to their maximum capacity.
double_limit_n1
class-attribute
instance-attribute
#
If passed, then double limits will be computed for the N-1 flows. Lines that are below double_limit_n1 relative load in the unsplit configuration will have their capacities multiplied by double_limit_n1 to prevent loading them up to their maximum capacity.
initial_loadflow_processes
class-attribute
instance-attribute
#
How many processes to use to compute the initial AC loadflow
fail_on_non_convergence
class-attribute
instance-attribute
#
Whether to raise an error if the initial loadflow does not converge. If False, a warning is logged instead and the backend is initialized with the dc loadflow results.
StartPreprocessingCommand
#
Bases: BaseModel
A command to launch a preprocessing run of a timestep upon reception.
importer_parameters
class-attribute
instance-attribute
#
The parameters to the importer, depending which input source was chosen
preprocess_parameters
class-attribute
instance-attribute
#
preprocess_parameters = PreprocessParameters()
Parameters required for preprocessing independent of the data source
preprocess_id
instance-attribute
#
The id of the preprocessing run, should be included in all responses to identify where the data came from
ShutdownCommand
#
toop_engine_interfaces.messages.preprocess.preprocess_heartbeat
#
Contains the message classes for a preprocessing worker's heartbeat messages
ConvertToJaxStage
module-attribute
#
ConvertToJaxStage = Literal[
"convert_to_jax_started",
"convert_tot_stat",
"convert_relevant_inj",
"convert_masks",
"switching_distance_info",
"pad_out_branch_actions",
"convert_rel_bb_outage_data",
"create_static_information",
"filter_branch_actions",
"bb_outage_baseline_analysis",
"convert_to_jax_done",
]
NumpyPreprocessStage
module-attribute
#
NumpyPreprocessStage = Literal[
"preprocess_started",
"extract_network_data_from_interface",
"exclude_nonlinear_psts_from_controllable",
"filter_relevant_nodes",
"assert_network_data",
"compute_ptdf_if_not_given",
"compute_psdf_if_not_given",
"add_nodal_injections_to_network_data",
"combine_phaseshift_and_injection",
"compute_bridging_branches",
"exclude_bridges_from_outage_masks",
"reduce_branch_dimension",
"reduce_node_dimension",
"filter_disconnectable_branches_nminus2",
"compute_branch_topology_info",
"compute_electrical_actions",
"enumerate_station_realizations",
"remove_relevant_subs_without_actions",
"simplify_asset_topology",
"compute_separation_set",
"convert_multi_outages",
"filter_inactive_injections",
"compute_injection_topology_info",
"process_injection_outages",
"add_missing_asset_topo_info",
"add_bus_b_columns_to_ptdf",
"enumerate_injection_actions",
"preprocess_bb_outage",
"preprocess_done",
]
LoadGridStage
module-attribute
#
LoadGridStage = Literal[
"load_grid_into_loadflow_solver_backend",
"compute_base_loadflows",
"save_artifacts",
]
InitialLoadflowStage
module-attribute
#
ImporterStage
module-attribute
#
ImporterStage = Literal[
"start",
"load_from_fs",
"reduce_network_to_view_area",
"get_topology_model",
"modify_low_impedance_lines",
"modify_branches_over_switches",
"apply_cb_list",
"cross_border_current",
"get_masks",
"end",
]
PreprocessStage
module-attribute
#
PreprocessStage = Literal[
ImporterStage,
NumpyPreprocessStage,
ConvertToJaxStage,
LoadGridStage,
InitialLoadflowStage,
]
PreprocessStatusInfo
#
Bases: BaseModel
A status info to inform about an ongoing preprocess action.
PreprocessHeartbeat
#
Bases: BaseModel
A message class for heartbeats from the preprocessing worker.
When idle, this just sends a hello, and when preprocessing it also conveys a status update at which stage the preprocessing is so it can be tracked in the frontend.
Loadflow Service#
toop_engine_interfaces.loadflow_results
#
Defines interfaces for loadflow results.
The overall process is that a job is called on a loadflow engine for a grid. The grid holds some information that is referenced in the results: - an N-1 definition, which can include multi-contingencys. An N-1 case is uniquely identified by a string descriptor but can include multiple failing elements. The string identifier of the N-1 case should be delivered upon loading. - a number of timesteps, which are uniquely identified by an integer index. - branches which are uniquely identified by a string descriptor and have either two or three sides. - nodes which are uniquely identified by a string descriptor and have a type (PV, PQ, REF) - regulating elements which are uniquely identified by a string descriptor and have a type (generator, regulating transformer, SVC, ...)
LoadflowResultTable
module-attribute
#
LoadflowResultTable = Union[
pat.DataFrame[NodeResultSchema],
pat.DataFrame[BranchResultSchema],
pat.DataFrame[VADiffResultSchema],
pat.DataFrame[ConnectivityResultSchema],
pat.DataFrame[SwitchResultsSchema],
pat.DataFrame[RegulatingElementResultSchema],
pat.DataFrame[ConvergedSchema],
pat.DataFrame[SppsResultsSchema],
pat.DataFrame[CascadeResultSchema],
]
BranchSide
#
Bases: Enum
The side of a branch.
ONE
class-attribute
instance-attribute
#
The following side for the types of branches: - line: from side - 2 winding trafo: high voltage side - 3 winding trafo: high voltage side - other: from side
TWO
class-attribute
instance-attribute
#
The following side for the types of branches: - line: to side - 2 winding trafo: low voltage side - 3 winding trafo: medium voltage side - other: to side
THREE
class-attribute
instance-attribute
#
Only valid for 3 winding transformers, representing the low voltage side.
RegulatingElementType
#
Bases: Enum
A list of known regulating elements, TODO expand
GENERATOR_Q
class-attribute
instance-attribute
#
A generator that is used to control the reactive power output.
SLACK_P
class-attribute
instance-attribute
#
The active power output of the slack node.
SLACK_Q
class-attribute
instance-attribute
#
The reactive power output of the slack node.
REGULATING_TRANSFORMER_TAP
class-attribute
instance-attribute
#
A regulating transformer that is used to control the tap position.
SVC_Q
class-attribute
instance-attribute
#
A static var compensator that is used to control the reactive power output.
HVDC_CONVERTER_Q
class-attribute
instance-attribute
#
An HVDC converter station.
OTHER
class-attribute
instance-attribute
#
A placeholder for not yet known regulating elements.
ConvergenceStatus
#
Bases: Enum
The convergence status of the loadflow in a single timestep/contingency/component
FAILED
class-attribute
instance-attribute
#
The loadflow failed to start, e.g. because no slack bus was available
MAX_ITERATION_REACHED
class-attribute
instance-attribute
#
The maximum number of iterations was reached, i.e. the loadflow did not converge.
NO_CALCULATION
class-attribute
instance-attribute
#
The component was ignored due to other reasons (engine did not support it)
BranchResultSchema
#
Bases: DataFrameModel
A schema for the branch results table.
This holds i, p and q values for all monitored branches with a multi-index of timestep, contingency (CO), branch (CB) and side.
If no branches are monitored, this is the empty DataFrame.
TODO Decide if this should be used for injections aswell#
timestep
instance-attribute
#
The timestep of this result. This indexes into the timesteps that were loaded
contingency
instance-attribute
#
The contingency that caused this loadflow. For N-0 results, the special CO 'BASECASE' without GridElements is used, if its added.
side
class-attribute
instance-attribute
#
side = pa.Field(isin=[(side.value) for side in BranchSide])
The side of the branch that these results correspond to
i
class-attribute
instance-attribute
#
The current in the branch in A
This should only be NaN if the branch has no connection to the slack bus.
p
class-attribute
instance-attribute
#
The active power in the branch in MW
This should only be NaN if the branch has no connection to the slack bus.
q
class-attribute
instance-attribute
#
The reactive power in the branch in MVar
This should only be NaN if the branch has no connection to the slack bus.
loading
class-attribute
instance-attribute
#
The loading of the branch in % of rated current. This always refers to the permanent/default rating of the branch if there are multiple ratings available. If no rating is available for the branch, this should be set to NaN. If the engine does not support the computation of this value, the column can be omitted.
element_name
instance-attribute
#
The name of the Branch, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
contingency_name
instance-attribute
#
The name of the contingency, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
NodeResultSchema
#
Bases: DataFrameModel
A schema for the node results table.
This holds p and q values for all monitored nodes with a multi-index of timestep and contingency. If no nodes are monitored, this is the empty DataFrame.
timestep
instance-attribute
#
The timestep of this result. This indexes into the timesteps that were loaded
contingency
instance-attribute
#
The contingency that caused this loadflow. For N-0 results, the special CO 'BASECASE' is used.
vm
class-attribute
instance-attribute
#
The voltage magnitude at the node in kV.
In DC, this should be the nominal voltage of the node. This should only be NaN if the node does not have a connection to the slack bus.
vm_loading
class-attribute
instance-attribute
#
How close the voltage magnitude is to the max/min voltage limits in percent. This is computed as: (vm - v_nominal) / (v_max - v_nominal) for vm > v_nominal and (vm - v_nominal) / (v_nominal - v_min) for vm < v_nominal.
va
class-attribute
instance-attribute
#
The voltage angle at the node in degrees
This should only be NaN if the node does not have a connection to the slack bus.
p
class-attribute
instance-attribute
#
The accumulated absolute active power at the node in MW, obtained by summing the absolute active power of all branches and injections connected to the node.
If the engine does not support the computation of this value, the column can be omitted.
q
class-attribute
instance-attribute
#
The accumulated absolute reactive power at the node in MVar, obtained by summing the absolute reactive power of all branches and injections connected to the node
If the engine does not support the computation of this value, the column can be omitted.
vm_basecase_deviation
class-attribute
instance-attribute
#
Voltage magnitude deviation from the basecase (N-0) in percent. Computed as: abs(vm_contingency - vm_basecase) / vm_basecase * 100 For basecase contingency, the deviation will be 0.0 (basecase vs basecase). NaN if no valid basecase voltage exists(basecase not converged).
element_name
instance-attribute
#
The name of the node, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
contingency_name
instance-attribute
#
The name of the contingency, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
ConnectivityResultSchema
#
Bases: DataFrameModel
Schema defining the contingency-to-element connectivity mapping.
Each row represents a relationship between a contingency and an affected grid element, based on outage group logic.
contingency
instance-attribute
#
Global unique identifier of the contingency event.
Represents the triggering outage (e.g., line, transformer, generator). This is the first level of the MultiIndex.
element
instance-attribute
#
Global unique identifier of a grid element affected by the contingency.
Each element listed here belongs to the outage group associated with the contingency and is therefore considered disconnected when the contingency occurs. This is the second level of the MultiIndex.
outage_group_id
instance-attribute
#
Identifier of the outage group shared by the contingency and element.
Outage groups represent sets of elements that become de-energized together when separated from the rest of the network by circuit breakers. Multiple contingencies may map to the same outage group.
VADiffResultSchema
#
Bases: DataFrameModel
A schema for the voltage angle results.
Holds information about the voltage angle difference between busses that could be (re)connected by power switches.
timestep
instance-attribute
#
The timestep of this result. This indexes into the timesteps that were loaded
contingency
instance-attribute
#
The critical contingency that caused this loadflow. For N-0 results, the special CO 'BASECASE' is used.
element
instance-attribute
#
The element over which the voltage angle difference is computed. Can be either an open switch or any switch or branch under N-1. If under N-1, then element and contingency are the same.
va_diff
class-attribute
instance-attribute
#
The voltage angle difference in degrees between the two ends of the element. nan if at least one of the ends has no voltage angle (island, out of service)
element_name
instance-attribute
#
The name of the Branch or Switch, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
contingency_name
instance-attribute
#
The name of the contingency, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
SwitchResultsSchema
#
Bases: DataFrameModel
A schema for the voltage angle results.
Holds information about the voltage angle difference between busses that could be (re)connected by power switches.
timestep
instance-attribute
#
The timestep of this result. This indexes into the timesteps that were loaded
contingency
instance-attribute
#
The critical contingency that caused this loadflow. For N-0 results, the special CO 'BASECASE' is used.
element
instance-attribute
#
The element over which the voltage angle difference is computed. Can be either an open switch or any switch or branch under N-1. If under N-1, then element and contingency are the same.
p
class-attribute
instance-attribute
#
The accumulated absolute active power at the node in MW, obtained by summing the absolute active power of all branches and injections connected to the node.
If the engine does not support the computation of this value, the column can be omitted.
q
class-attribute
instance-attribute
#
The accumulated absolute reactive power at the node in MVar, obtained by summing the absolute reactive power of all branches and injections connected to the node
If the engine does not support the computation of this value, the column can be omitted.
vm
class-attribute
instance-attribute
#
The voltage magnitude at the node in kV.
In DC, this should be the nominal voltage of the node. This should only be NaN if the node does not have a connection to the slack bus.
i
class-attribute
instance-attribute
#
The current in the branch in A
This should only be NaN if the branch has no connection to the slack bus.
element_name
instance-attribute
#
The name of the Branch or Switch, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
contingency_name
instance-attribute
#
The name of the contingency, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
side
class-attribute
instance-attribute
#
The measurement side of the switch result.
"from": values measured at the from-bus terminal (taken fromnet.res_switch)."to": values measured at the to-bus terminal (taken fromnet.res_switch).null: result was computed by aggregating branch flows and node injections. Switches modelled without impedance have identical electrical conditions on both terminals (no voltage drop, no power loss across the switch), so a single aggregated value is sufficient and no side distinction is needed.
SwitchElementMappingSchema
#
Bases: DataFrameModel
Schema for mapping switches to connected elements.
This table defines which elements are electrically connected to each switch. It is used to aggregate branch flows and node injections when computing switch-level results.
The mapping includes both: - branch-like elements (lines, trafos, impedances, etc.) - buses
If no switches are mapped, this is an empty DataFrame.
switch_id
class-attribute
instance-attribute
#
The pandapower index of the switch.
This identifies the switch for which connected elements are collected and used in result aggregation.
element
class-attribute
instance-attribute
#
The globally unique identifier of the connected element.
This can represent either: - a branch-like element (e.g. "12__line", "5__trafo") - a bus (e.g. "3__bus")
side
class-attribute
instance-attribute
#
The side of the branch element.
- For branch-like elements: Indicates the terminal of the element connected to the bus (e.g. BranchSide.ONE, BranchSide.TWO, BranchSide.THREE).
- For bus entries: This value is NaN, since buses do not have sides.
RegulatingElementResultSchema
#
Bases: DataFrameModel
A schema for the regulating elements.
A regulating element can either be a branch (a trafo with regulating tap) or a node (a generator, SVC, ...). If no regulating elements are monitored, this is the empty DataFrame.
timestep
instance-attribute
#
The timestep of this result. This indexes into the timesteps that were loaded
contingency
instance-attribute
#
The critical contingency that caused this loadflow. For N-0 results, the special CO 'BASECASE' is used.
element
instance-attribute
#
The regulating element that these loadflow results correspond to
value
instance-attribute
#
The value of the regulating element. Depending on the type of the regulating element, this can mean different things.
regulating_element_type
class-attribute
instance-attribute
#
regulating_element_type = pa.Field(
isin=[(side.value) for side in RegulatingElementType]
)
The type of the regulating element (generator, regulating transformer, SVC, ...).
element_name
instance-attribute
#
The name of the Regulating Element, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
contingency_name
instance-attribute
#
The name of the contingency, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
ConvergedSchema
#
Bases: DataFrameModel
A schema for the converged table. This holds the convergence information for each timestep.
Potentially, multiple islands can exist in the same grid. In this case, the synchronous component needs to be distinguished. A synchronous component is a grid area consisting of all nodes and branches that are connected to the same slack through AC lines (no HVDC). The largest component must always be called 'MAIN' while the names of the other components are arbitrary. Usually only one component is present. If no convergence information is available, this is the empty DataFrame.
timestep
instance-attribute
#
The timestep of this result. This indexes into the timesteps that were loaded
contingency
instance-attribute
#
The critical contingency that caused this loadflow. For N-0 results, the special CO 'BASECASE' is used.
status
class-attribute
instance-attribute
#
status = pa.Field(
isin=[(side.value) for side in ConvergenceStatus]
)
Whether the loadflow converged at this timestep/contingency.
iteration_count
class-attribute
instance-attribute
#
The number of iterations required for the loadflow to converge.
warnings
class-attribute
instance-attribute
#
An additional string field that carries warnings or error logs for specific timesteps/contingencys/components.
contingency_name
instance-attribute
#
The name of the contingency, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
SppsResultsSchema
#
Bases: DataFrameModel
SpPS run summaries, one row per (timestep, contingency).
activated_schemes_per_iter holds a JSON string encoding of
list[list[str]] (outer list = SpPS outer iterations, inner = scheme
names that fired in that iteration), so the table remains parquet-friendly.
Use json.loads to recover the nested structure.
timestep
instance-attribute
#
Loadflow timestep index for the outage that produced this row.
contingency
instance-attribute
#
Globally unique id of the contingency (same value as in other loadflow result tables).
activated_schemes_per_iter
class-attribute
instance-attribute
#
JSON string for list[list[str]] of scheme names that activated per iteration.
max_iterations_reached
instance-attribute
#
Whether the run stopped because the iteration cap was hit while schemes still fired.
power_flow_failed
instance-attribute
#
Whether a post-action power flow failed in keep_previous mode.
CascadeResultSchema
#
Bases: DataFrameModel
A schema for cascade simulation event results.
This table contains one row per cascade event created after a converged contingency load flow. It records why the cascade advanced and which element/outage group was affected.
contingency
instance-attribute
#
Globally unique id of the contingency that started the cascade.
element_mrid
class-attribute
instance-attribute
#
External identifier of the affected element, if known.
element_id
class-attribute
instance-attribute
#
Globally unique id of the affected element, if known.
contingency_outage_id
class-attribute
instance-attribute
#
Identifier of the outage group for the contingency that started the cascade.
contingency_name
class-attribute
instance-attribute
#
Human-readable name of the contingency that started the cascade, if known.
element_outage_group_id
class-attribute
instance-attribute
#
Stable identifier of the affected element's outage group.
element_name
class-attribute
instance-attribute
#
Human-readable name of the affected element, if known.
cascade_reason
instance-attribute
#
Reason for the cascade event, such as current overload or distance protection.
loading
class-attribute
instance-attribute
#
Branch loading value that triggered the cascade event, if available.
r_ohm
class-attribute
instance-attribute
#
Relay resistance value for distance-protection events, if available.
x_ohm
class-attribute
instance-attribute
#
Relay reactance value for distance-protection events, if available.
distance_protection_severity
class-attribute
instance-attribute
#
Distance-protection severity for relay events. Empty for other event types.
activated_schemes_per_iter
class-attribute
instance-attribute
#
JSON string of SpPS scheme names that activated per inner cascade load-flow iteration.
LoadflowResults
#
Bases: BaseModel
A container for the loadflow results for a computation job.
branch_results
class-attribute
instance-attribute
#
The results for the branches. If no branches are monitored, this is the empty DataFrame. Non converging contingencys/timesteps are to be omitted
node_results
class-attribute
instance-attribute
#
The results for the nodes. If no nodes are monitored, this is the empty DataFrame.
regulating_element_results
class-attribute
instance-attribute
#
The results for the regulating elements. If no regulating elements are monitored, this is the empty DataFrame.
converged
class-attribute
instance-attribute
#
The convergence information for each timestep and contingency. If there were non-converging loadflows for some timesteps/contingencys, these results should be omitted from the other tables.
va_diff_results
class-attribute
instance-attribute
#
The voltage angle difference results for each timestep and contingency. Considers the ends of the outaged branch, aswell as all open switches in monitored elements.
switch_results
class-attribute
instance-attribute
#
The results for the switches.
Contains aggregated power flow and injection results per switch for each timestep and contingency.
Switch results are computed by aggregating contributions from all elements (branches and buses) electrically connected to one side of the switch. This represents the power flowing through the switch.
If no switches are monitored, this is the empty DataFrame. For non-converging contingencies/timesteps, result values are present but set to NaN.
connectivity_result
class-attribute
instance-attribute
#
Connectivity mapping between contingencies and affected grid elements. This DataFrame defines which elements become unavailable for each contingency, based on outage group logic. Each row represents a (contingency, element) pair, indicating that the element is part of the outage group triggered by the contingency.
warnings
class-attribute
instance-attribute
#
Global warnings that occured during the computation (e.g. monitored elements/contingencies that were not found)
spps_results
class-attribute
instance-attribute
#
SpPS run summaries, concatenated in single-outage order. When SpPS did not run for a case, that chunk contributes no rows. If no job recorded SpPS, this is the empty DataFrame (default).
cascade_results
class-attribute
instance-attribute
#
Cascade simulation events, one row per event. Empty when cascade simulation is disabled or has no events.
__eq__
#
Compare two LoadflowResults objects for equality.
Rounds floats to 6 decimal places for comparison. This is necessary because floating point arithmetic can lead to small differences in the results.
Ignores the order of the DataFrames, but checks that the indices are equal.
| PARAMETER | DESCRIPTION |
|---|---|
lf_result
|
The LoadflowResults object to compare with.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the two LoadflowResults objects are equal, False otherwise. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_results.py
toop_engine_interfaces.loadflow_results_polars
#
Defines performance-improved polars versions of the loadflow results.
The loadflow results here mirror what is defined in loadflow_results.py, but use polars dataframes which are faster.
LoadflowResultTablePolars
module-attribute
#
LoadflowResultTablePolars = Union[
patpl.LazyFrame[NodeResultSchemaPolars],
patpl.LazyFrame[BranchResultSchemaPolars],
patpl.LazyFrame[VADiffResultSchemaPolars],
patpl.LazyFrame[ConnectivityResultSchemaPolars],
patpl.LazyFrame[SwitchResultsSchemaPolars],
patpl.LazyFrame[RegulatingElementResultSchemaPolars],
patpl.LazyFrame[ConvergedSchemaPolars],
patpl.LazyFrame[SppsResultsSchemaPolars],
patpl.LazyFrame[CascadeResultSchemaPolars],
]
BranchResultSchemaPolars
#
Bases: DataFrameModel, BranchResultSchema
Polars variant of BranchResultSchema.
timestep
instance-attribute
#
The timestep of this result. This indexes into the timesteps that were loaded
contingency
instance-attribute
#
The contingency that caused this loadflow. For N-0 results, the special CO 'BASECASE' without GridElements is used, if its added.
side
class-attribute
instance-attribute
#
side = pa.Field(isin=[(side.value) for side in BranchSide])
The side of the branch that these results correspond to
i
class-attribute
instance-attribute
#
The current in the branch in A
This should only be NaN if the branch has no connection to the slack bus.
p
class-attribute
instance-attribute
#
The active power in the branch in MW
This should only be NaN if the branch has no connection to the slack bus.
q
class-attribute
instance-attribute
#
The reactive power in the branch in MVar
This should only be NaN if the branch has no connection to the slack bus.
loading
class-attribute
instance-attribute
#
The loading of the branch in % of rated current. This always refers to the permanent/default rating of the branch if there are multiple ratings available. If no rating is available for the branch, this should be set to NaN. If the engine does not support the computation of this value, the column can be omitted.
element_name
instance-attribute
#
The name of the Branch, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
contingency_name
instance-attribute
#
The name of the contingency, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
NodeResultSchemaPolars
#
Bases: DataFrameModel, NodeResultSchema
Polars variant of NodeResultSchema.
timestep
instance-attribute
#
The timestep of this result. This indexes into the timesteps that were loaded
contingency
instance-attribute
#
The contingency that caused this loadflow. For N-0 results, the special CO 'BASECASE' is used.
vm
class-attribute
instance-attribute
#
The voltage magnitude at the node in kV.
In DC, this should be the nominal voltage of the node. This should only be NaN if the node does not have a connection to the slack bus.
vm_loading
class-attribute
instance-attribute
#
How close the voltage magnitude is to the max/min voltage limits in percent. This is computed as: (vm - v_nominal) / (v_max - v_nominal) for vm > v_nominal and (vm - v_nominal) / (v_nominal - v_min) for vm < v_nominal.
va
class-attribute
instance-attribute
#
The voltage angle at the node in degrees
This should only be NaN if the node does not have a connection to the slack bus.
p
class-attribute
instance-attribute
#
The accumulated absolute active power at the node in MW, obtained by summing the absolute active power of all branches and injections connected to the node.
If the engine does not support the computation of this value, the column can be omitted.
q
class-attribute
instance-attribute
#
The accumulated absolute reactive power at the node in MVar, obtained by summing the absolute reactive power of all branches and injections connected to the node
If the engine does not support the computation of this value, the column can be omitted.
vm_basecase_deviation
class-attribute
instance-attribute
#
Voltage magnitude deviation from the basecase (N-0) in percent. Computed as: abs(vm_contingency - vm_basecase) / vm_basecase * 100 For basecase contingency, the deviation will be 0.0 (basecase vs basecase). NaN if no valid basecase voltage exists(basecase not converged).
element_name
instance-attribute
#
The name of the node, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
contingency_name
instance-attribute
#
The name of the contingency, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
ConnectivityResultSchemaPolars
#
Bases: DataFrameModel, ConnectivityResultSchema
Polars variant of ConnectivityResultSchema.
contingency
instance-attribute
#
Global unique identifier of the contingency event.
Represents the triggering outage (e.g., line, transformer, generator). This is the first level of the MultiIndex.
element
instance-attribute
#
Global unique identifier of a grid element affected by the contingency.
Each element listed here belongs to the outage group associated with the contingency and is therefore considered disconnected when the contingency occurs. This is the second level of the MultiIndex.
outage_group_id
instance-attribute
#
Identifier of the outage group shared by the contingency and element.
Outage groups represent sets of elements that become de-energized together when separated from the rest of the network by circuit breakers. Multiple contingencies may map to the same outage group.
VADiffResultSchemaPolars
#
Bases: DataFrameModel, VADiffResultSchema
Polars variant of VADiffResultSchema.
timestep
instance-attribute
#
The timestep of this result. This indexes into the timesteps that were loaded
contingency
instance-attribute
#
The critical contingency that caused this loadflow. For N-0 results, the special CO 'BASECASE' is used.
element
instance-attribute
#
The element over which the voltage angle difference is computed. Can be either an open switch or any switch or branch under N-1. If under N-1, then element and contingency are the same.
va_diff
class-attribute
instance-attribute
#
The voltage angle difference in degrees between the two ends of the element. nan if at least one of the ends has no voltage angle (island, out of service)
element_name
instance-attribute
#
The name of the Branch or Switch, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
contingency_name
instance-attribute
#
The name of the contingency, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
SwitchResultsSchemaPolars
#
Bases: DataFrameModel, SwitchResultsSchema
Polars variant of SwitchResultsSchema.
timestep
instance-attribute
#
The timestep of this result. This indexes into the timesteps that were loaded
contingency
instance-attribute
#
The critical contingency that caused this loadflow. For N-0 results, the special CO 'BASECASE' is used.
element
instance-attribute
#
The element over which the voltage angle difference is computed. Can be either an open switch or any switch or branch under N-1. If under N-1, then element and contingency are the same.
p
class-attribute
instance-attribute
#
The accumulated absolute active power at the node in MW, obtained by summing the absolute active power of all branches and injections connected to the node.
If the engine does not support the computation of this value, the column can be omitted.
q
class-attribute
instance-attribute
#
The accumulated absolute reactive power at the node in MVar, obtained by summing the absolute reactive power of all branches and injections connected to the node
If the engine does not support the computation of this value, the column can be omitted.
vm
class-attribute
instance-attribute
#
The voltage magnitude at the node in kV.
In DC, this should be the nominal voltage of the node. This should only be NaN if the node does not have a connection to the slack bus.
i
class-attribute
instance-attribute
#
The current in the branch in A
This should only be NaN if the branch has no connection to the slack bus.
element_name
instance-attribute
#
The name of the Branch or Switch, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
contingency_name
instance-attribute
#
The name of the contingency, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
side
class-attribute
instance-attribute
#
The measurement side of the switch result.
"from": values measured at the from-bus terminal (taken fromnet.res_switch)."to": values measured at the to-bus terminal (taken fromnet.res_switch).null: result was computed by aggregating branch flows and node injections. Switches modelled without impedance have identical electrical conditions on both terminals (no voltage drop, no power loss across the switch), so a single aggregated value is sufficient and no side distinction is needed.
RegulatingElementResultSchemaPolars
#
Bases: DataFrameModel, RegulatingElementResultSchema
Polars variant of RegulatingElementResultSchema.
timestep
instance-attribute
#
The timestep of this result. This indexes into the timesteps that were loaded
contingency
instance-attribute
#
The critical contingency that caused this loadflow. For N-0 results, the special CO 'BASECASE' is used.
element
instance-attribute
#
The regulating element that these loadflow results correspond to
value
instance-attribute
#
The value of the regulating element. Depending on the type of the regulating element, this can mean different things.
regulating_element_type
class-attribute
instance-attribute
#
regulating_element_type = pa.Field(
isin=[(side.value) for side in RegulatingElementType]
)
The type of the regulating element (generator, regulating transformer, SVC, ...).
element_name
instance-attribute
#
The name of the Regulating Element, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
contingency_name
instance-attribute
#
The name of the contingency, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
ConvergedSchemaPolars
#
Bases: DataFrameModel, ConvergedSchema
Polars variant of ConvergedSchema.
timestep
instance-attribute
#
The timestep of this result. This indexes into the timesteps that were loaded
contingency
instance-attribute
#
The critical contingency that caused this loadflow. For N-0 results, the special CO 'BASECASE' is used.
status
class-attribute
instance-attribute
#
status = pa.Field(
isin=[(side.value) for side in ConvergenceStatus]
)
Whether the loadflow converged at this timestep/contingency.
iteration_count
class-attribute
instance-attribute
#
The number of iterations required for the loadflow to converge.
warnings
class-attribute
instance-attribute
#
An additional string field that carries warnings or error logs for specific timesteps/contingencys/components.
contingency_name
instance-attribute
#
The name of the contingency, if available. This is not used for the loadflow computation, but can be used for display purposes. If no name is available, this should be set to an empty string.
SppsResultsSchemaPolars
#
Bases: DataFrameModel, SppsResultsSchema
Polars variant of SppsResultsSchema.
timestep
instance-attribute
#
Loadflow timestep index for the outage that produced this row.
contingency
instance-attribute
#
Globally unique id of the contingency (same value as in other loadflow result tables).
activated_schemes_per_iter
class-attribute
instance-attribute
#
JSON string for list[list[str]] of scheme names that activated per iteration.
max_iterations_reached
instance-attribute
#
Whether the run stopped because the iteration cap was hit while schemes still fired.
power_flow_failed
instance-attribute
#
Whether a post-action power flow failed in keep_previous mode.
CascadeResultSchemaPolars
#
Bases: DataFrameModel, CascadeResultSchema
Polars variant of CascadeResultSchema.
contingency
instance-attribute
#
Globally unique id of the contingency that started the cascade.
element_mrid
class-attribute
instance-attribute
#
External identifier of the affected element, if known.
element_id
class-attribute
instance-attribute
#
Globally unique id of the affected element, if known.
contingency_outage_id
class-attribute
instance-attribute
#
Identifier of the outage group for the contingency that started the cascade.
contingency_name
class-attribute
instance-attribute
#
Human-readable name of the contingency that started the cascade, if known.
element_outage_group_id
class-attribute
instance-attribute
#
Stable identifier of the affected element's outage group.
element_name
class-attribute
instance-attribute
#
Human-readable name of the affected element, if known.
cascade_reason
instance-attribute
#
Reason for the cascade event, such as current overload or distance protection.
loading
class-attribute
instance-attribute
#
Branch loading value that triggered the cascade event, if available.
r_ohm
class-attribute
instance-attribute
#
Relay resistance value for distance-protection events, if available.
x_ohm
class-attribute
instance-attribute
#
Relay reactance value for distance-protection events, if available.
distance_protection_severity
class-attribute
instance-attribute
#
Distance-protection severity for relay events. Empty for other event types.
activated_schemes_per_iter
class-attribute
instance-attribute
#
JSON string of SpPS scheme names that activated per inner cascade load-flow iteration.
LoadflowResultsPolars
#
Bases: BaseModel
A container for the loadflow results for a computation job.
branch_results
class-attribute
instance-attribute
#
The results for the branches. If no branches are monitored, this is the empty DataFrame. Non converging contingencys/timesteps are to be omitted
node_results
class-attribute
instance-attribute
#
The results for the nodes. If no nodes are monitored, this is the empty DataFrame.
regulating_element_results
class-attribute
instance-attribute
#
The results for the regulating elements. If no regulating elements are monitored, this is the empty DataFrame.
converged
class-attribute
instance-attribute
#
The convergence information for each timestep and contingency. If there were non-converging loadflows for some timesteps/contingencys, these results should be omitted from the other tables.
va_diff_results
class-attribute
instance-attribute
#
The voltage angle difference results for each timestep and contingency. Considers the ends of the outaged branch, aswell as all open switches in monitored elements.
switch_results
class-attribute
instance-attribute
#
The results for the switches.
Contains aggregated power flow and injection results per switch for each timestep and contingency.
Switch results are computed by aggregating contributions from all elements (branches and buses) electrically connected to one side of the switch. This represents the power flowing through the switch.
If no switches are monitored, this is the empty DataFrame. For non-converging contingencies/timesteps, result values are present but set to NaN.
connectivity_result
class-attribute
instance-attribute
#
Connectivity mapping between contingencies and affected grid elements. This DataFrame defines which elements become unavailable for each contingency, based on outage group logic. Each row represents a (contingency, element) pair, indicating that the element is part of the outage group triggered by the contingency.
warnings
class-attribute
instance-attribute
#
Global warnings that occured during the computation (e.g. monitored elements/contingencies that were not found)
spps_results
class-attribute
instance-attribute
#
SpPS run summaries, concatenated in single-outage order. Empty when no SpPS was recorded (default).
cascade_results
class-attribute
instance-attribute
#
Cascade simulation events. Empty when cascade simulation is disabled or has no events.
Config
#
Pydantic configuration for the LoadflowResultsPolars model.
arbitrary_types_allowed
class-attribute
instance-attribute
#
Allow arbitrary types in the model.
__eq__
#
Compare two LoadflowResults objects for equality.
Rounds floats to 6 decimal places for comparison. This is necessary because floating point arithmetic can lead to small differences in the results.
Ignores the order of the DataFrames, but checks that the indices are equal.
Note: This functions is not very efficient and can take up to half a minute for >10Mio rows.
| PARAMETER | DESCRIPTION |
|---|---|
lf_result
|
The LoadflowResults object to compare with.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the two LoadflowResults objects are equal, False otherwise. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_results_polars.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
toop_engine_interfaces.loadflow_result_helpers_polars
#
Loadflow result helpers for polars LazyFrames or DataFrames.
Holds functions to work with the loadflow results interfaces.
save_loadflow_results_polars
#
Save loadflow results to a file in hdf5 format.
| PARAMETER | DESCRIPTION |
|---|---|
fs
|
The filesystem to use to save the results. This can be a local filesystem or an object store like S3 or Azure, using the fsspec library. For writing to local disk, you should use the DirFilesystem to inject a base path like this: Similarly, buckets can be used with the appropriate fsspec filesystem like adbs
TYPE:
|
file_path
|
The file path where to save the results to. This is relative to the base name or bucket defined in the storage
TYPE:
|
loadflows
|
The loadflow results to save.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
StoredLoadflowReference
|
A reference to the stored loadflow results. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers_polars.py
load_loadflow_results_polars
#
Load loadflow results from a StoredLoadflowReference.
| PARAMETER | DESCRIPTION |
|---|---|
fs
|
The filesystem to use to load the results. This can be a local filesystem or an object store like S3 or Azure, using the fsspec library.
TYPE:
|
reference
|
The reference to the stored loadflow results.
TYPE:
|
validate
|
Whether to validate the loaded results against the schemas defined in the interfaces. For dataframes with a lot of data this can take a few seconds.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LoadflowResults
|
The loaded loadflow results. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers_polars.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
concatenate_loadflow_results_polars
#
Concatenate the results of the loadflow results.
| PARAMETER | DESCRIPTION |
|---|---|
loadflow_results_list
|
The list of loadflow results to concatenate
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LoadflowResultsPolars
|
The concatenated loadflow results |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers_polars.py
select_timestep_polars
#
Select a single timestep from the loadflow results.
| PARAMETER | DESCRIPTION |
|---|---|
loadflow_results
|
The loadflow results to select the timestep from.
TYPE:
|
timestep
|
The timestep to select.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LoadflowResultsPolars
|
The loadflow results for the selected timestep. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers_polars.py
subset_contingencies_polars
#
Subset the loadflow results to a list of contingencies.
| PARAMETER | DESCRIPTION |
|---|---|
loadflow_results
|
The loadflow results to subset.
TYPE:
|
contingencies
|
The list of contingencies to subset to.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LoadflowResultsPolars
|
The loadflow results for the selected contingencies. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers_polars.py
extract_branch_results_polars
#
extract_branch_results_polars(
branch_results,
timestep,
contingencies,
monitored_branches,
basecase,
)
Extract the branch results for a specific timestep.
| PARAMETER | DESCRIPTION |
|---|---|
branch_results
|
The branch results dataframe to extract the branch results from.
TYPE:
|
timestep
|
The selected timestep to pull from the loadflow results.
TYPE:
|
basecase
|
The basecase contingency id to use for the N-0 results.
TYPE:
|
contingencies
|
The list of contingencies to extract the results for.
TYPE:
|
monitored_branches
|
The list of monitored branches to extract the results for. buses switches etc should not be included here, only branches.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Float[ndarray, ' n_contingencies n_branches_monitored']
|
The branch results with the following: - shape (n_contingencies, n_branches_monitored) - only the p values of the monitored branches at the from-end - For three winding transformers, the p values are split into three rows for each side (hv, mv, lv). |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers_polars.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | |
extract_node_matrices_polars
#
extract_node_matrices_polars(
node_results,
timestep,
contingencies,
monitored_nodes,
basecase="BASECASE",
)
Extract the node results for a specific timestep.
| PARAMETER | DESCRIPTION |
|---|---|
node_results
|
The node results polars dataframe to extract the node results from.
TYPE:
|
timestep
|
The selected timestep to pull from the loadflow results.
TYPE:
|
basecase
|
The basecase contingency id to use for the N-0 results.
TYPE:
|
contingencies
|
The list of contingencies to extract the results for.
TYPE:
|
monitored_nodes
|
The list of monitored nodes to extract the results for. buses switches etc should not be included here, only nodes.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
vm_n0
|
The voltage magnitude results for the basecase contingency at the monitored nodes.
TYPE:
|
va_n0
|
The voltage angle results for the basecase contingency at the monitored nodes.
TYPE:
|
vm_n1
|
The voltage magnitude results for the contingencies at the monitored nodes.
TYPE:
|
va_n1
|
The voltage angle results for the contingencies at the monitored nodes.
TYPE:
|
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers_polars.py
extract_solver_matrices_polars
#
Extract the N-0 and N-1 matrices in a similar format to the DC solver.
| PARAMETER | DESCRIPTION |
|---|---|
loadflow_results
|
The loadflow results to extract the matrices from.
TYPE:
|
nminus1_definition
|
The N-1 definition to use for the contingencies and monitored elements.
TYPE:
|
timestep
|
The selected timestep to pull from the loadflow results.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Float[ndarray, ' n_branches_monitored']
|
The N-0 matrix |
Float[ndarray, ' n_solver_contingencies n_branches_monitored']
|
The N-1 matrix |
Bool[ndarray, ' n_solver_contingencies']
|
The convergence status of the contingencies in the N-1 matrix True if converged or not calculated, False if not converged. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers_polars.py
toop_engine_interfaces.loadflow_result_helpers
#
Loadflow result helpers. Holds functions to work with the loadflow results interfaces.
save_loadflow_results
#
Save loadflow results to a file in hdf5 format.
| PARAMETER | DESCRIPTION |
|---|---|
fs
|
The filesystem to use to save the results. This can be a local filesystem or an object store like S3 or Azure, using the fsspec library. For writing to local disk, you should use the DirFilesystem to inject a base path like this: Similarly, buckets can be used with the appropriate fsspec filesystem like adbs
TYPE:
|
file_path
|
The file path where to save the results to. This is relative to the base name or bucket defined in the storage
TYPE:
|
loadflows
|
The loadflow results to save.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
StoredLoadflowReference
|
A reference to the stored loadflow results. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers.py
load_loadflow_results
#
Load loadflow results from a StoredLoadflowReference.
| PARAMETER | DESCRIPTION |
|---|---|
fs
|
The filesystem to use to load the results. This can be a local filesystem or an object store like S3 or Azure, using the fsspec library.
TYPE:
|
reference
|
The reference to the stored loadflow results.
TYPE:
|
validate
|
Whether to validate the loaded results against the schemas defined in the interfaces. For dataframes with a lot of data this can take a few seconds.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LoadflowResults
|
The loaded loadflow results. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers.py
concatenate_loadflow_results
#
Concatenate the results of the loadflow results.
| PARAMETER | DESCRIPTION |
|---|---|
loadflow_results_list
|
The list of loadflow results to concatenate
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LoadflowResults
|
The concatenated loadflow results |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers.py
get_failed_branch_results
#
get_failed_branch_results(
timestep,
failed_outages,
monitored_2_end_branches,
monitored_3_end_branches,
)
Get the failed branch results.
| PARAMETER | DESCRIPTION |
|---|---|
timestep
|
The timestep of the results
TYPE:
|
failed_outages
|
The list of failed outages
TYPE:
|
monitored_2_end_branches
|
The list of monitored 2 end branches. i.e. most branches
TYPE:
|
monitored_3_end_branches
|
The list of monitored 3 end branches. i.e. 3 winding transformers
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame[BranchResultSchema]
|
The failed branch results |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers.py
get_failed_node_results
#
Get the failed node results.
| PARAMETER | DESCRIPTION |
|---|---|
timestep
|
The timestep of the results
TYPE:
|
failed_outages
|
The list of failed outages
TYPE:
|
monitored_nodes
|
The list of monitored nodes
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame[NodeResultSchema]
|
The failed node results |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers.py
extract_branch_results
#
Extract the branch results for a specific timestep.
| PARAMETER | DESCRIPTION |
|---|---|
branch_results
|
The branch results dataframe to extract the branch results from.
TYPE:
|
timestep
|
The selected timestep to pull from the loadflow results.
TYPE:
|
basecase
|
The basecase contingency id to use for the N-0 results.
TYPE:
|
contingencies
|
The list of contingencies to extract the results for.
TYPE:
|
monitored_branches
|
The list of monitored branches to extract the results for. buses switches etc should not be included here, only branches.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Float[ndarray, ' n_contingencies n_branches_monitored']
|
The branch results with the following: - shape (n_contingencies, n_branches_monitored) - only the p values of the monitored branches at the from-end - For three winding transformers, the p values are split into three rows for each side (hv, mv, lv). |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers.py
extract_node_matrices
#
extract_node_matrices(
node_results,
timestep,
contingencies,
monitored_nodes,
basecase="BASECASE",
)
Extract the node results for a specific timestep.
| PARAMETER | DESCRIPTION |
|---|---|
node_results
|
The node results dataframe to extract the node results from.
TYPE:
|
timestep
|
The selected timestep to pull from the loadflow results.
TYPE:
|
basecase
|
The basecase contingency id to use for the N-0 results.
TYPE:
|
contingencies
|
The list of contingencies to extract the results for.
TYPE:
|
monitored_nodes
|
The list of monitored nodes to extract the results for. buses switches etc should not be included here, only nodes.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
vm_n0
|
The voltage magnitude results for the basecase contingency at the monitored nodes.
TYPE:
|
va_n0
|
The voltage angle results for the basecase contingency at the monitored nodes.
TYPE:
|
vm_n1
|
The voltage magnitude results for the contingencies at the monitored nodes.
TYPE:
|
va_n1
|
The voltage angle results for the contingencies at the monitored nodes.
TYPE:
|
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers.py
extract_solver_matrices
#
Extract the N-0 and N-1 matrices in a similar format to the DC solver.
| PARAMETER | DESCRIPTION |
|---|---|
loadflow_results
|
The loadflow results to extract the matrices from.
TYPE:
|
nminus1_definition
|
The N-1 definition to use for the contingencies and monitored elements.
TYPE:
|
timestep
|
The selected timestep to pull from the loadflow results.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Float[ndarray, ' n_branches_monitored']
|
The N-0 matrix |
Float[ndarray, ' n_solver_contingencies n_branches_monitored']
|
The N-1 matrix |
Bool[ndarray, ' n_solver_contingencies']
|
The convergence status of the contingencies in the N-1 matrix True if converged or not calculated, False if not converged. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers.py
select_timestep
#
Select a specific timestep from the loadflow results.
| PARAMETER | DESCRIPTION |
|---|---|
loadflow_results
|
The loadflow results to select the timestep from.
TYPE:
|
timestep
|
The timestep to select.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LoadflowResults
|
The loadflow results for the selected timestep. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers.py
convert_polars_loadflow_results_to_pandas
#
Convert the LoadflowResultsPolars class to LoadflowResults class.
| PARAMETER | DESCRIPTION |
|---|---|
loadflow_results_polars
|
The loadflow results in polars format.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LoadflowResults
|
The loadflow results in pandas format. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers.py
pandas_to_polars
#
Convert a pandas DataFrame to a polars DataFrame.
| PARAMETER | DESCRIPTION |
|---|---|
df
|
The pandas DataFrame to convert.
TYPE:
|
lazy
|
Whether to return a LazyFrame or a DataFrame.
TYPE:
|
nan_to_null
|
Whether NaN values should be converted to polars null values.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Optional[DataFrame]
|
The polars DataFrame or None if the input was None. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers.py
cascade_pandas_to_polars
#
Convert cascade results to polars with stable nullable dtypes.
| PARAMETER | DESCRIPTION |
|---|---|
df
|
Cascade results in pandas format.
TYPE:
|
lazy
|
Whether to return a LazyFrame or a DataFrame.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Optional[DataFrame | LazyFrame]
|
Cascade results converted to polars, or None if the input was None. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers.py
convert_pandas_loadflow_results_to_polars
#
Convert the LoadflowResults class to LoadflowResultsPolars class.
| PARAMETER | DESCRIPTION |
|---|---|
loadflow_results
|
The loadflow results in pandas format.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LoadflowResultsPolars
|
The loadflow results in polars format. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers.py
toop_engine_interfaces.nminus1_definition
#
The N-1 definition holds monitored and outaged elements for a grid.
This information is not present in the grid models and hence needs to be stored separately to run an N-1 computation. The order of the outages should be the same as in the jax code, where it's hardcoded to the following: - branch outages - multi outage - non-relevant injection outages - relevant injection outages
POWSYBL_SUPPORTED_ID_TYPES
module-attribute
#
PANDAPOWER_SUPPORTED_ID_TYPES
module-attribute
#
ELEMENT_ID_TYPES
module-attribute
#
ELEMENT_ID_TYPES = Literal[
PANDAPOWER_SUPPORTED_ID_TYPES,
POWSYBL_SUPPORTED_ID_TYPES,
]
GridElement
#
Bases: BaseModel
A grid element is identified by its id(powsybl) or its id and type (pandapower)
id
instance-attribute
#
The id of the element. For powsybl grids this is the global string id, for pandapower this is the integer index into the dataframe
name
class-attribute
instance-attribute
#
The name of the element. This is optional, but can be used to provide a more human-readable name for the element.
type
instance-attribute
#
For pandapower, we need to further specify a type which corresponds to the table pandapower stores the information in. Valid tables are 'line', 'trafo', 'ext_grid', 'gen', 'load', 'shunt', ... For powsybl, this is not strictly needed to identify the element however it makes it easier. In that case, type will be something like TIE_LINE, LINE, TWO_WINDING_TRANSFORMER, GENERATOR, etc.
kind
instance-attribute
#
The kind of the element. Usually these are handled differently in the grid modelling software, so it can make assembling an N-1 analysis easier if it is known if the element is a branch, bus or injection. This could be inferred from the type, however for conveniece it is stored separately.
For the bus type there is some potential confusion in powsybl. In pandapower, this always refers to the net.bus df. In powsybl in a bus/branch model, there are no busbar sections in powsybl, i.e. net.get_node_breaker_topology does not deliver busbar sections. Meaning, the "bus" type refers to the net.get_bus_breaker_topology buses if it's a bus/breaker topology bus. If it's a node/breaker topology, then "bus" refers to the busbar section.
SwitchMonitoringScope
#
Bases: str, Enum
A single monitoring aspect for a switch element.
Set monitoring_scope on a :class:MonitoredElement with kind="switch" to
restrict monitoring to one aspect. None (the default) activates all three.
FLOW: active power (p), reactive power (q), and current (i) through the switch.ANGLE: voltage-angle difference (va) and voltage magnitude (vm) across the open switch; used to assess reclosing conditions.PROTECTION: the switch carries a protection relay and participates in cascade-tripping.
MonitoredElement
#
Bases: GridElement
A grid element that is observed during N-1 computation.
Extends :class:GridElement with an optional monitoring_scope that restricts
which aspects are computed for switch elements.
For kind="switch", None activates all three aspects (flow, angle, protection).
Passing a frozenset restricts monitoring to those aspects only.
For other kinds this field must remain None.
monitoring_scope
class-attribute
instance-attribute
#
Which aspects of this switch to monitor. None enables all defaults.
For kind="switch":
- None → monitor flow, angle, and protection (the extractor stores
frozenset(SwitchMonitoringScope) in the DataFrame column).
- A frozenset of :class:SwitchMonitoringScope values → monitor only those aspects.
For other kinds this field must be None.
id
instance-attribute
#
The id of the element. For powsybl grids this is the global string id, for pandapower this is the integer index into the dataframe
name
class-attribute
instance-attribute
#
The name of the element. This is optional, but can be used to provide a more human-readable name for the element.
type
instance-attribute
#
For pandapower, we need to further specify a type which corresponds to the table pandapower stores the information in. Valid tables are 'line', 'trafo', 'ext_grid', 'gen', 'load', 'shunt', ... For powsybl, this is not strictly needed to identify the element however it makes it easier. In that case, type will be something like TIE_LINE, LINE, TWO_WINDING_TRANSFORMER, GENERATOR, etc.
kind
instance-attribute
#
The kind of the element. Usually these are handled differently in the grid modelling software, so it can make assembling an N-1 analysis easier if it is known if the element is a branch, bus or injection. This could be inferred from the type, however for conveniece it is stored separately.
For the bus type there is some potential confusion in powsybl. In pandapower, this always refers to the net.bus df. In powsybl in a bus/branch model, there are no busbar sections in powsybl, i.e. net.get_node_breaker_topology does not deliver busbar sections. Meaning, the "bus" type refers to the net.get_bus_breaker_topology buses if it's a bus/breaker topology bus. If it's a node/breaker topology, then "bus" refers to the busbar section.
Contingency
#
Bases: BaseModel
A single N-1 case
elements
instance-attribute
#
The grid elements that are to be outaged under this contingency. Usually, this will be exactly one element however exceptional contingencies and multi-outages might include more than one element.
id
instance-attribute
#
The id of the contingency. This is used to identify the contingency in the results. It should be unique across all contingencies in the N-1 definition.
name
class-attribute
instance-attribute
#
The name of the contingency. This is optional, but can be used to provide a more human-readable name. This will show up in the Loadflowresult-tables as column contingency_name.
is_multi_outage
#
Check if the contingency is a multi-outage.
A multi-outage is defined as a contingency that has more than one element in it.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/nminus1_definition.py
is_basecase
#
Check if the contingency is the N-0 base case.
A base case is defined as a contingency that has no elements in it.
is_single_outage
#
Check if the contingency is a normal single-element outage.
A single outage is defined as a contingency that has exactly one element in it.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/nminus1_definition.py
Condition
#
Bases: BaseModel
Represents a single condition in a rule.
condition_check_type
class-attribute
instance-attribute
#
Comparison operator or special check.
condition_side
class-attribute
instance-attribute
#
Element side or aggregation mode.
condition_limit_value
class-attribute
instance-attribute
#
Threshold value for numeric checks.
condition_element_unique_id
instance-attribute
#
Globally unique identifier of the condition element.
condition_mode
class-attribute
instance-attribute
#
Network state against which the condition is evaluated.
BC— base-case results (before the contingency is applied).CON— post-contingency results (default).
Action
#
Bases: BaseModel
Represents a single action in a rule.
SppsRule
#
Bases: BaseModel
Represents a full scheme with multiple conditions and actions.
Nminus1Definition
#
Bases: BaseModel
An N-1 definition holds monitored and outaged elements for a grid.
For powsybl, ids are unique across types (i.e. a branch and an injection can not have the same id), however in pandapower, ids are not unique and we have to store the type alongside with them.
monitored_elements
instance-attribute
#
A list of monitored elements that should be observed during the N-1 computation.
contingencies
instance-attribute
#
A list of contingencies that should be computed during the N-1 computation.
spps_rules
class-attribute
instance-attribute
#
The spps ruleset to use for the N-1 computation. This is optional. If not provided, spps ruleset will not be used.
id_type
class-attribute
instance-attribute
#
The type of the ids used in the N-1 definition. This is used to determine how to interpret the ids in the monitored elements and contingencies. See ELEMENT_ID_TYPES for more information. If none, pandapower will try to use the globally unique ids, and powsybl will use the global string ids.
base_case
property
#
Get the base case contingency, which is the contingency with no elements in it.
__getitem__
#
Get a subset of the nminus1definition based on the contingencies.
If a string is given, the contingency id must be in the contingencies list. If an integer or slice is given, the case id will be indexed by the integer or slice.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/nminus1_definition.py
load_nminus1_definition_fs
#
Load an N-1 definition from a file system.
| PARAMETER | DESCRIPTION |
|---|---|
filesystem
|
The file system to use to load the N-1 definition.
TYPE:
|
file_path
|
The path to the file containing the N-1 definition in json format.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Nminus1Definition
|
The loaded N-1 definition. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/nminus1_definition.py
load_nminus1_definition
#
Load an N-1 definition from a json file
| PARAMETER | DESCRIPTION |
|---|---|
filename
|
The path to the json file containing the N-1 definition.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Nminus1Definition
|
The loaded N-1 definition. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/nminus1_definition.py
save_nminus1_definition
#
Save an N-1 definition to a json file
| PARAMETER | DESCRIPTION |
|---|---|
filename
|
The path to the json file to save the N-1 definition to.
TYPE:
|
nminus1_definition
|
The N-1 definition to save.
TYPE:
|
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/nminus1_definition.py
Asset Topology#
toop_engine_interfaces.asset_topology
#
Public asset topology API.
This package re-exports the main topology data models so downstream imports and documentation can refer to a stable package-level namespace.
__all__
module-attribute
#
__all__ = [
"AppliedStation",
"AssetBay",
"AssetSetpoint",
"BusGroupAssetConnection",
"Busbar",
"BusbarCoupler",
"CircuitGroup",
"MasterAssetTopology",
"MasterBusGroup",
"RealizedBusGroup",
"RealizedStation",
"RealizedTopology",
"RuntimeAssetConnection",
"RuntimeAssetTopology",
"RuntimeBranchAsset",
"RuntimeBusGroup",
"RuntimeBusbar",
"RuntimeBusbarCoupler",
"RuntimeInjectionAsset",
"RuntimeSwitchableAsset",
"SimplifiedAssetTopology",
"SimplifiedBusGroup",
"SwitchableAsset",
"get_asset_bay_ids_for_bus_group_asset",
"get_asset_bays_for_bus_group_asset",
"validate_runtime_bus_group_asset_references",
]
AppliedStation
#
Bases: RealizedStation
Backward-compatible alias for RealizedStation.
branch_reassignment_diff
instance-attribute
#
Branch reassignments as (branch_index, busbar_index, connected) tuples.
injection_reassignment_diff
instance-attribute
#
Injection reassignments as (injection_index, busbar_index, connected) tuples.
branch_disconnection_diff
instance-attribute
#
Branch indices that were disconnected.
injection_disconnection_diff
instance-attribute
#
Injection indices that were disconnected.
RealizedStation
#
Bases: BaseModel
Legacy station-level diff wrapper around one runtime bus group.
The wrapped bus_group contains the full runtime snapshot after applying an action,
while the diff fields isolate the switching changes relative to the reference state.
branch_reassignment_diff
instance-attribute
#
Branch reassignments as (branch_index, busbar_index, connected) tuples.
injection_reassignment_diff
instance-attribute
#
Injection reassignments as (injection_index, busbar_index, connected) tuples.
branch_disconnection_diff
instance-attribute
#
Branch indices that were disconnected.
injection_disconnection_diff
instance-attribute
#
Injection indices that were disconnected.
RealizedTopology
#
Bases: BaseModel
A realized topology, including the new topology and the changes made to the original topology.
DeprecationWarning:
This model is deprecated and should be replaced by RuntimeAssetTopology plus
explicit switch updates in new code.
This is similar to RealizedStation but holds information for all stations in the topology.
The diffs are include a station identifier that shows which station in the topology was affected by the
diff.
master_data
class-attribute
instance-attribute
#
Canonical master data associated with the realized runtime stations when available.
bus_groups
class-attribute
instance-attribute
#
The realized asset stations that were directly applied or compared.
coupler_diff
instance-attribute
#
A list of couplers that have been switched. Each tuple contains the station id and the coupler that was switched.
branch_reassignment_diff
instance-attribute
#
Branch reassignments as (station_id, branch_index, busbar_index, connected) tuples.
injection_reassignment_diff
instance-attribute
#
Injection reassignments as (station_id, injection_index, busbar_index, connected) tuples.
branch_disconnection_diff
instance-attribute
#
Branch disconnections as (station_id, branch_index) tuples.
injection_disconnection_diff
instance-attribute
#
Injection disconnections as (station_id, injection_index) tuples.
BusGroupAssetConnection
#
Bases: BaseModel
Bus-group-local association between a switching-table column and a topology asset.
asset_id
instance-attribute
#
Grid model id of the topology-owned asset referenced by this bus-group-local column.
branch_end
class-attribute
instance-attribute
#
Optional branch-end metadata for this bus-group-local asset occurrence.
asset_bay_id
class-attribute
instance-attribute
#
Optional topology-scoped asset bay identifier for this bus-group-local asset occurrence.
CircuitGroup
#
Bases: BaseModel
A circuit group represents assets connected without power switches.
All assets inside the same circuit group are treated as jointly outaged. In master data this is a structural grouping only: it records which assets share a no-breaker path in the station design. Runtime open or closed disconnector states do not mutate this list; callers must combine the structural group with runtime switch states when reasoning about the current electrical reachability.
asset_ids
instance-attribute
#
Grid-model ids of the assets contained in the circuit group.
asset_bay_ids
instance-attribute
#
Asset-bay ids whose switches implement the circuit-group outage effect.
The ids identify the relevant bays structurally. Their live switch state is stored only on runtime station snapshots.
MasterAssetTopology
#
Bases: BaseModel
Canonical grid master data without runtime switching or outage state.
grid_model_file
class-attribute
instance-attribute
#
The source grid model file the master data was derived from.
bus_groups
instance-attribute
#
Canonical bus groups with asset references and physical connectivity only.
circuit_groups
class-attribute
instance-attribute
#
Topology-owned structural circuit groups.
These groups are derived from the master bus-group layout and are not updated when runtime disconnectors open or close. Runtime callers must therefore interpret them together with the current bus-group switch state.
branch_assets
class-attribute
instance-attribute
#
The canonical branch master data payloads.
injection_assets
class-attribute
instance-attribute
#
The canonical injection master data payloads.
asset_bays
class-attribute
instance-attribute
#
The canonical asset-bay payloads.
asset_setpoints
class-attribute
instance-attribute
#
Optional topology-owned setpoint payloads.
check_bus_group_ids_unique
classmethod
#
Validate uniqueness of canonical bus-group identifiers.
| PARAMETER | DESCRIPTION |
|---|---|
v
|
Canonical bus groups assigned to the topology master data.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[MasterBusGroup]
|
Validated canonical stations. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/asset_topology.py
check_branch_asset_ids_unique
classmethod
#
Validate uniqueness of canonical branch asset ids.
| PARAMETER | DESCRIPTION |
|---|---|
v
|
Canonical branch assets.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[BranchAsset]
|
Validated branch assets. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/asset_topology.py
check_injection_asset_ids_unique
classmethod
#
Validate uniqueness of canonical injection asset ids.
| PARAMETER | DESCRIPTION |
|---|---|
v
|
Canonical injection assets.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[InjectionAsset]
|
Validated injection assets. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/asset_topology.py
check_asset_bay_ids_unique
classmethod
#
Validate uniqueness and presence of canonical asset-bay ids.
| PARAMETER | DESCRIPTION |
|---|---|
v
|
Canonical asset-bay payloads.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[AssetBay]
|
Validated asset-bay payloads. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/asset_topology.py
check_station_asset_references
#
Validate station asset references against canonical topology collections.
| RETURNS | DESCRIPTION |
|---|---|
MasterAssetTopology
|
Validated topology master data. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/asset_topology.py
MasterBusGroup
#
Bases: BaseModel
Canonical bus-group master data without runtime switching state.
model_config
class-attribute
instance-attribute
#
bus_group_id
instance-attribute
#
The unique identifier of the canonical bus-group view.
This is the stable identifier used to align master data, runtime snapshots, and action
sets. Deterministic suffixes such as _a or _b distinguish multiple structural
bus groups that originate from the same physical substation.
voltage_level_id
class-attribute
instance-attribute
#
The voltage level identifier backing this canonical bus-group view.
voltage_level
class-attribute
instance-attribute
#
The voltage level of the station in kV.
busbars
instance-attribute
#
Canonical busbars owned by the bus group.
Runtime outage state is stripped; all busbars are assumed in service in this model.
couplers
instance-attribute
#
Canonical couplers owned by the bus group.
Runtime switch state is stripped; all couplers are assumed closed and in service.
branch_connections
class-attribute
instance-attribute
#
Bus-group-local canonical branch references aligned with branch_connectivity.
injection_connections
class-attribute
instance-attribute
#
Bus-group-local canonical injection references aligned with injection_connectivity.
branch_connectivity
class-attribute
instance-attribute
#
Physically possible branch-to-busbar assignments for the bus group.
injection_connectivity
class-attribute
instance-attribute
#
Physically possible injection-to-busbar assignments for the bus group.
model_copy
#
Copy and revalidate the bus group.
| PARAMETER | DESCRIPTION |
|---|---|
update
|
Field updates to merge into the copied bus group.
TYPE:
|
deep
|
Whether to deep-copy nested structures before validation.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
MasterBusGroup
|
Copied and revalidated bus-group instance. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/asset_topology.py
normalize_connectivity_tables
classmethod
#
Normalize connectivity table inputs to boolean arrays.
| PARAMETER | DESCRIPTION |
|---|---|
v
|
Raw connectivity table input.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Optional[ndarray]
|
Boolean connectivity table or |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/asset_topology.py
check_busbar_int_ids_unique
classmethod
#
Validate that bus-group busbar integer ids are unique.
| PARAMETER | DESCRIPTION |
|---|---|
v
|
Busbars assigned to the bus group.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Busbar]
|
Validated busbars. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/asset_topology.py
check_asset_reference_alignment
#
Validate connectivity matrices against canonical asset references.
| RETURNS | DESCRIPTION |
|---|---|
MasterBusGroup
|
Validated bus-group instance. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/asset_topology.py
AssetBay
#
Bases: BaseModel
Saves the physical connection from the asset to the substation busbars - a bay (Schaltfeld).
A line usually has three switches, before it is connected to the busbar. Two disconnector switches and one circuit breaker switch. A transformer usually has two switches, before it is connected to the busbar. One disconnector switch and one circuit breaker switch.
type: n - node type: b - busbar (Sammelschiene) type: CB - Breaker / Power Switch (Leistungsschalter) type: DS - Disconnector Switch (Trennschalter)
------------------ busbar 1 - type: b | / type: DS - Busbar disconnector busbar 1 -> used for reassigning the asset to another busbar | ------|----------- busbar 2 - type: b | | / | type: DS - Busbar disconnector busbar 2 -> used for reassigning the asset to another busbar | | --------- bus_3 - type: n - busbar section bus | / type: CB - Breaker / Power Switch -> used for disconnecting the asset from the busbar | --------- bus_2 - type: n - circuit breaker bus | / type: DS - Asset disconnector (optional) -> not used by the asset | --------- bus_1 - type: n - asset bus ^ | Line/Transformer
asset_disconnector_grid_model_id
class-attribute
instance-attribute
#
The id of the switch, which connects the asset to the circuit breaker node. This switch is a disconnector switch. Do not use for anything, leave state as found. Default should be closed.
breaker_grid_model_id
instance-attribute
#
This switch is a circuit breaker / power switch. Use for disconnecting / reconnecting the asset from the busbar.
busbar_disconnector_grid_model_id
instance-attribute
#
The ids of the switches, which assign the asset to the busbars. key: busbar_grid_model_id e.g. 4%%bus value: busbar_disconnector_grid_model_id This switch is a disconnector switch. Use for reassigning the asset to another busbar. Only one switch should be closed at a time.
Master data stores only the switch ids, not their live open or closed state. Runtime materialization interprets the current switch states to reconstruct the active station assignment.
check_is_empty
classmethod
#
Check if the dict is empty.
| PARAMETER | DESCRIPTION |
|---|---|
v
|
The dictionary of busbar_disconnector_grid_model_id to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, str]
|
The dictionary itself. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the dictionary is empty. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/assets.py
AssetSetpoint
#
Bases: BaseModel
Asset data describing a single asset with a setpoint.
This could for example be a PST or HVDC setpoint. Note: The same asset can both be switchable and have a setpoint. In this case, the asset will be represented twice.
grid_model_id
instance-attribute
#
The unique identifier of the asset. Corresponds to the asset's id in the grid model.
asset_type
class-attribute
instance-attribute
#
The type of the asset, might be useful for finding the asset later on
name
class-attribute
instance-attribute
#
The name of the asset, might be useful for finding the asset later on
Busbar
#
Bases: BaseModel
Canonical busbar data describing a physical busbar in a bus group.
grid_model_id
instance-attribute
#
The unique identifier of the busbar. Corresponds to the busbar's id in the grid model.
busbar_type
class-attribute
instance-attribute
#
The type of the busbar, might be useful for finding the busbar later on
name
class-attribute
instance-attribute
#
The name of the busbar, might be useful for finding the busbar later on
int_id
instance-attribute
#
Is used to reference busbars in the couplers. Needs to be unique per bus group
bus_breaker_bus_id
class-attribute
instance-attribute
#
Physical bus-breaker bus id backing this busbar section.
This field is primarily populated by node-breaker backends such as Powsybl. It
identifies the bus in the source bus-breaker topology that the physical busbar
section belongs to. Unlike bus_branch_bus_id this is not meant to reflect
runtime regrouping after switching operations.
BusbarCoupler
#
Bases: BaseModel
Canonical coupler data describing a physical busbar coupler at a station.
This references only busbar couplers, i.e. couplers connecting two busbars. Switches connecting assets to a busbar are represented in the asset_switching_table in the station model.
Note: A busbar couple is a physical connection between two busbars, this can be also a cross coupler. To further specify the connection of an asset to a busbar, the asset connection
grid_model_id
instance-attribute
#
The unique identifier of the coupler. Corresponds to the coupler's id in the grid model.
coupler_type
class-attribute
instance-attribute
#
The type of the coupler, might be useful for finding the coupler later on
name
class-attribute
instance-attribute
#
The name of the coupler, might be useful for finding the coupler later on
asset_bay
class-attribute
instance-attribute
#
The asset bay (Schaltfeld) of the coupler.
Note: A coupler can have multiple from and to busbars.
The asset bay busbar_disconnector_grid_model_id is used save the selector switches of the coupler.
Note: A coupler has never an asset_disconnector_grid_model_id. Central coupler-path switches are
stored on the coupler bay via coupler_breaker_ids and coupler_disconnector_ids.
Multiple selector-switch endpoints may exist in runtime data. Current action generation still assumes one active selector per side and does not synthesize switching plans for multiple simultaneously closed selector paths on one coupler side.
coupler_bay
class-attribute
instance-attribute
#
Side-aware coupler bay metadata used to reconstruct runtime endpoints.
SwitchableAsset
#
Bases: BaseModel
Canonical asset data describing a single switchable asset.
An asset can be for instance a transformer, line, generator, load, shunt.
Note: An asset that is out-of-service can be represented, but its switching entries will be ignored.
grid_model_id
instance-attribute
#
The unique identifier of the asset. Corresponds to the asset's id in the grid model.
asset_type
class-attribute
instance-attribute
#
The type of the asset. These refer loosely to the types in the pandapower/powsybl grid models. If set, this can be used to disambiguate branches from injections
name
class-attribute
instance-attribute
#
The name of the asset, might be useful for finding the asset later on
RuntimeBranchAsset
#
Bases: BranchAsset, RuntimeSwitchableAsset
Runtime switchable asset representing a branch-type element.
grid_model_id
instance-attribute
#
The unique identifier of the asset. Corresponds to the asset's id in the grid model.
name
class-attribute
instance-attribute
#
The name of the asset, might be useful for finding the asset later on
in_service
class-attribute
instance-attribute
#
Whether the asset is in service in the current runtime state.
RuntimeBusbar
#
Bases: Busbar
Runtime busbar with live service and electrical-bus state.
grid_model_id
instance-attribute
#
The unique identifier of the busbar. Corresponds to the busbar's id in the grid model.
busbar_type
class-attribute
instance-attribute
#
The type of the busbar, might be useful for finding the busbar later on
name
class-attribute
instance-attribute
#
The name of the busbar, might be useful for finding the busbar later on
int_id
instance-attribute
#
Is used to reference busbars in the couplers. Needs to be unique per bus group
bus_breaker_bus_id
class-attribute
instance-attribute
#
Physical bus-breaker bus id backing this busbar section.
This field is primarily populated by node-breaker backends such as Powsybl. It
identifies the bus in the source bus-breaker topology that the physical busbar
section belongs to. Unlike bus_branch_bus_id this is not meant to reflect
runtime regrouping after switching operations.
in_service
class-attribute
instance-attribute
#
Whether the busbar is in service in the current runtime state.
bus_branch_bus_id
class-attribute
instance-attribute
#
Runtime-only electrical bus id for this physical busbar.
RuntimeBusbarCoupler
#
Bases: BusbarCoupler
Runtime coupler with live open and service state.
grid_model_id
instance-attribute
#
The unique identifier of the coupler. Corresponds to the coupler's id in the grid model.
coupler_type
class-attribute
instance-attribute
#
The type of the coupler, might be useful for finding the coupler later on
name
class-attribute
instance-attribute
#
The name of the coupler, might be useful for finding the coupler later on
asset_bay
class-attribute
instance-attribute
#
The asset bay (Schaltfeld) of the coupler.
Note: A coupler can have multiple from and to busbars.
The asset bay busbar_disconnector_grid_model_id is used save the selector switches of the coupler.
Note: A coupler has never an asset_disconnector_grid_model_id. Central coupler-path switches are
stored on the coupler bay via coupler_breaker_ids and coupler_disconnector_ids.
Multiple selector-switch endpoints may exist in runtime data. Current action generation still assumes one active selector per side and does not synthesize switching plans for multiple simultaneously closed selector paths on one coupler side.
coupler_bay
class-attribute
instance-attribute
#
Side-aware coupler bay metadata used to reconstruct runtime endpoints.
open
class-attribute
instance-attribute
#
Whether the coupler is open in the current runtime state.
in_service
class-attribute
instance-attribute
#
Whether the coupler is in service in the current runtime state.
RuntimeInjectionAsset
#
Bases: InjectionAsset, RuntimeSwitchableAsset
Runtime switchable asset representing an injection-type element.
grid_model_id
instance-attribute
#
The unique identifier of the asset. Corresponds to the asset's id in the grid model.
name
class-attribute
instance-attribute
#
The name of the asset, might be useful for finding the asset later on
in_service
class-attribute
instance-attribute
#
Whether the asset is in service in the current runtime state.
RuntimeSwitchableAsset
#
Bases: SwitchableAsset
Runtime switchable asset with live service state.
grid_model_id
instance-attribute
#
The unique identifier of the asset. Corresponds to the asset's id in the grid model.
asset_type
class-attribute
instance-attribute
#
The type of the asset. These refer loosely to the types in the pandapower/powsybl grid models. If set, this can be used to disambiguate branches from injections
name
class-attribute
instance-attribute
#
The name of the asset, might be useful for finding the asset later on
in_service
class-attribute
instance-attribute
#
Whether the asset is in service in the current runtime state.
RuntimeAssetConnection
#
Bases: BaseModel
Busgroup-local association between a switching-table column and a materialized asset payload.
| ATTRIBUTE | DESCRIPTION |
|---|---|
asset |
Bus-group-local runtime asset payload aligned with one switching-table column.
TYPE:
|
branch_end |
Optional canonical branch-end metadata for the bus-group-local occurrence.
TYPE:
|
asset_bay |
Optional bus-group-local asset-bay payload describing the physical switch path.
TYPE:
|
asset
instance-attribute
#
Bus-group-local asset payload aligned with one switching-table column.
branch_end
class-attribute
instance-attribute
#
Optional branch-end metadata for this bus-group-local asset occurrence.
asset_bay
class-attribute
instance-attribute
#
Optional bus-group-local asset bay payload for this bus-group-local asset occurrence.
get_busbar_disconnector
#
Return the selector-switch mapping of the asset bay, if available.
| RETURNS | DESCRIPTION |
|---|---|
Optional[dict[str, str]]
|
Mapping from busbar id to selector-switch id, or |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
RuntimeAssetTopology
#
Bases: BaseModel
Runtime topology payload grouped independently from canonical master data.
The wrapper carries runtime station snapshots and optional runtime-visible
circuit-group metadata aligned with the same topology view. It is the runtime
companion of MasterAssetTopology and intentionally carries no topology-owned
canonical asset collections itself.
circuit_groups
class-attribute
instance-attribute
#
Optional circuit-group metadata carried alongside the runtime stations.
check_bus_group_ids_unique
classmethod
#
Validate uniqueness of runtime bus-group identifiers.
| PARAMETER | DESCRIPTION |
|---|---|
v
|
Runtime bus groups assigned to the wrapper.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[RuntimeBusGroup]
|
Validated runtime stations. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
RuntimeBusGroup
#
Bases: BaseModel
Bus-group data describing a single materialized bus group.
The bus-group identity refers to a bus-group or station-view identifier. A physical substation or voltage level may contain multiple bus-branch model bus ids. The bus-group assets are aligned with the switching tables and describe the assets visible in that bus-group view; they are not intended to define a topology-owned canonical asset list.
model_config
class-attribute
instance-attribute
#
bus_group_id
instance-attribute
#
The unique identifier of the bus-group or station view.
This is a bus-group-view identifier and may be synthetic. Runtime electrical bus ids are tracked separately on the busbars.
Included are all assets, busbars and couplers that are connectable via switches. Buses in the same bus group that are connected via branches are excluded in this specific bus.
This means that two bus groups can have the same elements if the underlying station is currently split.
voltage_level_id
class-attribute
instance-attribute
#
Voltage level identifier backing this bus-group view in the source grid.
voltage_level
class-attribute
instance-attribute
#
The voltage level of the station.
bus_branch_bus_ids
class-attribute
instance-attribute
#
Unique non-empty bus-branch bus ids currently represented by this bus-group view.
branch_switching_table
instance-attribute
#
Holds the switching of each branch asset to each busbar, shape (n_bus, n_branch_asset).
An entry is true if the asset is connected to the busbar. Note: An asset can be connected to multiple busbars, in which case a closed coupler is assumed to be present between these busbars. Note: An asset can be connected to none of the busbars. In this case, the asset is intentionally disconnected as part of a transmission line switching action. In practice, this usually involves a separate switch from the asset-to-busbar couplers, as each asset usually has a switch that completely disconnects it from the bus group. These switches are not modelled here, a postprocessing routine needs to do the translation to this physical layout. Do not use in_service for intentional disconnections.
injection_switching_table
instance-attribute
#
Holds the switching of each injection asset to each busbar, shape (n_bus, n_injection_asset).
branch_connectivity
class-attribute
instance-attribute
#
Holds all physically possible branch layouts, shape (n_bus, n_branch_asset).
injection_connectivity
class-attribute
instance-attribute
#
Holds all physically possible injection layouts, shape (n_bus, n_injection_asset).
model_log
class-attribute
instance-attribute
#
Holds log messages from the model creation process.
This can be used to store information about the model creation process, e.g. warnings or errors. A potential use case is to inform the user about data quality issues e.g. missing the Asset Bay switches.
branch_connections
class-attribute
instance-attribute
#
Bus-group-local branch payloads aligned with branch_switching_table.
injection_connections
class-attribute
instance-attribute
#
Bus-group-local injection payloads aligned with injection_switching_table.
asset_switching_table
property
#
Return the combined switching table in legacy branch-then-injection order.
asset_connectivity
property
#
Return the combined connectivity matrix in legacy branch-then-injection order.
normalize_station_tables
classmethod
#
Normalize switching and connectivity table inputs to boolean arrays.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
check_int_id_unique
classmethod
#
Check if the int_ids of the busbars are unique.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
normalize_runtime_busbars
classmethod
#
Validate bus-group busbars as runtime busbars.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
normalize_bus_branch_bus_ids
classmethod
#
Normalize explicit bus-branch bus ids to a unique sorted list.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
check_coupler_busbars_different
classmethod
#
Check if the couplers do not connect the same busbar on both ends.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
normalize_runtime_couplers
classmethod
#
Validate bus-group couplers as runtime couplers.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
check_coupler_busbars_exist
#
Check if all coupler busbar ids exist in busbars.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
check_coupler_references
#
Check if all closed couplers reference in-service busbars.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
sync_bus_branch_bus_ids
#
Store the unique bus-branch bus ids contained in the station busbars.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
check_asset_shapes
#
Check if switching-table-aligned station-local assets match the matrix shapes.
| RETURNS | DESCRIPTION |
|---|---|
RuntimeBusGroup
|
The validated station instance. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If switching tables, connectivity tables, or asset-bay busbar references do not align with the station-local structure. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
__eq__
#
Check if two stations are equal.
| PARAMETER | DESCRIPTION |
|---|---|
other
|
The other station to compare to.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the stations are equal, False otherwise. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
model_copy
#
Copy and revalidate the station.
| PARAMETER | DESCRIPTION |
|---|---|
update
|
Field updates to merge into the copied station.
TYPE:
|
deep
|
Whether to deep-copy nested structures before validation.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RuntimeBusGroup
|
Copied and revalidated station instance. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
is_split
#
Return whether the station view spans more than one non-empty bus-branch bus id.
get_connected_assets
#
Return in-service assets connected to one busbar.
| PARAMETER | DESCRIPTION |
|---|---|
busbar_index
|
Row index into the station switching tables.
TYPE:
|
topology_assets
|
Ignored for materialized stations because payloads are embedded locally.
TYPE:
|
asset_scope
|
Restrict the lookup to branch or injection connections.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[RuntimeSwitchableAsset]
|
Connected in-service assets for the requested busbar and scope. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
SimplifiedAssetTopology
#
Bases: RuntimeAssetTopology
Runtime topology subclass carrying already simplified bus-group views.
circuit_groups
class-attribute
instance-attribute
#
Optional circuit-group metadata carried alongside the runtime stations.
bus_groups
instance-attribute
#
Simplified runtime bus-group snapshots for the topology view.
check_bus_group_ids_unique
classmethod
#
Validate uniqueness of runtime bus-group identifiers.
| PARAMETER | DESCRIPTION |
|---|---|
v
|
Runtime bus groups assigned to the wrapper.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[RuntimeBusGroup]
|
Validated runtime stations. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
SimplifiedBusGroup
#
Bases: RuntimeBusGroup
Runtime bus-group subclass marking groups that passed preprocessing simplification.
model_config
class-attribute
instance-attribute
#
bus_group_id
instance-attribute
#
The unique identifier of the bus-group or station view.
This is a bus-group-view identifier and may be synthetic. Runtime electrical bus ids are tracked separately on the busbars.
Included are all assets, busbars and couplers that are connectable via switches. Buses in the same bus group that are connected via branches are excluded in this specific bus.
This means that two bus groups can have the same elements if the underlying station is currently split.
voltage_level_id
class-attribute
instance-attribute
#
Voltage level identifier backing this bus-group view in the source grid.
voltage_level
class-attribute
instance-attribute
#
The voltage level of the station.
bus_branch_bus_ids
class-attribute
instance-attribute
#
Unique non-empty bus-branch bus ids currently represented by this bus-group view.
branch_switching_table
instance-attribute
#
Holds the switching of each branch asset to each busbar, shape (n_bus, n_branch_asset).
An entry is true if the asset is connected to the busbar. Note: An asset can be connected to multiple busbars, in which case a closed coupler is assumed to be present between these busbars. Note: An asset can be connected to none of the busbars. In this case, the asset is intentionally disconnected as part of a transmission line switching action. In practice, this usually involves a separate switch from the asset-to-busbar couplers, as each asset usually has a switch that completely disconnects it from the bus group. These switches are not modelled here, a postprocessing routine needs to do the translation to this physical layout. Do not use in_service for intentional disconnections.
injection_switching_table
instance-attribute
#
Holds the switching of each injection asset to each busbar, shape (n_bus, n_injection_asset).
branch_connectivity
class-attribute
instance-attribute
#
Holds all physically possible branch layouts, shape (n_bus, n_branch_asset).
injection_connectivity
class-attribute
instance-attribute
#
Holds all physically possible injection layouts, shape (n_bus, n_injection_asset).
model_log
class-attribute
instance-attribute
#
Holds log messages from the model creation process.
This can be used to store information about the model creation process, e.g. warnings or errors. A potential use case is to inform the user about data quality issues e.g. missing the Asset Bay switches.
branch_connections
class-attribute
instance-attribute
#
Bus-group-local branch payloads aligned with branch_switching_table.
injection_connections
class-attribute
instance-attribute
#
Bus-group-local injection payloads aligned with injection_switching_table.
asset_switching_table
property
#
Return the combined switching table in legacy branch-then-injection order.
asset_connectivity
property
#
Return the combined connectivity matrix in legacy branch-then-injection order.
normalize_station_tables
classmethod
#
Normalize switching and connectivity table inputs to boolean arrays.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
check_int_id_unique
classmethod
#
Check if the int_ids of the busbars are unique.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
normalize_runtime_busbars
classmethod
#
Validate bus-group busbars as runtime busbars.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
normalize_bus_branch_bus_ids
classmethod
#
Normalize explicit bus-branch bus ids to a unique sorted list.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
check_coupler_busbars_different
classmethod
#
Check if the couplers do not connect the same busbar on both ends.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
normalize_runtime_couplers
classmethod
#
Validate bus-group couplers as runtime couplers.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
check_coupler_busbars_exist
#
Check if all coupler busbar ids exist in busbars.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
check_coupler_references
#
Check if all closed couplers reference in-service busbars.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
sync_bus_branch_bus_ids
#
Store the unique bus-branch bus ids contained in the station busbars.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
check_asset_shapes
#
Check if switching-table-aligned station-local assets match the matrix shapes.
| RETURNS | DESCRIPTION |
|---|---|
RuntimeBusGroup
|
The validated station instance. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If switching tables, connectivity tables, or asset-bay busbar references do not align with the station-local structure. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
__eq__
#
Check if two stations are equal.
| PARAMETER | DESCRIPTION |
|---|---|
other
|
The other station to compare to.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the stations are equal, False otherwise. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
model_copy
#
Copy and revalidate the station.
| PARAMETER | DESCRIPTION |
|---|---|
update
|
Field updates to merge into the copied station.
TYPE:
|
deep
|
Whether to deep-copy nested structures before validation.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RuntimeBusGroup
|
Copied and revalidated station instance. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
is_split
#
Return whether the station view spans more than one non-empty bus-branch bus id.
get_connected_assets
#
Return in-service assets connected to one busbar.
| PARAMETER | DESCRIPTION |
|---|---|
busbar_index
|
Row index into the station switching tables.
TYPE:
|
topology_assets
|
Ignored for materialized stations because payloads are embedded locally.
TYPE:
|
asset_scope
|
Restrict the lookup to branch or injection connections.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[RuntimeSwitchableAsset]
|
Connected in-service assets for the requested busbar and scope. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
get_asset_bay_ids_for_bus_group_asset
#
Return ordered unique asset-bay ids for one asset.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
get_asset_bays_for_bus_group_asset
#
Return ordered unique asset-bay payloads for one asset.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
validate_runtime_bus_group_asset_references
#
validate_runtime_bus_group_asset_references(
stations, branch_assets, injection_assets, asset_bays
)
Validate runtime station references against canonical topology payloads.
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/runtime_topology.py
toop_engine_interfaces.asset_topology.topology_conversion
#
Conversions between materialized bus groups and canonical master data.
RuntimeSwitchingState
dataclass
#
RuntimeSwitchingState(
busbar_bus_branch_bus_ids=None,
branch_current_bus_ids=None,
injection_current_bus_ids=None,
busbar_out_of_service_ids=frozenset(),
open_coupler_ids=frozenset(),
out_of_service_coupler_ids=frozenset(),
open_switch_ids=frozenset(),
)
Compact runtime overlay describing the current live switching state of a bus group.
busbar_bus_branch_bus_ids
class-attribute
instance-attribute
#
Mapping from canonical busbar ids to current runtime bus-branch bus ids.
branch_current_bus_ids
class-attribute
instance-attribute
#
Current runtime bus ids for branch connections, aligned with the bus group's canonical branch connections.
injection_current_bus_ids
class-attribute
instance-attribute
#
Current runtime bus ids for injection connections, aligned with the bus group's canonical injection connections.
busbar_out_of_service_ids
class-attribute
instance-attribute
#
Canonical busbar ids that are currently out of service.
open_coupler_ids
class-attribute
instance-attribute
#
Canonical coupler ids that are currently open.
out_of_service_coupler_ids
class-attribute
instance-attribute
#
Canonical coupler ids that are currently out of service.
open_switch_ids
class-attribute
instance-attribute
#
Asset-bay switch ids that are currently open.
validate_complete_master_asset_topology
#
Validate that canonical master data already contains productive asset metadata.
| PARAMETER | DESCRIPTION |
|---|---|
master_data
|
Canonical master data to validate.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If canonical assets or station-local branch references are missing metadata that productive preprocessing requires. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/topology_conversion.py
materialize_runtime_bus_group_from_runtime_state
#
materialize_runtime_bus_group_from_runtime_state(
canonical_bus_group,
branch_asset_map,
injection_asset_map,
asset_bay_map,
runtime_switching_state,
*,
model_log=None,
)
Materialize one master bus group from compact runtime switching state.
| PARAMETER | DESCRIPTION |
|---|---|
canonical_bus_group
|
Canonical bus-group definition.
TYPE:
|
branch_asset_map
|
Canonical branch assets keyed by grid-model id.
TYPE:
|
injection_asset_map
|
Canonical injection assets keyed by grid-model id.
TYPE:
|
asset_bay_map
|
Canonical asset bays keyed by asset-bay id.
TYPE:
|
runtime_switching_state
|
Compact runtime overlay describing the current live state.
TYPE:
|
model_log
|
Optional log messages to attach to the materialized bus group.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RuntimeBusGroup
|
Runtime bus-group snapshot combining canonical structure and live switching state. |
Source code in packages/interfaces_pkg/src/toop_engine_interfaces/asset_topology/topology_conversion.py
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 | |
Switch Updates#
toop_engine_interfaces.switch_update_schema
#
Shared schema for switch updates induced by a topology.
A switch update is a collection of switch ids in the grid model and their new open/closed state. The internal representation of actions does not follow this structure but instead reference the action set. To enable export of the actions to other tools, this needs to be translated into multiple formats, e.g. .dgs for powerfactory or .json for OpenRAO.
SwitchUpdateSchema
#
Bases: DataFrameModel
Schema for switch update dataframes.