Topological Searches

Once you converted your network into a MultiGraph there are several functions to perform topological searches and analyses at your disposal. You can either use the general-purpose functions that come with NetworkX (see http:/networkx.github.io/documentation/networkx-1.10/reference/algorithms.html) or topology’s own ones which are specialized on electrical networks.

calc_distance_to_bus

pandapower.topology.calc_distance_to_bus(net, bus, respect_switches=True, nogobuses=None, notravbuses=None, weight='weight', g=None)

Calculates the shortest distance between a source bus and all buses connected to it.

Parameters:
  • net (pandapowerNet) – Variable that contains a pandapower network.

  • bus (integer) – Index of the source bus.

  • respect_switches (boolean, True) –

    • True: open line switches are being considered (no edge between nodes).

    • False: open line switches are being ignored.

  • nogobuses (integer/list, None) – nogobuses are not being considered.

  • notravbuses (integer/list, None) – lines connected to these buses are not being considered.

  • weight (string, None) – Edge data key corresponding to the edge weight.

  • g (nx.MultiGraph, None) – MultiGraph of the network. If None, the graph will be created.

Returns:

A pandas series with containing all distances to the source bus in km. If weight=None dist is the topological distance (int).

Example

>>> from pandapower.topology.graph_searches import calc_distance_to_bus
>>> dist = calc_distance_to_bus(net, 5)

connected_component

pandapower.topology.connected_component(mg, bus, notravbuses=[])

Finds all buses in a NetworkX graph that are connected to a certain bus.

Parameters:
  • mg (NetworkX graph) – NetworkX Graph or MultiGraph that represents a pandapower network.

  • bus (integer) – Index of the bus at which the search for connected components originates

  • notravbuses (list/set) – indices of notravbuses: lines connected to these buses are not being considered in the graph

Returns:

Returns a generator that yields all buses connected to the input bus

Return type:

cc (generator)

Examples

>>> from pandapower.topology.create_graph import create_nxgraph
>>> from pandapower.topology.graph_searches import connected_component
>>> mg = create_nxgraph(net)
>>> cc = connected_component(mg, 5)
pandapower.topology.connected_components(mg, notravbuses=set())

Clusters all buses in a NetworkX graph that are connected to each other.

Parameters:
  • mg (NetworkX graph) – NetworkX Graph or MultiGraph that represents a pandapower network.

  • notravbuses (set) – Indices of notravbuses: lines connected to these buses are not being considered in the graph

Returns:

Returns a generator that yields all clusters of buses connected to each other.

Return type:

cc (generator)

Example

>>> from pandapower.topology.create_graph import create_nxgraph
>>> from pandapower.topology.graph_searches import connected_components
>>> mg = create_nxgraph(net)
>>> cc = connected_components(mg, 5)

unsupplied_buses

pandapower.topology.unsupplied_buses(net, mg=None, slacks=None, respect_switches=True)

Finds buses, that are not connected electrically (no lines, trafos etc or if respect_switches is True only connected via open switches) to an external grid and that are in service.

Parameters:
  • net (pandapowerNet) – variable that contains a pandapower network

  • mg (NetworkX graph) – NetworkX Graph or MultiGraph that represents a pandapower network.

  • in_service_only (boolean, False) – Defines whether only in service buses should be included in unsupplied_buses.

  • slacks (set, None) – buses which are considered as root / slack buses. If None, all existing slack buses are considered.

  • respect_switches (boolean, True) – Fixes how to consider switches - only in case of no given mg.

Returns:

A Set of unsupplied buses

Example

>>> from pandapower.topology.graph_searches import unsupplied_buses
>>> unsupplied_buses(net)

determine_stubs

pandapower.topology.determine_stubs(net, roots=None, mg=None, respect_switches=False)

Finds stubs in a network. Open switches are being ignored. Results are being written in a new column in the bus table (“on_stub”) and line table (“is_stub”) as True/False value.

Parameters:
  • net (pandapowerNet) – Variable that contains a pandapower network.

  • roots (integer/list, None) – indices of buses that should be excluded (by default, the ext_grid buses will be set as roots)

Example

>>> from pandapower.topology.graph_searches import determine_stubs
>>> determine_stubs(net, roots = [0, 1])