NLP

/

Solver: IPOPT

AC

Full nonlinear AC in polar coordinates

Motivation

The AC formulation is the reference model for Optimal Power Flow. It describes the nonlinear sinusoidal steady-state operation of an electrical power network, neglecting transient phenomena. The model explicitly couples voltage magnitudes, phase angles, active and reactive power injections, and branch power flow equations. By enforcing the full AC power-balance equations without linearization or convex relaxation, it preserves the physical structure of the original OPF problem. This exactness comes at a cost: the resulting problem is non-convex. In Lirion, this formulation serves as the baseline against which alternative OPF models are derived, approximated, or relaxed.

Derivation

From Maxwell to circuit theory

At 50–60 Hz, the electromagnetic wavelength is on the order of thousands of kilometers (c / 60 Hz ≈ 5000 km), much larger than most individual components and many network sections in a power system. Under sinusoidal steady state and quasi-stationary assumptions, Maxwell’s equations can be approximated by lumped-element circuit theory: voltages and currents are represented as phasors, impedances as complex numbers, and Kirchhoff’s laws provide the algebraic structure of the network. For transmission lines that are not electrically short, typically above 250 km, this reduction must be refined through the telegrapher’s equations, partial differential equations that describe voltage and current propagation along the line. Their hyperbolic solutions yield the corrected equivalent-π parameters used in the network model. The compact result, in either case, is:

$$Y = G + jB, \quad Z = R + jX, \quad Y = 1/Z.$$

Reactive elements (inductors, capacitors) introduce 90° phase shifts and so map to the imaginary axis; resistive elements stay on the real axis. This complex-number formalism is the foundation on which every power-system equation in this page is built.

Phasors and complex power

In sinusoidal steady state at angular frequency ω, every voltage and current is represented by a phasor — a complex number that encodes both magnitude and phase. For bus i we write the voltage phasor as

$$V_i = |V_i|\, e^{j\theta_i}, \qquad v_i(t) = \operatorname{Re}\!\left(V_i\, e^{j\omega t}\right).$$

The apparent power injected at bus i combines active power P (real part, transferred energy) and reactive power Q (imaginary part, oscillating energy in fields):

$$S_i = P_i + j Q_i = V_i I_i^{*},$$

where the conjugate on the current reflects the convention that lagging currents (inductive loads) consume positive reactive power.

Full derivation: Phasors & complex power

Bus admittance matrix

Assembling the network from individual branch admittances yields the Y-bus matrix, a complex symmetric matrix relating bus current injections to bus voltages:

$$\mathbf{I} = Y \mathbf{V}, \qquad Y_{ik} = G_{ik} + j B_{ik}.$$

Substituting into the complex-power equation gives the master equation from which every centralized OPF model in Lirion is derived:

$$S_i = V_i \sum_{k} Y_{ik}^{*}\, V_k^{*}.$$

From here on, each formulation is a different way of representing Vi and Si — polar coordinates yield AC, rectangular coordinates yield ACR, and various approximations or relaxations yield the remaining seven models.

Full derivation: Bus admittance matrix

AC power-flow equations (polar form)

Writing the voltage in polar form Vi = |Vi| ejθi and the admittance as Yik = Gik + jBik, the real and imaginary parts of the complex power injection yield the AC power-flow equations:

$$P_i = |V_i| \sum_{k} |V_k| \left(G_{ik}\cos\theta_{ik} + B_{ik}\sin\theta_{ik}\right)$$
$$Q_i = |V_i| \sum_{k} |V_k| \left(G_{ik}\sin\theta_{ik} – B_{ik}\cos\theta_{ik}\right)$$

where θik := θi − θk.

These equations are non-convex due to the trigonometric and bilinear terms — the source of both the AC formulation’s exactness and its computational difficulty. They are the constraints around which the optimization problem in the next section is built.

AC OPF — full problem

Combining the AC power-flow equations with generator cost functions and physical limits yields the complete AC Optimal Power Flow problem. Decision variables are active and reactive generator dispatches (Pg, Qg) and bus voltages (|V|, θ). The problem reads:

