e2nIEE / pandapower

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

[bug] Wrong direction of transformers when importing .m files #2409

Open SimonUlm opened 1 month ago

SimonUlm commented 1 month ago

Bug report checklis

Reproducible Example

from pandapower.converter.matpower.from_mpc import _m2ppc

file = 'pglib_opf_case24_ieee_rts.m'
ppc_before = _m2ppc(file, 'mpc')
net = pp.converter.from_mpc(file)
ppc_after = pp.converter.to_ppc(net, init='flat')

Issue Description and Traceback

Note

The file mentioned above is from the pglib-opf library.

Issue

When comparing ppc_before['branch'] and ppc_after['branch'], you will notice that the from and to buses of all transformers have been swapped. However, the tap ratios remain the same, which will result in wrong results in pf and opf calculations. Afaik this is due to _fromppc.py (lines 241 to 245) where hv_bus and lv_bus are swapped in case the base voltage of the from bus is less than the base voltage if the to bus, but the tap ratio and phase shift remain the same.

Expected Behavior

The pandapower case structure should contain the correct direction of the transformer or at least contain information to restore the original direction.

Installed Versions

Label

vogt31337 commented 4 weeks ago

Hi, interesting error. I'll discuss it with some people. I am wondering that this problem hasn't surfaced earlier, since pandapower is basically built around the matpower architecture. And I am confused why the tests don't capture it...

vogt31337 commented 4 weeks ago

Discussed this a little, seems to be a really weird setup, since normally you would connect the HV-Side of a transformer to the higher voltage in a grid model and the LV-Side of the transformer to the lower voltage. Your suggest that this was flipped in your example and therefore errors occured. I'd suggest repairing your examples / test cases. But still this should be at least communicated to the user.

SimonUlm commented 2 weeks ago

Hi, thank you very much for your reply and sorry for my very late response. I agree that this setting is rather unusual. However, this wasn't just any test case, but a pglib-opf (former NESTA) test case which are considered state-of-the-art benachmarking test cases by many. (Especially when it comes to convex relaxation, which is admittedly not the focus of pandapower, yet). Also, this wasn't the only test case having this issue. Therefore, I think this issue should be addressed. Either by communicating it to the user (as you already suggested) or recalculate the tap ratio. Personally, I would prefer the latter.