Home > matpower5.0 > makeSbus.m

makeSbus

PURPOSE ^

MAKESBUS Builds the vector of complex bus power injections.

SYNOPSIS ^

function Sbus = makeSbus(baseMVA, bus, gen)

DESCRIPTION ^

MAKESBUS   Builds the vector of complex bus power injections.
   SBUS = MAKESBUS(BASEMVA, BUS, GEN) returns the vector of complex bus
   power injections, that is, generation minus load. Power is expressed
   in per unit.

   See also MAKEYBUS.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function Sbus = makeSbus(baseMVA, bus, gen)
0002 %MAKESBUS   Builds the vector of complex bus power injections.
0003 %   SBUS = MAKESBUS(BASEMVA, BUS, GEN) returns the vector of complex bus
0004 %   power injections, that is, generation minus load. Power is expressed
0005 %   in per unit.
0006 %
0007 %   See also MAKEYBUS.
0008 
0009 %   MATPOWER
0010 %   $Id: makeSbus.m 1635 2010-04-26 19:45:26Z ray $
0011 %   by Ray Zimmerman, PSERC Cornell
0012 %   Copyright (c) 1996-2010 by Power System Engineering Research Center (PSERC)
0013 %
0014 %   This file is part of MATPOWER.
0015 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0016 %
0017 %   MATPOWER is free software: you can redistribute it and/or modify
0018 %   it under the terms of the GNU General Public License as published
0019 %   by the Free Software Foundation, either version 3 of the License,
0020 %   or (at your option) any later version.
0021 %
0022 %   MATPOWER is distributed in the hope that it will be useful,
0023 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0024 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0025 %   GNU General Public License for more details.
0026 %
0027 %   You should have received a copy of the GNU General Public License
0028 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0029 %
0030 %   Additional permission under GNU GPL version 3 section 7
0031 %
0032 %   If you modify MATPOWER, or any covered work, to interface with
0033 %   other modules (such as MATLAB code and MEX-files) available in a
0034 %   MATLAB(R) or comparable environment containing parts covered
0035 %   under other licensing terms, the licensors of MATPOWER grant
0036 %   you additional permission to convey the resulting work.
0037 
0038 %% define named indices into bus, gen matrices
0039 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0040     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0041 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0042     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0043     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0044 
0045 %% generator info
0046 on = find(gen(:, GEN_STATUS) > 0);      %% which generators are on?
0047 gbus = gen(on, GEN_BUS);                %% what buses are they at?
0048 
0049 %% form net complex bus power injection vector
0050 nb = size(bus, 1);
0051 ngon = size(on, 1);
0052 Cg = sparse(gbus, (1:ngon)', ones(ngon, 1), nb, ngon);  %% connection matrix
0053                                                         %% element i, j is 1 if
0054                                                         %% gen on(j) at bus i is ON
0055 Sbus =  ( Cg * (gen(on, PG) + 1j * gen(on, QG)) ... %% power injected by generators
0056            - (bus(:, PD) + 1j * bus(:, QD)) ) / ... %% plus power injected by loads
0057         baseMVA;                                    %% converted to p.u.

Generated on Mon 26-Jan-2015 15:21:31 by m2html © 2005