[BUG] PowerModels export: wrong `s_base` scaling, `to_powermodels` mutates its input, `from_powermodels` fails for a JSON path

Aperta
#862 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
54/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend, databases

Direzione di ricerca

Start with edisgo/io/powermodels_io.py at the listed _build_branch, to_powermodels and from_powermodels locations, then read the four strict xfail tests in tests/properties/test_properties_io.py. Check the unit conversions, repeatability, and JSON-path behavior against the passing scaling tests in the same classes. Done means all four xfail cases pass and the existing scaling checks remain passing.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area: opf bug correctness priority: medium

Summary

With the default s_base = 1 the first two errors cancel out; they show as soon as another s_base is used.

  1. _build_branch multiplies b and g by s_base. The admittance base is S_base / U², so they must be divided.
  2. The initial and final storage states are not divided by s_base, while the capacities are:
    • batteries: soc_initial/soc_end in MWh vs. energy_rating
    • thermal storage: soc_initial/soc_end vs. capacity
    • charging points: initial energy vs. e_min/e_max
  3. to_powermodels overwrites overlying_grid.storage_units_soc and heat_storage_units_soc with energies in MWh (SoC · capacity). A second call on the same object multiplies by the capacity again, so soc_initial changes between calls.
  4. from_powermodels reads pm_results["nw"] instead of the parsed dict when pm_results is a path to a JSON file → TypeError: string indices must be integers.

Where

  • edisgo/io/powermodels_io.py:874 _build_branch.
  • edisgo/io/powermodels_io.py:1128-1148 (overwrite of storage_units_soc), storage and charging point builders in the same module.
  • edisgo/io/powermodels_io.py:317 from_powermodels.

How to reproduce

Tests (strict xfail, added in #856):

  • tests/properties/test_properties_io.py::TestPowerModelsUnits::test_line_susceptance_in_siemens[10]
  • tests/properties/test_properties_io.py::TestPowerModelsUnits::test_s_base_rescales_storage_states[storage|heat_storage|electromobility]
  • tests/properties/test_properties_io.py::TestPowerModelsMapping::test_to_powermodels_is_repeatable
  • tests/properties/test_properties_io.py::TestFromPowerModels::test_json_path_equals_dict

The passing tests in the same classes check that powers, impedances of lines and single transformers and time series scale correctly with s_base.

Proposed fix

  1. Divide b, g by the admittance base.
  2. Divide all energies by s_base.
  3. Work on a copy of the SoC series in to_powermodels.
  4. Use the parsed dict in from_powermodels.

Related

#822 (to_powermodels passes wrong flexibility data), #753 (battery storage overlying-grid requirement).

Lingua principale
Python
Stelle
48
Fork
22
Merge medio
1g 16h
PR unite (30g)
36

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di openego/eDisGo

Tutte le issue di openego/eDisGo

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.