-
Notifications
You must be signed in to change notification settings - Fork 465
/
ppci_variables.py
41 lines (32 loc) · 1.49 KB
/
ppci_variables.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- coding: utf-8 -*-
# Copyright (c) 2016-2022 by University of Kassel and Fraunhofer Institute for Energy Economics
# and Energy System Technology (IEE), Kassel. All rights reserved.
from pandapower.pypower.idx_bus import VM, VA
from pandapower.pypower.idx_gen import GEN_BUS, GEN_STATUS, VG
from pandapower.pypower.bustypes import bustypes
from numpy import flatnonzero as find, pi, exp
def _get_pf_variables_from_ppci(ppci):
## default arguments
if ppci is None:
ValueError('ppci is empty')
# ppopt = ppoption(ppopt)
# get data for calc
baseMVA, bus, gen, branch = \
ppci["baseMVA"], ppci["bus"], ppci["gen"], ppci["branch"]
## get bus index lists of each type of bus
ref, pv, pq = bustypes(bus, gen)
## generator info
on = find(gen[:, GEN_STATUS] > 0) ## which generators are on?
gbus = gen[on, GEN_BUS].astype(int) ## what buses are they at?
## initial state
# V0 = ones(bus.shape[0]) ## flat start
V0 = bus[:, VM] * exp(1j * pi / 180. * bus[:, VA])
V0[gbus] = gen[on, VG] / abs(V0[gbus]) * V0[gbus]
ref_gens = ppci["internal"]["ref_gens"]
return baseMVA, bus, gen, branch, ref, pv, pq, on, gbus, V0, ref_gens
def _store_results_from_pf_in_ppci(ppci, bus, gen, branch, success, iterations, et):
ppci["bus"], ppci["gen"], ppci["branch"] = bus, gen, branch
ppci["success"] = bool(success)
ppci["iterations"] = iterations
ppci["et"] = et
return ppci