Package pypower :: Module makeB
[hide private]
[frames] | no frames]

Source Code for Module pypower.makeB

 1  # Copyright (C) 1996-2011 Power System Engineering Research Center (PSERC) 
 2  # Copyright (C) 2011 Richard Lincoln 
 3  # 
 4  # PYPOWER is free software: you can redistribute it and/or modify 
 5  # it under the terms of the GNU General Public License as published 
 6  # by the Free Software Foundation, either version 3 of the License, 
 7  # or (at your option) any later version. 
 8  # 
 9  # PYPOWER is distributed in the hope that it will be useful, 
10  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
11  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
12  # GNU General Public License for more details. 
13  # 
14  # You should have received a copy of the GNU General Public License 
15  # along with PYPOWER. If not, see <http://www.gnu.org/licenses/>. 
16   
17  """Builds the FDPF matrices, B prime and B double prime. 
18  """ 
19   
20  from numpy import ones, zeros, copy 
21   
22  from idx_bus import BS 
23  from idx_brch import BR_B, BR_R, TAP, SHIFT 
24   
25  from makeYbus import makeYbus 
26   
27   
28 -def makeB(baseMVA, bus, branch, alg):
29 """Builds the FDPF matrices, B prime and B double prime. 30 31 Returns the two matrices B prime and B double prime used in the fast 32 decoupled power flow. Does appropriate conversions to p.u. C{alg} is the 33 value of the C{PF_ALG} option specifying the power flow algorithm. 34 35 @see: L{fdpf} 36 37 @author: Ray Zimmerman (PSERC Cornell) 38 @author: Richard Lincoln 39 """ 40 ## constants 41 nb = bus.shape[0] ## number of buses 42 nl = branch.shape[0] ## number of lines 43 44 ##----- form Bp (B prime) ----- 45 temp_branch = copy(branch) ## modify a copy of branch 46 temp_bus = copy(bus) ## modify a copy of bus 47 temp_bus[:, BS] = zeros(nb) ## zero out shunts at buses 48 temp_branch[:, BR_B] = zeros(nl) ## zero out line charging shunts 49 temp_branch[:, TAP] = ones(nl) ## cancel out taps 50 if alg == 2: ## if XB method 51 temp_branch[:, BR_R] = zeros(nl) ## zero out line resistance 52 Bp = -1 * makeYbus(baseMVA, temp_bus, temp_branch)[0].imag 53 54 ##----- form Bpp (B double prime) ----- 55 temp_branch = copy(branch) ## modify a copy of branch 56 temp_branch[:, SHIFT] = zeros(nl) ## zero out phase shifters 57 if alg == 3: ## if BX method 58 temp_branch[:, BR_R] = zeros(nl) ## zero out line resistance 59 Bpp = -1 * makeYbus(baseMVA, bus, temp_branch)[0].imag 60 61 return Bp, Bpp
62