Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

lpf() and pf() fail on stochastic networks

Aperta
#1,979 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à
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Start with pypsa/network/graph.py:294 and the inds handling in pypsa/network/power_flow.py:106 and :1855; the report links the latter to #1977. Run the supplied reproducible example on the current master branch and check how lpf() and pf() handle scenario-indexed buses and components. Done means both run per scenario, or fail fast with a clear NotImplementedError stating stochastic networks are unsupported.

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

Descrizione

AC power flow needs triage reliability & uncertainty

[!NOTE]
This issue was drafted with AI assistance.

Version Checks (indicate both or one)
  • I have confirmed this bug exists on the lastest release of PyPSA.
  • I have confirmed this bug exists on the current master branch of PyPSA.
Issue Description

n.lpf() and n.pf() fail on stochastic networks (after n.set_scenarios(...)). The error comes from incidence_matrix in pypsa/network/graph.py:294, where the bus lookup gives -1 for (scenario, name) indexed buses, and scipy rejects the negative index.

Related: pypsa/network/power_flow.py:106 and :1855 pass c.static.query("active").index as inds to get_switchable_as_dense. On a stochastic network this is a (scenario, name) MultiIndex, but inds is matched on the name level only, so the result is silently empty (see #1977).

Reproducible Example
import pypsa

n = pypsa.Network()
n.set_snapshots(range(2))
n.add("Bus", ["a", "b"], v_nom=380)
n.add("Line", "l", bus0="a", bus1="b", x=0.1, r=0.01, s_nom=100)
n.add("Generator", "g", bus="a", p_set=50, control="Slack")
n.add("Load", "d", bus="b", p_set=50)
n.set_scenarios(["s1", "s2"])

n.lpf()  # ValueError: negative axis 0 index: -1
n.pf()   # ValueError: negative axis 1 index: -1
Expected Behavior

Power flow runs per scenario, or fails fast with a clear NotImplementedError saying that power flow does not support stochastic networks.

Installed Versions
  • PyPSA master d371a505
Lingua principale
Python
Stelle
2.2k
Fork
712
Merge medio
1g 13h
PR unite (30g)
34

Preparare l'ambiente

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 PyPSA/PyPSA

Tutte le issue di PyPSA/PyPSA

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.