In GridPACK, a power grid is represented as a graph: buses are the nodes and branches (transmission lines, transformers) are the edges. This graph is stored in aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/GridOPTICS/GridPACK/llms.txt
Use this file to discover all available pages before exploring further.
BaseNetwork<Bus, Branch> template object that distributes the graph across MPI ranks, tracks which buses and branches are owned locally versus mirrored as ghosts from neighboring ranks, and provides the partitioner that minimizes inter-rank communication. Understanding the network model is the first step to writing any GridPACK application.
Buses and branches
A bus corresponds to a physical bus bar or node in the power grid — a point where equipment connects. A branch corresponds to a transmission line or transformer connecting exactly two buses. Each bus and branch has:- An original index — the integer label from the input file (PSS/E
.rawor similar). These are not required to be consecutive. - A global index — a contiguous index assigned by the framework after partitioning.
- A local index — a process-local index in the range
[0, numBuses()-1]used to address the bus or branch on a given rank. - An associated
DataCollectionobject holding key-value pairs read from the input file. - An application-supplied component object (your
BusorBranchclass) attached to the topology entry.
The BaseNetwork<Bus, Branch> template class
Networks are declared by specializing BaseNetwork with application-specific bus and branch types:
Communicator that defines the set of processors the network lives on:
Key network queries
Ghost buses and branches
When the network is partitioned, each rank owns a contiguous subgraph. However, buses and branches that are connected to locally-owned components but live on a neighboring rank must still be accessible for physics calculations. The partitioner creates ghost copies of these remote components on the local rank. Ghost buses and branches are read-only mirrors. Their data is kept current by periodic update operations that copy values from the active (home) rank to all ranks holding a ghost copy:getActiveBus(i) returns false for ghost buses. Application code that loops over all local buses typically skips ghosts for output or accumulation:
Bus and branch exchange buffers must be allocated before calling
initBusUpdate() or initBranchUpdate(). This is done by calling factory.setExchange() after network->partition(). See the factory pattern for the full initialization sequence.Network partitioning
Partitioning splits the graph across MPI ranks to balance computational load while minimizing the number of branches that cross rank boundaries (since each such crossing creates a ghost and requires communication). GridPACK uses an embedded graph partitioner (based on PTScotch or similar) accessible via:Finding components by original index
After partitioning, the local index of a component changes. To locate a bus by its original (input file) index, use:Data flow: parser → network → factory → mapper → solver
A full GridPACK solve follows this pipeline:Parse input file
A parser (e.g.,
gridpack::powerflow::PTIParser) reads the network configuration file, creates buses and branches, and fills each component’s DataCollection object with raw parameters.Partition the network
network->partition() distributes the graph across ranks and creates ghost entries at partition boundaries.Initialize components via factory
factory.setComponents() pushes topology (neighbor lists) into bus/branch objects. factory.setExchange() allocates exchange buffers. factory.load() calls each component’s load(data) method to transfer values from DataCollection into component fields.Assemble matrix and vector
After setting the calculation mode with
factory.setMode(YBus), a FullMatrixMap<MyNetwork> loops over all buses and branches, calls their MatVecInterface methods, and assembles a distributed sparse matrix.Declaring a network — complete example
Framework overview
The four-layer architecture and factory pattern
Bus and branch components
How components implement physics via MatVecInterface