Skip to content

docs(pypsa): the cycle rows read each investment period's own cycle basis - #814

Merged
FabianHofmann merged 17 commits into
mainfrom
docs/pypsa-network-periods
Oct 2, 2026
Merged

FabianHofmann merged 17 commits into
mainfrom
docs/pypsa-network-periods

Conversation

@FabianHofmann

Copy link
Copy Markdown
Contributor

Prompt: Continue PyPSA parity for energy-models/mathspec: implement step 4 of the plan in tracking issue #783. Step 4 covers the parity items the language can already state. Run it as an ultracode workflow with at most 4 agents, one PR per group.

Note

The following content was generated by AI.

Kirchhoff_Voltage_Law now reads the cycle basis of each snapshot's investment period, as PyPSA does. Rung 66 records a line that closes a mesh in 2030, and the empty security copies linopy counts. Part of #783; stacks on #787 and #786.

Method, gate output, PyPSA cites, what is not done

What changed

  • examples/pypsa.yaml: Line_cycle_weight, Transformer_cycle_weight and Transformer_phase_shift_cycle_weight span [period, …, cycle]. Line_angle_sum and Transformer_angle_sum read them with at(…, by=snapshot_period, over=period, into=snapshot). The cycle dimension and Kirchhoff_Voltage_Law say that a label is a position in its period's basis. A cycle label that a period's basis does not reach has no weight there, so the row has no variable and is not built. No language work was needed.
  • tests/test_pypsa_collapses.py: a standard parameter may gain a leading period as well as a leading scenario. With one period the frame collapses to the standard one. The docstring no longer calls period "mask-only".
  • Rung 66 (rung_66_cycles_per_period.py): optimize_security_constrained(multi_investment_periods=True), outage ca66. Lines ab66, bc66 form a path in 2020. ca66 comes in with 2030 and closes a triangle. PyPSA builds 2 Kirchhoff-Voltage-Law rows (2030 only) and solves to 16000.0.
  • docs/examples/pypsa.md: a rung 66 section; rows in the rung 6 and rung 15 tables; the rung 30 row "a branch not active in a period" now points at rung 66 and has the status split.

PyPSA cites (02bdcbba)

  • Cycles per period: constraints.py:1640-1652. window.iter_periods() yields one (None, all snapshots) pair without multi_investment_periods (window.py:173-175). cycle_matrix(investment_period=…) drops the branches that are not active in that period (networks.py:1278-1281).
  • Empty security rows: abstract.py:472-489. In rung 66 each of Line-fix-s-lower-security-… and -upper-… has 12 rows. 2 of them, 2020 × monitored ca66 × outage ca66, read +0 ≥ -40. The file builds the other 10 of each. The feasible set is the same.

Measured (this PR)

  • A single basis over all branches would hold the 2020 snapshots to the triangle's row with ca66 absent. That forces zero flow on ab66 and bc66. PyPSA on the same network without those lines in 2020 solves to 43900.0, against 16000.0. The page cites this PR for the number.

Gates

  • pixi run python -m tools.pypsa_split split examples/pypsa && pixi run python -m tools.gallery: regenerated examples/pypsa/{line,transformer,power_flow}.yaml and their pages.
  • uv run --script examples/references/pypsa/reference.py: only rung_66_cycles_per_period is new in references.json. Every other record is unchanged.
  • uv run --script examples/references/pypsa/reference.py --check: "every rung solves to its record".
  • pixi run lint: pass. pixi run ci: exit 0, 2626 passed, docs-build and compile-tex done.

Not done, and found on the way

@FBumann FBumann added the docs Documentation pages, guides, reference and README label Oct 1, 2026
@read-the-docs-community

read-the-docs-community Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

@FabianHofmann
FabianHofmann force-pushed the docs/pypsa-fixed-modular branch from df7f835 to 34af2a0 Compare October 2, 2026 09:06
@FabianHofmann
FabianHofmann changed the base branch from docs/pypsa-fixed-modular to main October 2, 2026 09:11
…riods

# Conflicts:
#	CHANGELOG.md
#	docs/examples/pypsa.md
#	docs/examples/pypsa/line.md
#	docs/examples/pypsa/link.md
#	docs/examples/pypsa/transformer.md
#	examples/pypsa.yaml
#	examples/pypsa/line.yaml
#	examples/references/pypsa/references.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation pages, guides, reference and README

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants