MAKEB Builds the FDPF matrices, B prime and B double prime. [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. 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.
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(BASEMVA, BUS, BRANCH, ALG) returns the two 0004 % matrices B prime and B double prime used in the fast decoupled power 0005 % flow. Does appropriate conversions to p.u. ALG is either 'FDXB' or 0006 % 'FDBX', the corresponding value of MPOPT.pf.alg option specifying the 0007 % power flow algorithm. 0008 % 0009 % Note: For backward compatibility, ALG can also take on a value of 0010 % 2 or 3, corresponding to values of the old PF_ALG option. This usage 0011 % is deprecated and will be removed in a future version. 0012 % 0013 % Example: 0014 % [Bp, Bpp] = makeB(baseMVA, bus, branch, 'FDXB'); 0015 % 0016 % See also FDPF. 0017 0018 % MATPOWER 0019 % Copyright (c) 1996-2015 by Power System Engineering Research Center (PSERC) 0020 % by Ray Zimmerman, PSERC Cornell 0021 % 0022 % $Id: makeB.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 %% backward compatiblility (deprecated) 0033 if ~ischar(alg) 0034 if alg == 2 0035 alg = 'FDXB'; 0036 elseif alg == 3 0037 alg = 'FDBX'; 0038 end 0039 end 0040 0041 %% check for valid ALG value 0042 alg = upper(alg); 0043 if ~strcmp(alg, 'FDXB') && ~strcmp(alg, 'FDBX') 0044 error('makeB: ''%s'' is not a valid value for ALG', alg); 0045 end 0046 0047 %% define named indices into bus, branch matrices 0048 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ... 0049 VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus; 0050 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ... 0051 TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ... 0052 ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch; 0053 0054 %%----- form Bp (B prime) ----- 0055 temp_branch = branch; %% modify a copy of branch 0056 temp_bus = bus; %% modify a copy of bus 0057 temp_bus(:, BS) = zeros(nb, 1); %% zero out shunts at buses 0058 temp_branch(:, BR_B) = zeros(nl, 1); %% zero out line charging shunts 0059 temp_branch(:, TAP) = ones(nl, 1); %% cancel out taps 0060 if strcmp(alg, 'FDXB') %% if XB method 0061 temp_branch(:, BR_R) = zeros(nl, 1); %% zero out line resistance 0062 end 0063 Bp = -imag( makeYbus(baseMVA, temp_bus, temp_branch) ); 0064 0065 %%----- form Bpp (B double prime) ----- 0066 if nargout == 2 0067 temp_branch = branch; %% modify a copy of branch 0068 temp_branch(:, SHIFT) = zeros(nl, 1); %% zero out phase shifters 0069 if strcmp(alg, 'FDBX') %% if BX method 0070 temp_branch(:, BR_R) = zeros(nl, 1); %% zero out line resistance 0071 end 0072 Bpp = -imag( makeYbus(baseMVA, bus, temp_branch) ); 0073 end