GridPACK’s contingency analysis application distributes a set of power system contingencies across multiple MPI communicator groups, evaluating each one by running an independent power flow solve. TheDocumentation 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.
CADriver class in the gridpack::contingency_analysis namespace orchestrates this parallel sweep: it reads or auto-generates the contingency list, divides contingencies among process groups using a task manager, evaluates voltage and thermal violations, and writes per-contingency result files alongside aggregate statistical summaries. Because the underlying solver is PFAppModule, any feature of the power flow module—Q-limit enforcement, switched shunts, LTC control—can be activated in the contingency analysis by setting the corresponding XML flags.
Contingency definition
Contingencies are represented by thegridpack::powerflow::Contingency struct, which supports both branch (line) outages and generator outages:
Specifying contingencies
Three options can be used separately or in combination.Option 1: Auto-generate N-1 contingencies
SetFullBranchN1 and/or FullGeneratorN1 to true to automatically create one contingency per in-service branch or generator in the network. Branch contingencies are named BR_<from>_<to>_<ckt> and generator contingencies are named GN_<bus>_<id>.
Option 2: Explicit contingency list file
Provide a contingency list in a separate XML file:Option 3: Combined auto-generated and explicit
When bothFullBranchN1/FullGeneratorN1 and a contingencyList are specified, the driver loads both sources and calls isDuplicateContingency() to skip any entries in the file that duplicate an auto-generated contingency.
Full input file example
Parallel execution model
The driver uses GridPACK’s task manager to divide contingencies across independent MPI communicator groups. ThegroupSize parameter controls how many MPI ranks share each contingency’s power flow network. For large transmission systems a group size greater than 1 enables intra-contingency parallelism; for most medium-sized cases groupSize=1 is sufficient and maximizes contingency throughput.
PFAppModule. Contingencies are distributed dynamically so that idle ranks pick up new work as soon as they finish their current task.
Automatic slack bus transfer
When a generator contingency removes the slack bus generator from service, the driver automatically transfers the slack bus role to the bus with the largest remaining online generator capacity. This matches the behavior of commercial power flow tools such as PSS/E and PowerWorld.restoreSlack().
Slack capacity check
After each post-contingency power flow converges, the driver callscheckSlackCapacity() to verify that the slack bus generator output does not exceed its Pmax rating. If capacity is exceeded, the contingency is flagged as a failure:
Island detection
Branch outages can split the network into disconnected islands. The driver callsgetIslandCount() and hasLoneBus() before attempting a power flow solve. When isolation is detected, the contingency is flagged with a warning: isolated tag in the results and, where possible, the main connected portion is still solved.
Violation checking
After solving each post-contingency power flow, the driver checks for:- Voltage violations: bus voltages outside
[minVoltage, maxVoltage](default[0.9, 1.1]pu). - Line overload violations: branch currents or power flows exceeding the rating stored in the PSS/E network file (Rate A by default; Rate B can be selected by calling
useRateB(true)on the underlyingPFAppModule).
ignoreVoltageViolations() and ignoreLineOverloadViolations() so that the contingency screening reports only new violations.
Output files
The application writes aggregate result files to the working directory. All columns are space-delimited.| File | Contents | ||
|---|---|---|---|
success.txt | Per-contingency: convergence status, violation type, isolation warning | ||
vmag.txt | Per-bus: average voltage magnitude, RMS deviation from average and from base case | ||
vmag_mm.txt | Per-bus: base case value, minimum and maximum voltage over all contingencies, contingency indices | ||
vang.txt | Per-bus: average voltage angle (PV buses included) | ||
pgen.txt / pgen_mm.txt | Per-generator: average and min/max real power across contingencies | ||
qgen.txt / qgen_mm.txt | Per-generator: average and min/max reactive power across contingencies | ||
pflow.txt / pflow_mm.txt | Per-branch: average and min/max real power flow, with rate A limits | ||
perf_mm.txt | Per-branch: min/max performance index ( | S | /rating)² |
perf_sum.txt | Per-contingency: sum and average of performance index over all branches | ||
line_flt_cnt.txt | Per-branch: total number of contingencies that caused a fault on that branch | ||
pq_changed_cnt.txt | Per-bus: number of PV→PQ conversions (only when qlim=true) |
success.txt entry looks like:
Power flow
The PFAppModule class that contingency analysis builds on top of.
State estimation
Use state estimation to produce a calibrated base case before contingency screening.