Home > matpower5.1 > 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 %   Copyright (c) 1996-2015 by Power System Engineering Research Center (PSERC)
0011 %   by Ray Zimmerman, PSERC Cornell
0012 %
0013 %   $Id: makeSbus.m 2644 2015-03-11 19:34:22Z ray $
0014 %
0015 %   This file is part of MATPOWER.
0016 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0017 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0018 
0019 %% define named indices into bus, gen matrices
0020 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0021     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0022 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0023     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0024     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0025 
0026 %% generator info
0027 on = find(gen(:, GEN_STATUS) > 0);      %% which generators are on?
0028 gbus = gen(on, GEN_BUS);                %% what buses are they at?
0029 
0030 %% form net complex bus power injection vector
0031 nb = size(bus, 1);
0032 ngon = size(on, 1);
0033 Cg = sparse(gbus, (1:ngon)', ones(ngon, 1), nb, ngon);  %% connection matrix
0034                                                         %% element i, j is 1 if
0035                                                         %% gen on(j) at bus i is ON
0036 Sbus =  ( Cg * (gen(on, PG) + 1j * gen(on, QG)) ... %% power injected by generators
0037            - (bus(:, PD) + 1j * bus(:, QD)) ) / ... %% plus power injected by loads
0038         baseMVA;                                    %% converted to p.u.

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