@@ -11,7 +11,7 @@
Loading
11 11
from pandapower.pypower.idx_bus import VM, VA, PD, QD, LAM_P, LAM_Q, BASE_KV,NONE
12 12
13 13
from pandapower.pypower.idx_gen import PG, QG
14 -
from pandapower.build_bus import _get_motor_pq
14 +
from pandapower.build_bus import _get_motor_pq, _get_symmetric_pq_of_unsymetric_element
15 15
16 16
17 17
def _set_buses_out_of_service(ppc):
@@ -186,6 +186,11 @@
Loading
186 186
        net[res_]["p_mw"].values[:] = p_mw
187 187
        net[res_]["q_mvar"].values[:] = q_mvar
188 188
        return net
189 +
    elif element.startswith("asymmetric"):
190 +
        p_mw, q_mvar = _get_symmetric_pq_of_unsymetric_element(net, element)
191 +
        net[res_]["p_mw"].values[:] = p_mw
192 +
        net[res_]["q_mvar"].values[:] = q_mvar
193 +
        return net
189 194
190 195
    # Wards and xwards have different names in their element table, but not in res table. Also no scaling -> Fix...
191 196
    p_mw = "ps_mw" if element in ["ward", "xward"] else "p_mw"
@@ -194,13 +199,13 @@
Loading
194 199
195 200
    element_in_service = _is_elements[element]
196 201
197 -
    # P result in kw to element
202 +
    # P result in mw to element
198 203
    net[res_]["p_mw"].values[:] = el_data[p_mw].values * scaling * element_in_service
199 204
    if is_controllable:
200 205
        net[res_]["p_mw"].loc[controlled_elements] = ppc["gen"][gen_idx, PG] * gen_sign
201 206
202 207
    if ac:
203 -
        # Q result in kvar to element
208 +
        # Q result in mvar to element
204 209
        net[res_]["q_mvar"].values[:] = el_data[q_mvar].values * scaling * element_in_service
205 210
        if is_controllable:
206 211
            net[res_]["q_mvar"].loc[controlled_elements] = ppc["gen"][gen_idx, QG] * gen_sign
@@ -291,19 +296,20 @@
Loading
291 296
    b, p, q = np.array([]), np.array([]), np.array([])
292 297
293 298
    ac = net["_options"]["ac"]
299 +
    elements = ["load", "motor", "sgen", "storage", "ward", "xward",
300 +
                "asymmetric_load", "asymmetric_sgen"]
301 +
294 302
    if net["_options"]["voltage_depend_loads"] and ac:
295 303
        # voltage dependend loads need special treatment here
296 304
297 305
        p, q, b = write_voltage_dependend_load_results(net, p, q, b)
298 -
        elements = ["sgen", "motor", "storage", "ward", "xward"]
299 -
    else:
300 -
        elements = ["load", "motor", "sgen", "storage", "ward", "xward"]
306 +
        elements.remove("load")
301 307
302 308
    for element in elements:
303 309
        if len(net[element]):
304 310
            write_pq_results_to_element(net, ppc, element)
305 311
            p_el, q_el, bus_el = get_p_q_b(net, element)
306 -
            if element == "sgen":
312 +
            if element.endswith("sgen"):
307 313
                p = np.hstack([p, -p_el])
308 314
                q = np.hstack([q, -q_el])
309 315
            else:

@@ -123,7 +123,7 @@
Loading
123 123
    if mode == "pf" or mode == "opf":
124 124
        return ["bus", "line", "trafo", "trafo3w", "impedance", "ext_grid",
125 125
                "load", "motor", "sgen", "storage", "shunt", "gen", "ward",
126 -
                "xward", "dcline"]
126 +
                "xward", "dcline", "asymmetric_load", "asymmetric_sgen"]
127 127
    elif mode == "sc":
128 128
        return ["bus", "line", "trafo", "trafo3w", "ext_grid", "gen", "sgen"]
129 129
    elif mode == "se":

@@ -108,20 +108,6 @@
Loading
108 108
                            ("in_service", 'bool'),
109 109
                            ("type", dtype(object)),
110 110
                            ("current_source", "bool")],
111 -
        # =============================================================================
112 -
        #         "impedance_load": [("name", dtype(object)),
113 -
        #                  ("bus", "u4"),
114 -
        #                  ("r_A", "f8"),
115 -
        #                  ("r_B", "f8"),
116 -
        #                  ("r_C", "f8"),
117 -
        #                  ("x_A", "f8"),
