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. 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.

49 stars 5 forksGit & Code Review

Install

skills CLI (Claude Code, Cursor, Codex and more)
npx skills add UCSB-NLP-Chang/Skill-Usage --skill ac-branch-pi-model
Manual install
git clone --depth 1 https://github.com/UCSB-NLP-Chang/Skill-Usage.git /tmp/Skill-Usage
mkdir -p ~/.claude/skills
cp -r /tmp/Skill-Usage/tasks/energy-ac-optimal-power-flow/environment/skills/ac-branch-pi-model ~/.claude/skills/ac-branch-pi-model

Personal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.

From the SKILL.md

# 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.py` to 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:

```python
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}\).
Read the full skill on GitHub

Details

Skill name
ac-branch-pi-model
Path
tasks/energy-ac-optimal-power-flow/environment/skills/ac-branch-pi-model/SKILL.md
Repo updated
8 April 2026

FAQ

What does the Ac Branch Pi Model skill do?

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.

How do I install the Ac Branch Pi Model skill?

skills CLI (Claude Code, Cursor, Codex and more): npx skills add UCSB-NLP-Chang/Skill-Usage --skill ac-branch-pi-model. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.

Is Ac Branch Pi Model popular?

It lives in UCSB-NLP-Chang/Skill-Usage, which has 49 GitHub stars and 5 forks.

Related skills

Browse the most popular Claude skills, all git & code review skills, or write your own with the skills generator.