System Graphs

System Graphs#

We start by loading a sample distribution system.

from gdm.distribution import DistributionSystem
from gdmloader.constants import GCS_CASE_SOURCE
from gdmloader.source import SystemLoader

gdm_loader = SystemLoader()
gdm_loader.add_source(GCS_CASE_SOURCE)

distribution_system: DistributionSystem = gdm_loader.load_dataset(
    source_name=GCS_CASE_SOURCE.name,
    system_type=DistributionSystem,
    dataset_name="three_feeder_switch",
)
distribution_system.name = "three_feeder_switch"

Distribution systems have helper functions that return either undirected or directed graphs. These graph representations are useful for understanding model connectivity, such as when building constraints in CADET-OPT.

Warning

Undirected graphs contain complete connectivity information. If there are cycles in the undirected graphs (e.g., an open switch connected between two buses), edges will be removed to create a directed radial graph.

undirected_graph = distribution_system.get_undirected_graph()
print(undirected_graph)

directed_graph = distribution_system.get_directed_graph()
print(directed_graph)
2025-09-04 23:57:09.973 | INFO     | gdm.distribution.distribution_system:get_directed_graph:307 - Creating directed graph with source bus -> sourcebus
2025-09-04 23:57:09.974 | INFO     | gdm.distribution.distribution_system:get_directed_graph:314 -   An open switch edge (fdr1_6, fdr2_7) has been removed.
2025-09-04 23:57:09.974 | INFO     | gdm.distribution.distribution_system:get_directed_graph:314 -   An open switch edge (fdr1_9, fdr3_9) has been removed.
2025-09-04 23:57:09.975 | INFO     | gdm.distribution.distribution_system:get_directed_graph:314 -   An open switch edge (fdr2_5, fdr3_5) has been removed.
Graph with 86 nodes and 88 edges
DiGraph with 86 nodes and 85 edges

Graphs are lightweight and contain limited information, such as bus and edge names. Helper functions are provided to efficiently retrieve connectivity information for a particular node.

from gdm.distribution.components import DistributionLoad

loads = distribution_system.get_bus_connected_components(
    bus_name="fdr1_2_load", component_type=DistributionLoad
)
for load in loads:
    print(load.name, load.bus.name)
fdr1_load1 fdr1_2_load