dc-power-flow
$
npx mdskill add elizaOS/eliza/dc-power-flowDC power flow is a linearized approximation of AC power flow, suitable for economic dispatch and contingency analysis.
SKILL.md
.github/skills/dc-power-flowView on GitHub ↗
---
name: dc-power-flow
description: "DC power flow analysis for power systems. Use when computing power flows using DC approximation, building susceptance matrices, calculating line flows and loading percentages, or performing sensitivity analysis on transmission networks."
---
# DC Power Flow
DC power flow is a linearized approximation of AC power flow, suitable for economic dispatch and contingency analysis.
## DC Approximations
1. **Lossless lines** - Ignore resistance (R ≈ 0)
2. **Flat voltage** - All bus voltages = 1.0 pu
3. **Small angles** - sin(θ) ≈ θ, cos(θ) ≈ 1
Result: Power flow depends only on bus angles (θ) and line reactances (X).
## Bus Number Mapping
Power system bus numbers may not be contiguous (e.g., case300 has non-sequential bus IDs). Always create a mapping from bus numbers to 0-indexed array positions:
```python
# Create mapping: bus_number -> 0-indexed position
bus_num_to_idx = {int(buses[i, 0]): i for i in range(n_bus)}
# Use mapping for branch endpoints
f = bus_num_to_idx[int(br[0])] # NOT br[0] - 1
t = bus_num_to_idx[int(br[1])]
```
## Susceptance Matrix (B)
Build from branch reactances using bus number mapping:
```python
# Run: scripts/build_b_matrix.py
# Or inline:
bus_num_to_idx = {int(buses[i, 0]): i for i in range(n_bus)}
B = np.zeros((n_bus, n_bus))
for br in branches:
f = bus_num_to_idx[int(br[0])] # Map bus number to index
t = bus_num_to_idx[int(br[1])]
x = br[3] # Reactance
if x != 0:
b = 1.0 / x
B[f, f] += b
B[t, t] += b
B[f, t] -= b
B[t, f] -= b
```
## Power Balance Equation
At each bus: `Pg - Pd = B[i, :] @ θ`
Where:
- Pg = generation at bus (pu)
- Pd = load at bus (pu)
- θ = vector of bus angles (radians)
## Slack Bus
One bus must have θ = 0 as reference. Find slack bus (type=3):
```python
slack_idx = None
for i in range(n_bus):
if buses[i, 1] == 3:
slack_idx = i
break
constraints.append(theta[slack_idx] == 0)
```
## Line Flow Calculation
Flow on branch from bus f to bus t (use bus number mapping):
```python
f = bus_num_to_idx[int(br[0])]
t = bus_num_to_idx[int(br[1])]
b = 1.0 / br[3] # Susceptance = 1/X
flow_pu = b * (theta[f] - theta[t])
flow_MW = flow_pu * baseMVA
```
## Line Loading Percentage
```python
loading_pct = abs(flow_MW) / rating_MW * 100
```
Where `rating_MW = branch[5]` (RATE_A column).
## Branch Susceptances for Constraints
Store susceptances when building constraints:
```python
branch_susceptances = []
for br in branches:
x = br[3]
b = 1.0 / x if x != 0 else 0
branch_susceptances.append(b)
```
## Line Flow Limits (for OPF)
Enforce thermal limits as linear constraints:
```python
# |flow| <= rating → -rating <= flow <= rating
flow = b * (theta[f] - theta[t]) * baseMVA
constraints.append(flow <= rate)
constraints.append(flow >= -rate)
```
More from elizaOS/eliza
- ac-branch-pi-modelAC branch pi-model power flow equations (P/Q and |S|) with transformer tap ratio and phase shift, matching `acopf-math-model.md` and MATPOWER branch fields. Use when computing branch flows in either direction, aggregating bus injections for nodal balance, checking MVA (rateA) limits, computing branch loading %, or debugging sign/units issues in AC power flow.
- academic-pdf-redactionRedact text from PDF documents for blind review anonymization
- ada-plan-view-accessibilityUse when checking simplified ADA-derived plan-view bathroom accessibility constraints such as turning space, door clear width, toilet centerline, grab bars, and lavatory knee/toe clearance.
- analyze-ciAnalyze failed GitHub Action jobs for a pull request.
- architectural-dxf-extractionUse when extracting plan-view architectural geometry from DXF files with semantic CAD layers, especially when outputs must normalize rooms, doors, fixtures, clearances, and grab bars into machine-checkable JSON.
- attitude-controller-plannerUse this skill when implementing the inner control loop for a quadrotor — attitude (roll/pitch/yaw) PID control and attitude planning (converting desired acceleration to desired Euler angles). Covers gain layout, integral reset pattern, and the attitude planner inverse kinematics.
- azure-bgpAnalyze and resolve BGP oscillation and BGP route leaks in Azure Virtual WAN–style hub-and-spoke topologies (and similar cloud-managed BGP environments). Detect preference cycles, identify valley-free violations, and propose allowed policy-level mitigations while rejecting prohibited fixes.
- box-least-squaresBox Least Squares (BLS) periodogram for detecting transiting exoplanets and eclipsing binaries. Use when searching for periodic box-shaped dips in light curves. Alternative to Transit Least Squares, available in astropy.timeseries. Based on Kovács et al. (2002).
- browser-testingVERIFY your changes work. Measure CLS, detect theme flicker, test visual stability, check performance. Use BEFORE and AFTER making changes to confirm fixes. Includes ready-to-run scripts: measure-cls.ts, detect-flicker.ts
- cache-policy-comparisonCompare and implement eviction policies (LRU, LFU, FIFO, S3FIFO, ARC) for bounded-capacity caches. Use when choosing or implementing an eviction policy for a buffer pool, page cache, CDN edge, or LLM KV cache, or when writing a replay simulator that supports multiple policies. Clarifies recency vs frequency semantics, queue topology, saturating counters, ghost buffers, and the second-chance rule that distinguishes modern FIFO-family policies from classic LRU.