$$ \begin{aligned} \min_{P^g, Q^g, |V|, \theta} \quad & \sum_{g \in \mathcal{G}} c_g(P_g^g) \\[6pt] \text{s.t.} \quad & P_i^g – P_i^d = P_i(|V|, \theta), && \forall i \in \mathcal{N} \\ & Q_i^g – Q_i^d = Q_i(|V|, \theta), && \forall i \in \mathcal{N} \\ & \underline{V}_i \le |V_i| \le \overline{V}_i, && \forall i \in \mathcal{N} \\ & \underline{P}_g^g \le P_g^g \le \overline{P}_g^g, && \forall g \in \mathcal{G} \\ & \underline{Q}_g^g \le Q_g^g \le \overline{Q}_g^g, && \forall g \in \mathcal{G} \\ & |S_{ij}|^2 \le \overline{S}_{ij}^2, && \forall (i,j) \in \mathcal{E} \\ & \underline{\theta}_{ij} \le \theta_i – \theta_j \le \overline{\theta}_{ij}, && \forall (i,j) \in \mathcal{E} \end{aligned} $$

The first two constraint families are the AC power-balance equations derived above. The remaining constraints impose voltage magnitude limits, generator capability box constraints, branch thermal limits (apparent-power squared form for differentiability), and phase-angle difference bounds enforcing branch stability. Sets 𝒩, 𝒢, ℰ index buses, generators, and branches respectively.

Computational considerations

The AC formulation is non-convex on two counts: the trigonometric power-balance constraints and the apparent-power thermal limits. Despite this, modern interior-point solvers — Ipopt being the standard — converge reliably on well-conditioned problems within tens of iterations, starting from a flat profile (|V| = 1 p.u., θ = 0) or a DC-OPF warm start.

Difficulties typically arise on heavily loaded networks, in the presence of binding voltage limits, or when reactive power capability is tight. In such cases, common remedies include constraint relaxation, careful variable scaling, increased barrier tolerance, or homotopy from a relaxed problem (e.g., SOCWR) into the full AC formulation. Lirion exposes solver options as keyword arguments to solve(), allowing per-case tuning without modifying the model.

Lirion usage

Solving the AC OPF problem on a MATPOWER case file requires a single call to solve() with model = ac() and algorithm = centralized(). Lirion handles parsing, problem construction, Ipopt invocation, and result extraction — returning a structured output with primal variables, dual prices, generation cost, and solver diagnostics.

using Lirion

# Load a standard test case and solve the full AC OPF
out = solve("case118.m"; model = ac(), algorithm = centralized())

# Inspect the solution
println("Objective:    \$", round(out.objective, digits=2))
println("Solve time:    ", round(out.solve_time, digits=3), " s")
println("Status:        ", out.termination_status)

# Access primal variables
V_mag = out.solution["bus"]["vm"]    # voltage magnitudes
V_ang = out.solution["bus"]["va"]    # voltage angles (radians)
Pg    = out.solution["gen"]["pg"]    # active generation
Qg    = out.solution["gen"]["qg"]    # reactive generation

The out object follows the PowerModels.jl result schema, ensuring interoperability with existing analysis tooling. For batch experiments — solving the same case under multiple formulations — pair this with the benchmark() utility documented in the Quickstart.

References

  1. Carpentier, J. (1962). Contribution à l'étude du dispatching économique. Bulletin de la Société Française des Électriciens.
  2. Frank, S., Steponavice, I., & Rebennack, S. (2012). Optimal power flow: a bibliographic survey I & II. Energy Systems, 3(3–4), 221–289.
  3. Wächter, A., & Biegler, L. T. (2006). On the implementation of an interior-point filter line-search algorithm for large-scale nonlinear programming. Mathematical Programming, 106(1), 25–57.
  4. Babaeinejadsarookolaee, S., et al. (2019). The Power Grid Library for benchmarking AC optimal power flow algorithms. arXiv:1908.02788.
  5. Coffrin, C., Bent, R., Sundar, K., Ng, Y., & Lubin, M. (2018). PowerModels.jl: An open-source framework for exploring power flow formulations. PSCC 2018.