← 返回 Skills 市场
wu-uk

ac-branch-pi-model

作者 wu-uk · GitHub ↗ · v0.1.0 · MIT-0
cross-platform ✓ 安全检测通过
80
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install energy-ac-optimal-power-flow-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....
使用说明 (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:

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) \x3C 1e-12, treat tap = 1.0 (no transformer).
    • Convert SHIFT from degrees to radians.
    • Use the angle shift by modifying the angle difference:
      • (\delta_{ij} = heta_i - heta_j - shift)
      • (\delta_{ji} = heta_j - heta_i + shift)

Series admittance

Given BR_R = r, BR_X = x:

  • If r == 0 and x == 0, set g = 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_B is 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 heta_i}), (V_j = |V_j| e^{j heta_j})
  • tap is real, shift is radians
  • inv_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_A is 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_A if RATE_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=0 and TAP=1, if (V_i = V_j) and ( heta_i= heta_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 as g=b=0 (no series element).
安全使用建议
This skill appears to do exactly what it claims (compute AC branch flows). Before running: ensure you execute it in a Python environment with numpy installed, review and replace the example's /root/network.json path with a safe/test dataset (to avoid the agent reading host files), and run it in a sandbox if you don't trust the source. The only real coherence issues are: (1) numpy is required but not declared, and (2) the example references an absolute host path — neither is evidence of malice, but both are worth correcting.
功能分析
Type: OpenClaw Skill Name: energy-ac-optimal-power-flow-ac-branch-pi-model Version: 0.1.0 The skill bundle provides a standard mathematical implementation of AC branch pi-model power flow equations used in electrical engineering. The Python script `scripts/branch_flows.py` and the instructions in `SKILL.md` are strictly focused on power system calculations and do not contain any malicious logic, data exfiltration, or prompt injection attempts.
能力评估
Purpose & Capability
The SKILL.md, name, description, and the included Python implementation all align: the code computes per-unit branch flows for MATPOWER-style branch rows and matches the documented equations. There are no unrelated requirements (no cloud creds, no unusual binaries).
Instruction Scope
The runtime instructions and example focus only on local numeric computation and using the provided script. The example shows opening /root/network.json (an absolute host path) which could cause an agent to read a sensitive host file if followed verbatim — the SKILL.md doesn't otherwise instruct broad file access or external network calls. The code expects numpy arrays shaped like MATPOWER data.
Install Mechanism
There is no install spec (instruction-only), which minimizes risk. However, the included Python file imports numpy (and uses Python) but the skill metadata does not declare this dependency or an install step to ensure numpy is available — a minor coherence gap.
Credentials
No environment variables, credentials, or config paths are requested. The skill does not attempt to access external services or secrets.
Persistence & Privilege
always is false and the skill does not request or modify persistent agent/system settings. It does not write installers or change other skills' configs.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install energy-ac-optimal-power-flow-ac-branch-pi-model
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /energy-ac-optimal-power-flow-ac-branch-pi-model 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.1.0
Bulk publish from all-task-skills-dedup
元数据
Slug energy-ac-optimal-power-flow-ac-branch-pi-model
版本 0.1.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

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.... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 80 次。

如何安装 ac-branch-pi-model?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install energy-ac-optimal-power-flow-ac-branch-pi-model」即可一键安装,无需额外配置。

ac-branch-pi-model 是免费的吗?

是的,ac-branch-pi-model 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

ac-branch-pi-model 支持哪些平台?

ac-branch-pi-model 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 ac-branch-pi-model?

由 wu-uk(@wu-uk)开发并维护,当前版本 v0.1.0。

💬 留言讨论