118 -
        #                  ("x_B", "f8"),
119 -
        #                  ("x_C", "f8"),
120 -
        #                  ("sn_mva", "f8"),
121 -
        #                  ("scaling", "f8"),
122 -
        #                  ("in_service", 'bool'),
123 -
        #                  ("type", dtype(object))],
124 -
        # =============================================================================
125 111
        "storage": [("name", dtype(object)),
126 112
                    ("bus", "i8"),
127 113
                    ("p_mw", "f8"),
@@ -339,6 +325,10 @@
Loading
339 325
                             ("loading_percent", "f8")],
340 326
        "_empty_res_load": [("p_mw", "f8"),
341 327
                            ("q_mvar", "f8")],
328 +
        "_empty_res_asymmetric_load": [("p_mw", "f8"),
329 +
                            ("q_mvar", "f8")],
330 +
        "_empty_res_asymmetric_sgen": [("p_mw", "f8"),
331 +
                            ("q_mvar", "f8")],
342 332
        "_empty_res_motor": [("p_mw", "f8"),
343 333
                             ("q_mvar", "f8")],
344 334
        "_empty_res_sgen": [("p_mw", "f8"),

@@ -412,19 +412,13 @@
Loading
412 412
                q = np.hstack([q, tab["q_mvar"].values * active * scaling * sign])
413 413
            b = np.hstack([b, tab["bus"].values])
414 414
415 -
    l_3ph = net["asymmetric_load"]
416 -
    if len(l_3ph) > 0 and mode == "pf":
417 -
            # TODO: Voltage dependent loads
418 -
        vl = _is_elements["asymmetric_load"] * l_3ph["scaling"].values.T / np.float64(1000.)
419 -
        q = np.hstack([q, np.sum(l_3ph[["q_a_mvar", "q_b_mvar", "q_c_mvar"]].values, axis=1) * vl])
420 -
        p = np.hstack([p, np.sum(l_3ph[["p_a_mw", "p_b_mw", "p_c_mw"]].values, axis=1) * vl])
421 -
        b = np.hstack([b, l_3ph["bus"].values])
422 -
    sgen_3ph = net["asymmetric_sgen"]
423 -
    if len(sgen_3ph) > 0 and mode == "pf":
424 -
        vl = _is_elements["sgen_3ph"] * sgen_3ph["scaling"].values.T / np.float64(1000.)
425 -
        q = np.hstack([q, np.sum(sgen_3ph[["q_a_mvar", "q_b_mvar", "q_c_mvar"]].values, axis=1) * vl])
426 -
        p = np.hstack([p, np.sum(sgen_3ph[["p_a_mw", "p_b_mw", "p_c_mw"]].values, axis=1) * vl])
427 -
        b = np.hstack([b, sgen_3ph["bus"].values])
415 +
    for element in ["asymmetric_load", "asymmetric_sgen"]:
416 +
        if len(net[element]) > 0 and mode == "pf":
417 +
            p_mw, q_mvar = _get_symmetric_pq_of_unsymetric_element(net, element)
418 +
            sign = -1 if element.endswith("sgen") else 1
419 +
            p = np.hstack([p, p_mw * sign])
420 +
            q = np.hstack([q, q_mvar * sign ])
421 +
            b = np.hstack([b, net[element]["bus"].values])
428 422
429 423
    # sum up p & q of bus elements
430 424
    if b.size:
@@ -433,9 +427,14 @@
Loading
433 427
        b, vp, vq = _sum_by_group(b, p, q)
434 428
        ppc["bus"][b, PD] = vp
435 429
        ppc["bus"][b, QD] = vq
436 -
        # Todo: Actually, P and Q have to be divided by 3 because Sabc=3*S012 (we are writing pos. seq. values here!)
437 430
438 431
432 +
def _get_symmetric_pq_of_unsymetric_element(net, element):
433 +
    scale = net["_is_elements"][element] * net[element]["scaling"].values.T
434 +
    q_mvar = np.sum(net[element][["q_a_mvar", "q_b_mvar", "q_c_mvar"]].values, axis=1)
435 +
    p_mw = np.sum(net[element][["p_a_mw", "p_b_mw", "p_c_mw"]].values, axis=1)
436 +
    return p_mw*scale, q_mvar*scale
437 +
439 438
def _get_motor_pq(net):
440 439
    tab = net["motor"]
441 440
    active = net._is_elements["motor"]
Files Coverage
pandapower 87.69%
setup.py 0.00%
Project Totals (162 files) 87.61%

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading