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

Fix bypass_pf...() #2267

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
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
40 changes: 39 additions & 1 deletion pandapower/test/loadflow/test_runpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,30 @@ def test_pypower_algorithms_iter():
net.last_added_case)


def test_bypass_pf():
net2 = pp.create_empty_network()
pp.create_buses(net2, 2, 380, index=[1, 2])
pp.create_line(net2, 1, 2, 150, '490-AL1/64-ST1A 380.0')
pp.create_ext_grid(net2, 1)
pp.create_ext_grid(net2, 2, va_degree=2)

net3 = pp.create_empty_network()
pp.create_buses(net3, 3, 380, index=[1, 2, 3])
pp.create_lines(net3, [1, 2], [2, 3], 75, '490-AL1/64-ST1A 380.0')
pp.create_ext_grid(net3, 1)
pp.create_ext_grid(net3, 3, va_degree=2)

pp.runpp(net2, calculate_voltage_angles=True) # _bypass_pf_and_set_results() is used internally
pp.runpp(net3, calculate_voltage_angles=True)

assert np.allclose(net2.res_bus.values, net3.res_bus.values[[0, 2], :])
assert np.allclose(net2.res_ext_grid.values, net3.res_ext_grid.values, atol=1e-4)
line_cols = pd.Series(net2.res_line.columns)
line_cols = list(line_cols.loc[line_cols.str.contains("_to_")])
assert np.allclose(net2.res_line[line_cols].iloc[-1], net3.res_line[line_cols].iloc[-1])
assert np.isclose(net2.res_line.at[0, "pl_mw"], net3.res_line["pl_mw"].sum())


@pytest.mark.xfail
def test_zip_loads_gridcal():
# Tests newton power flow considering zip loads against GridCal's pf result
Expand Down Expand Up @@ -1473,4 +1497,18 @@ def test_lightsim2grid_option():


if __name__ == "__main__":
pytest.main([__file__, "-xs"])
test_bypass_pf()
# pytest.main([__file__])
# test_minimal_net()
# net = pp.create_empty_network()
# b = pp.create_bus(net, 110)
# pp.create_ext_grid(net, b)
# runpp_with_consistency_checks(net)
#
# pp.create_load(net, b, p_mw=0.1)
# runpp_with_consistency_checks(net)
#
# b2 = pp.create_bus(net, 110)
# pp.create_switch(net, b, b2, 'b')
# pp.create_sgen(net, b2, p_mw=0.2)
# runpp_with_consistency_checks(net)
Loading