Home > matpower6.0 > bustypes.m

bustypes

PURPOSE ^

BUSTYPES Builds index lists for each type of bus (REF, PV, PQ).

SYNOPSIS ^

function [ref, pv, pq] = bustypes(bus, gen)

DESCRIPTION ^

BUSTYPES   Builds index lists for each type of bus (REF, PV, PQ).
   [REF, PV, PQ] = BUSTYPES(BUS, GEN)
   Generators with "out-of-service" status are treated as PQ buses with
   zero generation (regardless of Pg/Qg values in gen). Expects BUS and
   GEN have been converted to use internal consecutive bus numbering.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ref, pv, pq] = bustypes(bus, gen)
0002 %BUSTYPES   Builds index lists for each type of bus (REF, PV, PQ).
0003 %   [REF, PV, PQ] = BUSTYPES(BUS, GEN)
0004 %   Generators with "out-of-service" status are treated as PQ buses with
0005 %   zero generation (regardless of Pg/Qg values in gen). Expects BUS and
0006 %   GEN have been converted to use internal consecutive bus numbering.
0007 
0008 %   MATPOWER
0009 %   Copyright (c) 1996-2016, Power Systems Engineering Research Center (PSERC)
0010 %   by Ray Zimmerman, PSERC Cornell
0011 %
0012 %   This file is part of MATPOWER.
0013 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0014 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0015 
0016 %% constants
0017 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0018     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0019 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0020     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0021     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0022 
0023 %% get generator status
0024 % bus_gen_status = zeros(size(bus, 1), 1);
0025 % bus_gen_status(gen(:, GEN_BUS)) = gen(:, GEN_STATUS) > 0;
0026 nb = size(bus, 1);
0027 ng = size(gen, 1);
0028 Cg = sparse(gen(:, GEN_BUS), (1:ng)', gen(:, GEN_STATUS) > 0, nb, ng);  %% gen connection matrix
0029                                         %% element i, j is 1 if, generator j at bus i is ON
0030 bus_gen_status = Cg * ones(ng, 1);      %% number of generators at each bus that are ON
0031 
0032 
0033 %% form index lists for slack, PV, and PQ buses
0034 ref = find(bus(:, BUS_TYPE) == REF & bus_gen_status);   %% reference bus index
0035 pv  = find(bus(:, BUS_TYPE) == PV  & bus_gen_status);   %% PV bus indices
0036 pq  = find(bus(:, BUS_TYPE) == PQ | ~bus_gen_status);   %% PQ bus indices
0037 
0038 %% pick a new reference bus if for some reason there is none (may have been shut down)
0039 if isempty(ref)
0040 %     if isempty(pv)
0041 %         %% no PV bus left to convert to reference bus
0042 %     else
0043         ref = pv(1);    %% use the first PV bus
0044         pv(1) = [];     %% delete it from PV list
0045 %     end
0046 end

Generated on Fri 16-Dec-2016 12:45:37 by m2html © 2005