From cb3d5cea8dbe6c621f0463826c6bc201814a338f Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 1 Oct 2026 12:58:00 +0000 Subject: [PATCH 1/2] docs: every spec in the docs and examples opens with its given block Each spec that reads another file's names now puts its `given:` block first, after its `description:`. The PyPSA splitter writes its fragments in that order, and the gallery pages are regenerated. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_019i7xNVeQzGJykmE9id6w51 --- docs/examples/library/generator.md | 12 +-- docs/examples/library/load.md | 10 +- docs/examples/library/surface.md | 6 +- docs/examples/pypsa/carrier.md | 8 +- docs/examples/pypsa/cost.md | 16 +-- docs/examples/pypsa/generator.md | 44 ++++---- docs/examples/pypsa/generator_commitment.md | 44 ++++---- docs/examples/pypsa/generator_maintenance.md | 26 ++--- docs/examples/pypsa/generator_ramping.md | 38 +++---- docs/examples/pypsa/global_constraints.md | 20 ++-- docs/examples/pypsa/line.md | 26 ++--- docs/examples/pypsa/link.md | 40 +++---- docs/examples/pypsa/link_commitment.md | 44 ++++---- docs/examples/pypsa/link_maintenance.md | 26 ++--- docs/examples/pypsa/link_ramping.md | 38 +++---- docs/examples/pypsa/load.md | 8 +- docs/examples/pypsa/network.md | 18 ++-- docs/examples/pypsa/power_flow.md | 16 +-- docs/examples/pypsa/process.md | 36 +++---- docs/examples/pypsa/process_commitment.md | 44 ++++---- docs/examples/pypsa/process_maintenance.md | 26 ++--- docs/examples/pypsa/process_ramping.md | 38 +++---- docs/examples/pypsa/security.md | 30 +++--- docs/examples/pypsa/settings.md | 104 +++++++++---------- docs/examples/pypsa/storage_unit.md | 38 +++---- docs/examples/pypsa/store.md | 38 +++---- docs/examples/pypsa/transformer.md | 18 ++-- docs/howto/compose.md | 42 ++++---- docs/reference/language/declarations.md | 40 +++---- docs/several-files.md | 44 ++++---- examples/library/generator.yaml | 12 +-- examples/library/load.yaml | 10 +- examples/library/surface.yaml | 6 +- examples/pypsa/carrier.yaml | 8 +- examples/pypsa/cost.yaml | 16 +-- examples/pypsa/generator.yaml | 44 ++++---- examples/pypsa/generator_commitment.yaml | 44 ++++---- examples/pypsa/generator_maintenance.yaml | 26 ++--- examples/pypsa/generator_ramping.yaml | 38 +++---- examples/pypsa/global_constraints.yaml | 20 ++-- examples/pypsa/line.yaml | 26 ++--- examples/pypsa/link.yaml | 40 +++---- examples/pypsa/link_commitment.yaml | 44 ++++---- examples/pypsa/link_maintenance.yaml | 26 ++--- examples/pypsa/link_ramping.yaml | 38 +++---- examples/pypsa/load.yaml | 8 +- examples/pypsa/network.yaml | 18 ++-- examples/pypsa/power_flow.yaml | 16 +-- examples/pypsa/process.yaml | 36 +++---- examples/pypsa/process_commitment.yaml | 44 ++++---- examples/pypsa/process_maintenance.yaml | 26 ++--- examples/pypsa/process_ramping.yaml | 38 +++---- examples/pypsa/security.yaml | 30 +++--- examples/pypsa/settings.yaml | 104 +++++++++---------- examples/pypsa/storage_unit.yaml | 38 +++---- examples/pypsa/store.yaml | 38 +++---- examples/pypsa/transformer.yaml | 18 ++-- tools/pypsa_split.py | 6 +- 58 files changed, 878 insertions(+), 878 deletions(-) diff --git a/docs/examples/library/generator.md b/docs/examples/library/generator.md index 354fc6b5..1be19a03 100644 --- a/docs/examples/library/generator.md +++ b/docs/examples/library/generator.md @@ -32,12 +32,6 @@ description: >- PyPSA's `Generator`, wired to a port rather than straight to a bus, and cut to what a dispatch spec needs: a fixed build, no availability profile, no ramp limits. -dimensions: - snapshot: { dtype: datetime, description: dispatch periods } - port: { dtype: str, description: "the connections components make, one label per connection" } - generator: { dtype: str, description: "generating units, each on one port" } -relations: - Generator_port: { key: generator, values: port } given: variables: Port_p: @@ -45,6 +39,12 @@ given: description: the surface introduces this flow, and this file pins it at its own ports expressions: total_cost: { dims: [] } +dimensions: + snapshot: { dtype: datetime, description: dispatch periods } + port: { dtype: str, description: "the connections components make, one label per connection" } + generator: { dtype: str, description: "generating units, each on one port" } +relations: + Generator_port: { key: generator, values: port } parameters: Generator_p_nom: { dims: [generator], description: nominal power } Generator_marginal_cost: { dims: [generator], description: cost of one unit of output } diff --git a/docs/examples/library/load.md b/docs/examples/library/load.md index ece3e87f..710aebf9 100644 --- a/docs/examples/library/load.md +++ b/docs/examples/library/load.md @@ -15,17 +15,17 @@ withdrawal is a negative injection. ```yaml description: PyPSA's `Load`, wired to a port rather than straight to a bus. What it takes is data, so it decides nothing. +given: + variables: + Port_p: + dims: [snapshot, port] + description: the surface introduces this flow, and this file pins it at its own ports dimensions: snapshot: { dtype: datetime, description: dispatch periods } port: { dtype: str, description: "the connections components make, one label per connection" } load: { dtype: str, description: "demands, each on one port" } relations: Load_port: { key: load, values: port } -given: - variables: - Port_p: - dims: [snapshot, port] - description: the surface introduces this flow, and this file pins it at its own ports parameters: Load_p_set: { dims: [snapshot, load], description: "`Load-p_set` — what a load takes in a snapshot" } constraints: diff --git a/docs/examples/library/surface.md b/docs/examples/library/surface.md index b926db62..0856ee3b 100644 --- a/docs/examples/library/surface.md +++ b/docs/examples/library/surface.md @@ -30,6 +30,9 @@ description: >- wired to a port, the port to a bus, and the balance names no component class. A flow is positive where the port injects into its bus. A component that costs something adds its cost to `total_cost`. +given: + expressions: + total_cost: { dims: [], description: what running the system costs } dimensions: snapshot: { dtype: datetime, description: dispatch periods } bus: { dtype: str, description: network nodes } @@ -45,9 +48,6 @@ constraints: description: "`Bus-nodal_balance` — what the ports on a bus put in nets to nothing" dims: [snapshot, bus] expression: sum(Port_p, by=Port_bus, over=port, into=bus) == 0 -given: - expressions: - total_cost: { dims: [], description: what running the system costs } objective: sense: minimize expression: total_cost diff --git a/docs/examples/pypsa/carrier.md b/docs/examples/pypsa/carrier.md index aaa4e562..3075d184 100644 --- a/docs/examples/pypsa/carrier.md +++ b/docs/examples/pypsa/carrier.md @@ -9,6 +9,10 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: the growth limits ```yaml +given: + expressions: + Carrier_additions: { dims: [period, carrier] } + dimensions: period: description: investment periods — PyPSA's `investment_periods` @@ -31,10 +35,6 @@ parameters: least over the scenarios, as PyPSA takes it, data prep dims: [carrier] -given: - expressions: - Carrier_additions: { dims: [period, carrier] } - expressions: Carrier_relative_growth: description: >- diff --git a/docs/examples/pypsa/cost.md b/docs/examples/pypsa/cost.md index f4d1174c..d4bca3d3 100644 --- a/docs/examples/pypsa/cost.md +++ b/docs/examples/pypsa/cost.md @@ -9,6 +9,14 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: the expected opera ```yaml +given: + parameters: + scenario_weight: { dims: [scenario] } + CVaR_omega: { dims: [] } + expressions: + scenario_opex: { dims: [scenario] } + total_cost: { dims: [] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -31,14 +39,6 @@ variables: description: "`CVaR` — the tail's average cost, what the objective prices at `omega`" dims: [] -given: - parameters: - scenario_weight: { dims: [scenario] } - CVaR_omega: { dims: [] } - expressions: - scenario_opex: { dims: [scenario] } - total_cost: { dims: [] } - expressions: risk_weighted_opex: expression: (1 - CVaR_omega) * sum(scenario_weight * scenario_opex, over=scenario) + CVaR_omega * CVaR diff --git a/docs/examples/pypsa/generator.md b/docs/examples/pypsa/generator.md index 4e4b82ab..a1a511b1 100644 --- a/docs/examples/pypsa/generator.md +++ b/docs/examples/pypsa/generator.md @@ -9,6 +9,28 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: PyPSA's `Generator ```yaml +given: + parameters: + snapshot_weightings_objective: { dims: [snapshot] } + Generator_committable: { dims: [generator], dtype: bool } + Generator_maintenance_pu: { dims: [scenario, generator] } + scenario_weight: { dims: [scenario] } + CVaR_omega: { dims: [] } + period_weight_objective: { dims: [period] } + snapshot_weightings_generators: { dims: [snapshot] } + variables: + Generator_maintenance: { dims: [scenario, snapshot, generator] } + Generator_maintenance_capacity: { dims: [scenario, snapshot, generator] } + expressions: + GlobalConstraint_energy_weight: { dims: [scenario, global_constraint, snapshot] } + primary_energy: { dims: [scenario, global_constraint] } + operational_limit: { dims: [scenario, global_constraint] } + tech_capacity_expansion: { dims: [global_constraint] } + scenario_opex: { dims: [scenario] } + total_cost: { dims: [] } + Carrier_additions: { dims: [period, carrier] } + Bus_injection: { dims: [scenario, snapshot, bus] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -153,28 +175,6 @@ variables: dims: [generator] where: Generator_p_nom_extendable -given: - parameters: - snapshot_weightings_objective: { dims: [snapshot] } - Generator_committable: { dims: [generator], dtype: bool } - Generator_maintenance_pu: { dims: [scenario, generator] } - scenario_weight: { dims: [scenario] } - CVaR_omega: { dims: [] } - period_weight_objective: { dims: [period] } - snapshot_weightings_generators: { dims: [snapshot] } - variables: - Generator_maintenance: { dims: [scenario, snapshot, generator] } - Generator_maintenance_capacity: { dims: [scenario, snapshot, generator] } - expressions: - GlobalConstraint_energy_weight: { dims: [scenario, global_constraint, snapshot] } - primary_energy: { dims: [scenario, global_constraint] } - operational_limit: { dims: [scenario, global_constraint] } - tech_capacity_expansion: { dims: [global_constraint] } - scenario_opex: { dims: [scenario] } - total_cost: { dims: [] } - Carrier_additions: { dims: [period, carrier] } - Bus_injection: { dims: [scenario, snapshot, bus] } - expressions: Generator_p_nom_effective: description: the build a generator's limits are taken against — the chosen one where it is extendable, the given one otherwise diff --git a/docs/examples/pypsa/generator_commitment.md b/docs/examples/pypsa/generator_commitment.md index 2384d6f3..220a7dbc 100644 --- a/docs/examples/pypsa/generator_commitment.md +++ b/docs/examples/pypsa/generator_commitment.md @@ -9,6 +9,28 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: PyPSA's `Generator ```yaml +given: + parameters: + snapshot_weightings_objective: { dims: [snapshot] } + Generator_p_nom: { dims: [scenario, generator] } + Generator_p_nom_extendable: { dims: [generator], dtype: bool } + Generator_p_min_pu: { dims: [scenario, snapshot, generator] } + Generator_p_max_pu: { dims: [scenario, snapshot, generator] } + Generator_p_nom_mod: { dims: [generator] } + Generator_modules_installed: { dims: [scenario, generator] } + Generator_p_min_pu_nonneg: { dims: [generator], dtype: bool } + Generator_maintenance_pu: { dims: [scenario, generator] } + period_weight_objective: { dims: [period] } + Generator_active: { dims: [snapshot, generator], dtype: bool } + variables: + Generator_p: { dims: [scenario, snapshot, generator] } + Generator_n_mod: { dims: [generator], domain: integer } + Generator_maintenance_capacity: { dims: [scenario, snapshot, generator] } + Generator_maintenance_status: { dims: [scenario, snapshot, generator] } + Generator_p_nom_ext: { dims: [generator] } + expressions: + scenario_opex: { dims: [scenario] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -97,28 +119,6 @@ variables: bounds: lower: 0 -given: - parameters: - snapshot_weightings_objective: { dims: [snapshot] } - Generator_p_nom: { dims: [scenario, generator] } - Generator_p_nom_extendable: { dims: [generator], dtype: bool } - Generator_p_min_pu: { dims: [scenario, snapshot, generator] } - Generator_p_max_pu: { dims: [scenario, snapshot, generator] } - Generator_p_nom_mod: { dims: [generator] } - Generator_modules_installed: { dims: [scenario, generator] } - Generator_p_min_pu_nonneg: { dims: [generator], dtype: bool } - Generator_maintenance_pu: { dims: [scenario, generator] } - period_weight_objective: { dims: [period] } - Generator_active: { dims: [snapshot, generator], dtype: bool } - variables: - Generator_p: { dims: [scenario, snapshot, generator] } - Generator_n_mod: { dims: [generator], domain: integer } - Generator_maintenance_capacity: { dims: [scenario, snapshot, generator] } - Generator_maintenance_status: { dims: [scenario, snapshot, generator] } - Generator_p_nom_ext: { dims: [generator] } - expressions: - scenario_opex: { dims: [scenario] } - expressions: Generator_previous_status: description: >- diff --git a/docs/examples/pypsa/generator_maintenance.md b/docs/examples/pypsa/generator_maintenance.md index de416877..e82a38a4 100644 --- a/docs/examples/pypsa/generator_maintenance.md +++ b/docs/examples/pypsa/generator_maintenance.md @@ -9,6 +9,19 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: PyPSA's `Generator ```yaml +given: + parameters: + Generator_p_nom_extendable: { dims: [generator], dtype: bool } + Generator_committable: { dims: [generator], dtype: bool } + Generator_p_nom_mod: { dims: [generator] } + Generator_active: { dims: [snapshot, generator], dtype: bool } + snapshot_weightings_generators: { dims: [snapshot] } + Generator_p_nom_min: { dims: [scenario, generator] } + Generator_p_nom_max: { dims: [scenario, generator] } + variables: + Generator_status: { dims: [scenario, snapshot, generator], domain: integer } + Generator_p_nom_ext: { dims: [generator] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -100,19 +113,6 @@ variables: bounds: lower: 0 -given: - parameters: - Generator_p_nom_extendable: { dims: [generator], dtype: bool } - Generator_committable: { dims: [generator], dtype: bool } - Generator_p_nom_mod: { dims: [generator] } - Generator_active: { dims: [snapshot, generator], dtype: bool } - snapshot_weightings_generators: { dims: [snapshot] } - Generator_p_nom_min: { dims: [scenario, generator] } - Generator_p_nom_max: { dims: [scenario, generator] } - variables: - Generator_status: { dims: [scenario, snapshot, generator], domain: integer } - Generator_p_nom_ext: { dims: [generator] } - constraints: Generator_maint_event_count: description: "`Generator-maint-event-count` — a maintainable generator holds its number of maintenance events over the horizon" diff --git a/docs/examples/pypsa/generator_ramping.md b/docs/examples/pypsa/generator_ramping.md index bcb55e43..9009caa0 100644 --- a/docs/examples/pypsa/generator_ramping.md +++ b/docs/examples/pypsa/generator_ramping.md @@ -9,6 +9,25 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: PyPSA's `Generator ```yaml +given: + parameters: + Generator_p_nom_extendable: { dims: [generator], dtype: bool } + Generator_committable: { dims: [generator], dtype: bool } + Generator_status_initial: { dims: [scenario, generator], dtype: int } + Generator_p_nom_mod: { dims: [generator] } + Generator_big_m: { dims: [scenario, generator] } + Generator_active: { dims: [snapshot, generator], dtype: bool } + variables: + Generator_p: { dims: [scenario, snapshot, generator] } + Generator_status: { dims: [scenario, snapshot, generator], domain: integer } + Generator_start_up: { dims: [scenario, snapshot, generator], domain: integer } + Generator_shut_down: { dims: [scenario, snapshot, generator], domain: integer } + Generator_p_nom_ext: { dims: [generator] } + expressions: + Generator_previous_status: { dims: [scenario, snapshot, generator] } + Generator_p_nom_effective: { dims: [scenario, generator] } + Generator_p_nom_committed: { dims: [scenario, generator] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -47,25 +66,6 @@ parameters: the unit carries no ramp row at the first snapshot dims: [scenario, generator] -given: - parameters: - Generator_p_nom_extendable: { dims: [generator], dtype: bool } - Generator_committable: { dims: [generator], dtype: bool } - Generator_status_initial: { dims: [scenario, generator], dtype: int } - Generator_p_nom_mod: { dims: [generator] } - Generator_big_m: { dims: [scenario, generator] } - Generator_active: { dims: [snapshot, generator], dtype: bool } - variables: - Generator_p: { dims: [scenario, snapshot, generator] } - Generator_status: { dims: [scenario, snapshot, generator], domain: integer } - Generator_start_up: { dims: [scenario, snapshot, generator], domain: integer } - Generator_shut_down: { dims: [scenario, snapshot, generator], domain: integer } - Generator_p_nom_ext: { dims: [generator] } - expressions: - Generator_previous_status: { dims: [scenario, snapshot, generator] } - Generator_p_nom_effective: { dims: [scenario, generator] } - Generator_p_nom_committed: { dims: [scenario, generator] } - expressions: Generator_previous_p: description: >- diff --git a/docs/examples/pypsa/global_constraints.md b/docs/examples/pypsa/global_constraints.md index a6d6f723..d71fa566 100644 --- a/docs/examples/pypsa/global_constraints.md +++ b/docs/examples/pypsa/global_constraints.md @@ -9,6 +9,16 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: the five system to ```yaml +given: + parameters: + scenario_weight: { dims: [scenario] } + expressions: + primary_energy: { dims: [scenario, global_constraint] } + operational_limit: { dims: [scenario, global_constraint] } + transmission_volume_expansion: { dims: [scenario, global_constraint] } + transmission_expansion_cost: { dims: [scenario, global_constraint] } + tech_capacity_expansion: { dims: [global_constraint] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -40,16 +50,6 @@ parameters: (`global_constraints.py:557`, `:749`, `:861`) dims: [scenario, global_constraint] -given: - parameters: - scenario_weight: { dims: [scenario] } - expressions: - primary_energy: { dims: [scenario, global_constraint] } - operational_limit: { dims: [scenario, global_constraint] } - transmission_volume_expansion: { dims: [scenario, global_constraint] } - transmission_expansion_cost: { dims: [scenario, global_constraint] } - tech_capacity_expansion: { dims: [global_constraint] } - constraints: GlobalConstraint_primary_energy_ub: description: "`primary_energy` — its total, at most its constant" diff --git a/docs/examples/pypsa/line.md b/docs/examples/pypsa/line.md index 7d980d8f..09703f8f 100644 --- a/docs/examples/pypsa/line.md +++ b/docs/examples/pypsa/line.md @@ -9,6 +9,19 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: PyPSA's `Line`. It ```yaml +given: + parameters: + scenario_weight: { dims: [scenario] } + transmission_losses: { dims: [], dtype: bool } + expressions: + transmission_volume_expansion: { dims: [scenario, global_constraint] } + transmission_expansion_cost: { dims: [scenario, global_constraint] } + tech_capacity_expansion: { dims: [global_constraint] } + total_cost: { dims: [] } + Carrier_additions: { dims: [period, carrier] } + Bus_injection: { dims: [scenario, snapshot, bus] } + Cycle_angle_sum: { dims: [scenario, snapshot, cycle] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -156,19 +169,6 @@ variables: dims: [line] where: Line_s_nom_extendable -given: - parameters: - scenario_weight: { dims: [scenario] } - transmission_losses: { dims: [], dtype: bool } - expressions: - transmission_volume_expansion: { dims: [scenario, global_constraint] } - transmission_expansion_cost: { dims: [scenario, global_constraint] } - tech_capacity_expansion: { dims: [global_constraint] } - total_cost: { dims: [] } - Carrier_additions: { dims: [period, carrier] } - Bus_injection: { dims: [scenario, snapshot, bus] } - Cycle_angle_sum: { dims: [scenario, snapshot, cycle] } - expressions: Line_transmission_volume_expansion: expression: sum(Line_s_nom_ext * Line_volume_weight, over=line) diff --git a/docs/examples/pypsa/link.md b/docs/examples/pypsa/link.md index 77f20182..e7a7272e 100644 --- a/docs/examples/pypsa/link.md +++ b/docs/examples/pypsa/link.md @@ -9,6 +9,26 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: PyPSA's `Link`. It ```yaml +given: + parameters: + snapshot_weightings_objective: { dims: [snapshot] } + Link_committable: { dims: [link], dtype: bool } + Link_maintenance_pu: { dims: [scenario, link] } + scenario_weight: { dims: [scenario] } + CVaR_omega: { dims: [] } + period_weight_objective: { dims: [period] } + variables: + Link_maintenance: { dims: [scenario, snapshot, link] } + Link_maintenance_capacity: { dims: [scenario, snapshot, link] } + expressions: + transmission_volume_expansion: { dims: [scenario, global_constraint] } + transmission_expansion_cost: { dims: [scenario, global_constraint] } + tech_capacity_expansion: { dims: [global_constraint] } + scenario_opex: { dims: [scenario] } + total_cost: { dims: [] } + Carrier_additions: { dims: [period, carrier] } + Bus_injection: { dims: [scenario, snapshot, bus] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -193,26 +213,6 @@ variables: dims: [link] where: Link_p_nom_extendable -given: - parameters: - snapshot_weightings_objective: { dims: [snapshot] } - Link_committable: { dims: [link], dtype: bool } - Link_maintenance_pu: { dims: [scenario, link] } - scenario_weight: { dims: [scenario] } - CVaR_omega: { dims: [] } - period_weight_objective: { dims: [period] } - variables: - Link_maintenance: { dims: [scenario, snapshot, link] } - Link_maintenance_capacity: { dims: [scenario, snapshot, link] } - expressions: - transmission_volume_expansion: { dims: [scenario, global_constraint] } - transmission_expansion_cost: { dims: [scenario, global_constraint] } - tech_capacity_expansion: { dims: [global_constraint] } - scenario_opex: { dims: [scenario] } - total_cost: { dims: [] } - Carrier_additions: { dims: [period, carrier] } - Bus_injection: { dims: [scenario, snapshot, bus] } - expressions: Link_p_nom_effective: description: the build a link's limits are taken against — the chosen one where it is extendable, the given one otherwise diff --git a/docs/examples/pypsa/link_commitment.md b/docs/examples/pypsa/link_commitment.md index 0f76a073..e9cf3793 100644 --- a/docs/examples/pypsa/link_commitment.md +++ b/docs/examples/pypsa/link_commitment.md @@ -9,6 +9,28 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: PyPSA's `Link`, th ```yaml +given: + parameters: + snapshot_weightings_objective: { dims: [snapshot] } + Link_p_nom: { dims: [scenario, link] } + Link_p_nom_extendable: { dims: [link], dtype: bool } + Link_p_min_pu: { dims: [scenario, snapshot, link] } + Link_p_max_pu: { dims: [scenario, snapshot, link] } + Link_p_nom_mod: { dims: [link] } + Link_modules_installed: { dims: [scenario, link] } + Link_p_min_pu_nonneg: { dims: [link], dtype: bool } + Link_maintenance_pu: { dims: [scenario, link] } + period_weight_objective: { dims: [period] } + Link_active: { dims: [snapshot, link], dtype: bool } + variables: + Link_p: { dims: [scenario, snapshot, link] } + Link_n_mod: { dims: [link], domain: integer } + Link_maintenance_capacity: { dims: [scenario, snapshot, link] } + Link_maintenance_status: { dims: [scenario, snapshot, link] } + Link_p_nom_ext: { dims: [link] } + expressions: + scenario_opex: { dims: [scenario] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -97,28 +119,6 @@ variables: bounds: lower: 0 -given: - parameters: - snapshot_weightings_objective: { dims: [snapshot] } - Link_p_nom: { dims: [scenario, link] } - Link_p_nom_extendable: { dims: [link], dtype: bool } - Link_p_min_pu: { dims: [scenario, snapshot, link] } - Link_p_max_pu: { dims: [scenario, snapshot, link] } - Link_p_nom_mod: { dims: [link] } - Link_modules_installed: { dims: [scenario, link] } - Link_p_min_pu_nonneg: { dims: [link], dtype: bool } - Link_maintenance_pu: { dims: [scenario, link] } - period_weight_objective: { dims: [period] } - Link_active: { dims: [snapshot, link], dtype: bool } - variables: - Link_p: { dims: [scenario, snapshot, link] } - Link_n_mod: { dims: [link], domain: integer } - Link_maintenance_capacity: { dims: [scenario, snapshot, link] } - Link_maintenance_status: { dims: [scenario, snapshot, link] } - Link_p_nom_ext: { dims: [link] } - expressions: - scenario_opex: { dims: [scenario] } - expressions: Link_previous_status: description: >- diff --git a/docs/examples/pypsa/link_maintenance.md b/docs/examples/pypsa/link_maintenance.md index d8b5ed3d..ab2e32c7 100644 --- a/docs/examples/pypsa/link_maintenance.md +++ b/docs/examples/pypsa/link_maintenance.md @@ -9,6 +9,19 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: PyPSA's `Link`, th ```yaml +given: + parameters: + Link_p_nom_extendable: { dims: [link], dtype: bool } + Link_committable: { dims: [link], dtype: bool } + Link_p_nom_mod: { dims: [link] } + Link_active: { dims: [snapshot, link], dtype: bool } + snapshot_weightings_generators: { dims: [snapshot] } + Link_p_nom_min: { dims: [scenario, link] } + Link_p_nom_max: { dims: [scenario, link] } + variables: + Link_status: { dims: [scenario, snapshot, link], domain: integer } + Link_p_nom_ext: { dims: [link] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -100,19 +113,6 @@ variables: bounds: lower: 0 -given: - parameters: - Link_p_nom_extendable: { dims: [link], dtype: bool } - Link_committable: { dims: [link], dtype: bool } - Link_p_nom_mod: { dims: [link] } - Link_active: { dims: [snapshot, link], dtype: bool } - snapshot_weightings_generators: { dims: [snapshot] } - Link_p_nom_min: { dims: [scenario, link] } - Link_p_nom_max: { dims: [scenario, link] } - variables: - Link_status: { dims: [scenario, snapshot, link], domain: integer } - Link_p_nom_ext: { dims: [link] } - constraints: Link_maint_event_count: description: "`Link-maint-event-count` — a maintainable link holds its number of maintenance events over the horizon" diff --git a/docs/examples/pypsa/link_ramping.md b/docs/examples/pypsa/link_ramping.md index 0b55db30..b8948e08 100644 --- a/docs/examples/pypsa/link_ramping.md +++ b/docs/examples/pypsa/link_ramping.md @@ -9,6 +9,25 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: PyPSA's `Link`, th ```yaml +given: + parameters: + Link_p_nom_extendable: { dims: [link], dtype: bool } + Link_committable: { dims: [link], dtype: bool } + Link_status_initial: { dims: [scenario, link], dtype: int } + Link_p_nom_mod: { dims: [link] } + Link_big_m: { dims: [scenario, link] } + Link_active: { dims: [snapshot, link], dtype: bool } + variables: + Link_p: { dims: [scenario, snapshot, link] } + Link_status: { dims: [scenario, snapshot, link], domain: integer } + Link_start_up: { dims: [scenario, snapshot, link], domain: integer } + Link_shut_down: { dims: [scenario, snapshot, link], domain: integer } + Link_p_nom_ext: { dims: [link] } + expressions: + Link_p_nom_effective: { dims: [scenario, link] } + Link_previous_status: { dims: [scenario, snapshot, link] } + Link_p_nom_committed: { dims: [scenario, link] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -47,25 +66,6 @@ parameters: the link carries no ramp row at the first snapshot dims: [scenario, link] -given: - parameters: - Link_p_nom_extendable: { dims: [link], dtype: bool } - Link_committable: { dims: [link], dtype: bool } - Link_status_initial: { dims: [scenario, link], dtype: int } - Link_p_nom_mod: { dims: [link] } - Link_big_m: { dims: [scenario, link] } - Link_active: { dims: [snapshot, link], dtype: bool } - variables: - Link_p: { dims: [scenario, snapshot, link] } - Link_status: { dims: [scenario, snapshot, link], domain: integer } - Link_start_up: { dims: [scenario, snapshot, link], domain: integer } - Link_shut_down: { dims: [scenario, snapshot, link], domain: integer } - Link_p_nom_ext: { dims: [link] } - expressions: - Link_p_nom_effective: { dims: [scenario, link] } - Link_previous_status: { dims: [scenario, snapshot, link] } - Link_p_nom_committed: { dims: [scenario, link] } - expressions: Link_previous_p: description: >- diff --git a/docs/examples/pypsa/load.md b/docs/examples/pypsa/load.md index 1373b50f..7bfab6a8 100644 --- a/docs/examples/pypsa/load.md +++ b/docs/examples/pypsa/load.md @@ -9,6 +9,10 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: PyPSA's `Load`. It ```yaml +given: + expressions: + Bus_injection: { dims: [scenario, snapshot, bus] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -44,10 +48,6 @@ parameters: dims: [load] dtype: bool -given: - expressions: - Bus_injection: { dims: [scenario, snapshot, bus] } - expressions: Load_demand: description: >- diff --git a/docs/examples/pypsa/network.md b/docs/examples/pypsa/network.md index d86b3344..3ecb8112 100644 --- a/docs/examples/pypsa/network.md +++ b/docs/examples/pypsa/network.md @@ -9,15 +9,6 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: the buses and the ```yaml -dimensions: - scenario: - description: the futures dispatch is chosen in, each with a weight - snapshot: - description: dispatch periods - dtype: datetime - bus: - description: network nodes - given: expressions: Bus_injection: @@ -27,6 +18,15 @@ given: PyPSA writes each term into the balance, and a load on its right-hand side +dimensions: + scenario: + description: the futures dispatch is chosen in, each with a weight + snapshot: + description: dispatch periods + dtype: datetime + bus: + description: network nodes + constraints: Bus_nodal_balance: description: >- diff --git a/docs/examples/pypsa/power_flow.md b/docs/examples/pypsa/power_flow.md index 98bc6358..3b874f77 100644 --- a/docs/examples/pypsa/power_flow.md +++ b/docs/examples/pypsa/power_flow.md @@ -9,6 +9,14 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: Kirchhoff's voltag ```yaml +given: + expressions: + Cycle_angle_sum: + dims: [scenario, snapshot, cycle] + description: >- + the voltage angle differences around a cycle: every branch flow times + its cycle weight, and every transformer phase shift + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -18,14 +26,6 @@ dimensions: cycle: description: independent cycles of the passive network graph — the cycle basis, data prep -given: - expressions: - Cycle_angle_sum: - dims: [scenario, snapshot, cycle] - description: >- - the voltage angle differences around a cycle: every branch flow times - its cycle weight, and every transformer phase shift - constraints: Kirchhoff_Voltage_Law: description: >- diff --git a/docs/examples/pypsa/process.md b/docs/examples/pypsa/process.md index 00711b99..98630eb8 100644 --- a/docs/examples/pypsa/process.md +++ b/docs/examples/pypsa/process.md @@ -9,6 +9,24 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: PyPSA's `Process`. ```yaml +given: + parameters: + snapshot_weightings_objective: { dims: [snapshot] } + Process_committable: { dims: [process], dtype: bool } + Process_maintenance_pu: { dims: [scenario, process] } + scenario_weight: { dims: [scenario] } + CVaR_omega: { dims: [] } + period_weight_objective: { dims: [period] } + variables: + Process_maintenance: { dims: [scenario, snapshot, process] } + Process_maintenance_capacity: { dims: [scenario, snapshot, process] } + expressions: + tech_capacity_expansion: { dims: [global_constraint] } + scenario_opex: { dims: [scenario] } + total_cost: { dims: [] } + Carrier_additions: { dims: [period, carrier] } + Bus_injection: { dims: [scenario, snapshot, bus] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -172,24 +190,6 @@ variables: dims: [process] where: Process_p_nom_extendable -given: - parameters: - snapshot_weightings_objective: { dims: [snapshot] } - Process_committable: { dims: [process], dtype: bool } - Process_maintenance_pu: { dims: [scenario, process] } - scenario_weight: { dims: [scenario] } - CVaR_omega: { dims: [] } - period_weight_objective: { dims: [period] } - variables: - Process_maintenance: { dims: [scenario, snapshot, process] } - Process_maintenance_capacity: { dims: [scenario, snapshot, process] } - expressions: - tech_capacity_expansion: { dims: [global_constraint] } - scenario_opex: { dims: [scenario] } - total_cost: { dims: [] } - Carrier_additions: { dims: [period, carrier] } - Bus_injection: { dims: [scenario, snapshot, bus] } - expressions: Process_p_nom_effective: description: the build a process's limits are taken against — the chosen one where it is extendable, the given one otherwise diff --git a/docs/examples/pypsa/process_commitment.md b/docs/examples/pypsa/process_commitment.md index f2087dc2..96ffc681 100644 --- a/docs/examples/pypsa/process_commitment.md +++ b/docs/examples/pypsa/process_commitment.md @@ -9,6 +9,28 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: PyPSA's `Process`, ```yaml +given: + parameters: + snapshot_weightings_objective: { dims: [snapshot] } + Process_p_nom: { dims: [scenario, process] } + Process_p_nom_extendable: { dims: [process], dtype: bool } + Process_p_min_pu: { dims: [scenario, snapshot, process] } + Process_p_max_pu: { dims: [scenario, snapshot, process] } + Process_p_nom_mod: { dims: [process] } + Process_modules_installed: { dims: [scenario, process] } + Process_p_min_pu_nonneg: { dims: [process], dtype: bool } + Process_maintenance_pu: { dims: [scenario, process] } + period_weight_objective: { dims: [period] } + Process_active: { dims: [snapshot, process], dtype: bool } + variables: + Process_p: { dims: [scenario, snapshot, process] } + Process_n_mod: { dims: [process], domain: integer } + Process_maintenance_capacity: { dims: [scenario, snapshot, process] } + Process_maintenance_status: { dims: [scenario, snapshot, process] } + Process_p_nom_ext: { dims: [process] } + expressions: + scenario_opex: { dims: [scenario] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -97,28 +119,6 @@ variables: bounds: lower: 0 -given: - parameters: - snapshot_weightings_objective: { dims: [snapshot] } - Process_p_nom: { dims: [scenario, process] } - Process_p_nom_extendable: { dims: [process], dtype: bool } - Process_p_min_pu: { dims: [scenario, snapshot, process] } - Process_p_max_pu: { dims: [scenario, snapshot, process] } - Process_p_nom_mod: { dims: [process] } - Process_modules_installed: { dims: [scenario, process] } - Process_p_min_pu_nonneg: { dims: [process], dtype: bool } - Process_maintenance_pu: { dims: [scenario, process] } - period_weight_objective: { dims: [period] } - Process_active: { dims: [snapshot, process], dtype: bool } - variables: - Process_p: { dims: [scenario, snapshot, process] } - Process_n_mod: { dims: [process], domain: integer } - Process_maintenance_capacity: { dims: [scenario, snapshot, process] } - Process_maintenance_status: { dims: [scenario, snapshot, process] } - Process_p_nom_ext: { dims: [process] } - expressions: - scenario_opex: { dims: [scenario] } - expressions: Process_previous_status: description: >- diff --git a/docs/examples/pypsa/process_maintenance.md b/docs/examples/pypsa/process_maintenance.md index 0c223e1b..f0fe5d4c 100644 --- a/docs/examples/pypsa/process_maintenance.md +++ b/docs/examples/pypsa/process_maintenance.md @@ -9,6 +9,19 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: PyPSA's `Process`, ```yaml +given: + parameters: + Process_p_nom_extendable: { dims: [process], dtype: bool } + Process_p_nom_min: { dims: [scenario, process] } + Process_p_nom_max: { dims: [scenario, process] } + Process_committable: { dims: [process], dtype: bool } + Process_p_nom_mod: { dims: [process] } + Process_active: { dims: [snapshot, process], dtype: bool } + snapshot_weightings_generators: { dims: [snapshot] } + variables: + Process_status: { dims: [scenario, snapshot, process], domain: integer } + Process_p_nom_ext: { dims: [process] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -100,19 +113,6 @@ variables: bounds: lower: 0 -given: - parameters: - Process_p_nom_extendable: { dims: [process], dtype: bool } - Process_p_nom_min: { dims: [scenario, process] } - Process_p_nom_max: { dims: [scenario, process] } - Process_committable: { dims: [process], dtype: bool } - Process_p_nom_mod: { dims: [process] } - Process_active: { dims: [snapshot, process], dtype: bool } - snapshot_weightings_generators: { dims: [snapshot] } - variables: - Process_status: { dims: [scenario, snapshot, process], domain: integer } - Process_p_nom_ext: { dims: [process] } - constraints: Process_maint_event_count: description: "`Process-maint-event-count` — a maintainable process holds its number of maintenance events over the horizon" diff --git a/docs/examples/pypsa/process_ramping.md b/docs/examples/pypsa/process_ramping.md index ab830860..823ba720 100644 --- a/docs/examples/pypsa/process_ramping.md +++ b/docs/examples/pypsa/process_ramping.md @@ -9,6 +9,25 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: PyPSA's `Process`, ```yaml +given: + parameters: + Process_p_nom_extendable: { dims: [process], dtype: bool } + Process_committable: { dims: [process], dtype: bool } + Process_status_initial: { dims: [scenario, process], dtype: int } + Process_p_nom_mod: { dims: [process] } + Process_big_m: { dims: [scenario, process] } + Process_active: { dims: [snapshot, process], dtype: bool } + variables: + Process_p: { dims: [scenario, snapshot, process] } + Process_status: { dims: [scenario, snapshot, process], domain: integer } + Process_start_up: { dims: [scenario, snapshot, process], domain: integer } + Process_shut_down: { dims: [scenario, snapshot, process], domain: integer } + Process_p_nom_ext: { dims: [process] } + expressions: + Process_p_nom_effective: { dims: [scenario, process] } + Process_previous_status: { dims: [scenario, snapshot, process] } + Process_p_nom_committed: { dims: [scenario, process] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -47,25 +66,6 @@ parameters: the process carries no ramp row at the first snapshot dims: [scenario, process] -given: - parameters: - Process_p_nom_extendable: { dims: [process], dtype: bool } - Process_committable: { dims: [process], dtype: bool } - Process_status_initial: { dims: [scenario, process], dtype: int } - Process_p_nom_mod: { dims: [process] } - Process_big_m: { dims: [scenario, process] } - Process_active: { dims: [snapshot, process], dtype: bool } - variables: - Process_p: { dims: [scenario, snapshot, process] } - Process_status: { dims: [scenario, snapshot, process], domain: integer } - Process_start_up: { dims: [scenario, snapshot, process], domain: integer } - Process_shut_down: { dims: [scenario, snapshot, process], domain: integer } - Process_p_nom_ext: { dims: [process] } - expressions: - Process_p_nom_effective: { dims: [scenario, process] } - Process_previous_status: { dims: [scenario, snapshot, process] } - Process_p_nom_committed: { dims: [scenario, process] } - expressions: Process_previous_p: description: >- diff --git a/docs/examples/pypsa/security.md b/docs/examples/pypsa/security.md index 63c13034..88974c2a 100644 --- a/docs/examples/pypsa/security.md +++ b/docs/examples/pypsa/security.md @@ -9,6 +9,21 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: the security-const ```yaml +given: + parameters: + Line_s_nom: { dims: [scenario, line] } + Line_s_nom_extendable: { dims: [line], dtype: bool } + Line_s_max_pu: { dims: [scenario, snapshot, line] } + Transformer_s_nom: { dims: [scenario, transformer] } + Transformer_s_nom_extendable: { dims: [transformer], dtype: bool } + Transformer_s_max_pu: { dims: [scenario, snapshot, transformer] } + variables: + Line_s_nom_ext: { dims: [line] } + Transformer_s_nom_ext: { dims: [transformer] } + expressions: + Line_s_monitored: { dims: [scenario, snapshot, line] } + Transformer_s_monitored: { dims: [scenario, snapshot, transformer] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -50,21 +65,6 @@ parameters: outage share a sub-network dims: [transformer, outage] -given: - parameters: - Line_s_nom: { dims: [scenario, line] } - Line_s_nom_extendable: { dims: [line], dtype: bool } - Line_s_max_pu: { dims: [scenario, snapshot, line] } - Transformer_s_nom: { dims: [scenario, transformer] } - Transformer_s_nom_extendable: { dims: [transformer], dtype: bool } - Transformer_s_max_pu: { dims: [scenario, snapshot, transformer] } - variables: - Line_s_nom_ext: { dims: [line] } - Transformer_s_nom_ext: { dims: [transformer] } - expressions: - Line_s_monitored: { dims: [scenario, snapshot, line] } - Transformer_s_monitored: { dims: [scenario, snapshot, transformer] } - expressions: Outage_s: description: >- diff --git a/docs/examples/pypsa/settings.md b/docs/examples/pypsa/settings.md index ab633b46..dd563250 100644 --- a/docs/examples/pypsa/settings.md +++ b/docs/examples/pypsa/settings.md @@ -9,6 +9,58 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: the weightings, th ```yaml +given: + expressions: + primary_energy: + dims: [scenario, global_constraint] + description: >- + what a `primary_energy` row totals — weighted generator energy over the + snapshots it counts, less the charge left in weighted storage at the + close; the initial charge it is compared against is folded into the + row's constant + operational_limit: + dims: [scenario, global_constraint] + description: >- + what an `operational_limit` row totals — the weighted energy its + generators deliver over the snapshots it counts, plus what its + non-cyclic storage draws down; the initial charge it draws from is + folded into the row's constant + transmission_volume_expansion: + dims: [scenario, global_constraint] + description: >- + what a `transmission_volume_expansion_limit` row totals — length times + the chosen build of the row's branches + transmission_expansion_cost: + dims: [scenario, global_constraint] + description: >- + what a `transmission_expansion_cost_limit` row totals — capital cost + times the chosen build of the row's branches + tech_capacity_expansion: + dims: [global_constraint] + description: >- + what a `tech_capacity_expansion_limit` row totals — the chosen build of + the row's carrier-and-bus set + scenario_opex: + dims: [scenario] + description: >- + what a future costs to run — every operating term, weighted by the + snapshot's hours and its period, before the scenario's own weight; a + start and a stop cost what they cost, unweighted, as PyPSA adds them + (`optimize.py:414-429`) + total_cost: + dims: [] + description: >- + what the system costs — capacity once per active period at its expected + cost over the scenarios, operation in expectation over the scenarios, + and a share of it at the tail + Carrier_additions: + dims: [period, carrier] + description: >- + what a carrier adds in a period — every extendable component of that + carrier, counting each build in the first period it stands in. Like + PyPSA, it sums only the components that carry a carrier attribute, so a + transformer, which has none, counts in no carrier + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -76,58 +128,6 @@ parameters: dims: [scenario, global_constraint, snapshot] dtype: bool -given: - expressions: - primary_energy: - dims: [scenario, global_constraint] - description: >- - what a `primary_energy` row totals — weighted generator energy over the - snapshots it counts, less the charge left in weighted storage at the - close; the initial charge it is compared against is folded into the - row's constant - operational_limit: - dims: [scenario, global_constraint] - description: >- - what an `operational_limit` row totals — the weighted energy its - generators deliver over the snapshots it counts, plus what its - non-cyclic storage draws down; the initial charge it draws from is - folded into the row's constant - transmission_volume_expansion: - dims: [scenario, global_constraint] - description: >- - what a `transmission_volume_expansion_limit` row totals — length times - the chosen build of the row's branches - transmission_expansion_cost: - dims: [scenario, global_constraint] - description: >- - what a `transmission_expansion_cost_limit` row totals — capital cost - times the chosen build of the row's branches - tech_capacity_expansion: - dims: [global_constraint] - description: >- - what a `tech_capacity_expansion_limit` row totals — the chosen build of - the row's carrier-and-bus set - scenario_opex: - dims: [scenario] - description: >- - what a future costs to run — every operating term, weighted by the - snapshot's hours and its period, before the scenario's own weight; a - start and a stop cost what they cost, unweighted, as PyPSA adds them - (`optimize.py:414-429`) - total_cost: - dims: [] - description: >- - what the system costs — capacity once per active period at its expected - cost over the scenarios, operation in expectation over the scenarios, - and a share of it at the tail - Carrier_additions: - dims: [period, carrier] - description: >- - what a carrier adds in a period — every extendable component of that - carrier, counting each build in the first period it stands in. Like - PyPSA, it sums only the components that carry a carrier attribute, so a - transformer, which has none, counts in no carrier - expressions: GlobalConstraint_energy_weight: description: >- diff --git a/docs/examples/pypsa/storage_unit.md b/docs/examples/pypsa/storage_unit.md index f02ac6e1..80e5ba4d 100644 --- a/docs/examples/pypsa/storage_unit.md +++ b/docs/examples/pypsa/storage_unit.md @@ -9,6 +9,25 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: PyPSA's `StorageUn ```yaml +given: + parameters: + snapshot_weightings_objective: { dims: [snapshot] } + scenario_weight: { dims: [scenario] } + CVaR_omega: { dims: [] } + period_weight_objective: { dims: [period] } + period_weight_years: { dims: [period] } + snapshot_weightings_stores: { dims: [snapshot] } + GlobalConstraint_counts_snapshot: { dims: [scenario, global_constraint, snapshot], dtype: bool } + expressions: + GlobalConstraint_snapshot_closes: { dims: [scenario, global_constraint, snapshot] } + primary_energy: { dims: [scenario, global_constraint] } + operational_limit: { dims: [scenario, global_constraint] } + tech_capacity_expansion: { dims: [global_constraint] } + scenario_opex: { dims: [scenario] } + total_cost: { dims: [] } + Carrier_additions: { dims: [period, carrier] } + Bus_injection: { dims: [scenario, snapshot, bus] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -207,25 +226,6 @@ variables: dims: [storage_unit] where: StorageUnit_p_nom_extendable -given: - parameters: - snapshot_weightings_objective: { dims: [snapshot] } - scenario_weight: { dims: [scenario] } - CVaR_omega: { dims: [] } - period_weight_objective: { dims: [period] } - period_weight_years: { dims: [period] } - snapshot_weightings_stores: { dims: [snapshot] } - GlobalConstraint_counts_snapshot: { dims: [scenario, global_constraint, snapshot], dtype: bool } - expressions: - GlobalConstraint_snapshot_closes: { dims: [scenario, global_constraint, snapshot] } - primary_energy: { dims: [scenario, global_constraint] } - operational_limit: { dims: [scenario, global_constraint] } - tech_capacity_expansion: { dims: [global_constraint] } - scenario_opex: { dims: [scenario] } - total_cost: { dims: [] } - Carrier_additions: { dims: [period, carrier] } - Bus_injection: { dims: [scenario, snapshot, bus] } - expressions: StorageUnit_charge_carried_in: description: >- diff --git a/docs/examples/pypsa/store.md b/docs/examples/pypsa/store.md index 7c350436..e86f5f30 100644 --- a/docs/examples/pypsa/store.md +++ b/docs/examples/pypsa/store.md @@ -9,6 +9,25 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: PyPSA's `Store`. I ```yaml +given: + parameters: + snapshot_weightings_objective: { dims: [snapshot] } + scenario_weight: { dims: [scenario] } + CVaR_omega: { dims: [] } + period_weight_objective: { dims: [period] } + period_weight_years: { dims: [period] } + snapshot_weightings_stores: { dims: [snapshot] } + GlobalConstraint_counts_snapshot: { dims: [scenario, global_constraint, snapshot], dtype: bool } + expressions: + GlobalConstraint_snapshot_closes: { dims: [scenario, global_constraint, snapshot] } + primary_energy: { dims: [scenario, global_constraint] } + operational_limit: { dims: [scenario, global_constraint] } + tech_capacity_expansion: { dims: [global_constraint] } + scenario_opex: { dims: [scenario] } + total_cost: { dims: [] } + Carrier_additions: { dims: [period, carrier] } + Bus_injection: { dims: [scenario, snapshot, bus] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -171,25 +190,6 @@ variables: dims: [store] where: Store_e_nom_extendable -given: - parameters: - snapshot_weightings_objective: { dims: [snapshot] } - scenario_weight: { dims: [scenario] } - CVaR_omega: { dims: [] } - period_weight_objective: { dims: [period] } - period_weight_years: { dims: [period] } - snapshot_weightings_stores: { dims: [snapshot] } - GlobalConstraint_counts_snapshot: { dims: [scenario, global_constraint, snapshot], dtype: bool } - expressions: - GlobalConstraint_snapshot_closes: { dims: [scenario, global_constraint, snapshot] } - primary_energy: { dims: [scenario, global_constraint] } - operational_limit: { dims: [scenario, global_constraint] } - tech_capacity_expansion: { dims: [global_constraint] } - scenario_opex: { dims: [scenario] } - total_cost: { dims: [] } - Carrier_additions: { dims: [period, carrier] } - Bus_injection: { dims: [scenario, snapshot, bus] } - expressions: Store_energy_carried_in: description: >- diff --git a/docs/examples/pypsa/transformer.md b/docs/examples/pypsa/transformer.md index c8c87e20..83a43f5d 100644 --- a/docs/examples/pypsa/transformer.md +++ b/docs/examples/pypsa/transformer.md @@ -9,6 +9,15 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: PyPSA's `Transform ```yaml +given: + parameters: + scenario_weight: { dims: [scenario] } + transmission_losses: { dims: [], dtype: bool } + expressions: + total_cost: { dims: [] } + Bus_injection: { dims: [scenario, snapshot, bus] } + Cycle_angle_sum: { dims: [scenario, snapshot, cycle] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -167,15 +176,6 @@ variables: dims: [transformer] where: Transformer_s_nom_extendable -given: - parameters: - scenario_weight: { dims: [scenario] } - transmission_losses: { dims: [], dtype: bool } - expressions: - total_cost: { dims: [] } - Bus_injection: { dims: [scenario, snapshot, bus] } - Cycle_angle_sum: { dims: [scenario, snapshot, cycle] } - expressions: Transformer_capex: expression: sum(scenario_weight * Transformer_s_nom_ext * Transformer_capital_cost * Transformer_capital_weight) diff --git a/docs/howto/compose.md b/docs/howto/compose.md index 3950adbe..b11b6eae 100644 --- a/docs/howto/compose.md +++ b/docs/howto/compose.md @@ -23,9 +23,6 @@ takes its files as a list, and the two compose as `override(merge([…]), […]) Nothing in it names a component class. ```yaml title="network.yaml" - dimensions: - snapshot: { dtype: int } - bus: { dtype: str } given: expressions: Bus_injection: @@ -34,6 +31,9 @@ takes its files as a list, and the two compose as `override(merge([…]), […]) total_cost: dims: [] description: what running the system costs + dimensions: + snapshot: { dtype: int } + bus: { dtype: str } constraints: Bus_balance: dims: [snapshot, bus] @@ -51,6 +51,10 @@ takes its files as a list, and the two compose as `override(merge([…]), […]) `total_cost` the same way. ```yaml title="generator.yaml" + given: + expressions: + Bus_injection: { dims: [snapshot, bus] } + total_cost: { dims: [] } dimensions: snapshot: { dtype: int } bus: { dtype: str } @@ -62,10 +66,6 @@ takes its files as a list, and the two compose as `override(merge([…]), […]) Generator_marginal_cost: { dims: [generator] } variables: Generator_p: { dims: [snapshot, generator], bounds: { lower: 0, upper: Generator_p_nom } } - given: - expressions: - Bus_injection: { dims: [snapshot, bus] } - total_cost: { dims: [] } expressions: Generator_injection: expression: sum(Generator_p, by=Generator_bus, over=generator, into=bus) @@ -76,6 +76,9 @@ takes its files as a list, and the two compose as `override(merge([…]), […]) ``` ```yaml title="load.yaml" + given: + expressions: + Bus_injection: { dims: [snapshot, bus] } dimensions: snapshot: { dtype: int } bus: { dtype: str } @@ -84,9 +87,6 @@ takes its files as a list, and the two compose as `override(merge([…]), […]) Load_bus: { key: load, values: bus } parameters: Load_p_set: { dims: [snapshot, load] } - given: - expressions: - Bus_injection: { dims: [snapshot, bus] } expressions: Load_injection: expression: -sum(Load_p_set, by=Load_bus, over=load, into=bus) @@ -119,6 +119,9 @@ takes its files as a list, and the two compose as `override(merge([…]), […]) term, and `network.yaml` stays as it is. ```yaml title="store.yaml" + given: + expressions: + Bus_injection: { dims: [snapshot, bus] } dimensions: snapshot: { dtype: int } bus: { dtype: str } @@ -134,9 +137,6 @@ takes its files as a list, and the two compose as `override(merge([…]), […]) Store_energy_balance: dims: [snapshot, store] expression: Store_e == shift(Store_e, along=snapshot, offset=1, edge='wrap') - Store_p - given: - expressions: - Bus_injection: { dims: [snapshot, bus] } expressions: Store_injection: expression: sum(Store_p, by=Store_bus, over=store, into=bus) @@ -159,6 +159,11 @@ takes its files as a list, and the two compose as `override(merge([…]), […]) follows it. The component files stay as they are. ```yaml title="network_slack.yaml" + given: + expressions: + total_cost: + dims: [] + description: what running the system costs dimensions: snapshot: { dtype: int } bus: { dtype: str } @@ -169,11 +174,6 @@ takes its files as a list, and the two compose as `override(merge([…]), […]) dims: [snapshot, bus] expression: Bus_slack description: what the components put into a bus - given: - expressions: - total_cost: - dims: [] - description: what running the system costs constraints: Bus_balance: dims: [snapshot, bus] @@ -231,12 +231,12 @@ that introduces the column. The reader may say less, such as the frame with no reads `Generator_p` as binary: ```yaml title="emissions.yaml" -dimensions: - snapshot: { dtype: int } - generator: { dtype: str } given: variables: Generator_p: { dims: [snapshot, generator], domain: binary } +dimensions: + snapshot: { dtype: int } + generator: { dtype: str } parameters: Generator_co2: { dims: [generator] } co2_cap: { dims: [] } diff --git a/docs/reference/language/declarations.md b/docs/reference/language/declarations.md index 2cef6649..e51c83c7 100644 --- a/docs/reference/language/declarations.md +++ b/docs/reference/language/declarations.md @@ -97,15 +97,15 @@ and no other. A file with a `given:` block loads and prints on its own. A given parameter is data this file reads and another file declares. ```yaml -dimensions: - snapshot: { dtype: int } - generator: { dtype: str } given: parameters: gen_cost: { dims: [generator], description: what one unit of output costs } gen_on: { dims: [generator], dtype: bool } variables: gen_p: { dims: [snapshot, generator] } +dimensions: + snapshot: { dtype: int } + generator: { dtype: str } constraints: off_units_idle: dims: [snapshot, generator] @@ -132,6 +132,11 @@ under _Given_. A given variable is a column this file reads and another file introduces. ```yaml +given: + variables: + flow: + dims: [snapshot, port] + description: what a port puts into its bus dimensions: snapshot: { dtype: int } port: { dtype: str } @@ -140,11 +145,6 @@ relations: gen_port: { key: generator, values: port } variables: gen_p: { dims: [snapshot, generator], bounds: { lower: 0 } } -given: - variables: - flow: - dims: [snapshot, port] - description: what a port puts into its bus constraints: gen_injects: dims: [snapshot, generator] @@ -179,14 +179,14 @@ A given constraint is a row family that another model builds. This file reads its dual. ```yaml -dimensions: - snapshot: { dtype: int } - bus: { dtype: str } given: constraints: balance: dims: [snapshot, bus] description: the host model clears each bus +dimensions: + snapshot: { dtype: int } + bus: { dtype: str } expressions: price: expression: dual(balance) @@ -208,14 +208,14 @@ A given expression is a named expression this file reads and another file defines. ```yaml -dimensions: - snapshot: { dtype: int } - bus: { dtype: str } given: expressions: injection: dims: [snapshot, bus] description: what the components put into a bus +dimensions: + snapshot: { dtype: int } + bus: { dtype: str } constraints: balance: dims: [snapshot, bus] @@ -254,6 +254,9 @@ part of it. ```yaml # fleet.yaml adds a term +given: + expressions: + injection: { dims: [snapshot, bus] } dimensions: snapshot: { dtype: int } bus: { dtype: str } @@ -262,9 +265,6 @@ relations: gen_bus: { key: generator, values: bus } variables: gen_p: { dims: [snapshot, generator], bounds: { lower: 0 } } -given: - expressions: - injection: { dims: [snapshot, bus] } expressions: generation: description: what the fleet puts into a bus @@ -274,14 +274,14 @@ expressions: ```yaml # balance.yaml reads the sum, and adds nothing to it -dimensions: - snapshot: { dtype: int } - bus: { dtype: str } given: expressions: injection: dims: [snapshot, bus] description: what the components put into a bus +dimensions: + snapshot: { dtype: int } + bus: { dtype: str } constraints: balance: dims: [snapshot, bus] diff --git a/docs/several-files.md b/docs/several-files.md index 92a64322..07359a19 100644 --- a/docs/several-files.md +++ b/docs/several-files.md @@ -21,10 +21,6 @@ component costs is a term of its own. ```yaml title="network.yaml" description: Every bus is balanced in every snapshot. -dimensions: - snapshot: { dtype: int, description: dispatch periods } - bus: { description: network nodes } - given: expressions: injection: @@ -34,6 +30,10 @@ given: dims: [] description: what running the system costs +dimensions: + snapshot: { dtype: int, description: dispatch periods } + bus: { description: network nodes } + constraints: balance: dims: [snapshot, bus] @@ -70,6 +70,11 @@ a claim, and `merge` carries the network's. ```yaml title="generators.yaml" description: A generator fleet, each unit on one bus. +given: + expressions: + injection: { dims: [snapshot, bus] } + total_cost: { dims: [] } + dimensions: snapshot: { dtype: int } bus: { dtype: str } @@ -88,11 +93,6 @@ variables: dims: [snapshot, generator] bounds: { lower: 0, upper: capacity } -given: - expressions: - injection: { dims: [snapshot, bus] } - total_cost: { dims: [] } - expressions: generation: description: what the fleet puts into a bus @@ -163,6 +163,10 @@ bus: ```yaml title="loads.yaml" description: The demand at every bus. +given: + expressions: + injection: { dims: [snapshot, bus] } + dimensions: snapshot: { dtype: int } bus: { dtype: str } @@ -170,10 +174,6 @@ dimensions: parameters: demand: { dims: [snapshot, bus], description: demand to be met } -given: - expressions: - injection: { dims: [snapshot, bus] } - expressions: consumption: description: what the loads take out of a bus @@ -282,6 +282,11 @@ term, `import_cost`, to the total cost: ```yaml title="imports.yaml" description: Power bought from outside the network, at a price. +given: + expressions: + injection: { dims: [snapshot, bus] } + total_cost: { dims: [] } + dimensions: snapshot: { dtype: int } bus: { dtype: str } @@ -296,11 +301,6 @@ variables: dims: [snapshot, bus] bounds: { lower: 0, upper: import_limit } -given: - expressions: - injection: { dims: [snapshot, bus] } - total_cost: { dims: [] } - expressions: purchase: description: what the imports put into a bus @@ -340,14 +340,14 @@ Make a file `emissions.yaml`. It caps what the fleet emits, and it reads ```yaml title="emissions.yaml" description: A cap on what the fleet emits over the horizon. -dimensions: - snapshot: { dtype: int } - generator: { dtype: str } - given: variables: dispatch: { dims: [snapshot, generator] } +dimensions: + snapshot: { dtype: int } + generator: { dtype: str } + parameters: emission_rate: { dims: [generator], description: emissions per unit of output } emission_cap: { dims: [], description: most the fleet may emit } diff --git a/examples/library/generator.yaml b/examples/library/generator.yaml index 12e7fe93..915b17da 100644 --- a/examples/library/generator.yaml +++ b/examples/library/generator.yaml @@ -6,12 +6,6 @@ description: >- PyPSA's `Generator`, wired to a port rather than straight to a bus, and cut to what a dispatch spec needs: a fixed build, no availability profile, no ramp limits. -dimensions: - snapshot: { dtype: datetime, description: dispatch periods } - port: { dtype: str, description: "the connections components make, one label per connection" } - generator: { dtype: str, description: "generating units, each on one port" } -relations: - Generator_port: { key: generator, values: port } given: variables: Port_p: @@ -19,6 +13,12 @@ given: description: the surface introduces this flow, and this file pins it at its own ports expressions: total_cost: { dims: [] } +dimensions: + snapshot: { dtype: datetime, description: dispatch periods } + port: { dtype: str, description: "the connections components make, one label per connection" } + generator: { dtype: str, description: "generating units, each on one port" } +relations: + Generator_port: { key: generator, values: port } parameters: Generator_p_nom: { dims: [generator], description: nominal power } Generator_marginal_cost: { dims: [generator], description: cost of one unit of output } diff --git a/examples/library/load.yaml b/examples/library/load.yaml index 91f194df..d77032be 100644 --- a/examples/library/load.yaml +++ b/examples/library/load.yaml @@ -3,17 +3,17 @@ # SPDX-License-Identifier: MIT description: PyPSA's `Load`, wired to a port rather than straight to a bus. What it takes is data, so it decides nothing. +given: + variables: + Port_p: + dims: [snapshot, port] + description: the surface introduces this flow, and this file pins it at its own ports dimensions: snapshot: { dtype: datetime, description: dispatch periods } port: { dtype: str, description: "the connections components make, one label per connection" } load: { dtype: str, description: "demands, each on one port" } relations: Load_port: { key: load, values: port } -given: - variables: - Port_p: - dims: [snapshot, port] - description: the surface introduces this flow, and this file pins it at its own ports parameters: Load_p_set: { dims: [snapshot, load], description: "`Load-p_set` — what a load takes in a snapshot" } constraints: diff --git a/examples/library/surface.yaml b/examples/library/surface.yaml index 91a1586e..f53d4618 100644 --- a/examples/library/surface.yaml +++ b/examples/library/surface.yaml @@ -8,6 +8,9 @@ description: >- wired to a port, the port to a bus, and the balance names no component class. A flow is positive where the port injects into its bus. A component that costs something adds its cost to `total_cost`. +given: + expressions: + total_cost: { dims: [], description: what running the system costs } dimensions: snapshot: { dtype: datetime, description: dispatch periods } bus: { dtype: str, description: network nodes } @@ -23,9 +26,6 @@ constraints: description: "`Bus-nodal_balance` — what the ports on a bus put in nets to nothing" dims: [snapshot, bus] expression: sum(Port_p, by=Port_bus, over=port, into=bus) == 0 -given: - expressions: - total_cost: { dims: [], description: what running the system costs } objective: sense: minimize expression: total_cost diff --git a/examples/pypsa/carrier.yaml b/examples/pypsa/carrier.yaml index f762b653..fc30fb7a 100644 --- a/examples/pypsa/carrier.yaml +++ b/examples/pypsa/carrier.yaml @@ -2,6 +2,10 @@ # # SPDX-License-Identifier: MIT +given: + expressions: + Carrier_additions: { dims: [period, carrier] } + dimensions: period: description: investment periods — PyPSA's `investment_periods` @@ -24,10 +28,6 @@ parameters: least over the scenarios, as PyPSA takes it, data prep dims: [carrier] -given: - expressions: - Carrier_additions: { dims: [period, carrier] } - expressions: Carrier_relative_growth: description: >- diff --git a/examples/pypsa/cost.yaml b/examples/pypsa/cost.yaml index 63703cdd..02943784 100644 --- a/examples/pypsa/cost.yaml +++ b/examples/pypsa/cost.yaml @@ -2,6 +2,14 @@ # # SPDX-License-Identifier: MIT +given: + parameters: + scenario_weight: { dims: [scenario] } + CVaR_omega: { dims: [] } + expressions: + scenario_opex: { dims: [scenario] } + total_cost: { dims: [] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -24,14 +32,6 @@ variables: description: "`CVaR` — the tail's average cost, what the objective prices at `omega`" dims: [] -given: - parameters: - scenario_weight: { dims: [scenario] } - CVaR_omega: { dims: [] } - expressions: - scenario_opex: { dims: [scenario] } - total_cost: { dims: [] } - expressions: risk_weighted_opex: expression: (1 - CVaR_omega) * sum(scenario_weight * scenario_opex, over=scenario) + CVaR_omega * CVaR diff --git a/examples/pypsa/generator.yaml b/examples/pypsa/generator.yaml index 36379bcb..662146e7 100644 --- a/examples/pypsa/generator.yaml +++ b/examples/pypsa/generator.yaml @@ -2,6 +2,28 @@ # # SPDX-License-Identifier: MIT +given: + parameters: + snapshot_weightings_objective: { dims: [snapshot] } + Generator_committable: { dims: [generator], dtype: bool } + Generator_maintenance_pu: { dims: [scenario, generator] } + scenario_weight: { dims: [scenario] } + CVaR_omega: { dims: [] } + period_weight_objective: { dims: [period] } + snapshot_weightings_generators: { dims: [snapshot] } + variables: + Generator_maintenance: { dims: [scenario, snapshot, generator] } + Generator_maintenance_capacity: { dims: [scenario, snapshot, generator] } + expressions: + GlobalConstraint_energy_weight: { dims: [scenario, global_constraint, snapshot] } + primary_energy: { dims: [scenario, global_constraint] } + operational_limit: { dims: [scenario, global_constraint] } + tech_capacity_expansion: { dims: [global_constraint] } + scenario_opex: { dims: [scenario] } + total_cost: { dims: [] } + Carrier_additions: { dims: [period, carrier] } + Bus_injection: { dims: [scenario, snapshot, bus] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -146,28 +168,6 @@ variables: dims: [generator] where: Generator_p_nom_extendable -given: - parameters: - snapshot_weightings_objective: { dims: [snapshot] } - Generator_committable: { dims: [generator], dtype: bool } - Generator_maintenance_pu: { dims: [scenario, generator] } - scenario_weight: { dims: [scenario] } - CVaR_omega: { dims: [] } - period_weight_objective: { dims: [period] } - snapshot_weightings_generators: { dims: [snapshot] } - variables: - Generator_maintenance: { dims: [scenario, snapshot, generator] } - Generator_maintenance_capacity: { dims: [scenario, snapshot, generator] } - expressions: - GlobalConstraint_energy_weight: { dims: [scenario, global_constraint, snapshot] } - primary_energy: { dims: [scenario, global_constraint] } - operational_limit: { dims: [scenario, global_constraint] } - tech_capacity_expansion: { dims: [global_constraint] } - scenario_opex: { dims: [scenario] } - total_cost: { dims: [] } - Carrier_additions: { dims: [period, carrier] } - Bus_injection: { dims: [scenario, snapshot, bus] } - expressions: Generator_p_nom_effective: description: the build a generator's limits are taken against — the chosen one where it is extendable, the given one otherwise diff --git a/examples/pypsa/generator_commitment.yaml b/examples/pypsa/generator_commitment.yaml index 8551031e..9af227b2 100644 --- a/examples/pypsa/generator_commitment.yaml +++ b/examples/pypsa/generator_commitment.yaml @@ -2,6 +2,28 @@ # # SPDX-License-Identifier: MIT +given: + parameters: + snapshot_weightings_objective: { dims: [snapshot] } + Generator_p_nom: { dims: [scenario, generator] } + Generator_p_nom_extendable: { dims: [generator], dtype: bool } + Generator_p_min_pu: { dims: [scenario, snapshot, generator] } + Generator_p_max_pu: { dims: [scenario, snapshot, generator] } + Generator_p_nom_mod: { dims: [generator] } + Generator_modules_installed: { dims: [scenario, generator] } + Generator_p_min_pu_nonneg: { dims: [generator], dtype: bool } + Generator_maintenance_pu: { dims: [scenario, generator] } + period_weight_objective: { dims: [period] } + Generator_active: { dims: [snapshot, generator], dtype: bool } + variables: + Generator_p: { dims: [scenario, snapshot, generator] } + Generator_n_mod: { dims: [generator], domain: integer } + Generator_maintenance_capacity: { dims: [scenario, snapshot, generator] } + Generator_maintenance_status: { dims: [scenario, snapshot, generator] } + Generator_p_nom_ext: { dims: [generator] } + expressions: + scenario_opex: { dims: [scenario] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -90,28 +112,6 @@ variables: bounds: lower: 0 -given: - parameters: - snapshot_weightings_objective: { dims: [snapshot] } - Generator_p_nom: { dims: [scenario, generator] } - Generator_p_nom_extendable: { dims: [generator], dtype: bool } - Generator_p_min_pu: { dims: [scenario, snapshot, generator] } - Generator_p_max_pu: { dims: [scenario, snapshot, generator] } - Generator_p_nom_mod: { dims: [generator] } - Generator_modules_installed: { dims: [scenario, generator] } - Generator_p_min_pu_nonneg: { dims: [generator], dtype: bool } - Generator_maintenance_pu: { dims: [scenario, generator] } - period_weight_objective: { dims: [period] } - Generator_active: { dims: [snapshot, generator], dtype: bool } - variables: - Generator_p: { dims: [scenario, snapshot, generator] } - Generator_n_mod: { dims: [generator], domain: integer } - Generator_maintenance_capacity: { dims: [scenario, snapshot, generator] } - Generator_maintenance_status: { dims: [scenario, snapshot, generator] } - Generator_p_nom_ext: { dims: [generator] } - expressions: - scenario_opex: { dims: [scenario] } - expressions: Generator_previous_status: description: >- diff --git a/examples/pypsa/generator_maintenance.yaml b/examples/pypsa/generator_maintenance.yaml index 1f8ca404..95f44111 100644 --- a/examples/pypsa/generator_maintenance.yaml +++ b/examples/pypsa/generator_maintenance.yaml @@ -2,6 +2,19 @@ # # SPDX-License-Identifier: MIT +given: + parameters: + Generator_p_nom_extendable: { dims: [generator], dtype: bool } + Generator_committable: { dims: [generator], dtype: bool } + Generator_p_nom_mod: { dims: [generator] } + Generator_active: { dims: [snapshot, generator], dtype: bool } + snapshot_weightings_generators: { dims: [snapshot] } + Generator_p_nom_min: { dims: [scenario, generator] } + Generator_p_nom_max: { dims: [scenario, generator] } + variables: + Generator_status: { dims: [scenario, snapshot, generator], domain: integer } + Generator_p_nom_ext: { dims: [generator] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -93,19 +106,6 @@ variables: bounds: lower: 0 -given: - parameters: - Generator_p_nom_extendable: { dims: [generator], dtype: bool } - Generator_committable: { dims: [generator], dtype: bool } - Generator_p_nom_mod: { dims: [generator] } - Generator_active: { dims: [snapshot, generator], dtype: bool } - snapshot_weightings_generators: { dims: [snapshot] } - Generator_p_nom_min: { dims: [scenario, generator] } - Generator_p_nom_max: { dims: [scenario, generator] } - variables: - Generator_status: { dims: [scenario, snapshot, generator], domain: integer } - Generator_p_nom_ext: { dims: [generator] } - constraints: Generator_maint_event_count: description: "`Generator-maint-event-count` — a maintainable generator holds its number of maintenance events over the horizon" diff --git a/examples/pypsa/generator_ramping.yaml b/examples/pypsa/generator_ramping.yaml index c128b6b6..efaac574 100644 --- a/examples/pypsa/generator_ramping.yaml +++ b/examples/pypsa/generator_ramping.yaml @@ -2,6 +2,25 @@ # # SPDX-License-Identifier: MIT +given: + parameters: + Generator_p_nom_extendable: { dims: [generator], dtype: bool } + Generator_committable: { dims: [generator], dtype: bool } + Generator_status_initial: { dims: [scenario, generator], dtype: int } + Generator_p_nom_mod: { dims: [generator] } + Generator_big_m: { dims: [scenario, generator] } + Generator_active: { dims: [snapshot, generator], dtype: bool } + variables: + Generator_p: { dims: [scenario, snapshot, generator] } + Generator_status: { dims: [scenario, snapshot, generator], domain: integer } + Generator_start_up: { dims: [scenario, snapshot, generator], domain: integer } + Generator_shut_down: { dims: [scenario, snapshot, generator], domain: integer } + Generator_p_nom_ext: { dims: [generator] } + expressions: + Generator_previous_status: { dims: [scenario, snapshot, generator] } + Generator_p_nom_effective: { dims: [scenario, generator] } + Generator_p_nom_committed: { dims: [scenario, generator] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -40,25 +59,6 @@ parameters: the unit carries no ramp row at the first snapshot dims: [scenario, generator] -given: - parameters: - Generator_p_nom_extendable: { dims: [generator], dtype: bool } - Generator_committable: { dims: [generator], dtype: bool } - Generator_status_initial: { dims: [scenario, generator], dtype: int } - Generator_p_nom_mod: { dims: [generator] } - Generator_big_m: { dims: [scenario, generator] } - Generator_active: { dims: [snapshot, generator], dtype: bool } - variables: - Generator_p: { dims: [scenario, snapshot, generator] } - Generator_status: { dims: [scenario, snapshot, generator], domain: integer } - Generator_start_up: { dims: [scenario, snapshot, generator], domain: integer } - Generator_shut_down: { dims: [scenario, snapshot, generator], domain: integer } - Generator_p_nom_ext: { dims: [generator] } - expressions: - Generator_previous_status: { dims: [scenario, snapshot, generator] } - Generator_p_nom_effective: { dims: [scenario, generator] } - Generator_p_nom_committed: { dims: [scenario, generator] } - expressions: Generator_previous_p: description: >- diff --git a/examples/pypsa/global_constraints.yaml b/examples/pypsa/global_constraints.yaml index b2df5d5b..fd9774a3 100644 --- a/examples/pypsa/global_constraints.yaml +++ b/examples/pypsa/global_constraints.yaml @@ -2,6 +2,16 @@ # # SPDX-License-Identifier: MIT +given: + parameters: + scenario_weight: { dims: [scenario] } + expressions: + primary_energy: { dims: [scenario, global_constraint] } + operational_limit: { dims: [scenario, global_constraint] } + transmission_volume_expansion: { dims: [scenario, global_constraint] } + transmission_expansion_cost: { dims: [scenario, global_constraint] } + tech_capacity_expansion: { dims: [global_constraint] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -33,16 +43,6 @@ parameters: (`global_constraints.py:557`, `:749`, `:861`) dims: [scenario, global_constraint] -given: - parameters: - scenario_weight: { dims: [scenario] } - expressions: - primary_energy: { dims: [scenario, global_constraint] } - operational_limit: { dims: [scenario, global_constraint] } - transmission_volume_expansion: { dims: [scenario, global_constraint] } - transmission_expansion_cost: { dims: [scenario, global_constraint] } - tech_capacity_expansion: { dims: [global_constraint] } - constraints: GlobalConstraint_primary_energy_ub: description: "`primary_energy` — its total, at most its constant" diff --git a/examples/pypsa/line.yaml b/examples/pypsa/line.yaml index dd325ecd..57651d4b 100644 --- a/examples/pypsa/line.yaml +++ b/examples/pypsa/line.yaml @@ -2,6 +2,19 @@ # # SPDX-License-Identifier: MIT +given: + parameters: + scenario_weight: { dims: [scenario] } + transmission_losses: { dims: [], dtype: bool } + expressions: + transmission_volume_expansion: { dims: [scenario, global_constraint] } + transmission_expansion_cost: { dims: [scenario, global_constraint] } + tech_capacity_expansion: { dims: [global_constraint] } + total_cost: { dims: [] } + Carrier_additions: { dims: [period, carrier] } + Bus_injection: { dims: [scenario, snapshot, bus] } + Cycle_angle_sum: { dims: [scenario, snapshot, cycle] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -149,19 +162,6 @@ variables: dims: [line] where: Line_s_nom_extendable -given: - parameters: - scenario_weight: { dims: [scenario] } - transmission_losses: { dims: [], dtype: bool } - expressions: - transmission_volume_expansion: { dims: [scenario, global_constraint] } - transmission_expansion_cost: { dims: [scenario, global_constraint] } - tech_capacity_expansion: { dims: [global_constraint] } - total_cost: { dims: [] } - Carrier_additions: { dims: [period, carrier] } - Bus_injection: { dims: [scenario, snapshot, bus] } - Cycle_angle_sum: { dims: [scenario, snapshot, cycle] } - expressions: Line_transmission_volume_expansion: expression: sum(Line_s_nom_ext * Line_volume_weight, over=line) diff --git a/examples/pypsa/link.yaml b/examples/pypsa/link.yaml index cc46eafe..17dd7d4e 100644 --- a/examples/pypsa/link.yaml +++ b/examples/pypsa/link.yaml @@ -2,6 +2,26 @@ # # SPDX-License-Identifier: MIT +given: + parameters: + snapshot_weightings_objective: { dims: [snapshot] } + Link_committable: { dims: [link], dtype: bool } + Link_maintenance_pu: { dims: [scenario, link] } + scenario_weight: { dims: [scenario] } + CVaR_omega: { dims: [] } + period_weight_objective: { dims: [period] } + variables: + Link_maintenance: { dims: [scenario, snapshot, link] } + Link_maintenance_capacity: { dims: [scenario, snapshot, link] } + expressions: + transmission_volume_expansion: { dims: [scenario, global_constraint] } + transmission_expansion_cost: { dims: [scenario, global_constraint] } + tech_capacity_expansion: { dims: [global_constraint] } + scenario_opex: { dims: [scenario] } + total_cost: { dims: [] } + Carrier_additions: { dims: [period, carrier] } + Bus_injection: { dims: [scenario, snapshot, bus] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -186,26 +206,6 @@ variables: dims: [link] where: Link_p_nom_extendable -given: - parameters: - snapshot_weightings_objective: { dims: [snapshot] } - Link_committable: { dims: [link], dtype: bool } - Link_maintenance_pu: { dims: [scenario, link] } - scenario_weight: { dims: [scenario] } - CVaR_omega: { dims: [] } - period_weight_objective: { dims: [period] } - variables: - Link_maintenance: { dims: [scenario, snapshot, link] } - Link_maintenance_capacity: { dims: [scenario, snapshot, link] } - expressions: - transmission_volume_expansion: { dims: [scenario, global_constraint] } - transmission_expansion_cost: { dims: [scenario, global_constraint] } - tech_capacity_expansion: { dims: [global_constraint] } - scenario_opex: { dims: [scenario] } - total_cost: { dims: [] } - Carrier_additions: { dims: [period, carrier] } - Bus_injection: { dims: [scenario, snapshot, bus] } - expressions: Link_p_nom_effective: description: the build a link's limits are taken against — the chosen one where it is extendable, the given one otherwise diff --git a/examples/pypsa/link_commitment.yaml b/examples/pypsa/link_commitment.yaml index 9c5cea68..e5e39af5 100644 --- a/examples/pypsa/link_commitment.yaml +++ b/examples/pypsa/link_commitment.yaml @@ -2,6 +2,28 @@ # # SPDX-License-Identifier: MIT +given: + parameters: + snapshot_weightings_objective: { dims: [snapshot] } + Link_p_nom: { dims: [scenario, link] } + Link_p_nom_extendable: { dims: [link], dtype: bool } + Link_p_min_pu: { dims: [scenario, snapshot, link] } + Link_p_max_pu: { dims: [scenario, snapshot, link] } + Link_p_nom_mod: { dims: [link] } + Link_modules_installed: { dims: [scenario, link] } + Link_p_min_pu_nonneg: { dims: [link], dtype: bool } + Link_maintenance_pu: { dims: [scenario, link] } + period_weight_objective: { dims: [period] } + Link_active: { dims: [snapshot, link], dtype: bool } + variables: + Link_p: { dims: [scenario, snapshot, link] } + Link_n_mod: { dims: [link], domain: integer } + Link_maintenance_capacity: { dims: [scenario, snapshot, link] } + Link_maintenance_status: { dims: [scenario, snapshot, link] } + Link_p_nom_ext: { dims: [link] } + expressions: + scenario_opex: { dims: [scenario] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -90,28 +112,6 @@ variables: bounds: lower: 0 -given: - parameters: - snapshot_weightings_objective: { dims: [snapshot] } - Link_p_nom: { dims: [scenario, link] } - Link_p_nom_extendable: { dims: [link], dtype: bool } - Link_p_min_pu: { dims: [scenario, snapshot, link] } - Link_p_max_pu: { dims: [scenario, snapshot, link] } - Link_p_nom_mod: { dims: [link] } - Link_modules_installed: { dims: [scenario, link] } - Link_p_min_pu_nonneg: { dims: [link], dtype: bool } - Link_maintenance_pu: { dims: [scenario, link] } - period_weight_objective: { dims: [period] } - Link_active: { dims: [snapshot, link], dtype: bool } - variables: - Link_p: { dims: [scenario, snapshot, link] } - Link_n_mod: { dims: [link], domain: integer } - Link_maintenance_capacity: { dims: [scenario, snapshot, link] } - Link_maintenance_status: { dims: [scenario, snapshot, link] } - Link_p_nom_ext: { dims: [link] } - expressions: - scenario_opex: { dims: [scenario] } - expressions: Link_previous_status: description: >- diff --git a/examples/pypsa/link_maintenance.yaml b/examples/pypsa/link_maintenance.yaml index e81eefbf..411c3168 100644 --- a/examples/pypsa/link_maintenance.yaml +++ b/examples/pypsa/link_maintenance.yaml @@ -2,6 +2,19 @@ # # SPDX-License-Identifier: MIT +given: + parameters: + Link_p_nom_extendable: { dims: [link], dtype: bool } + Link_committable: { dims: [link], dtype: bool } + Link_p_nom_mod: { dims: [link] } + Link_active: { dims: [snapshot, link], dtype: bool } + snapshot_weightings_generators: { dims: [snapshot] } + Link_p_nom_min: { dims: [scenario, link] } + Link_p_nom_max: { dims: [scenario, link] } + variables: + Link_status: { dims: [scenario, snapshot, link], domain: integer } + Link_p_nom_ext: { dims: [link] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -93,19 +106,6 @@ variables: bounds: lower: 0 -given: - parameters: - Link_p_nom_extendable: { dims: [link], dtype: bool } - Link_committable: { dims: [link], dtype: bool } - Link_p_nom_mod: { dims: [link] } - Link_active: { dims: [snapshot, link], dtype: bool } - snapshot_weightings_generators: { dims: [snapshot] } - Link_p_nom_min: { dims: [scenario, link] } - Link_p_nom_max: { dims: [scenario, link] } - variables: - Link_status: { dims: [scenario, snapshot, link], domain: integer } - Link_p_nom_ext: { dims: [link] } - constraints: Link_maint_event_count: description: "`Link-maint-event-count` — a maintainable link holds its number of maintenance events over the horizon" diff --git a/examples/pypsa/link_ramping.yaml b/examples/pypsa/link_ramping.yaml index 4b643a02..7d0630d7 100644 --- a/examples/pypsa/link_ramping.yaml +++ b/examples/pypsa/link_ramping.yaml @@ -2,6 +2,25 @@ # # SPDX-License-Identifier: MIT +given: + parameters: + Link_p_nom_extendable: { dims: [link], dtype: bool } + Link_committable: { dims: [link], dtype: bool } + Link_status_initial: { dims: [scenario, link], dtype: int } + Link_p_nom_mod: { dims: [link] } + Link_big_m: { dims: [scenario, link] } + Link_active: { dims: [snapshot, link], dtype: bool } + variables: + Link_p: { dims: [scenario, snapshot, link] } + Link_status: { dims: [scenario, snapshot, link], domain: integer } + Link_start_up: { dims: [scenario, snapshot, link], domain: integer } + Link_shut_down: { dims: [scenario, snapshot, link], domain: integer } + Link_p_nom_ext: { dims: [link] } + expressions: + Link_p_nom_effective: { dims: [scenario, link] } + Link_previous_status: { dims: [scenario, snapshot, link] } + Link_p_nom_committed: { dims: [scenario, link] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -40,25 +59,6 @@ parameters: the link carries no ramp row at the first snapshot dims: [scenario, link] -given: - parameters: - Link_p_nom_extendable: { dims: [link], dtype: bool } - Link_committable: { dims: [link], dtype: bool } - Link_status_initial: { dims: [scenario, link], dtype: int } - Link_p_nom_mod: { dims: [link] } - Link_big_m: { dims: [scenario, link] } - Link_active: { dims: [snapshot, link], dtype: bool } - variables: - Link_p: { dims: [scenario, snapshot, link] } - Link_status: { dims: [scenario, snapshot, link], domain: integer } - Link_start_up: { dims: [scenario, snapshot, link], domain: integer } - Link_shut_down: { dims: [scenario, snapshot, link], domain: integer } - Link_p_nom_ext: { dims: [link] } - expressions: - Link_p_nom_effective: { dims: [scenario, link] } - Link_previous_status: { dims: [scenario, snapshot, link] } - Link_p_nom_committed: { dims: [scenario, link] } - expressions: Link_previous_p: description: >- diff --git a/examples/pypsa/load.yaml b/examples/pypsa/load.yaml index b84a0740..3d63358e 100644 --- a/examples/pypsa/load.yaml +++ b/examples/pypsa/load.yaml @@ -2,6 +2,10 @@ # # SPDX-License-Identifier: MIT +given: + expressions: + Bus_injection: { dims: [scenario, snapshot, bus] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -37,10 +41,6 @@ parameters: dims: [load] dtype: bool -given: - expressions: - Bus_injection: { dims: [scenario, snapshot, bus] } - expressions: Load_demand: description: >- diff --git a/examples/pypsa/network.yaml b/examples/pypsa/network.yaml index 87ea1317..21031492 100644 --- a/examples/pypsa/network.yaml +++ b/examples/pypsa/network.yaml @@ -2,15 +2,6 @@ # # SPDX-License-Identifier: MIT -dimensions: - scenario: - description: the futures dispatch is chosen in, each with a weight - snapshot: - description: dispatch periods - dtype: datetime - bus: - description: network nodes - given: expressions: Bus_injection: @@ -20,6 +11,15 @@ given: PyPSA writes each term into the balance, and a load on its right-hand side +dimensions: + scenario: + description: the futures dispatch is chosen in, each with a weight + snapshot: + description: dispatch periods + dtype: datetime + bus: + description: network nodes + constraints: Bus_nodal_balance: description: >- diff --git a/examples/pypsa/power_flow.yaml b/examples/pypsa/power_flow.yaml index b7edbe54..7fadc9bb 100644 --- a/examples/pypsa/power_flow.yaml +++ b/examples/pypsa/power_flow.yaml @@ -2,6 +2,14 @@ # # SPDX-License-Identifier: MIT +given: + expressions: + Cycle_angle_sum: + dims: [scenario, snapshot, cycle] + description: >- + the voltage angle differences around a cycle: every branch flow times + its cycle weight, and every transformer phase shift + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -11,14 +19,6 @@ dimensions: cycle: description: independent cycles of the passive network graph — the cycle basis, data prep -given: - expressions: - Cycle_angle_sum: - dims: [scenario, snapshot, cycle] - description: >- - the voltage angle differences around a cycle: every branch flow times - its cycle weight, and every transformer phase shift - constraints: Kirchhoff_Voltage_Law: description: >- diff --git a/examples/pypsa/process.yaml b/examples/pypsa/process.yaml index 8c16c8a9..317db162 100644 --- a/examples/pypsa/process.yaml +++ b/examples/pypsa/process.yaml @@ -2,6 +2,24 @@ # # SPDX-License-Identifier: MIT +given: + parameters: + snapshot_weightings_objective: { dims: [snapshot] } + Process_committable: { dims: [process], dtype: bool } + Process_maintenance_pu: { dims: [scenario, process] } + scenario_weight: { dims: [scenario] } + CVaR_omega: { dims: [] } + period_weight_objective: { dims: [period] } + variables: + Process_maintenance: { dims: [scenario, snapshot, process] } + Process_maintenance_capacity: { dims: [scenario, snapshot, process] } + expressions: + tech_capacity_expansion: { dims: [global_constraint] } + scenario_opex: { dims: [scenario] } + total_cost: { dims: [] } + Carrier_additions: { dims: [period, carrier] } + Bus_injection: { dims: [scenario, snapshot, bus] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -165,24 +183,6 @@ variables: dims: [process] where: Process_p_nom_extendable -given: - parameters: - snapshot_weightings_objective: { dims: [snapshot] } - Process_committable: { dims: [process], dtype: bool } - Process_maintenance_pu: { dims: [scenario, process] } - scenario_weight: { dims: [scenario] } - CVaR_omega: { dims: [] } - period_weight_objective: { dims: [period] } - variables: - Process_maintenance: { dims: [scenario, snapshot, process] } - Process_maintenance_capacity: { dims: [scenario, snapshot, process] } - expressions: - tech_capacity_expansion: { dims: [global_constraint] } - scenario_opex: { dims: [scenario] } - total_cost: { dims: [] } - Carrier_additions: { dims: [period, carrier] } - Bus_injection: { dims: [scenario, snapshot, bus] } - expressions: Process_p_nom_effective: description: the build a process's limits are taken against — the chosen one where it is extendable, the given one otherwise diff --git a/examples/pypsa/process_commitment.yaml b/examples/pypsa/process_commitment.yaml index 79c1a12d..6e2716f3 100644 --- a/examples/pypsa/process_commitment.yaml +++ b/examples/pypsa/process_commitment.yaml @@ -2,6 +2,28 @@ # # SPDX-License-Identifier: MIT +given: + parameters: + snapshot_weightings_objective: { dims: [snapshot] } + Process_p_nom: { dims: [scenario, process] } + Process_p_nom_extendable: { dims: [process], dtype: bool } + Process_p_min_pu: { dims: [scenario, snapshot, process] } + Process_p_max_pu: { dims: [scenario, snapshot, process] } + Process_p_nom_mod: { dims: [process] } + Process_modules_installed: { dims: [scenario, process] } + Process_p_min_pu_nonneg: { dims: [process], dtype: bool } + Process_maintenance_pu: { dims: [scenario, process] } + period_weight_objective: { dims: [period] } + Process_active: { dims: [snapshot, process], dtype: bool } + variables: + Process_p: { dims: [scenario, snapshot, process] } + Process_n_mod: { dims: [process], domain: integer } + Process_maintenance_capacity: { dims: [scenario, snapshot, process] } + Process_maintenance_status: { dims: [scenario, snapshot, process] } + Process_p_nom_ext: { dims: [process] } + expressions: + scenario_opex: { dims: [scenario] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -90,28 +112,6 @@ variables: bounds: lower: 0 -given: - parameters: - snapshot_weightings_objective: { dims: [snapshot] } - Process_p_nom: { dims: [scenario, process] } - Process_p_nom_extendable: { dims: [process], dtype: bool } - Process_p_min_pu: { dims: [scenario, snapshot, process] } - Process_p_max_pu: { dims: [scenario, snapshot, process] } - Process_p_nom_mod: { dims: [process] } - Process_modules_installed: { dims: [scenario, process] } - Process_p_min_pu_nonneg: { dims: [process], dtype: bool } - Process_maintenance_pu: { dims: [scenario, process] } - period_weight_objective: { dims: [period] } - Process_active: { dims: [snapshot, process], dtype: bool } - variables: - Process_p: { dims: [scenario, snapshot, process] } - Process_n_mod: { dims: [process], domain: integer } - Process_maintenance_capacity: { dims: [scenario, snapshot, process] } - Process_maintenance_status: { dims: [scenario, snapshot, process] } - Process_p_nom_ext: { dims: [process] } - expressions: - scenario_opex: { dims: [scenario] } - expressions: Process_previous_status: description: >- diff --git a/examples/pypsa/process_maintenance.yaml b/examples/pypsa/process_maintenance.yaml index 2f1b9de8..7acaf109 100644 --- a/examples/pypsa/process_maintenance.yaml +++ b/examples/pypsa/process_maintenance.yaml @@ -2,6 +2,19 @@ # # SPDX-License-Identifier: MIT +given: + parameters: + Process_p_nom_extendable: { dims: [process], dtype: bool } + Process_p_nom_min: { dims: [scenario, process] } + Process_p_nom_max: { dims: [scenario, process] } + Process_committable: { dims: [process], dtype: bool } + Process_p_nom_mod: { dims: [process] } + Process_active: { dims: [snapshot, process], dtype: bool } + snapshot_weightings_generators: { dims: [snapshot] } + variables: + Process_status: { dims: [scenario, snapshot, process], domain: integer } + Process_p_nom_ext: { dims: [process] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -93,19 +106,6 @@ variables: bounds: lower: 0 -given: - parameters: - Process_p_nom_extendable: { dims: [process], dtype: bool } - Process_p_nom_min: { dims: [scenario, process] } - Process_p_nom_max: { dims: [scenario, process] } - Process_committable: { dims: [process], dtype: bool } - Process_p_nom_mod: { dims: [process] } - Process_active: { dims: [snapshot, process], dtype: bool } - snapshot_weightings_generators: { dims: [snapshot] } - variables: - Process_status: { dims: [scenario, snapshot, process], domain: integer } - Process_p_nom_ext: { dims: [process] } - constraints: Process_maint_event_count: description: "`Process-maint-event-count` — a maintainable process holds its number of maintenance events over the horizon" diff --git a/examples/pypsa/process_ramping.yaml b/examples/pypsa/process_ramping.yaml index 7bb61fdf..a8e91b50 100644 --- a/examples/pypsa/process_ramping.yaml +++ b/examples/pypsa/process_ramping.yaml @@ -2,6 +2,25 @@ # # SPDX-License-Identifier: MIT +given: + parameters: + Process_p_nom_extendable: { dims: [process], dtype: bool } + Process_committable: { dims: [process], dtype: bool } + Process_status_initial: { dims: [scenario, process], dtype: int } + Process_p_nom_mod: { dims: [process] } + Process_big_m: { dims: [scenario, process] } + Process_active: { dims: [snapshot, process], dtype: bool } + variables: + Process_p: { dims: [scenario, snapshot, process] } + Process_status: { dims: [scenario, snapshot, process], domain: integer } + Process_start_up: { dims: [scenario, snapshot, process], domain: integer } + Process_shut_down: { dims: [scenario, snapshot, process], domain: integer } + Process_p_nom_ext: { dims: [process] } + expressions: + Process_p_nom_effective: { dims: [scenario, process] } + Process_previous_status: { dims: [scenario, snapshot, process] } + Process_p_nom_committed: { dims: [scenario, process] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -40,25 +59,6 @@ parameters: the process carries no ramp row at the first snapshot dims: [scenario, process] -given: - parameters: - Process_p_nom_extendable: { dims: [process], dtype: bool } - Process_committable: { dims: [process], dtype: bool } - Process_status_initial: { dims: [scenario, process], dtype: int } - Process_p_nom_mod: { dims: [process] } - Process_big_m: { dims: [scenario, process] } - Process_active: { dims: [snapshot, process], dtype: bool } - variables: - Process_p: { dims: [scenario, snapshot, process] } - Process_status: { dims: [scenario, snapshot, process], domain: integer } - Process_start_up: { dims: [scenario, snapshot, process], domain: integer } - Process_shut_down: { dims: [scenario, snapshot, process], domain: integer } - Process_p_nom_ext: { dims: [process] } - expressions: - Process_p_nom_effective: { dims: [scenario, process] } - Process_previous_status: { dims: [scenario, snapshot, process] } - Process_p_nom_committed: { dims: [scenario, process] } - expressions: Process_previous_p: description: >- diff --git a/examples/pypsa/security.yaml b/examples/pypsa/security.yaml index 79f9de02..c3b974cd 100644 --- a/examples/pypsa/security.yaml +++ b/examples/pypsa/security.yaml @@ -2,6 +2,21 @@ # # SPDX-License-Identifier: MIT +given: + parameters: + Line_s_nom: { dims: [scenario, line] } + Line_s_nom_extendable: { dims: [line], dtype: bool } + Line_s_max_pu: { dims: [scenario, snapshot, line] } + Transformer_s_nom: { dims: [scenario, transformer] } + Transformer_s_nom_extendable: { dims: [transformer], dtype: bool } + Transformer_s_max_pu: { dims: [scenario, snapshot, transformer] } + variables: + Line_s_nom_ext: { dims: [line] } + Transformer_s_nom_ext: { dims: [transformer] } + expressions: + Line_s_monitored: { dims: [scenario, snapshot, line] } + Transformer_s_monitored: { dims: [scenario, snapshot, transformer] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -43,21 +58,6 @@ parameters: outage share a sub-network dims: [transformer, outage] -given: - parameters: - Line_s_nom: { dims: [scenario, line] } - Line_s_nom_extendable: { dims: [line], dtype: bool } - Line_s_max_pu: { dims: [scenario, snapshot, line] } - Transformer_s_nom: { dims: [scenario, transformer] } - Transformer_s_nom_extendable: { dims: [transformer], dtype: bool } - Transformer_s_max_pu: { dims: [scenario, snapshot, transformer] } - variables: - Line_s_nom_ext: { dims: [line] } - Transformer_s_nom_ext: { dims: [transformer] } - expressions: - Line_s_monitored: { dims: [scenario, snapshot, line] } - Transformer_s_monitored: { dims: [scenario, snapshot, transformer] } - expressions: Outage_s: description: >- diff --git a/examples/pypsa/settings.yaml b/examples/pypsa/settings.yaml index 5e62069a..e781c283 100644 --- a/examples/pypsa/settings.yaml +++ b/examples/pypsa/settings.yaml @@ -2,6 +2,58 @@ # # SPDX-License-Identifier: MIT +given: + expressions: + primary_energy: + dims: [scenario, global_constraint] + description: >- + what a `primary_energy` row totals — weighted generator energy over the + snapshots it counts, less the charge left in weighted storage at the + close; the initial charge it is compared against is folded into the + row's constant + operational_limit: + dims: [scenario, global_constraint] + description: >- + what an `operational_limit` row totals — the weighted energy its + generators deliver over the snapshots it counts, plus what its + non-cyclic storage draws down; the initial charge it draws from is + folded into the row's constant + transmission_volume_expansion: + dims: [scenario, global_constraint] + description: >- + what a `transmission_volume_expansion_limit` row totals — length times + the chosen build of the row's branches + transmission_expansion_cost: + dims: [scenario, global_constraint] + description: >- + what a `transmission_expansion_cost_limit` row totals — capital cost + times the chosen build of the row's branches + tech_capacity_expansion: + dims: [global_constraint] + description: >- + what a `tech_capacity_expansion_limit` row totals — the chosen build of + the row's carrier-and-bus set + scenario_opex: + dims: [scenario] + description: >- + what a future costs to run — every operating term, weighted by the + snapshot's hours and its period, before the scenario's own weight; a + start and a stop cost what they cost, unweighted, as PyPSA adds them + (`optimize.py:414-429`) + total_cost: + dims: [] + description: >- + what the system costs — capacity once per active period at its expected + cost over the scenarios, operation in expectation over the scenarios, + and a share of it at the tail + Carrier_additions: + dims: [period, carrier] + description: >- + what a carrier adds in a period — every extendable component of that + carrier, counting each build in the first period it stands in. Like + PyPSA, it sums only the components that carry a carrier attribute, so a + transformer, which has none, counts in no carrier + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -69,58 +121,6 @@ parameters: dims: [scenario, global_constraint, snapshot] dtype: bool -given: - expressions: - primary_energy: - dims: [scenario, global_constraint] - description: >- - what a `primary_energy` row totals — weighted generator energy over the - snapshots it counts, less the charge left in weighted storage at the - close; the initial charge it is compared against is folded into the - row's constant - operational_limit: - dims: [scenario, global_constraint] - description: >- - what an `operational_limit` row totals — the weighted energy its - generators deliver over the snapshots it counts, plus what its - non-cyclic storage draws down; the initial charge it draws from is - folded into the row's constant - transmission_volume_expansion: - dims: [scenario, global_constraint] - description: >- - what a `transmission_volume_expansion_limit` row totals — length times - the chosen build of the row's branches - transmission_expansion_cost: - dims: [scenario, global_constraint] - description: >- - what a `transmission_expansion_cost_limit` row totals — capital cost - times the chosen build of the row's branches - tech_capacity_expansion: - dims: [global_constraint] - description: >- - what a `tech_capacity_expansion_limit` row totals — the chosen build of - the row's carrier-and-bus set - scenario_opex: - dims: [scenario] - description: >- - what a future costs to run — every operating term, weighted by the - snapshot's hours and its period, before the scenario's own weight; a - start and a stop cost what they cost, unweighted, as PyPSA adds them - (`optimize.py:414-429`) - total_cost: - dims: [] - description: >- - what the system costs — capacity once per active period at its expected - cost over the scenarios, operation in expectation over the scenarios, - and a share of it at the tail - Carrier_additions: - dims: [period, carrier] - description: >- - what a carrier adds in a period — every extendable component of that - carrier, counting each build in the first period it stands in. Like - PyPSA, it sums only the components that carry a carrier attribute, so a - transformer, which has none, counts in no carrier - expressions: GlobalConstraint_energy_weight: description: >- diff --git a/examples/pypsa/storage_unit.yaml b/examples/pypsa/storage_unit.yaml index 0bcc83d9..f90a4467 100644 --- a/examples/pypsa/storage_unit.yaml +++ b/examples/pypsa/storage_unit.yaml @@ -2,6 +2,25 @@ # # SPDX-License-Identifier: MIT +given: + parameters: + snapshot_weightings_objective: { dims: [snapshot] } + scenario_weight: { dims: [scenario] } + CVaR_omega: { dims: [] } + period_weight_objective: { dims: [period] } + period_weight_years: { dims: [period] } + snapshot_weightings_stores: { dims: [snapshot] } + GlobalConstraint_counts_snapshot: { dims: [scenario, global_constraint, snapshot], dtype: bool } + expressions: + GlobalConstraint_snapshot_closes: { dims: [scenario, global_constraint, snapshot] } + primary_energy: { dims: [scenario, global_constraint] } + operational_limit: { dims: [scenario, global_constraint] } + tech_capacity_expansion: { dims: [global_constraint] } + scenario_opex: { dims: [scenario] } + total_cost: { dims: [] } + Carrier_additions: { dims: [period, carrier] } + Bus_injection: { dims: [scenario, snapshot, bus] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -200,25 +219,6 @@ variables: dims: [storage_unit] where: StorageUnit_p_nom_extendable -given: - parameters: - snapshot_weightings_objective: { dims: [snapshot] } - scenario_weight: { dims: [scenario] } - CVaR_omega: { dims: [] } - period_weight_objective: { dims: [period] } - period_weight_years: { dims: [period] } - snapshot_weightings_stores: { dims: [snapshot] } - GlobalConstraint_counts_snapshot: { dims: [scenario, global_constraint, snapshot], dtype: bool } - expressions: - GlobalConstraint_snapshot_closes: { dims: [scenario, global_constraint, snapshot] } - primary_energy: { dims: [scenario, global_constraint] } - operational_limit: { dims: [scenario, global_constraint] } - tech_capacity_expansion: { dims: [global_constraint] } - scenario_opex: { dims: [scenario] } - total_cost: { dims: [] } - Carrier_additions: { dims: [period, carrier] } - Bus_injection: { dims: [scenario, snapshot, bus] } - expressions: StorageUnit_charge_carried_in: description: >- diff --git a/examples/pypsa/store.yaml b/examples/pypsa/store.yaml index d10d8e2b..8e06c0de 100644 --- a/examples/pypsa/store.yaml +++ b/examples/pypsa/store.yaml @@ -2,6 +2,25 @@ # # SPDX-License-Identifier: MIT +given: + parameters: + snapshot_weightings_objective: { dims: [snapshot] } + scenario_weight: { dims: [scenario] } + CVaR_omega: { dims: [] } + period_weight_objective: { dims: [period] } + period_weight_years: { dims: [period] } + snapshot_weightings_stores: { dims: [snapshot] } + GlobalConstraint_counts_snapshot: { dims: [scenario, global_constraint, snapshot], dtype: bool } + expressions: + GlobalConstraint_snapshot_closes: { dims: [scenario, global_constraint, snapshot] } + primary_energy: { dims: [scenario, global_constraint] } + operational_limit: { dims: [scenario, global_constraint] } + tech_capacity_expansion: { dims: [global_constraint] } + scenario_opex: { dims: [scenario] } + total_cost: { dims: [] } + Carrier_additions: { dims: [period, carrier] } + Bus_injection: { dims: [scenario, snapshot, bus] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -164,25 +183,6 @@ variables: dims: [store] where: Store_e_nom_extendable -given: - parameters: - snapshot_weightings_objective: { dims: [snapshot] } - scenario_weight: { dims: [scenario] } - CVaR_omega: { dims: [] } - period_weight_objective: { dims: [period] } - period_weight_years: { dims: [period] } - snapshot_weightings_stores: { dims: [snapshot] } - GlobalConstraint_counts_snapshot: { dims: [scenario, global_constraint, snapshot], dtype: bool } - expressions: - GlobalConstraint_snapshot_closes: { dims: [scenario, global_constraint, snapshot] } - primary_energy: { dims: [scenario, global_constraint] } - operational_limit: { dims: [scenario, global_constraint] } - tech_capacity_expansion: { dims: [global_constraint] } - scenario_opex: { dims: [scenario] } - total_cost: { dims: [] } - Carrier_additions: { dims: [period, carrier] } - Bus_injection: { dims: [scenario, snapshot, bus] } - expressions: Store_energy_carried_in: description: >- diff --git a/examples/pypsa/transformer.yaml b/examples/pypsa/transformer.yaml index 6f2f3061..1ed9b36b 100644 --- a/examples/pypsa/transformer.yaml +++ b/examples/pypsa/transformer.yaml @@ -2,6 +2,15 @@ # # SPDX-License-Identifier: MIT +given: + parameters: + scenario_weight: { dims: [scenario] } + transmission_losses: { dims: [], dtype: bool } + expressions: + total_cost: { dims: [] } + Bus_injection: { dims: [scenario, snapshot, bus] } + Cycle_angle_sum: { dims: [scenario, snapshot, cycle] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -160,15 +169,6 @@ variables: dims: [transformer] where: Transformer_s_nom_extendable -given: - parameters: - scenario_weight: { dims: [scenario] } - transmission_losses: { dims: [], dtype: bool } - expressions: - total_cost: { dims: [] } - Bus_injection: { dims: [scenario, snapshot, bus] } - Cycle_angle_sum: { dims: [scenario, snapshot, cycle] } - expressions: Transformer_capex: expression: sum(scenario_weight * Transformer_s_nom_ext * Transformer_capital_cost * Transformer_capital_weight) diff --git a/tools/pypsa_split.py b/tools/pypsa_split.py index 17639c0f..5f91baae 100644 --- a/tools/pypsa_split.py +++ b/tools/pypsa_split.py @@ -291,13 +291,15 @@ def _fragment( adds: Mapping[str, str], homes: set[str], ) -> str: - """One fragment as YAML text, its sections and declarations in the order of the source file. + """One fragment as YAML text, its ``given:`` block first, then its sections and declarations in source order. A term carries the hub it adds to as ``adds_to:``. A hub the fragment is home to is read under ``given:`` with its description, and the home of the hub the objective reads writes the objective. """ parts = [HEADER] + if given: + parts.append('given:\n' + ''.join(_given(model, kind, given, stated, homes) for kind in GIVEN_KINDS)) hubs = {term: hub for hub, term in adds.items()} for section in SECTIONS: blocks = [ @@ -309,8 +311,6 @@ def _fragment( ] if blocks: parts.append(f'{section}:\n' + '\n'.join(blocks) + '\n') - if section == 'variables' and given: - parts.append('given:\n' + ''.join(_given(model, kind, given, stated, homes) for kind in GIVEN_KINDS)) objective = model.data['objective'] if objective['expression'] in homes: parts.append(_dumped('objective', objective, indent='') + '\n') From 90699544992674060c3c28ee2f20f0819b0bfdca Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 1 Oct 2026 12:58:42 +0000 Subject: [PATCH 2/2] docs: add the changelog line for #813 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_019i7xNVeQzGJykmE9id6w51 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41ee080c..4739c5bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ request renames that heading to the version and the day, such as `## 0.1.0 (2026-10-01)`, and edits the section into the release notes. Merging it releases that version ([RELEASING.md](https://github.com/energy-models/mathspec/blob/main/RELEASING.md)). +## Upcoming version + +- docs: every spec in the docs and examples opens with its given block ([#813](https://github.com/energy-models/mathspec/pull/813)) + ## 0.2.1 (2026-10-01) A spec can now be written as several files. [`merge`](https://mathspec.readthedocs.io/en/latest/howto/compose/)