e2nIEE / pandapower
1
# -*- coding: utf-8 -*-
2

3
# Copyright (c) 2016-2021 by University of Kassel and Fraunhofer Institute for Energy Economics
4
# and Energy System Technology (IEE), Kassel. All rights reserved.
5

6 1
from pandapower.pypower.idx_bus import VM, VA
7 1
from pandapower.pypower.idx_gen import GEN_BUS, GEN_STATUS, VG
8 1
from pandapower.pypower.bustypes import bustypes
9 1
from numpy import flatnonzero as find, pi, exp
10

11 1
def _get_pf_variables_from_ppci(ppci):
12
    ## default arguments
13 1
    if ppci is None:
14 0
        ValueError('ppci is empty')
15
    # ppopt = ppoption(ppopt)
16

17
    # get data for calc
18 1
    baseMVA, bus, gen, branch = \
19
        ppci["baseMVA"], ppci["bus"], ppci["gen"], ppci["branch"]
20

21
    ## get bus index lists of each type of bus
22 1
    ref, pv, pq = bustypes(bus, gen)
23

24
    ## generator info
25 1
    on = find(gen[:, GEN_STATUS] > 0)  ## which generators are on?
26 1
    gbus = gen[on, GEN_BUS].astype(int)  ## what buses are they at?
27

28
    ## initial state
29
    # V0    = ones(bus.shape[0])            ## flat start
30 1
    V0 = bus[:, VM] * exp(1j * pi / 180. * bus[:, VA])
31 1
    V0[gbus] = gen[on, VG] / abs(V0[gbus]) * V0[gbus]
32

33 1
    ref_gens = ppci["internal"]["ref_gens"]
34 1
    return baseMVA, bus, gen, branch, ref, pv, pq, on, gbus, V0, ref_gens
35

36 1
def _store_results_from_pf_in_ppci(ppci, bus, gen, branch, success, iterations, et):
37 1
    ppci["bus"], ppci["gen"], ppci["branch"] = bus, gen, branch
38 1
    ppci["success"] = bool(success)
39 1
    ppci["iterations"] = iterations
40 1
    ppci["et"] = et
41 1
    return ppci

Read our documentation on viewing source code .

Loading