Home > matpower5.0 > 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(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.

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(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 %   $Id: makeB.m 2229 2013-12-11 01:28:09Z ray $
0020 %   by Ray Zimmerman, PSERC Cornell
0021 %   Copyright (c) 1996-2010 by Power System Engineering Research Center (PSERC)
0022 %
0023 %   This file is part of MATPOWER.
0024 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0025 %
0026 %   MATPOWER is free software: you can redistribute it and/or modify
0027 %   it under the terms of the GNU General Public License as published
0028 %   by the Free Software Foundation, either version 3 of the License,
0029 %   or (at your option) any later version.
0030 %
0031 %   MATPOWER is distributed in the hope that it will be useful,
0032 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0033 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0034 %   GNU General Public License for more details.
0035 %
0036 %   You should have received a copy of the GNU General Public License
0037 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0038 %
0039 %   Additional permission under GNU GPL version 3 section 7
0040 %
0041 %   If you modify MATPOWER, or any covered work, to interface with
0042 %   other modules (such as MATLAB code and MEX-files) available in a
0043 %   MATLAB(R) or comparable environment containing parts covered
0044 %   under other licensing terms, the licensors of MATPOWER grant
0045 %   you additional permission to convey the resulting work.
0046 
0047 %% constants
0048 nb = size(bus, 1);          %% number of buses
0049 nl = size(branch, 1);       %% number of lines
0050 
0051 %% backward compatiblility (deprecated)
0052 if ~ischar(alg)
0053     if alg == 2
0054         alg = 'FDXB';
0055     elseif alg == 3
0056         alg = 'FDBX';
0057     end
0058 end
0059 
0060 %% check for valid ALG value
0061 alg = upper(alg);
0062 if ~strcmp(alg, 'FDXB') && ~strcmp(alg, 'FDBX')
0063     error('makeB: ''%s'' is not a valid value for ALG', alg);
0064 end
0065 
0066 %% define named indices into bus, branch matrices
0067 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0068     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0069 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0070     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0071     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0072 
0073 %%-----  form Bp (B prime)  -----
0074 temp_branch = branch;                       %% modify a copy of branch
0075 temp_bus = bus;                             %% modify a copy of bus
0076 temp_bus(:, BS) = zeros(nb, 1);             %% zero out shunts at buses
0077 temp_branch(:, BR_B) = zeros(nl, 1);        %% zero out line charging shunts
0078 temp_branch(:, TAP) = ones(nl, 1);          %% cancel out taps
0079 if strcmp(alg, 'FDXB')                      %% if XB method
0080     temp_branch(:, BR_R) = zeros(nl, 1);        %% zero out line resistance
0081 end
0082 Bp = -imag( makeYbus(baseMVA, temp_bus, temp_branch) );
0083 
0084 %%-----  form Bpp (B double prime)  -----
0085 if nargout == 2
0086     temp_branch = branch;                       %% modify a copy of branch
0087     temp_branch(:, SHIFT) = zeros(nl, 1);       %% zero out phase shifters
0088     if strcmp(alg, 'FDBX')                      %% if BX method
0089         temp_branch(:, BR_R) = zeros(nl, 1);        %% zero out line resistance
0090     end
0091     Bpp = -imag( makeYbus(baseMVA, bus, temp_branch) );
0092 end

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