Ac opf casadi

From XuShuwenn/RedAct · View interactive version

Ac opf casadi is an AI agent skill from the GitHub repository XuShuwenn/RedAct. Formulate and solve AC Optimal Power Flow from MATPOWER-like data using CasADi/IPOPT and produce a verifiable feasibility report.

How to use this skill

Skill file

AC Optimal Power Flow with CasADi/IPOPT

Reusable workflow to build, solve, and verify an AC Optimal Power Flow (ACOPF) using CasADi + IPOPT from MATPOWER-style network data. Produces a structured report with dispatch, voltages, branch loadings, and feasibility checks.

When to Use

Core Workflow

  1. Inspect data
  1. Normalize units (per-unit) and identify active elements
  1. Decision variables (CasADi)
  1. Objective (generation cost)
  1. AC network equations (pi-model with taps/shift)
  1. Constraints
  1. Initialization (robustness)
  1. Solve (IPOPT)
  1. Post-processing and report

Verification

Common Pitfalls (and Fixes)

Optional Script Usage

Example (Python):

from scripts.branch_flows import compute_branch_flows_pu, build_bus_id_to_idx
from scripts.opf_feasibility import feasibility_metrics

bus_map = build_bus_id_to_idx(buses)
P_ij, Q_ij, P_ji, Q_ji = compute_branch_flows_pu(Vm_sol, Va_sol, branch_row, bus_map)
metrics = feasibility_metrics(buses, branches, Vm_sol, Va_sol, Pg_sol, Qg_sol, baseMVA)
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.