Home > matpower5.1 > 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-2015 by Power System Engineering Research Center (PSERC)
0010 %   by Ray Zimmerman, PSERC Cornell
0011 %
0012 %   $Id: bustypes.m 2644 2015-03-11 19:34:22Z ray $
0013 %
0014 %   This file is part of MATPOWER.
0015 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0016 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0017 
0018 %% constants
0019 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0020     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0021 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0022     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0023     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0024 
0025 %% get generator status
0026 % bus_gen_status = zeros(size(bus, 1), 1);
0027 % bus_gen_status(gen(:, GEN_BUS)) = gen(:, GEN_STATUS) > 0;
0028 nb = size(bus, 1);
0029 ng = size(gen, 1);
0030 Cg = sparse(gen(:, GEN_BUS), (1:ng)', gen(:, GEN_STATUS) > 0, nb, ng);  %% gen connection matrix
0031                                         %% element i, j is 1 if, generator j at bus i is ON
0032 bus_gen_status = Cg * ones(ng, 1);      %% number of generators at each bus that are ON
0033 
0034 
0035 %% form index lists for slack, PV, and PQ buses
0036 ref = find(bus(:, BUS_TYPE) == REF & bus_gen_status);   %% reference bus index
0037 pv  = find(bus(:, BUS_TYPE) == PV  & bus_gen_status);   %% PV bus indices
0038 pq  = find(bus(:, BUS_TYPE) == PQ | ~bus_gen_status);   %% PQ bus indices
0039 
0040 %% pick a new reference bus if for some reason there is none (may have been shut down)
0041 if isempty(ref)
0042     ref = pv(1);                %% use the first PV bus
0043     pv = pv(2:length(pv));      %% take it off PV list
0044 end

Generated on Fri 20-Mar-2015 18:23:34 by m2html © 2005