Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

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"
/opt/homebrew/Caskroom/miniconda/base/envs/gdm2/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py:502: UserWarning: Ellipsis is not a Python type (it may be an instance of an object), Pydantic will allow any object with no validation since we cannot even enforce that the input is an instance of the given type. To get rid of this error wrap the type with `pydantic.SkipValidation`.
  warn(

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.

undirected_graph = distribution_system.get_undirected_graph()
print(undirected_graph)

directed_graph = distribution_system.get_directed_graph()
print(directed_graph)
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