runpf

runpf(casedata, mpopt, fname, solvedcase)

runpf() - Runs a power flow.

[RESULTS, SUCCESS] = RUNPF(CASEDATA, MPOPT, FNAME, SOLVEDCASE)

Runs a power flow (full AC Newton's method by default), optionally
returning a RESULTS struct and SUCCESS flag.

Inputs (all are optional):
    CASEDATA : either a MATPOWER case struct or a string containing
        the name of the file with the case data (default is 'case9')
        (see CASEFORMAT and LOADCASE)
    MPOPT : MATPOWER options struct to override default options
        can be used to specify the solution algorithm, output options
        termination tolerances, and more (see MPOPTION).
    FNAME : name of a file to which the pretty-printed output will
        be appended
    SOLVEDCASE : name of file to which the solved case will be saved
        in MATPOWER case format (M-file will be assumed unless the
        specified name ends with '.mat')

Outputs (all are optional):
    RESULTS : results struct, with the following fields:
        (all fields from the input MATPOWER case, i.e. bus, branch,
            gen, etc., but with solved voltages, power flows, etc.)
        order - info used in external <-> internal data conversion
        et - elapsed time in seconds
        success - success flag, 1 = succeeded, 0 = failed
    SUCCESS : the success flag can additionally be returned as
        a second output argument

Calling syntax options:
    results = runpf;
    results = runpf(casedata);
    results = runpf(casedata, mpopt);
    results = runpf(casedata, mpopt, fname);
    results = runpf(casedata, mpopt, fname, solvedcase);
    [results, success] = runpf(...);

    Alternatively, for compatibility with previous versions of MATPOWER,
    some of the results can be returned as individual output arguments:

    [baseMVA, bus, gen, branch, success, et] = runpf(...);

If the pf.enforce_q_lims option is set to true (default is false) then, if
any generator reactive power limit is violated after running the AC power
flow, the corresponding bus is converted to a PQ bus, with Qg at the
limit, and the case is re-run. The voltage magnitude at the bus will
deviate from the specified value in order to satisfy the reactive power
limit. If the reference bus is converted to PQ, the first remaining PV
bus will be used as the slack bus for the next iteration. This may
result in the real power output at this generator being slightly off
from the specified values.

Examples:
    results = runpf('case30');
    results = runpf('case30', mpoption('pf.enforce_q_lims', 1));

See also rundcpf().