Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/power_grid_model_io/converters/pandapower_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1664,17 +1664,14 @@ def join_currents(table: str, bus_name: str, i_name: str) -> pd.DataFrame:
pp_switches_output_index = pp_switches_output.index

# Combine all branch bus, current and et in one dataframe
all_i_df = pd.concat(
[
(
join_currents(table, bus_name, i_name)
if not rest_switches_absent[table]
else pd.DataFrame(columns=["bus", "element", "et", "i_ka"])
)
for table, attr_names in switch_attrs.items()
for bus_name, i_name in attr_names.items()
]
)
dfs = [
join_currents(table, bus_name, i_name)
for table, attr_names in switch_attrs.items()
for bus_name, i_name in attr_names.items()
if not rest_switches_absent[table]
]
all_i_df = pd.DataFrame(columns=["bus", "element", "et", "i_ka"]) if not dfs else pd.concat(dfs)

# Merge on input data to get current and drop other columns
pp_switches_output = pd.merge(
pp_switches_output,
Expand Down
90 changes: 48 additions & 42 deletions tests/data/pandapower/pgm_asym_output_data.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,49 @@
{
"node":
[
{"id": 0, "energized": 1, "u_pu": [1.000000000042805, 1.000000000042805, 1.000000000040956], "u": [63508.52961357732, 63508.52961357732, 63508.52961345989], "u_angle": [-2.297462191765614e-10, -2.094395102622942, 2.094395102852041], "p": [765820.7217852274, 765820.7235734381, -1529485.490304183], "q": [-142683.6055350895, -142683.5967414472, -136520.3696246375], "id_reference": {"table": "bus", "index": 101}},
{"id": 1, "energized": 1, "u_pu": [0.9994132656313264, 0.9994132656313274, 1.002844167287654], "u": [11540.23035887859, 11540.2303588786, 11579.84699877547], "u_angle": [-0.002501623712801432, -2.096896726105997, 2.098735152107258], "p": [5.662039942836705e-08, 4.158749852077411e-07, 5.339208304447429e-08], "q": [-7.588863607722517e-08, -6.631148746093378e-08, 3.610845913546241e-07], "id_reference": {"table": "bus", "index": 102}},
{"id": 2, "energized": 1, "u_pu": [0.9987870960752929, 0.9987870960752938, 1.004418511811836], "u": [11532.9999756439, 11532.99997564391, 11598.02596347214], "u_angle": [-0.002966986920613948, -2.09736208931381, 2.099116406819713], "p": [-729999.9999998733, -730000.000000165, 1570000.000000135], "q": [189999.9999999996, 190000.0000003468, 189999.9999996292], "id_reference": {"table": "bus", "index": 103}},
{"id": 3, "energized": 1, "u_pu": [1.000000000042805, 1.000000000042805, 1.000000000040956], "u": [63508.52961357732, 63508.52961357732, 63508.52961345989], "u_angle": [-2.297462191765614e-10, -2.094395102622942, 2.094395102852041], "p": [0, 0, 0], "q": [0, 0, 0], "id_reference": {"table": "bus", "index": 106}}
],
"line":
[
{"id": 4, "energized": 1, "loading": 1.265330032238072, "p_from": [-729999.9999998733, -730000.000000165, 1570000.000000135], "q_from": [189999.9999999996, 190000.0000003468, 189999.9999996292], "i_from": [65.40543555178559, 65.40543555181758, 136.3555342275158], "s_from": [754320.8866257217, 754320.8866260914, 1581455.026233842], "p_to": [730552.3008243673, 730552.3008246894, -1567616.527443881], "q_to": [-216633.7469513389, -216633.7469515898, -216173.5239478488], "i_to": [66.02947091323357, 66.02947091326645, 136.6556434817117], "s_to": [761995.3048135885, 761995.3048139686, 1582451.44303743], "id_reference": {"table": "line", "index": 101}, "pgm_input": {"from_node": 2, "to_node": 1, "i_n": 108.0}}
],
"source":
[
{"id": 5, "energized": 1, "p": [765820.730621319, 765820.4766903995, -1529485.219644774], "q": [-142683.6428608279, -142684.1067247107, -136520.4031334404], "i": [12.26605892917178, 12.26605633625489, 24.17889348713215], "s": [778999.36674519, 778999.2020728515, 1535565.973048225], "pf": [0.9830826099654819, 0.9830824918082272, -0.9960400572100595], "id_reference": {"table": "ext_grid", "index": 0}, "pgm_input": {"node": 0}}
],
"sym_load":
[
{"id": 6, "energized": 1, "p": [833333.3333333333, 833333.3333333333, 833333.3333333333], "q": [79999.99999999999, 79999.99999999999, 79999.99999999999], "i": [72.58861772969922, 72.58861772969915, 72.18163928458914], "s": [837164.5265086454, 837164.5265086454, 837164.5265086454], "pf": [0.9954236078405162, 0.9954236078405162, 0.9954236078405162], "id_reference": {"table": "load", "name": "const_power", "index": 101}, "pgm_input": {"node": 2}},
{"id": 7, "energized": 1, "p": [0, 0, 0], "q": [0, 0, 0], "i": [0, 0, 0], "s": [0, 0, 0], "pf": [0, 0, 0], "id_reference": {"table": "load", "name": "const_impedance", "index": 101}, "pgm_input": {"node": 2}},
{"id": 8, "energized": 1, "p": [0, 0, 0], "q": [0, 0, 0], "i": [0, 0, 0], "s": [0, 0, 0], "pf": [0, 0, 0], "id_reference": {"table": "load", "name": "const_current", "index": 101}, "pgm_input": {"node": 2}}
],
"transformer":
[
{"id": 9, "energized": 1, "loading": 0.03883052565830863, "p_from": [765820.724989093, 765820.7249890427, -1529485.491438911], "q_from": [-142683.6001096883, -142683.6001099306, -136520.3668874493], "i_from": [12.26605871869048, 12.2660587186904, 24.17889769909201], "s_from": [778999.3533778327, 778999.3533778277, 1535566.240543602], "p_to": [-730552.3008242727, -730552.300824217, 1567616.527444104], "q_to": [216633.7469512629, 216633.7469515783, 216173.5239482207], "i_to": [66.02947091322386, 66.02947091322693, 136.6556434817352], "s_to": [761995.3048134763, 761995.3048135125, 1582451.443037701], "id_reference": {"table": "trafo", "index": 0}, "pgm_input": {"from_node": 0, "to_node": 1}, "pp_input": {"df": 1.0}}
],
"sym_gen":
[
{"id": 10, "energized": 1, "p": [403333.3333333333, 403333.3333333333, 403333.3333333333], "q": [269999.9999999999, 269999.9999999999, 269999.9999999999], "i": [42.08476139753746, 42.08476139753742, 41.84880717644763], "s": [485363.5521727787, 485363.5521727787, 485363.5521727787], "pf": [0.8309922150680065, 0.8309922150680065, 0.8309922150680065], "id_reference": {"table": "sgen", "index": 31}, "pgm_input": {"node": 2}}
],
"link":
[
{"id": 11, "energized": 1, "loading": 0, "p_from": [0, 0, 0], "q_from": [0, 0, 0], "i_from": [0, 0, 0], "s_from": [0, 0, 0], "p_to": [0, 0, 0], "q_to": [0, 0, 0], "i_to": [0, 0, 0], "s_to": [0, 0, 0], "id_reference": {"table": "switch", "name": "b2b_switches", "index": 3021}, "pgm_input": {"from_node": 0, "to_node": 3}}
],
"asym_load":
[
{"id": 12, "energized": 1, "p": [399999.9999999999, 500000, 1000000], "q": [10000, 10000, 10000], "i": [34.69392016993495, 43.36252415313805, 86.22588032650638], "s": [400124.980474851, 500099.9900019995, 1000049.998750063], "pf": [0.9996876464081228, 0.999800059980007, 0.9999500037496875], "id_reference": {"table": "asymmetric_load", "index": 33}, "pgm_input": {"node": 2}}
],
"asym_gen":
[
{"id": 13, "energized": 1, "p": [99999.99999999999, 200000, 3000000], "q": [10000, 10000, 10000], "i": [8.71401685801165, 17.3632050956306, 258.6661450895947], "s": [100498.7562112089, 200249.8439450078, 3000016.66662037], "pf": [0.9950371902099889, 0.9987523388778446, 0.9999944444907404], "id_reference": {"table": "asymmetric_sgen", "index": 32}, "pgm_input": {"node": 2}}
]
}
"version": "1.0",
"type": "asym_output",
"is_batch": false,
"attributes": {},
"data": {
"node":
[
{"id": 0, "energized": 1, "u_pu": [1.000000000042805, 1.000000000042805, 1.000000000040956], "u": [63508.52961357732, 63508.52961357732, 63508.52961345989], "u_angle": [-2.297462191765614e-10, -2.094395102622942, 2.094395102852041], "p": [765820.7217852274, 765820.7235734381, -1529485.490304183], "q": [-142683.6055350895, -142683.5967414472, -136520.3696246375], "id_reference": {"table": "bus", "index": 101}},
{"id": 1, "energized": 1, "u_pu": [0.9994132656313264, 0.9994132656313274, 1.002844167287654], "u": [11540.23035887859, 11540.2303588786, 11579.84699877547], "u_angle": [-0.002501623712801432, -2.096896726105997, 2.098735152107258], "p": [5.662039942836705e-08, 4.158749852077411e-07, 5.339208304447429e-08], "q": [-7.588863607722517e-08, -6.631148746093378e-08, 3.610845913546241e-07], "id_reference": {"table": "bus", "index": 102}},
{"id": 2, "energized": 1, "u_pu": [0.9987870960752929, 0.9987870960752938, 1.004418511811836], "u": [11532.9999756439, 11532.99997564391, 11598.02596347214], "u_angle": [-0.002966986920613948, -2.09736208931381, 2.099116406819713], "p": [-729999.9999998733, -730000.000000165, 1570000.000000135], "q": [189999.9999999996, 190000.0000003468, 189999.9999996292], "id_reference": {"table": "bus", "index": 103}},
{"id": 3, "energized": 1, "u_pu": [1.000000000042805, 1.000000000042805, 1.000000000040956], "u": [63508.52961357732, 63508.52961357732, 63508.52961345989], "u_angle": [-2.297462191765614e-10, -2.094395102622942, 2.094395102852041], "p": [0, 0, 0], "q": [0, 0, 0], "id_reference": {"table": "bus", "index": 106}}
],
"line":
[
{"id": 4, "energized": 1, "loading": 1.265330032238072, "p_from": [-729999.9999998733, -730000.000000165, 1570000.000000135], "q_from": [189999.9999999996, 190000.0000003468, 189999.9999996292], "i_from": [65.40543555178559, 65.40543555181758, 136.3555342275158], "s_from": [754320.8866257217, 754320.8866260914, 1581455.026233842], "p_to": [730552.3008243673, 730552.3008246894, -1567616.527443881], "q_to": [-216633.7469513389, -216633.7469515898, -216173.5239478488], "i_to": [66.02947091323357, 66.02947091326645, 136.6556434817117], "s_to": [761995.3048135885, 761995.3048139686, 1582451.44303743], "id_reference": {"table": "line", "index": 101}, "pgm_input": {"from_node": 2, "to_node": 1, "i_n": 108.0}}
],
"source":
[
{"id": 5, "energized": 1, "p": [765820.730621319, 765820.4766903995, -1529485.219644774], "q": [-142683.6428608279, -142684.1067247107, -136520.4031334404], "i": [12.26605892917178, 12.26605633625489, 24.17889348713215], "s": [778999.36674519, 778999.2020728515, 1535565.973048225], "pf": [0.9830826099654819, 0.9830824918082272, -0.9960400572100595], "id_reference": {"table": "ext_grid", "index": 0}, "pgm_input": {"node": 0}}
],
"sym_load":
[
{"id": 6, "energized": 1, "p": [833333.3333333333, 833333.3333333333, 833333.3333333333], "q": [79999.99999999999, 79999.99999999999, 79999.99999999999], "i": [72.58861772969922, 72.58861772969915, 72.18163928458914], "s": [837164.5265086454, 837164.5265086454, 837164.5265086454], "pf": [0.9954236078405162, 0.9954236078405162, 0.9954236078405162], "id_reference": {"table": "load", "name": "const_power", "index": 101}, "pgm_input": {"node": 2}},
{"id": 7, "energized": 1, "p": [0, 0, 0], "q": [0, 0, 0], "i": [0, 0, 0], "s": [0, 0, 0], "pf": [0, 0, 0], "id_reference": {"table": "load", "name": "const_impedance", "index": 101}, "pgm_input": {"node": 2}},
{"id": 8, "energized": 1, "p": [0, 0, 0], "q": [0, 0, 0], "i": [0, 0, 0], "s": [0, 0, 0], "pf": [0, 0, 0], "id_reference": {"table": "load", "name": "const_current", "index": 101}, "pgm_input": {"node": 2}}
],
"transformer":
[
{"id": 9, "energized": 1, "loading": 0.03883052565830863, "p_from": [765820.724989093, 765820.7249890427, -1529485.491438911], "q_from": [-142683.6001096883, -142683.6001099306, -136520.3668874493], "i_from": [12.26605871869048, 12.2660587186904, 24.17889769909201], "s_from": [778999.3533778327, 778999.3533778277, 1535566.240543602], "p_to": [-730552.3008242727, -730552.300824217, 1567616.527444104], "q_to": [216633.7469512629, 216633.7469515783, 216173.5239482207], "i_to": [66.02947091322386, 66.02947091322693, 136.6556434817352], "s_to": [761995.3048134763, 761995.3048135125, 1582451.443037701], "id_reference": {"table": "trafo", "index": 0}, "pgm_input": {"from_node": 0, "to_node": 1}, "pp_input": {"df": 1.0}}
],
"sym_gen":
[
{"id": 10, "energized": 1, "p": [403333.3333333333, 403333.3333333333, 403333.3333333333], "q": [269999.9999999999, 269999.9999999999, 269999.9999999999], "i": [42.08476139753746, 42.08476139753742, 41.84880717644763], "s": [485363.5521727787, 485363.5521727787, 485363.5521727787], "pf": [0.8309922150680065, 0.8309922150680065, 0.8309922150680065], "id_reference": {"table": "sgen", "index": 31}, "pgm_input": {"node": 2}}
],
"link":
[
{"id": 11, "energized": 1, "loading": 0, "p_from": [0, 0, 0], "q_from": [0, 0, 0], "i_from": [0, 0, 0], "s_from": [0, 0, 0], "p_to": [0, 0, 0], "q_to": [0, 0, 0], "i_to": [0, 0, 0], "s_to": [0, 0, 0], "id_reference": {"table": "switch", "name": "b2b_switches", "index": 3021}, "pgm_input": {"from_node": 0, "to_node": 3}}
],
"asym_load":
[
{"id": 12, "energized": 1, "p": [399999.9999999999, 500000, 1000000], "q": [10000, 10000, 10000], "i": [34.69392016993495, 43.36252415313805, 86.22588032650638], "s": [400124.980474851, 500099.9900019995, 1000049.998750063], "pf": [0.9996876464081228, 0.999800059980007, 0.9999500037496875], "id_reference": {"table": "asymmetric_load", "index": 33}, "pgm_input": {"node": 2}}
],
"asym_gen":
[
{"id": 13, "energized": 1, "p": [99999.99999999999, 200000, 3000000], "q": [10000, 10000, 10000], "i": [8.71401685801165, 17.3632050956306, 258.6661450895947], "s": [100498.7562112089, 200249.8439450078, 3000016.66662037], "pf": [0.9950371902099889, 0.9987523388778446, 0.9999944444907404], "id_reference": {"table": "asymmetric_sgen", "index": 32}, "pgm_input": {"node": 2}}
]
}
}
Loading