diff --git a/CHANGELOG.md b/CHANGELOG.md index eb8919feb..977cd6259 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ it releases that version ([RELEASING.md](https://github.com/energy-models/mathsp ## Upcoming version +- docs: every spec in the docs and examples opens with its given block ([#813](https://github.com/energy-models/mathspec/pull/813)) - feat(spec)!: a spec written back out puts its given block first ([#818](https://github.com/energy-models/mathspec/pull/818)) - feat(language)!: `missing:` says what a missing row means, a table short of a row is refused unless the file says otherwise, and a variable's `absence:` is now `missing:` ([#810](https://github.com/energy-models/mathspec/pull/810)) - docs(pypsa): a risk preference with weight zero builds the CVaR variables and refuses quadratic costs, as in PyPSA ([#849](https://github.com/energy-models/mathspec/pull/849)) diff --git a/docs/examples/library/generator.md b/docs/examples/library/generator.md index 9d7109045..915359df9 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 8f5a1ff29..f946af52d 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 3debf5e04..4fc11fc1f 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, over=port, by=Port_bus[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 64114deba..69192a52a 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` @@ -33,10 +37,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 00c086e4e..43acd8888 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 @@ -38,14 +46,6 @@ variables: where: CVaR_omega missing: neutral -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 295a43b95..4702cce76 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 @@ -164,28 +186,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 2ced3a7a1..e900ea4c0 100644 --- a/docs/examples/pypsa/generator_commitment.md +++ b/docs/examples/pypsa/generator_commitment.md @@ -9,6 +9,30 @@ 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] } + masks: + Generator_committed: { dims: [snapshot, generator] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -108,30 +132,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] } - masks: - Generator_committed: { dims: [snapshot, generator] } - expressions: Generator_previous_status: description: >- diff --git a/docs/examples/pypsa/generator_maintenance.md b/docs/examples/pypsa/generator_maintenance.md index e9dd6d6eb..8e6973993 100644 --- a/docs/examples/pypsa/generator_maintenance.md +++ b/docs/examples/pypsa/generator_maintenance.md @@ -9,6 +9,21 @@ 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] } + masks: + Generator_committed: { dims: [snapshot, generator] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -101,21 +116,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] } - masks: - Generator_committed: { dims: [snapshot, generator] } - masks: Generator_maint_ext: description: >- diff --git a/docs/examples/pypsa/generator_ramping.md b/docs/examples/pypsa/generator_ramping.md index 16556a673..1bcc65a26 100644 --- a/docs/examples/pypsa/generator_ramping.md +++ b/docs/examples/pypsa/generator_ramping.md @@ -9,6 +9,27 @@ 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] } + masks: + Generator_com_ext: { dims: [snapshot, generator] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -54,27 +75,6 @@ parameters: dims: [scenario, generator] missing: neutral -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] } - masks: - Generator_com_ext: { dims: [snapshot, generator] } - expressions: Generator_previous_p: description: >- diff --git a/docs/examples/pypsa/global_constraints.md b/docs/examples/pypsa/global_constraints.md index 7593993ff..c4bd0f488 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:552`, `:750`, `:829`) 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 2c0c043a2..62ed41859 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 @@ -201,19 +214,6 @@ variables: bounds: lower: 0 -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 5e83cd127..d26f3e50d 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 @@ -203,26 +223,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 07336f8f9..bcbcd27a0 100644 --- a/docs/examples/pypsa/link_commitment.md +++ b/docs/examples/pypsa/link_commitment.md @@ -9,6 +9,30 @@ 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] } + masks: + Link_committed: { dims: [snapshot, link] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -108,30 +132,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] } - masks: - Link_committed: { dims: [snapshot, link] } - expressions: Link_previous_status: description: >- diff --git a/docs/examples/pypsa/link_maintenance.md b/docs/examples/pypsa/link_maintenance.md index e5fd496a0..eb82a02e7 100644 --- a/docs/examples/pypsa/link_maintenance.md +++ b/docs/examples/pypsa/link_maintenance.md @@ -9,6 +9,21 @@ 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] } + masks: + Link_committed: { dims: [snapshot, link] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -98,21 +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] } - masks: - Link_committed: { dims: [snapshot, link] } - masks: Link_maint_ext: description: >- diff --git a/docs/examples/pypsa/link_ramping.md b/docs/examples/pypsa/link_ramping.md index 70b96c3b0..44274eb35 100644 --- a/docs/examples/pypsa/link_ramping.md +++ b/docs/examples/pypsa/link_ramping.md @@ -9,6 +9,27 @@ 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] } + masks: + Link_com_ext: { dims: [snapshot, link] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -54,27 +75,6 @@ parameters: dims: [scenario, link] missing: neutral -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] } - masks: - Link_com_ext: { dims: [snapshot, link] } - expressions: Link_previous_p: description: >- diff --git a/docs/examples/pypsa/load.md b/docs/examples/pypsa/load.md index 53582b938..e94172bbe 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 @@ -45,10 +49,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 b52002a64..ea0647a4c 100644 --- a/docs/examples/pypsa/network.md +++ b/docs/examples/pypsa/network.md @@ -9,6 +9,15 @@ One of the [24 fragments](index.md) of `examples/pypsa.yaml`: the buses and the ```yaml +given: + expressions: + Bus_injection: + dims: [scenario, snapshot, bus] + description: >- + what every component puts into a bus, less what it takes out of it; + 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 @@ -19,15 +28,6 @@ dimensions: bus: description: network nodes -given: - expressions: - Bus_injection: - dims: [scenario, snapshot, bus] - description: >- - what every component puts into a bus, less what it takes out of it; - PyPSA writes each term into the balance, and a load on its right-hand - side - constraints: Bus_nodal_balance: description: >- diff --git a/docs/examples/pypsa/power_flow.md b/docs/examples/pypsa/power_flow.md index 50377935f..16c3624d9 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 @@ -23,14 +31,6 @@ dimensions: a label is a position in that period's basis, so one label names a different cycle in another period -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 49b362565..73264c0e6 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 @@ -181,24 +199,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 5decfd5f4..685a6eb8a 100644 --- a/docs/examples/pypsa/process_commitment.md +++ b/docs/examples/pypsa/process_commitment.md @@ -9,6 +9,30 @@ 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] } + masks: + Process_committed: { dims: [snapshot, process] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -108,30 +132,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] } - masks: - Process_committed: { dims: [snapshot, process] } - expressions: Process_previous_status: description: >- diff --git a/docs/examples/pypsa/process_maintenance.md b/docs/examples/pypsa/process_maintenance.md index 16750539f..0fcf3a854 100644 --- a/docs/examples/pypsa/process_maintenance.md +++ b/docs/examples/pypsa/process_maintenance.md @@ -9,6 +9,21 @@ 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] } + masks: + Process_committed: { dims: [snapshot, process] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -101,21 +116,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] } - masks: - Process_committed: { dims: [snapshot, process] } - masks: Process_maint_ext: description: >- diff --git a/docs/examples/pypsa/process_ramping.md b/docs/examples/pypsa/process_ramping.md index 095f2f6bc..46cc03ca4 100644 --- a/docs/examples/pypsa/process_ramping.md +++ b/docs/examples/pypsa/process_ramping.md @@ -9,6 +9,27 @@ 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] } + masks: + Process_com_ext: { dims: [snapshot, process] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -54,27 +75,6 @@ parameters: dims: [scenario, process] missing: neutral -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] } - masks: - Process_com_ext: { dims: [snapshot, process] } - expressions: Process_previous_p: description: >- diff --git a/docs/examples/pypsa/security.md b/docs/examples/pypsa/security.md index f35eb0591..f0eff5306 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 @@ -65,21 +80,6 @@ parameters: dims: [period, transformer, outage] missing: neutral -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 f2d61ba6b..0cbbf5876 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:415-432`) + 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 @@ -84,58 +136,6 @@ parameters: dtype: bool missing: neutral -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:415-432`) - 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 8c80f5337..77b6fdc56 100644 --- a/docs/examples/pypsa/storage_unit.md +++ b/docs/examples/pypsa/storage_unit.md @@ -9,6 +9,24 @@ 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: + 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 @@ -231,24 +249,6 @@ variables: bounds: lower: 0 -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: - 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 73ffdfb26..e6cb2a7f2 100644 --- a/docs/examples/pypsa/store.md +++ b/docs/examples/pypsa/store.md @@ -9,6 +9,24 @@ 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: + 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 @@ -193,24 +211,6 @@ variables: bounds: lower: 0 -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: - 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 55505d98d..26c999a53 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 @@ -219,15 +228,6 @@ variables: bounds: lower: 0 -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 7fe945150..c28574cdc 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, over=generator, by=Generator_bus[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, over=load, by=Load_bus[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, ordered: true } 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, over=store, by=Store_bus[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] @@ -234,12 +234,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 fd8792e44..fb98af11f 100644 --- a/docs/reference/language/declarations.md +++ b/docs/reference/language/declarations.md @@ -151,15 +151,15 @@ takes those five keys and no other. A file with a `given:` block loads and print 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] @@ -186,6 +186,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 } @@ -194,11 +199,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] @@ -233,14 +233,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) @@ -262,14 +262,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] @@ -309,6 +309,9 @@ part of it. ```yaml # fleet.yaml adds a term +given: + expressions: + injection: { dims: [snapshot, bus] } dimensions: snapshot: { dtype: int } bus: { dtype: str } @@ -317,9 +320,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 @@ -329,14 +329,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] @@ -395,9 +395,6 @@ A given mask is a [mask](named.md#masks) this file reads and another file defines. ```yaml -dimensions: - period: { dtype: int, ordered: true } - generator: { dtype: str } given: variables: p: { dims: [period, generator] } @@ -405,6 +402,9 @@ given: stands: dims: [period, generator] description: the generator stands in this period +dimensions: + period: { dtype: int, ordered: true } + generator: { dtype: str } parameters: ramp: { dims: [generator] } constraints: diff --git a/docs/several-files.md b/docs/several-files.md index 3eb6ca320..9e6da3351 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 7875d5134..d99bf6922 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 7bef70881..102f3e01d 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 614988e44..f126035ba 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, over=port, by=Port_bus[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 4558b09a8..8dd646f79 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` @@ -26,10 +30,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 90de34271..be0532e39 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 @@ -31,14 +39,6 @@ variables: where: CVaR_omega missing: neutral -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 f4be3bb2b..b1f9b8bed 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 @@ -157,28 +179,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 d944d1778..f983ba449 100644 --- a/examples/pypsa/generator_commitment.yaml +++ b/examples/pypsa/generator_commitment.yaml @@ -2,6 +2,30 @@ # # 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] } + masks: + Generator_committed: { dims: [snapshot, generator] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -101,30 +125,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] } - masks: - Generator_committed: { dims: [snapshot, generator] } - expressions: Generator_previous_status: description: >- diff --git a/examples/pypsa/generator_maintenance.yaml b/examples/pypsa/generator_maintenance.yaml index e6c8f7218..dc57653ee 100644 --- a/examples/pypsa/generator_maintenance.yaml +++ b/examples/pypsa/generator_maintenance.yaml @@ -2,6 +2,21 @@ # # 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] } + masks: + Generator_committed: { dims: [snapshot, generator] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -94,21 +109,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] } - masks: - Generator_committed: { dims: [snapshot, generator] } - masks: Generator_maint_ext: description: >- diff --git a/examples/pypsa/generator_ramping.yaml b/examples/pypsa/generator_ramping.yaml index df0122a5d..eda49c2e0 100644 --- a/examples/pypsa/generator_ramping.yaml +++ b/examples/pypsa/generator_ramping.yaml @@ -2,6 +2,27 @@ # # 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] } + masks: + Generator_com_ext: { dims: [snapshot, generator] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -47,27 +68,6 @@ parameters: dims: [scenario, generator] missing: neutral -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] } - masks: - Generator_com_ext: { dims: [snapshot, generator] } - expressions: Generator_previous_p: description: >- diff --git a/examples/pypsa/global_constraints.yaml b/examples/pypsa/global_constraints.yaml index c75078b0d..0a0c3d4a0 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:552`, `:750`, `:829`) 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 15febfc3b..7d713ebb7 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 @@ -194,19 +207,6 @@ variables: bounds: lower: 0 -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 b945d3f35..ac252a7cb 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 @@ -196,26 +216,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 1977359f6..8a0253bd7 100644 --- a/examples/pypsa/link_commitment.yaml +++ b/examples/pypsa/link_commitment.yaml @@ -2,6 +2,30 @@ # # 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] } + masks: + Link_committed: { dims: [snapshot, link] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -101,30 +125,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] } - masks: - Link_committed: { dims: [snapshot, link] } - expressions: Link_previous_status: description: >- diff --git a/examples/pypsa/link_maintenance.yaml b/examples/pypsa/link_maintenance.yaml index a3503814a..6215179aa 100644 --- a/examples/pypsa/link_maintenance.yaml +++ b/examples/pypsa/link_maintenance.yaml @@ -2,6 +2,21 @@ # # 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] } + masks: + Link_committed: { dims: [snapshot, link] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -91,21 +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] } - masks: - Link_committed: { dims: [snapshot, link] } - masks: Link_maint_ext: description: >- diff --git a/examples/pypsa/link_ramping.yaml b/examples/pypsa/link_ramping.yaml index 24b0aeffc..eb3e342b0 100644 --- a/examples/pypsa/link_ramping.yaml +++ b/examples/pypsa/link_ramping.yaml @@ -2,6 +2,27 @@ # # 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] } + masks: + Link_com_ext: { dims: [snapshot, link] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -47,27 +68,6 @@ parameters: dims: [scenario, link] missing: neutral -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] } - masks: - Link_com_ext: { dims: [snapshot, link] } - expressions: Link_previous_p: description: >- diff --git a/examples/pypsa/load.yaml b/examples/pypsa/load.yaml index 456853288..d75ae2d43 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 @@ -38,10 +42,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 eb2fd89c9..07cb55b34 100644 --- a/examples/pypsa/network.yaml +++ b/examples/pypsa/network.yaml @@ -2,6 +2,15 @@ # # SPDX-License-Identifier: MIT +given: + expressions: + Bus_injection: + dims: [scenario, snapshot, bus] + description: >- + what every component puts into a bus, less what it takes out of it; + 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 @@ -12,15 +21,6 @@ dimensions: bus: description: network nodes -given: - expressions: - Bus_injection: - dims: [scenario, snapshot, bus] - description: >- - what every component puts into a bus, less what it takes out of it; - PyPSA writes each term into the balance, and a load on its right-hand - side - constraints: Bus_nodal_balance: description: >- diff --git a/examples/pypsa/power_flow.yaml b/examples/pypsa/power_flow.yaml index 1fb4b00d2..07eb4439b 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 @@ -16,14 +24,6 @@ dimensions: a label is a position in that period's basis, so one label names a different cycle in another period -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 6c1361448..856e484db 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 @@ -174,24 +192,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 2319bc585..eb9eb10a2 100644 --- a/examples/pypsa/process_commitment.yaml +++ b/examples/pypsa/process_commitment.yaml @@ -2,6 +2,30 @@ # # 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] } + masks: + Process_committed: { dims: [snapshot, process] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -101,30 +125,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] } - masks: - Process_committed: { dims: [snapshot, process] } - expressions: Process_previous_status: description: >- diff --git a/examples/pypsa/process_maintenance.yaml b/examples/pypsa/process_maintenance.yaml index 0e6b6329b..4d871a6a9 100644 --- a/examples/pypsa/process_maintenance.yaml +++ b/examples/pypsa/process_maintenance.yaml @@ -2,6 +2,21 @@ # # 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] } + masks: + Process_committed: { dims: [snapshot, process] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -94,21 +109,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] } - masks: - Process_committed: { dims: [snapshot, process] } - masks: Process_maint_ext: description: >- diff --git a/examples/pypsa/process_ramping.yaml b/examples/pypsa/process_ramping.yaml index 8ddad17f9..09e74c0a8 100644 --- a/examples/pypsa/process_ramping.yaml +++ b/examples/pypsa/process_ramping.yaml @@ -2,6 +2,27 @@ # # 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] } + masks: + Process_com_ext: { dims: [snapshot, process] } + dimensions: scenario: description: the futures dispatch is chosen in, each with a weight @@ -47,27 +68,6 @@ parameters: dims: [scenario, process] missing: neutral -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] } - masks: - Process_com_ext: { dims: [snapshot, process] } - expressions: Process_previous_p: description: >- diff --git a/examples/pypsa/security.yaml b/examples/pypsa/security.yaml index 38b8688a4..869228341 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 @@ -58,21 +73,6 @@ parameters: dims: [period, transformer, outage] missing: neutral -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 f97757a4a..d0ce81ee0 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:415-432`) + 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 @@ -77,58 +129,6 @@ parameters: dtype: bool missing: neutral -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:415-432`) - 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 e59f948f7..ba9dc22f0 100644 --- a/examples/pypsa/storage_unit.yaml +++ b/examples/pypsa/storage_unit.yaml @@ -2,6 +2,24 @@ # # 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: + 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 @@ -224,24 +242,6 @@ variables: bounds: lower: 0 -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: - 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 58c8b28c0..e490dd5ba 100644 --- a/examples/pypsa/store.yaml +++ b/examples/pypsa/store.yaml @@ -2,6 +2,24 @@ # # 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: + 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 @@ -186,24 +204,6 @@ variables: bounds: lower: 0 -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: - 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 7d42b080c..4bba7b22c 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 @@ -212,15 +221,6 @@ variables: bounds: lower: 0 -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 35dfa68df..cd4e7898c 100644 --- a/tools/pypsa_split.py +++ b/tools/pypsa_split.py @@ -296,13 +296,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 = [ @@ -314,8 +316,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')