Home > matpower7.1 > lib > makeB.m

makeB

PURPOSE ^

MAKEB Builds the FDPF matrices, B prime and B double prime.

SYNOPSIS ^

function [Bp, Bpp] = makeB(baseMVA, bus, branch, alg)

DESCRIPTION ^

MAKEB   Builds the FDPF matrices, B prime and B double prime.
   [BP, BPP] = MAKEB(MPC, ALG)
   [BP, BPP] = MAKEB(BASEMVA, BUS, BRANCH, ALG)

   Returns the two matrices B prime and B double prime used in the fast
   decoupled power flow. Does appropriate conversions to p.u. ALG is either
   'FDXB' or 'FDBX', the corresponding value of MPOPT.pf.alg option
   specifying the power flow algorithm.
   Bus numbers must be consecutive beginning at 1 (i.e. internal ordering).

   Note: For backward compatibility, ALG can also take on a value of
   2 or 3, corresponding to values of the old PF_ALG option. This usage
   is deprecated and will be removed in a future version.

   Example:
       [Bp, Bpp] = makeB(baseMVA, bus, branch, 'FDXB');

   See also FDPF.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [Bp, Bpp] = makeB(baseMVA, bus, branch, alg)
0002 %MAKEB   Builds the FDPF matrices, B prime and B double prime.
0003 %   [BP, BPP] = MAKEB(MPC, ALG)
0004 %   [BP, BPP] = MAKEB(BASEMVA, BUS, BRANCH, ALG)
0005 %
0006 %   Returns the two matrices B prime and B double prime used in the fast
0007 %   decoupled power flow. Does appropriate conversions to p.u. ALG is either
0008 %   'FDXB' or 'FDBX', the corresponding value of MPOPT.pf.alg option
0009 %   specifying the power flow algorithm.
0010 %   Bus numbers must be consecutive beginning at 1 (i.e. internal ordering).
0011 %
0012 %   Note: For backward compatibility, ALG can also take on a value of
0013 %   2 or 3, corresponding to values of the old PF_ALG option. This usage
0014 %   is deprecated and will be removed in a future version.
0015 %
0016 %   Example:
0017 %       [Bp, Bpp] = makeB(baseMVA, bus, branch, 'FDXB');
0018 %
0019 %   See also FDPF.
0020 
0021 %   MATPOWER
0022 %   Copyright (c) 1996-2016, Power Systems Engineering Research Center (PSERC)
0023 %   by Ray Zimmerman, PSERC Cornell
0024 %
0025 %   This file is part of MATPOWER.
0026 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0027 %   See https://matpower.org for more info.
0028 
0029 %% extract from MPC if necessary
0030 if nargin < 3
0031     mpc     = baseMVA;
0032     if nargin == 2
0033         alg = bus;
0034     end
0035     baseMVA = mpc.baseMVA;
0036     bus     = mpc.bus;
0037     branch  = mpc.branch;
0038 end
0039 
0040 %% constants
0041 nb = size(bus, 1);          %% number of buses
0042 nl = size(branch, 1);       %% number of lines
0043 
0044 %% backward compatiblility (deprecated)
0045 if ~ischar(alg)
0046     if alg == 2
0047         alg = 'FDXB';
0048     elseif alg == 3
0049         alg = 'FDBX';
0050     end
0051 end
0052 
0053 %% check for valid ALG value
0054 alg = upper(alg);
0055 if ~strcmp(alg, 'FDXB') && ~strcmp(alg, 'FDBX')
0056     error('makeB: ''%s'' is not a valid value for ALG', alg);
0057 end
0058 
0059 %% define named indices into bus, branch matrices
0060 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0061     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0062 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0063     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0064     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0065 
0066 %%-----  form Bp (B prime)  -----
0067 temp_branch = branch;                       %% modify a copy of branch
0068 temp_bus = bus;                             %% modify a copy of bus
0069 temp_bus(:, BS) = zeros(nb, 1);             %% zero out shunts at buses
0070 temp_branch(:, BR_B) = zeros(nl, 1);        %% zero out line charging shunts
0071 temp_branch(:, TAP) = ones(nl, 1);          %% cancel out taps
0072 if strcmp(alg, 'FDXB')                      %% if XB method
0073     temp_branch(:, BR_R) = zeros(nl, 1);        %% zero out line resistance
0074 end
0075 Bp = -imag( makeYbus(baseMVA, temp_bus, temp_branch) );
0076 
0077 %%-----  form Bpp (B double prime)  -----
0078 if nargout == 2
0079     temp_branch = branch;                       %% modify a copy of branch
0080     temp_branch(:, SHIFT) = zeros(nl, 1);       %% zero out phase shifters
0081     if strcmp(alg, 'FDBX')                      %% if BX method
0082         temp_branch(:, BR_R) = zeros(nl, 1);        %% zero out line resistance
0083     end
0084     Bpp = -imag( makeYbus(baseMVA, bus, temp_branch) );
0085 end

Generated on Fri 09-Oct-2020 11:21:31 by m2html © 2005