Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix trafo3w tap at star point #2411

Merged
merged 10 commits into from
Nov 18, 2024
Merged
3 changes: 2 additions & 1 deletion pandapower/build_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,8 @@ def _calculate_3w_tap_changers(t3, t2, sides):
if any_at_star_point & np.any(mask_star_point := (tap_mask & at_star_point)):
t = tap_arrays["tap_step_percent"][side][mask_star_point] * np.exp(1j * np.deg2rad(tap_arrays["tap_step_degree"][side][mask_star_point]))
tap_pos = tap_arrays["tap_pos"][side][mask_star_point]
t_corrected = 100 * t / (100 + (t * tap_pos))
tap_neutral = tap_arrays["tap_neutral"][side][mask_star_point]
t_corrected = 100 * t / (100 + (t * (tap_pos-tap_neutral)))
tap_arrays["tap_step_percent"][side][mask_star_point] = np.abs(t_corrected)
tap_arrays["tap_side"][side][mask_star_point] = "lv" if side == "hv" else "hv"
tap_arrays["tap_step_degree"][side][mask_star_point] = np.rad2deg(np.angle(t_corrected))
Expand Down
37 changes: 36 additions & 1 deletion pandapower/test/loadflow/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ def test_trafo3w(result_test_network, v_tol=1e-6, i_tol=1e-6, s_tol=2e-2, l_tol=

@pytest.mark.parametrize("tap_pos", (-1, 2))
@pytest.mark.parametrize("tap_side", ('hv', 'mv', 'lv'))
@pytest.mark.parametrize("tap_step_degree", (15, 30))
@pytest.mark.parametrize("tap_step_degree", (0, 15, 30))
def test_trafo3w_tap(tap_pos, tap_side, tap_step_degree):
results = pd.read_csv(os.path.join(pp.pp_dir, "test", "test_files", "test_results_files", "trafo_3w_tap_results.csv"), sep=";", decimal=",")

Expand All @@ -670,6 +670,41 @@ def test_trafo3w_tap(tap_pos, tap_side, tap_step_degree):
"index==@index & element=='bus' & variable==@variable").value,
rtol=0, atol=tol), f"failed for bus {index=}, {variable}, value {net.res_bus.at[index, variable]}"

@pytest.mark.parametrize("tap_pos", (2, 5))
@pytest.mark.parametrize("tap_side", ('hv', 'mv', 'lv'))
@pytest.mark.parametrize("tap_step_degree", (0, 15, 30))
def test_trafo3w_tap_neutral_not_zero(tap_pos, tap_side, tap_step_degree):
results = pd.read_csv(os.path.join(pp.pp_dir, "test", "test_files", "test_results_files", "trafo_3w_tap_results_neutral_not_zero.csv"), sep=";", decimal=",")

if results.query("tap_side == @tap_side & tap_pos == @tap_pos & tap_step_degree == @tap_step_degree").empty:
pytest.skip(f"Skipping combination: tap_side={tap_side}, tap_pos={tap_pos}, tap_step_degree={tap_step_degree}")

net = pp.from_json(os.path.join(pp.pp_dir, "test", "test_files","test_trafo3w_tap.json")) #

net.trafo3w.loc[[0, 1], 'tap_min'] += 3
net.trafo3w.loc[[0, 1], 'tap_max'] += 3
net.trafo3w.loc[[0, 1], 'tap_neutral'] += 3

net.trafo3w.loc[0, 'tap_at_star_point']= False
net.trafo3w.loc[1, 'tap_at_star_point']= True

net.trafo3w.loc[0, "tap_side"] = tap_side
net.trafo3w.loc[1, "tap_side"] = tap_side
net.trafo3w.loc[0, "tap_pos"] = tap_pos
net.trafo3w.loc[1, "tap_pos"] = tap_pos
net.trafo3w.loc[0, "tap_step_degree"] = tap_step_degree
net.trafo3w.loc[1, "tap_step_degree"] = tap_step_degree
pp.runpp(net)

for index in range(8):
for variable, tol in zip(("vm_pu", "va_degree"), (1e-6, 1e-3)):
assert np.isclose(net.res_bus.at[index, variable], results.query(
"tap_side==@tap_side & tap_pos==@tap_pos & tap_step_degree==@tap_step_degree &"
"index==@index & element=='bus' & variable==@variable").value,
rtol=0, atol=tol), f"failed for bus {index=}, {variable}, value {net.res_bus.at[index, variable]}"



