dc-power-flow
Build and use the DC power-flow model (B matrix, slack angle, line flows, and thermal limits) with correct MATPOWER bus-number mapping.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- dc-power-flow
- description
- Build and use the DC power-flow model (B matrix, slack angle, line flows, and thermal limits) with correct MATPOWER bus-number mapping.
02 资源文件 1
- 脚本scripts/build_b_matrix.py3.1 KB
03 SKILL.md 正文
Steps
- Create a bus-number → 0‑indexed row mapping (bus numbers may be non-contiguous):
bus_num_to_idx = {int(bus[i,0]): i for i in range(n_bus)} - Build the nodal susceptance matrix B from in-service branches using
X = branch[:,3]:B = np.zeros((n_bus, n_bus)) for br in branches: f = bus_num_to_idx[int(br[0])] t = bus_num_to_idx[int(br[1])] x = br[3] if x != 0: b = 1.0/x B[f,f] += b; B[t,t] += b B[f,t] -= b; B[t,f] -= b - Add a slack bus angle reference (MATPOWER bus type 3):
slack_idx = next(i for i in range(n_bus) if int(buses[i,1]) == 3) constraints.append(theta[slack_idx] == 0) - Enforce nodal DC balance (in per-unit, consistent with
Pg_puandPd/baseMVA): [ Pg_i - Pd_i = B_{i,:},\theta ] - Compute branch flow (MW) for reporting:
b = 1.0/br[3] flow_MW = b*(theta[f]-theta[t]) * baseMVA - Enforce branch thermal limits (RATE_A is
branch[:,5]) as linear constraints:rate = br[5] flow = b*(theta[f]-theta[t]) * baseMVA constraints += [flow <= rate, flow >= -rate]
Expected Result
A consistent DC network model where bus angles determine line flows, thermal limits can bind, and flows/loading can be computed in MW/%.
04 同仓库更多 Skills
video-frame-extraction
Extract frames from video files and save them as images using OpenCV
openai-vision
Analyze images and multi-frame sequences using OpenAI GPT vision models
image-ocr
Extract text content from images using Tesseract OCR via Python, including structured field extraction from receipts and forms
video-frame-extraction
Extract frames from video files and save them as images using OpenCV
openai-vision
Analyze images and multi-frame sequences using OpenAI GPT vision models
image-ocr
Extract text content from images using Tesseract OCR via Python, including structured field extraction from receipts and forms