4.1 AC Power Flow

In Matpower, by convention, a single generator bus is typically chosen as a reference bus to serve the roles of both a voltage angle reference and a real power slack. The voltage angle at the reference bus has a known value, but the real power generation at the slack bus is taken as unknown to avoid overspecifying the problem. The remaining generator buses are typically classified as PV buses, with the values of voltage magnitude and generator real power injection given. These are specified in the VG (6) and PG (3) columns of the gen matrix, respectively. Since the loads Pd  and Qd  are also given, all non-generator buses are classified as PQ buses, with real and reactive injections fully specified, taken from the PD (3) and QD (4) columns of the bus matrix. Let ℐref   , ℐPV   and ℐPQ   denote the sets of bus indices of the reference bus, PV buses and PQ buses, respectively. The bus type classification is specified in the Matpower case file in the BUS_TYPE column (2) of the bus matrix. Any isolated buses must be identified as such in this column as well.

In the traditional formulation of the AC power flow problem, the power balance equation in (3.17) is split into its real and reactive components, expressed as functions of the voltage angles Θ  and magnitudes Vm  and generator injections Pg  and Qg  , where the load injections are assumed constant and given:


For the AC power flow problem, the function g(x )  from (4.1) is formed by taking the left-hand side of the real power balance equations (4.2) for all non-slack buses and the reactive power balance equations (4.3) for all PQ buses and plugging in the reference angle, the loads and the known generator injections and voltage magnitudes:

       [   {i}            ]
g(x) =    gP{j}(Θ, Vm, Pg)      ∀i ∈ ℐPV ∪ ℐPQ
         g Q (Θ, Vm, Qg)      ∀j ∈ ℐPQ.

The vector x  consists of the remaining unknown voltage quantities, namely the voltage angles at all non-reference buses and the voltage magnitudes at PQ buses:

    [      ]
      𝜃{i}      ∀i ∕∈ ℐref
x =   v{mj}      ∀j ∈ ℐPQ.

This yields a system of nonlinear equations with npv + 2npq  equations and unknowns, where n
 pv  and n
  pq  are the number of PV and PQ buses, respectively. After solving for x  , the remaining real power balance equation can be used to compute the generator real power injection at the slack bus. Similarly, the remaining npv + 1  reactive power balance equations yield the generator reactive power injections.

Matpower includes four different algorithms for solving the general AC power flow problem.26 The default solver is based on a standard Newton’s method [10] using a polar form and a full Jacobian updated at each iteration. Each Newton step involves computing the mismatch g (x )  , forming the Jacobian based on the sensitivities of these mismatches to changes in x  and solving for an updated value of x  by factorizing this Jacobian. This method is described in detail in many textbooks. As of version 7, Matpower also includes variants of the Newton method using nodal current balance equations and/or cartesian representations for voltage as described in [11].

Also included are solvers based on variations of the fast-decoupled method [12], specifically, the XB and BX methods described in [13]. These solvers greatly reduce the amount of computation per iteration, by updating the voltage magnitudes and angles separately based on constant approximate Jacobians which are factored only once at the beginning of the solution process. These per-iteration savings, however, come at the cost of more iterations.

The fourth algorithm is the standard Gauss-Seidel method from Glimm and Stagg [14]. It has numerous disadvantages relative to the Newton method and is included primarily for academic interest.

By default, the AC power flow solvers simply solve the problem described above, ignoring any generator limits, branch flow limits, voltage magnitude limits, etc. However, there is an option (pf.enforce_q_lims) that allows for the generator reactive power limits to be respected at the expense of the voltage setpoint. This is done in a rather brute force fashion by adding an outer loop around the AC power flow solution. If any generator has a violated reactive power limit, its reactive injection is fixed at the limit, the corresponding bus is converted to a PQ bus and the power flow is solved again. This procedure is repeated until there are no more violations. Note that this option is based solely on the QMAX and QMIN parameters for the generator, from columns 4 and 5 of the gen matrix, and does not take into account the trapezoidal generator capability curves described in Section 6.4.3 and specifed in columns PC1QC2MAX (11–16). Note also that this option affects generators even if the bus they are attached to is already of type PQ.

In all, there are 4 different formulations implemented for the Newton power flow, described briefly below, with the details found in reference [11].

4.1.1 Cartesian vs. Polar Coordinates for Voltage

Another variation of the standard AC power flow problem represents the bus voltages in cartesian, rather than polar, coordinates. That is, instead of Θ  and Vm  , the vector x  of unknowns includes the real and imaginary parts of the complex voltage, denoted respectively by U  and W  , where V =  U + jW  . The active and reactive power balance equations from (4.2)–(4.3) are then expressed as functions of U  and W  .


The power flow problem of (4.4) becomes

       [                ]
g(x) =   gP{j}(U,W, Pg)      ∀i ∈ ℐPV ∪ ℐPQ
         gQ  (U, W, Qg )     ∀j ∈  ℐPQ.


    [      ]
      u {i}      ∀i ∈ ℐPQ
x =   w {j}      ∀j ∕∈ ℐref.

For PV buses, since the voltage magnitude is constant, Δu  can be expressed as a function of Δw  , allowing u  to be eliminated for PV buses by modifying the Jacobian terms corresponding to gP  and w  . This results once again in a system of nonlinear equations with npv + 2npq  equations and unknowns.

In Matpower setting the pf.v_cartesian option to 1 (0 by default) selects the cartesian representation for voltages when running a Newton-Raphson AC power flow, that is, when the pf.alg option is set to 'NR'.27

4.1.2 Current vs. Power for Nodal Balance Equations

Another variation of the standard AC power flow problem uses current balance equations in place of the power balance equations in (4.4) and (4.8). If we let M  and N  represent the real and imaginary parts, respectively, of the current, we can express the current balance functions for the polar form as


and for the cartesian form as


where Sd = Pd + jQd  , Sg = Pg + jQg  and [V ∗]−1   is a diagonal matrix whose i  -th diagonal entry is     ∗
1∕v i  , that is 1--j𝜃i
vime   or 1∕ (ui − jwi)  .

In order to handle PV buses, g(x)  is expanded to include the full set of mismatch equations for all PV and PQ buses, and the reactive power injections at PV buses are added to x  as independent variables, resulting in a system of nonlinear equations with 2npv + 2npq  equations and unknowns.

In Matpower setting the pf.current_balance option to 1 (0 by default) selects the current balance version when running a Newton-Raphson AC power flow, that is, when the pf.alg option is set to 'NR'. This option can be used in conjunction with either the polar or cartesian representation of bus voltages.28