def test_impedance(result_test_network, v_tol=1e-6, i_tol=1e-6, s_tol=5e-3, l_tol=1e-3):
net = result_test_network
buses = net.bus[net.bus.zone == "test_impedance"]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
tap_side;tap_pos;tap_step_degree;element;name;index;variable;value
hv;5;0;bus;0_Slack;0;vm_pu;1
hv;5;0;bus;0_Slack;0;va_degree;0
hv;5;0;bus;1_HV;1;vm_pu;0,998129
hv;5;0;bus;1_HV;1;va_degree;-0,093039
hv;5;0;bus;2_MV;2;vm_pu;0,898854
hv;5;0;bus;2_MV;2;va_degree;-0,686136
hv;5;0;bus;3_LV;3;vm_pu;0,903326
hv;5;0;bus;3_LV;3;va_degree;-0,394202
hv;5;0;bus;4_Slack;4;vm_pu;1
hv;5;0;bus;4_Slack;4;va_degree;0
hv;5;0;bus;5_HV;5;vm_pu;0,998127
hv;5;0;bus;5_HV;5;va_degree;-0,092972
hv;5;0;bus;6_MV;6;vm_pu;0,898367
hv;5;0;bus;6_MV;6;va_degree;-0,723542
hv;5;0;bus;7_LV;7;vm_pu;0,902842
hv;5;0;bus;7_LV;7;va_degree;-0,431292
hv;2;0;bus;0_Slack;0;vm_pu;1
hv;2;0;bus;0_Slack;0;va_degree;0
hv;2;0;bus;1_HV;1;vm_pu;0,998009
hv;2;0;bus;1_HV;1;va_degree;-0,092674
hv;2;0;bus;2_MV;2;vm_pu;1,042353
hv;2;0;bus;2_MV;2;va_degree;-0,583495
hv;2;0;bus;3_LV;3;vm_pu;1,046203
hv;2;0;bus;3_LV;3;va_degree;-0,366142
hv;2;0;bus;4_Slack;4;vm_pu;1
hv;2;0;bus;4_Slack;4;va_degree;0
hv;2;0;bus;5_HV;5;vm_pu;0,99801
hv;2;0;bus;5_HV;5;va_degree;-0,092708
hv;2;0;bus;6_MV;6;vm_pu;1,042629
hv;2;0;bus;6_MV;6;va_degree;-0,565781
hv;2;0;bus;7_LV;7;vm_pu;1,046477
hv;2;0;bus;7_LV;7;va_degree;-0,348542
mv;5;0;bus;0_Slack;0;vm_pu;1
mv;5;0;bus;0_Slack;0;va_degree;0
mv;5;0;bus;1_HV;1;vm_pu;0,998058
mv;5;0;bus;1_HV;1;va_degree;-0,092876
mv;5;0;bus;2_MV;2;vm_pu;1,089856
mv;5;0;bus;2_MV;2;va_degree;-0,555702
mv;5;0;bus;3_LV;3;vm_pu;0,993842
mv;5;0;bus;3_LV;3;va_degree;-0,374824
mv;5;0;bus;4_Slack;4;vm_pu;1
mv;5;0;bus;4_Slack;4;va_degree;0
mv;5;0;bus;5_HV;5;vm_pu;0,998055
mv;5;0;bus;5_HV;5;va_degree;-0,092822
mv;5;0;bus;6_MV;6;vm_pu;1,088759
mv;5;0;bus;6_MV;6;va_degree;-0,61575
mv;5;0;bus;7_LV;7;vm_pu;0,993837
mv;5;0;bus;7_LV;7;va_degree;-0,374788
mv;2;0;bus;0_Slack;0;vm_pu;1
mv;2;0;bus;0_Slack;0;va_degree;0
mv;2;0;bus;1_HV;1;vm_pu;0,998054
mv;2;0;bus;1_HV;1;va_degree;-0,092788
mv;2;0;bus;2_MV;2;vm_pu;0,9397
mv;2;0;bus;2_MV;2;va_degree;-0,653191
mv;2;0;bus;3_LV;3;vm_pu;0,993834
mv;2;0;bus;3_LV;3;va_degree;-0,374766
mv;2;0;bus;4_Slack;4;vm_pu;1
mv;2;0;bus;4_Slack;4;va_degree;0
mv;2;0;bus;5_HV;5;vm_pu;0,998055
mv;2;0;bus;5_HV;5;va_degree;-0,092822
mv;2;0;bus;6_MV;6;vm_pu;0,940291
mv;2;0;bus;6_MV;6;va_degree;-0,61575
mv;2;0;bus;7_LV;7;vm_pu;0,993837
mv;2;0;bus;7_LV;7;va_degree;-0,374788
lv;5;0;bus;0_Slack;0;vm_pu;1
lv;5;0;bus;0_Slack;0;va_degree;0
lv;5;0;bus;1_HV;1;vm_pu;0,998056
lv;5;0;bus;1_HV;1;va_degree;-0,092829
lv;5;0;bus;2_MV;2;vm_pu;0,989781
lv;5;0;bus;2_MV;2;va_degree;-0,615751
lv;5;0;bus;3_LV;3;vm_pu;1,093532
lv;5;0;bus;3_LV;3;va_degree;-0,356789
lv;5;0;bus;4_Slack;4;vm_pu;1
lv;5;0;bus;4_Slack;4;va_degree;0
lv;5;0;bus;5_HV;5;vm_pu;0,998055
lv;5;0;bus;5_HV;5;va_degree;-0,092822
lv;5;0;bus;6_MV;6;vm_pu;0,98978
lv;5;0;bus;6_MV;6;va_degree;-0,61575
lv;5;0;bus;7_LV;7;vm_pu;1,093221
lv;5;0;bus;7_LV;7;va_degree;-0,374788
lv;2;0;bus;0_Slack;0;vm_pu;1
lv;2;0;bus;0_Slack;0;va_degree;0
lv;2;0;bus;1_HV;1;vm_pu;0,998055
lv;2;0;bus;1_HV;1;va_degree;-0,092817
lv;2;0;bus;2_MV;2;vm_pu;0,98978
lv;2;0;bus;2_MV;2;va_degree;-0,61575
lv;2;0;bus;3_LV;3;vm_pu;0,943978
lv;2;0;bus;3_LV;3;va_degree;-0,385997
lv;2;0;bus;4_Slack;4;vm_pu;1
lv;2;0;bus;4_Slack;4;va_degree;0
lv;2;0;bus;5_HV;5;vm_pu;0,998055
lv;2;0;bus;5_HV;5;va_degree;-0,092822
lv;2;0;bus;6_MV;6;vm_pu;0,98978
lv;2;0;bus;6_MV;6;va_degree;-0,61575
lv;2;0;bus;7_LV;7;vm_pu;0,944145
lv;2;0;bus;7_LV;7;va_degree;-0,374788
hv;5;15;bus;0_Slack;0;vm_pu;1
hv;5;15;bus;0_Slack;0;va_degree;0
hv;5;15;bus;1_HV;1;vm_pu;0,998127
hv;5;15;bus;1_HV;1;va_degree;-0,093034
hv;5;15;bus;2_MV;2;vm_pu;0,901427
hv;5;15;bus;2_MV;2;va_degree;-2,035887
hv;5;15;bus;3_LV;3;vm_pu;0,905886
hv;5;15;bus;3_LV;3;va_degree;-1,74561
hv;5;15;bus;4_Slack;4;vm_pu;1
hv;5;15;bus;4_Slack;4;va_degree;0
hv;5;15;bus;5_HV;5;vm_pu;0,998125
hv;5;15;bus;5_HV;5;va_degree;-0,092969
hv;5;15;bus;6_MV;6;vm_pu;0,900955
hv;5;15;bus;6_MV;6;va_degree;-2,07209
hv;5;15;bus;7_LV;7;vm_pu;0,905417
hv;5;15;bus;7_LV;7;va_degree;-1,781509
hv;2;30;bus;0_Slack;0;vm_pu;1
hv;2;30;bus;0_Slack;0;va_degree;0
hv;2;30;bus;1_HV;1;vm_pu;0,998016
hv;2;30;bus;1_HV;1;va_degree;-0,092697
hv;2;30;bus;2_MV;2;vm_pu;1,034638
hv;2;30;bus;2_MV;2;va_degree;0,908979
hv;2;30;bus;3_LV;3;vm_pu;1,038516
hv;2;30;bus;3_LV;3;va_degree;1,129574
hv;2;30;bus;4_Slack;4;vm_pu;1
hv;2;30;bus;4_Slack;4;va_degree;0
hv;2;30;bus;5_HV;5;vm_pu;0,998017
hv;2;30;bus;5_HV;5;va_degree;-0,092725
hv;2;30;bus;6_MV;6;vm_pu;1,034873
hv;2;30;bus;6_MV;6;va_degree;0,924241
hv;2;30;bus;7_LV;7;vm_pu;1,038751
hv;2;30;bus;7_LV;7;va_degree;1,144736
Loading