Home > matpower5.1 > makeBdc.m

makeBdc

PURPOSE ^

MAKEBDC Builds the B matrices and phase shift injections for DC power flow.

SYNOPSIS ^

function [Bbus, Bf, Pbusinj, Pfinj] = makeBdc(baseMVA, bus, branch)

DESCRIPTION ^

MAKEBDC   Builds the B matrices and phase shift injections for DC power flow.
   [BBUS, BF, PBUSINJ, PFINJ] = MAKEBDC(BASEMVA, BUS, BRANCH) returns the
   B matrices and phase shift injection vectors needed for a DC power flow.
   The bus real power injections are related to bus voltage angles by
       P = BBUS * Va + PBUSINJ
   The real power flows at the from end the lines are related to the bus
   voltage angles by
       Pf = BF * Va + PFINJ
   Does appropriate conversions to p.u.

   Example:
       [Bbus, Bf, Pbusinj, Pfinj] = makeBdc(baseMVA, bus, branch);

   See also DCPF.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [Bbus, Bf, Pbusinj, Pfinj] = makeBdc(baseMVA, bus, branch)
0002 %MAKEBDC   Builds the B matrices and phase shift injections for DC power flow.
0003 %   [BBUS, BF, PBUSINJ, PFINJ] = MAKEBDC(BASEMVA, BUS, BRANCH) returns the
0004 %   B matrices and phase shift injection vectors needed for a DC power flow.
0005 %   The bus real power injections are related to bus voltage angles by
0006 %       P = BBUS * Va + PBUSINJ
0007 %   The real power flows at the from end the lines are related to the bus
0008 %   voltage angles by
0009 %       Pf = BF * Va + PFINJ
0010 %   Does appropriate conversions to p.u.
0011 %
0012 %   Example:
0013 %       [Bbus, Bf, Pbusinj, Pfinj] = makeBdc(baseMVA, bus, branch);
0014 %
0015 %   See also DCPF.
0016 
0017 %   MATPOWER
0018 %   Copyright (c) 1996-2015 by Power System Engineering Research Center (PSERC)
0019 %   by Carlos E. Murillo-Sanchez, PSERC Cornell & Universidad Autonoma de Manizales
0020 %   and Ray Zimmerman, PSERC Cornell
0021 %
0022 %   $Id: makeBdc.m 2644 2015-03-11 19:34:22Z ray $
0023 %
0024 %   This file is part of MATPOWER.
0025 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0026 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0027 
0028 %% constants
0029 nb = size(bus, 1);          %% number of buses
0030 nl = size(branch, 1);       %% number of lines
0031 
0032 %% define named indices into bus, branch matrices
0033 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0034     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0035 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0036     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0037     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0038 
0039 %% check that bus numbers are equal to indices to bus (one set of bus numbers)
0040 if any(bus(:, BUS_I) ~= (1:nb)')
0041     error('makeBdc: buses must be numbered consecutively in bus matrix')
0042 end
0043 
0044 %% for each branch, compute the elements of the branch B matrix and the phase
0045 %% shift "quiescent" injections, where
0046 %%
0047 %%      | Pf |   | Bff  Bft |   | Vaf |   | Pfinj |
0048 %%      |    | = |          | * |     | + |       |
0049 %%      | Pt |   | Btf  Btt |   | Vat |   | Ptinj |
0050 %%
0051 stat = branch(:, BR_STATUS);                    %% ones at in-service branches
0052 b = stat ./ branch(:, BR_X);                    %% series susceptance
0053 tap = ones(nl, 1);                              %% default tap ratio = 1
0054 i = find(branch(:, TAP));                       %% indices of non-zero tap ratios
0055 tap(i) = branch(i, TAP);                        %% assign non-zero tap ratios
0056 b = b ./ tap;
0057 
0058 %% build connection matrix Cft = Cf - Ct for line and from - to buses
0059 f = branch(:, F_BUS);                           %% list of "from" buses
0060 t = branch(:, T_BUS);                           %% list of "to" buses
0061 i = [(1:nl)'; (1:nl)'];                         %% double set of row indices
0062 Cft = sparse(i, [f;t], [ones(nl, 1); -ones(nl, 1)], nl, nb);    %% connection matrix
0063 
0064 %% build Bf such that Bf * Va is the vector of real branch powers injected
0065 %% at each branch's "from" bus
0066 Bf = sparse(i, [f; t], [b; -b]);    % = spdiags(b, 0, nl, nl) * Cft;
0067 
0068 %% build Bbus
0069 Bbus = Cft' * Bf;
0070 
0071 %% build phase shift injection vectors
0072 Pfinj = b .* (-branch(:, SHIFT) * pi/180);      %% injected at the from bus ...
0073     % Ptinj = -Pfinj;                           %% ... and extracted at the to bus
0074 Pbusinj = Cft' * Pfinj;                         %% Pbusinj = Cf * Pfinj + Ct * Ptinj;

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