e2nIEE / pandapower

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

[feature] KeyError: 'bus_dc' #2413

Open quant12345 opened 1 month ago

quant12345 commented 1 month ago

Feature Checklist

Feature Type

Problem Description

In the julia build (3.9, 2) I see three tests with an error: KeyError: 'bus_dc'. I assume this is because a non-existent key is being accessed. results.py -> _get_aranged_lookup - row 83

this line: if len(net[bus_table]) == 0:

Running the test: pytest pandapower/test/opf/test_pandamodels_runpm.py::test_runpm_multi_vstab

I tried adding setdefault before the line that causes the error:

net.setdefault(bus_table, np.array([], dtype=np.int64))# creates a dictionary key if it doesn't exist

but another error occurs:

FAILED pandapower/test/opf/test_pandamodels_runpm.py::test_runpm_multi_vstab - AttributeError: 'numpy.ndarray' object has no attribute 'index'

I haven't been able to figure out how the 'bus_dc' data is formed yet. Or is it in development and not ready yet?

Feature Description

Additional Context

No response

Label

yasirroni commented 1 month ago

Hi @quant12345, can you test this on matpowercaseframes to? PowerModels accept arbitrary data as far as I know and matpowercaseframes not implemented that yet.

quant12345 commented 1 month ago

Hi @yasirroni, my modest knowledge in this area is not enough. I have not yet figured out how the data is formed. I can assume that a dataframe should be created in the 'bus_dc' table, but it is not clear where it is formed. The error clearly says that there is no such key in the dictionary. You created a topic today, I saw that it concerns julia. In Actions I saw

the following failure: ``` FAILED pandapower/test/opf/test_TNEP.py::test_pm_tnep_cigre_dc - julia.core.JuliaError: Exception 'LoadError: ArgumentError: Package PandaModels does not have PowerModels in its dependencies: - You may have a partially installed environment. Try `Pkg.instantiate()` to ensure all packages in the environment are installed. - Or, if you have PandaModels checked out for development and have added PowerModels as a dependency but haven't updated your primary environment's manifest file, try `Pkg.resolve()`. - Otherwise you may need to report an issue with PandaModels in expression starting at /home/runner/.julia/packages/PandaModels/H0sdB/src/PandaModels.jl:1' occurred while calling julia code: using PandaModels FAILED pandapower/test/opf/test_TNEP.py::test_pm_tnep_cigre_ac_S - julia.core.JuliaError: Exception 'UndefVarError: `run_powermodels_tnep` not defined' occurred while calling julia code: run_powermodels_tnep(buffer_file) FAILED pandapower/test/opf/test_pandamodels_runpm.py::test_compare_pwl_and_poly - pandapower.auxiliary.OPFNotConverged: PowerModels.jl OPF not converged FAILED pandapower/test/opf/test_pandamodels_runpm.py::test_without_ext_grid - pandapower.auxiliary.OPFNotConverged: PowerModels.jl OPF not converged FAILED pandapower/test/opf/test_pandamodels_runpm.py::test_storage_opt - KeyError: 'bus_dc' FAILED pandapower/test/opf/test_pandamodels_runpm.py::test_runpm_multi_vstab - KeyError: 'bus_dc' FAILED pandapower/test/opf/test_pandamodels_runpm.py::test_runpm_qflex_and_multi_qflex - KeyError: 'bus_dc' ```

I have the same thing locally in tests, except for the lines with FAILED pandapower/test/opf/test_TNEP.py.

yasirroni commented 1 month ago

Hi @quant12345, I finally success installing PandaModels. Now, I'm also stuck with this same issue, that is bus_dc.

SimonUlm commented 1 month ago

I think this is caused by the commit fcf7bd7ea659c86d7c95b8eb61a7aaee786d3b4b. This also makes the SimBench plugin unusable.

yasirroni commented 1 month ago

Change to stable branch on master, test passed. Thanks @SimonUlm.

vogt31337 commented 1 day ago

@quant12345 is this stil relevant?

quant12345 commented 1 day ago

@vogt31337 I saw that in PR #2455 tests for julia (3.9, 2) pass. Need to ask @mfranz13 if there will be any more fixes in the code?

mfranz13 commented 22 hours ago

There was some unnecessary key dropping from the net object in the result extraction from PandaModels. Thanks for mentioning this issue to me.