e2nIEE / pandapower

Convenient Power System Modelling and Analysis based on PYPOWER and pandas
https://www.pandapower.org
Other
888 stars 484 forks source link

pp.runopp is not working with a trafo included #1377

Open SimonRubenDrauz opened 3 years ago

SimonRubenDrauz commented 3 years ago

It seems like a grid having a trafo is not converging when performing an OPF. See following example:

net = pp.create_empty_network()

b1 = pp.create_bus(net, 10)
b2 = pp.create_bus(net, 0.4)
b3 = pp.create_bus(net, 0.4)

pp.create_line(net, b2, b3, 1, 'NAYY 4x120 SE')

pp.create_transformer(net, b1, b2, std_type='0.25 MVA 10/0.4 kV')

pp.create_load(net, b3, 0.1)

g1 = pp.create_gen(net, b1, 0.5, min_p_mw=0, max_p_mw=0.5,controllable=True, slack=True,
                        min_vm_pu=0.99, max_vm_pu=1.1)

pp.create_poly_cost(net, g1, 'gen', cp1_eur_per_mw=50)

pp.runopp(net)

The OPF is not converging. However, as soon as I set the trafo out of service and connect the generator to b2, it works:

net.trafo.in_service=False net.gen.bus = b2

Is there a good reason for this behavior? (In both cases runpp is working)

SimonRubenDrauz commented 3 years ago

Okay, I found a reason why this causes a problem. If I set the shift_degree of the trafo, which is 150, equal to zero it works. Do you know why?

SimonRubenDrauz commented 3 years ago

We checked it with AMPL. It seems that the pypower OPF implementation/solver got some problems when it needs to consider the angles as well

angelinasyrri commented 2 years ago

Hi! I am looking now at this issue and I wonder whether I face a similar one, with my issue #1526. I also have 4 transformers and I changed the shift_degree to zero but still, it does not converge. Any help on what I could check? I have tried all the obvious actions (changing the limits of transformers and lines, reducing the load/gen, increasing the limits of reactive power ) but nothing works.

downbydawn commented 1 year ago

Thank you SimonRubenDrauz, your workaround worked for my problem, too.

Also, I tried working out the problem with an example similar to the tutorial (https://github.com/FlorianShepherd/pandapower-youtube/blob/master/scripts/simple_opf.py). It had convergence issues as well. While it did converge under specific settings, it resulted in odd voltage levels near 0 pu and a loss of 5 mw in the trafo. Since a converged problem might help to solve the problem, I will link it below.

import pandapower as pp

net = pp.create_empty_network()

#create buses
bus1 = pp.create_bus(net, vn_kv=110.)
bus2 = pp.create_bus(net, vn_kv=20.)
bus3 = pp.create_bus(net, vn_kv=20.)
bus4 = pp.create_bus(net, vn_kv=20)

#create 110/20 kV transformer
pp.create_transformer(net, 0, 1, std_type="40 MVA 110/20 kV")

#create 20 kV lines
pp.create_line(net, 1, 2, length_km=10., std_type='NA2XS2Y 1x95 RM/25 12/20 kV')
pp.create_line(net, 2, 3, length_km=10., std_type='NA2XS2Y 1x95 RM/25 12/20 kV')
pp.create_line(net, 3, 1, length_km=10., std_type='NA2XS2Y 1x95 RM/25 12/20 kV')

#create loads
pp.create_load(net, 1, p_mw=6, controllable=False)
pp.create_load(net, 2, p_mw=7, controllable=False)
pp.create_load(net, 3, p_mw=1, controllable=False)

#create generators
eg = pp.create_ext_grid(net, 0, min_p_mw=-100, max_p_mw=100,  min_q_mvar=-1000, max_q_mvar=1000)
g1 = pp.create_sgen(net, 2, p_mw=8, min_p_mw=0, max_p_mw=8,  min_q_mvar=0, max_q_mvar=0, controllable=True)
g2 = pp.create_sgen(net, 3, p_mw=10, min_p_mw=0, max_p_mw=10, min_q_mvar=0, max_q_mvar=0, controllable=True)

s0 = pp.create_storage(net, 1, p_mw=0, min_p_mw=-6, max_p_mw=6, min_q_mvar=0, max_q_mvar=0, soc_percent=0, min_e_mwh=0, max_e_mwh=10, controllable=True)

costeg = pp.create_poly_cost(net, 0, 'ext_grid', cp1_eur_per_mw=0, cp2_eur_per_mw2=10)

pp.runopp(net, delta=1e-16)
net.res_bus.vm_pu 
0    1.000000e+00
1    8.331277e-13
2    5.377548e-07
3    7.110324e-07
Name: vm_pu, dtype: float64

net.res_trafo.pl_mw
0    5.186637
Name: pl_mw, dtype: float64