e2nIEE / pandapower
1
# Copyright (c) 1996-2015 PSERC. All rights reserved.
2
# Use of this source code is governed by a BSD-style
3
# license that can be found in the LICENSE file.
4

5 1
"""Builds the FDPF matrices, B prime and B double prime.
6
"""
7

8 1
from numpy import ones, zeros, copy
9

10 1
from pandapower.pypower.idx_bus import BS
11 1
from pandapower.pypower.idx_brch import BR_B, BR_R, TAP, SHIFT
12 1
from pandapower.pypower.makeYbus import makeYbus
13

14

15 1
def makeB(baseMVA, bus, branch, alg):
16
    """Builds the FDPF matrices, B prime and B double prime.
17

18
    Returns the two matrices B prime and B double prime used in the fast
19
    decoupled power flow. Does appropriate conversions to p.u. C{alg} is the
20
    value of the C{PF_ALG} option specifying the power flow algorithm.
21

22
    @see: L{fdpf}
23

24
    @author: Ray Zimmerman (PSERC Cornell)
25
    """
26
    ## constants
27 1
    nb = bus.shape[0]          ## number of buses
28 1
    nl = branch.shape[0]       ## number of lines
29

30
    ##-----  form Bp (B prime)  -----
31 1
    temp_branch = copy(branch)                 ## modify a copy of branch
32 1
    temp_bus = copy(bus)                       ## modify a copy of bus
33 1
    temp_bus[:, BS] = zeros(nb)                ## zero out shunts at buses
34 1
    temp_branch[:, BR_B] = zeros(nl)           ## zero out line charging shunts
35 1
    temp_branch[:, TAP] = ones(nl)             ## cancel out taps
36 1
    if alg == 2:                               ## if XB method
37 1
        temp_branch[:, BR_R] = zeros(nl)       ## zero out line resistance
38 1
    Bp = -1 * makeYbus(baseMVA, temp_bus, temp_branch)[0].imag
39

40
    ##-----  form Bpp (B double prime)  -----
41 1
    temp_branch = copy(branch)                 ## modify a copy of branch
42 1
    temp_branch[:, SHIFT] = zeros(nl)          ## zero out phase shifters
43 1
    if alg == 3:                               ## if BX method
44 1
        temp_branch[:, BR_R] = zeros(nl)    ## zero out line resistance
45 1
    Bpp = -1 * makeYbus(baseMVA, bus, temp_branch)[0].imag
46

47 1
    return Bp, Bpp

Read our documentation on viewing source code .

Loading