ac-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
Install / Use
npx skills add benchflow-ai/skillsbench --skill ac-branch-pi-modelInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
AI & Machine LearningSupported Platforms
Tags
Our assessment of ac-branch-pi-model
ac-branch-pi-model scores 88/100 on our quality scale, 394th of 970 AI & Machine Learning skills we index (top 41%).
Its SKILL.md is 4.2 KB long, well organised into 13 sections with 2 code examples: a solid amount of guidance for an agent.
With 1,813 GitHub stars, it is one of the more widely adopted skills in the catalogue.
Maintenance, license and trust
- The repository was last updated about 2 months ago, so ac-branch-pi-model is actively maintained.
- It is released under the Apache-2.0 license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
ac-branch-pi-model compared with similar skills
All 4 of these similar skills score higher than ac-branch-pi-model; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| ac-branch-pi-model (this skill)by benchflow-ai | 88 | 1.8k | 2mo ago | SKILL.md |
| claude-memby thedotmack | 100 | 95.2k | today | CLAUDE.md |
| Understand-Anythingby Egonex-AI | 100 | 85.0k | today | CLAUDE.md |
| headroomby headroomlabs-ai | 100 | 74.3k | today | CLAUDE.md |
| CowAgentby zhayujie | 100 | 47.2k | today | CLAUDE.md |
Frequently asked questions
- How do I install ac-branch-pi-model?
- Run
npx skills add benchflow-ai/skillsbench --skill ac-branch-pi-model. The install tabs above show the steps for each supported agent. - Which AI agents does ac-branch-pi-model work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is ac-branch-pi-model safe to use?
- It is Apache-2.0-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is ac-branch-pi-model still maintained?
- The repository was last updated about 2 months ago, so ac-branch-pi-model is actively maintained.
Skill content
View source on GitHubname: ac-branch-pi-model
description: "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) limits, computing branch loading %, or debugging sign/units issues in AC power flow."
AC Branch Pi-Model + Transformer Handling
Implement the exact branch power flow equations in acopf-math-model.md using MATPOWER branch data:
[F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, TAP, SHIFT, BR_STATUS, ANGMIN, ANGMAX]
Quick start
- Use
scripts/branch_flows.pyto compute per-unit branch flows. - Treat the results as power leaving the “from” bus and power leaving the “to” bus (i.e., compute both directions explicitly).
Example:
import json
import numpy as np
from scripts.branch_flows import compute_branch_flows_pu, build_bus_id_to_idx
data = json.load(open("/root/network.json"))
baseMVA = float(data["baseMVA"])
buses = np.array(data["bus"], dtype=float)
branches = np.array(data["branch"], dtype=float)
bus_id_to_idx = build_bus_id_to_idx(buses)
Vm = buses[:, 7] # initial guess VM
Va = np.deg2rad(buses[:, 8]) # initial guess VA
br = branches[0]
P_ij, Q_ij, P_ji, Q_ji = compute_branch_flows_pu(Vm, Va, br, bus_id_to_idx)
S_ij_MVA = (P_ij**2 + Q_ij**2) ** 0.5 * baseMVA
S_ji_MVA = (P_ji**2 + Q_ji**2) ** 0.5 * baseMVA
print(S_ij_MVA, S_ji_MVA)
Model details (match the task formulation)
Per-unit conventions
- Work in per-unit internally.
- Convert with
baseMVA:- (P_{pu} = P_{MW} / baseMVA)
- (Q_{pu} = Q_{MVAr} / baseMVA)
- (|S|{MVA} = |S|{pu} \cdot baseMVA)
Transformer handling (MATPOWER TAP + SHIFT)
- Use (T_{ij} = tap \cdot e^{j \cdot shift}).
- Implementation shortcut (real tap + phase shift):
- If
abs(TAP) < 1e-12, treattap = 1.0(no transformer). - Convert
SHIFTfrom degrees to radians. - Use the angle shift by modifying the angle difference:
- (\delta_{ij} = \theta_i - \theta_j - shift)
- (\delta_{ji} = \theta_j - \theta_i + shift)
- If
Series admittance
Given BR_R = r, BR_X = x:
- If
r == 0 and x == 0, setg = 0,b = 0(avoid divide-by-zero). - Else:
- (y = 1/(r + jx) = g + jb)
- (g = r/(r^2 + x^2))
- (b = -x/(r^2 + x^2))
Line charging susceptance
BR_Bis the total line charging susceptance (b_c) (per unit).- Each end gets (b_c/2) in the standard pi model.
Power flow equations (use these exactly)
Let:
- (V_i = |V_i| e^{j\theta_i}), (V_j = |V_j| e^{j\theta_j})
tapis real,shiftis radiansinv_t = 1/tap,inv_t2 = inv_t^2
Then the real/reactive power flow from i→j is:
- (P_{ij} = g |V_i|^2 inv_t2 - |V_i||V_j| inv_t (g\cos\delta_{ij} + b\sin\delta_{ij}))
- (Q_{ij} = -(b + b_c/2)|V_i|^2 inv_t2 - |V_i||V_j| inv_t (g\sin\delta_{ij} - b\cos\delta_{ij}))
And from j→i is:
- (P_{ji} = g |V_j|^2 - |V_i||V_j| inv_t (g\cos\delta_{ji} + b\sin\delta_{ji}))
- (Q_{ji} = -(b + b_c/2)|V_j|^2 - |V_i||V_j| inv_t (g\sin\delta_{ji} - b\cos\delta_{ji}))
Compute apparent power:
- (|S_{ij}| = \sqrt{P_{ij}^2 + Q_{ij}^2})
- (|S_{ji}| = \sqrt{P_{ji}^2 + Q_{ji}^2})
Common uses
Enforce MVA limits (rateA)
RATE_Ais an MVA limit (may be 0 meaning “no limit”).- Enforce in both directions:
- (|S_{ij}| \le RATE_A)
- (|S_{ji}| \le RATE_A)
Compute branch loading %
For reporting “most loaded branches”:
loading_pct = 100 * max(|S_ij|, |S_ji|) / RATE_AifRATE_A > 0, else 0.
Aggregate bus injections for nodal balance
To build the branch flow sum for each bus (i):
- Add (P_{ij}, Q_{ij}) to bus i
- Add (P_{ji}, Q_{ji}) to bus j
This yields arrays P_out[i], Q_out[i] such that the nodal balance can be written as:
- (P^g - P^d - G^s|V|^2 = P_{out})
- (Q^g - Q^d + B^s|V|^2 = Q_{out})
Sanity checks (fast debug)
- With
SHIFT=0andTAP=1, if (V_i = V_j) and (\theta_i=\theta_j), then (P_{ij}\approx 0) and (P_{ji}\approx 0) (lossless only if r=0). - For a pure transformer (
r=x=0) you should not get meaningful flows; treat asg=b=0(no series element).
Related Skills
claude-mem
95.2kPersistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
Understand-Anything
85.0kGraphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.
headroom
74.3kCompress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
CowAgent
47.2kOpen-source personal AI assistant & Agent Harness. Plans tasks, runs tools and skills, self-evolves with memory and knowledge. Multi-agent, multi-model, multi-channel. Lightweight, extensible, one-line install.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
