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] run_contingency_ls2g doesn't work when there are redundant buses #2438

Open
6 tasks done
awarsewa opened this issue Nov 5, 2024 · 1 comment
Open
6 tasks done
Labels

Comments

@awarsewa
Copy link
Contributor

awarsewa commented Nov 5, 2024

Bug report checklis

  • Searched the issues page for similar reports

  • Read the relevant sections of the documentation

  • Browse the tutorials and tests for usefull code snippets and examples of use

  • Reproduced the issue after updating with pip install --upgrade pandapower (or git pull)

  • Tried basic troubleshooting (if a bug/error) like restarting the interpreter and checking the pythonpath

Reproducible Example

import pandapower.networks as pn
import pandapower.contingency as pc
import pandapower as pp 

net = pn.case30()
# Create a redundant bus
pp.create_bus(net, vn_kv=135, name="31", index=30, zone="3.0", max_vm_pu =1.05, min_vm_pu=0.95) # create a new bus
pp.create_switch(net, bus=30, element=29, et="b", type="CB", closed=True) # create a new switch

# Try running contingency analysis
nminus1_cases = {
    "line": {"index": net.line.index.values},
    "gen": {"index": net.gen.index.values}
}
# Running contingency analysis here should fail
pc.run_contingency_ls2g(net, nminus1_cases)

Issue Description and Traceback

When there is a redundant bus, the size of Vinit is not equal to the number of buses anymore.
I had originally reported this in issue#2361 and finally wrote an example that reproduces this behaviour.

Traceback (most recent call last):
File "c:\Users\XXX\Python\pandapower\test_pp_ls2g.py", line 14, in
pc.run_contingency_ls2g(net, nminus1_cases)
File "C:\Users\XXX\anaconda3\envs\pandapower\Lib\site-packages\pandapower\contingency\contingency.py", line 225, in run_contingency_ls2g
s.compute(v_init, net._options["max_iteration"], net._options["tolerance_mva"])
RuntimeError: SecurityAnalysis::compute: Size of the Vinit should be the same as the total number of buses. Currently: Vinit: 30 and there are 31 buses.(fyi: Components of Vinit corresponding to deactivated bus will be ignored anyway, so you can put whatever you want there).

Expected Behavior

run_contingency_ls2g should be able to handle redundant buses e. g. by:

v_init = net._ppc["internal"]["V"][net._pd2ppc_lookups["bus"]]

Installed Versions

INSTALLED VERSIONS

commit : 0691c5cf90477d3503834d983f69350f250a6ff7
python : 3.12.7
python-bits : 64
OS : Windows
OS-release : 11
Version : 10.0.22631
machine : AMD64
processor : Intel64 Family 6 Model 140 Stepping 1, GenuineIntel
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : English_Australia.1252

pandas : 2.2.3
numpy : 1.26.4
pytz : 2024.2
dateutil : 2.9.0.post0
pip : 24.3.1
Cython : None
sphinx : None
IPython : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : None
lxml.etree : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : None
pyreadstat : None
pytest : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.13.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2024.2
qtpy : None
pyqt5 : None

Label

  • Relevant labels are selected
@awarsewa awarsewa added the bug label Nov 5, 2024
@vogt31337
Copy link
Contributor

@awarsewa, id I understand you correctly this issue can be solved by using your reply: #2361 (comment) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants