Skip to content

Pathfinder

Depth-first search over the undirected bus/branch graph that enumerates every simple path from a source bus to the active fault bus. The resulting ordered branch lists are used by ElectricalNetwork to inject the mutual-coupling Norton sources with the correct sign.

pathfinder

PathFinder Module.

This module provides the PathFinder class, which is responsible for identifying all possible paths between sources and faults within an electrical network. It utilizes Depth-First Search (DFS) to traverse the network graph and determine the connectivity between different buses through branches.

The primary use cases include: - Determining all paths from a specific source to a fault point. - Analyzing the network's topology for fault impact assessment. - Facilitating impedance and grounding calculations based on identified paths.

PathFinder

PathFinder(network: Network)

A class to find all paths between sources and faults in a network.

The PathFinder class constructs an adjacency list representation of the network graph and uses Depth-First Search (DFS) to identify all possible paths between a given source bus and fault bus. These paths are essential for performing various electrical calculations, including impedance analysis and grounding assessments.

Initialize the PathFinder with a given Network.

Constructs the adjacency list representation of the network graph based on buses and branches.

Parameters:

Name Type Description Default
network Network

The Network instance containing buses and branches.

required
Source code in src/groundinsight/pathfinder.py
def __init__(self, network: Network):
    """
    Initialize the PathFinder with a given Network.

    Constructs the adjacency list representation of the network graph based on buses and branches.

    Args:
        network (Network): The Network instance containing buses and branches.

    """

    self.network = network
    self.graph = self._build_graph()

find_paths

find_paths(
    source_bus_name: str, fault_bus_name: str
) -> List[Path]

Find all paths between the source bus and fault bus.

Utilizes Depth-First Search (DFS) to explore all possible routes from the source to the fault.

Parameters:

Name Type Description Default
source_bus_name str

The name of the source bus.

required
fault_bus_name str

The name of the fault bus.

required

Returns:

Type Description
List[Path]

List[Path]: A list of Path instances representing all discovered paths.

Source code in src/groundinsight/pathfinder.py
def find_paths(self, source_bus_name: str, fault_bus_name: str) -> List[Path]:
    """
    Find all paths between the source bus and fault bus.

    Utilizes Depth-First Search (DFS) to explore all possible routes from the source to the fault.

    Args:
        source_bus_name (str): The name of the source bus.
        fault_bus_name (str): The name of the fault bus.

    Returns:
        List[Path]: A list of `Path` instances representing all discovered paths.

    """
    all_paths = []
    visited_buses = set()
    path = []

    self._dfs(source_bus_name, fault_bus_name, visited_buses, path, all_paths)

    # Convert each list of Branch objects to a Path object
    paths = []
    for branch_path in all_paths:
        path = Path(
            name="",  # Name will be assigned in define_paths()
            source="",  # Will be set in define_paths()
            fault="",  # Will be set in define_paths()
            segments=branch_path,
        )
        paths.append(path)
    return paths