dc-power-flow
/dc-power-flow
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.
- Author
- benchflow-ai ↗
- Repository
- skillsbench ↗
- Licence
- Apache-2.0
- Last repository change
- 12.10.2026
Assessment and security
- Files in this package
- 2
- Scripts
- 1
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 12.10.2026, without references to retired models or APIs.
Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.
- 1 scripts in this package. Review them before installing, as Claude may execute them.
Scripts: scripts/build_b_matrix.py
What it does and when to use it
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.
Original author 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.
How it works
- DC Approximations
- Bus Number Mapping
- Susceptance Matrix (B)
- Power Balance Equation
- Slack Bus
- Line Flow Calculation
- Line Loading Percentage
- Branch Susceptances for Constraints
- Line Flow Limits (for OPF)
SKILL.md preview
---
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)
```
Files in this package (2)
- SKILL.md 3 KB
- scripts/build_b_matrix.py 3 KB
Versions
The database has no other skills named dc-power-flow.
Identical content appears in 1 other GitHub folders. We show one copy with the highest score.
Database snapshot: 13.11.2026 · package version 21ef79677945 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 1 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 95power-flow-data
Power system network data formats and topology. Use when parsing bus, generator, and branch data for power flow analysis. - 90powerworld
Progressive-disclosure workflow for PowerWorld Simulator studies through PowerMCP. Use whenever the user wants to open a PowerWorld case, solve the base power flow, inspect flows or voltages, change model data, run contingency analysis, or pull sensitivity matrices (PTDF, LODF,… - 100pandapower
Power systems analysis and optimization library (pandapower v3.4.0). Use when working with electric power networks: building network models (buses, lines, transformers, loads, generators), running AC/DC power flow, optimal power flow (OPF), short circuit calculations (IEC… - 100ac-branch-pi-model
AC 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)… - 100surge
Use this skill for transmission power-system studies — AC/DC power flow, DC-OPF / AC-OPF / SCOPF, N-1 / N-2 contingency analysis, PTDF / LODF / OTDF sensitivities, NERC and AC Available Transfer Capability (ATC), SCED economic dispatch, and SCUC unit commitment. Also use for… - 90research-pipeline
Run a structured research analysis — hypotheses, power analysis, assumption checks, primary analysis, and reproducible reporting. Use when results must meet academic or regulatory standards.