4.4 runpf

In Matpower, a power flow is executed by calling runpf with a case struct or case file name as the first argument (casedata). In addition to printing output to the screen, which it does by default, runpf optionally returns the solution in a results struct.

>> results = runpf(casedata);

The results struct is a superset of the input Matpower case struct mpc, with some additional fields as well as additional columns in some of the existing data fields. The solution values are stored as shown in Table 4-1.

Table 4-1:Power Flow Results
name description
results.success success flag, 1 = succeeded, 0 = failed
results.et computation time required for solution
results.iterations number of iterations required for solution
results.order see ext2int help for details on this field
results.bus(:, VM) bus voltage magnitudes
results.bus(:, VA) bus voltage angles
results.gen(:, PG) generator real power injections
results.gen(:, QG) generator reactive power injections
results.branch(:, PF) real power injected into “from” end of branch
results.branch(:, PT) real power injected into “to” end of branch
results.branch(:, QF) reactive power injected into “from” end of branch
results.branch(:, QT) reactive power injected into “to” end of branch

AC power flow only.

Table 4-2:Power Flow Options
name default

description

model 'AC'

AC vs. DC modeling for power flow and OPF formulation

'AC' use AC formulation and corresponding alg options
'DC' use DC formulation and corresponding alg options
pf.alg 'NR'

AC power flow algorithm:

'NR'

Newtons’s method (formulation depends on values of pf.current_balance and pf.v_cartesian options)

'NR-SC'

Newtons’s method (power mismatch, cartesian)

'NR-IP'

Newtons’s method (current mismatch, polar)

'NR-IC'

Newtons’s method (current mismatch, cartesian)

'FDXB'

Fast-Decoupled (XB version)

'FDBX'

Fast-Decouple (BX version)

'GS'

Gauss-Seidel

'PQSUM'

Power Summation (radial networks only)

'ISUM'

Current Summation (radial networks only)

'YSUM'

Admittance Summation (radial networks only)

pf.current_balance 0

use current, as opposed to power, balance for AC PF, 0 or 1

pf.v_cartesian 0

use cartesian, as opposed to polar, representation for voltages for AC PF, 0 or 1

pf.tol   −8
10

termination tolerance on per unit P and Q dispatch

pf.nr.max_it 10

maximum number of iterations for Newton’s method

pf.nr.lin_solver ''

linear solver option for mplinsolve for computing Newton update step

(see mplinsolve for complete list of all options)

''

default to '' for small systems, 'LU3' for larger ones

''

built-in backslash operator

'LU'

explicit default LU decomposition and back substitution

'LU3'

3 output arg form of lu, Gilbert-Peierls algorithm with approximate minimum degree (AMD) reordering

'LU4'

4 output arg form of lu, UMFPACK solver (same as 'LU')

'LU5'

5 output arg form of lu, UMFPACK solver w/row scaling

pf.fd.max_it 30

maximum number of iterations for fast-decoupled method

pf.gs.max_it 1000

maximum number of iterations for Gauss-Seidel method

pf.radial.max_it 20

maximum number of iterations for radial power flow methods

pf.radial.vcorr 0

perform voltage correction procedure in distribution power flow

0 – do not perform voltage correction
1 – perform voltage correction
pf.enforce_q_lims 0

enforce gen reactive power limits at expense of |Vm|

0 – do not enforce limits
1 – enforce limits, simultaneous bus type conversion
2 – enforce limits, one-at-a-time bus type conversion

Automatically sets/overrides pf.current_balance and pf.v_cartesian options with corresponding values. Only relevant for Newton power flow solver.

Additional optional input arguments can be used to set options (mpopt) and provide file names for saving the pretty printed output (fname) or the solved case data (solvedcase).

>> results = runpf(casedata, mpopt, fname, solvedcase);

The options that control the power flow simulation are listed in Table 4-2 and those controlling the output printed to the screen in Table 4-3.

By default, runpf solves an AC power flow problem using a standard Newton’s method solver. To run a DC power flow, the model option must be set to 'DC'. For convenience, Matpower provides a function rundcpf which is simply a wrapper that sets the model option to 'DC' before calling runpf.

Table 4-3:Power Flow Output Options
name default

description

verbose 1

amount of progress info to be printed

0 – print no progress info
1 – print a little progress info
2 – print a lot of progress info
3 – print all progress info
out.all -1

controls pretty-printing of results

-1 – individual flags control what is printed
0 – do not print anything
1 – print everything
out.sys_sum 1

print system summary (0 or 1)

out.area_sum 0

print area summaries (0 or 1)

out.bus 1

print bus detail, includes per bus gen info (0 or 1)

out.branch 1

print branch detail (0 or 1)

out.gen 0

print generator detail (0 or 1)

out.force 0

print results even if success flag = 0 (0 or 1)

out.suppress_detail -1

suppress all output but system summary

-1 – suppress details for large systems (>   500 buses)
0 – do not suppress any output specified by other flags
1 – suppress all output except system summary section

Overrides individual flags, but (in the case of out.suppress_detail) not out.all = 1.

Internally, the runpf function does a number of conversions to the problem data before calling the appropriate solver routine for the selected power flow algorithm. This external-to-internal format conversion is performed by the ext2int function, described in more detail in Section 7.3.1, and includes the elimination of out-of-service equipment and the consecutive renumbering of buses. All computations are done using this internal indexing. When the simulation has completed, the data is converted back to external format by int2ext before the results are printed and returned.