Issue Description and Traceback
When running runopp and having it fail with OPF did not converge there may be residual gen elements in the net if a dcline is in the network. This leads to unexpected behavior on consecutive runs.
Expected Behavior
The run functions should do a teardown of helper elements regardless of the success or failure.
Reproducible Example
from pandapower import pandapowerNet
from pandapower.create import (
create_bus,
create_lines,
create_dcline,
create_ext_grid,
create_load,
create_poly_cost
)
from pandapower.run import runpp, runopp
from pandapower.create._utils import add_column_to_df
net = pandapowerNet(name="opf dcline")
b1 = create_bus(net, 380)
b2 = create_bus(net, 380)
b3 = create_bus(net, 380)
b4 = create_bus(net, 380)
b5 = create_bus(net, 380)
l1, l2, l3 = create_lines(net, [b1, b3, b4], [b2, b4, b5], [30, 20, 20], "490-AL1/64-ST1A 380.0")
dcl1 = create_dcline(net, name="dc line", from_bus=b2, to_bus=b3, p_mw=200, loss_percent=1.0,
loss_mw=0.5, vm_from_pu=1.01, vm_to_pu=1.012, max_p_mw=1000,
in_service=True)
eg1 = create_ext_grid(net, b1, 1.02, min_p_mw=0.)
eg2 = create_ext_grid(net, b5, 1.02, min_p_mw=0.)
l1 = create_load(net, bus=b4, p_mw=800, controllable=False)
runpp(net)
costeg0 = create_poly_cost(net, 0, 'ext_grid', cp1_eur_per_mw=10)
costeg1 = create_poly_cost(net, 1, 'ext_grid', cp1_eur_per_mw=8)
net.bus['max_vm_pu'] = 1.5
net.line['max_loading_percent'] = 1000
add_column_to_df(net, "dcline", "min_q_from_mvar")
add_column_to_df(net, "dcline", "max_q_from_mvar")
add_column_to_df(net, "dcline", "min_q_to_mvar")
add_column_to_df(net, "dcline", "max_q_to_mvar")
runopp(net, delta=1e-16)
net.poly_cost.cp1_eur_per_mw.at[costeg0] = 8
net.poly_cost.cp1_eur_per_mw.at[costeg1] = 10
runopp(net, delta=1e-16)
net.line["max_loading_percent"] = 100
# add missing columns to gen
add_column_to_df(net, "gen", "min_q_mvar")
add_column_to_df(net, "gen", "max_q_mvar")
add_column_to_df(net, "load", "sn_mva")
runopp(net, delta=1e-16)
Installed Versions
Version used is release/v4.0.0 but this most likely also affects develop.
The opp in the above example does not fail on the develop branch, so I could not test it there.
Issue Description and Traceback
When running
runoppand having it fail withOPF did not convergethere may be residual gen elements in the net if a dcline is in the network. This leads to unexpected behavior on consecutive runs.Expected Behavior
The run functions should do a teardown of helper elements regardless of the success or failure.
Reproducible Example
Installed Versions
Version used is release/v4.0.0 but this most likely also affects develop.
The opp in the above example does not fail on the develop branch, so I could not test it there.