Skip to content

Commit

Permalink
remove {ll} wildcard and replace with config setting (#1472)
Browse files Browse the repository at this point in the history
* remove {ll} wildcard and replace with config setting

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix postprocess.smk

* allow use of previous {ll} options in {opts} wildcard

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove remaining traces of {ll} wildcard

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
fneum and pre-commit-ci[bot] authored Jan 24, 2025
1 parent b7e7b40 commit 98a18f2
Show file tree
Hide file tree
Showing 23 changed files with 149 additions and 186 deletions.
4 changes: 2 additions & 2 deletions config/config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ foresight: overnight
# docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#scenario
# Wildcard docs in https://pypsa-eur.readthedocs.io/en/latest/wildcards.html
scenario:
ll:
- vopt
clusters:
- 39
- 128
Expand Down Expand Up @@ -130,6 +128,8 @@ electricity:
enable: false
by_country: false

transmission_limit: vopt

# docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#atlite
atlite:
default_cutout: europe-2013-sarah3-era5
Expand Down
1 change: 1 addition & 0 deletions doc/configtables/electricity.csv
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ estimate_renewable_capacities,,,
autarky,,,
-- enable,bool,true or false,Require each node to be autarkic by removing all lines and links.
-- by_country,bool,true or false,Require each country to be autarkic by removing all cross-border lines and links. ``electricity: autarky`` must be enabled.
transmission_limit,str,"Values like 'vopt', 'v1.25', 'copt', 'c1.25'","Limit on transmission expansion. The first part can be ``v`` (for setting a limit on line volume) or ``c`` (for setting a limit on line cost). The second part can be ``opt`` or a float bigger than one (e.g. 1.25). If ``opt`` is chosen line expansion is optimised according to its capital cost (where the choice ``v`` only considers overhead costs for HVDC transmission lines, while ``c`` uses more accurate costs distinguishing between overhead and underwater sections and including inverter pairs). The setting ``v1.25`` will limit the total volume of line expansion to 25% of currently installed capacities weighted by individual line lengths. The setting ``c1.25`` will allow to build a transmission network that costs no more than 25 % more than the current system."
1 change: 1 addition & 0 deletions doc/configtables/opts.csv
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ Trigger, Description, Definition, Status
``SAFE``,Add a capacity reserve margin of a certain fraction above the peak demand to which renewable generators and storage do *not* contribute. Ignores network., ``solve_network`` `add_opts_constraints() <https://github.com/PyPSA/pypsa-eur/blob/6b964540ed39d44079cdabddee8333f486d0cd63/scripts/solve_network.py#L73>`__, Untested
``carrier+{c|p|m}factor``,"Alter the capital cost (``c``), installable potential (``p``) or marginal costs (``m``) of a carrier by a factor. Example: ``solar+c0.5`` reduces the capital cost of solar to 50\% of original values.", ``prepare_network``, In active use
``CH4L``,"Add an overall absolute gas limit. If configured in ``electricity: gaslimit`` it is given in MWh thermal, if a float is appended, the overall gaslimit is assumed to be given in TWh thermal (e.g. ``CH4L200`` limits gas dispatch to 200 TWh termal)", ``prepare_network``: ``add_gaslimit()``, In active use
``l{v|c}factor``,"Add an overall transmission expansion limit relative to existing power transmission infrastructure based on volume (``v``) or cost (``c``). Example: ``lv1.25`` allows power grid expansion up to a volume (length times capacity) by 25%.",``prepare_network``: ``set_transmission_limit()``, In active use
1 change: 0 additions & 1 deletion doc/configtables/scenario.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
,Unit,Values,Description
clusters,--,cf. :ref:`clusters`,"List of ``{clusters}`` wildcards to run."
ll,--,cf. :ref:`ll`,"List of ``{ll}`` wildcards to run."
opts,--,cf. :ref:`opts`,"List of ``{opts}`` wildcards to run."
sector_opts,--,cf. :ref:`sector_opts`,"List of ``{sector_opts}`` wildcards to run."
planning_horizons,--,cf. :ref:`planning_horizons`,"List of ``{planning_horizon}`` wildcards to run."
2 changes: 1 addition & 1 deletion doc/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ facilitate running multiple scenarios through a single command
For each wildcard, a **list of values** is provided. The rule
``solve_all_elec_networks`` will trigger the rules for creating
``results/networks/base_s_{clusters}_elec_l{ll}_{opts}.nc`` for **all
``results/networks/base_s_{clusters}_elec_{opts}.nc`` for **all
combinations** of the provided wildcard values as defined by Python's
`itertools.product(...)
<https://docs.python.org/2/library/itertools.html#itertools.product>`__ function
Expand Down
6 changes: 6 additions & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,15 @@ Upcoming Release

* Development: Ruff is now used for linting and formatting. It is used in the pre-commit, so no changes are needed. But you might wanna set it up in your IDE.

* Removed ``{ll}`` wildcard. This is now a configuration option ``electricity:
transmission_limit:``, defaulting to ``vopt``. All previous options of the
``{ll}`` wildcard are also now available within the ``{opts}`` wildcard (e.g.
as ``-lv1.25-``).

* Update locations and capacities of ammonia plants.



PyPSA-Eur 0.13.0 (13th September 2024)
======================================

Expand Down
30 changes: 0 additions & 30 deletions doc/wildcards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,36 +48,6 @@ network model should be reduced to in the rule :mod:`cluster_network`.
The number of clusters must be lower than the total number of nodes
and higher than the number of countries. However, a country counts twice if
it has two asynchronous subnetworks (e.g. Denmark or Italy).
.. _ll:

The ``{ll}`` wildcard
=====================

The ``{ll}`` wildcard specifies what limits on
line expansion are set for the optimisation model.
It is handled in the rule :mod:`prepare_network`.

The wildcard, in general, consists of two parts:

1. The first part can be
``v`` (for setting a limit on line volume) or
``c`` (for setting a limit on line cost)

2. The second part can be
``opt`` or a float bigger than one (e.g. 1.25).

(a) If ``opt`` is chosen line expansion is optimised
according to its capital cost
(where the choice ``v`` only considers overhead costs for HVDC transmission lines, while
``c`` uses more accurate costs distinguishing between
overhead and underwater sections and including inverter pairs).

(b) ``v1.25`` will limit the total volume of line expansion
to 25 % of currently installed capacities weighted by
individual line lengths; investment costs are neglected.

(c) ``c1.25`` will allow to build a transmission network that
costs no more than 25 % more than the current system.

.. _opts:

Expand Down
7 changes: 4 additions & 3 deletions rules/build_electricity.smk
Original file line number Diff line number Diff line change
Expand Up @@ -724,18 +724,19 @@ rule prepare_network:
adjustments=config_provider("adjustments", "electricity"),
autarky=config_provider("electricity", "autarky", default={}),
drop_leap_day=config_provider("enable", "drop_leap_day"),
transmission_limit=config_provider("electricity", "transmission_limit"),
input:
resources("networks/base_s_{clusters}_elec.nc"),
tech_costs=lambda w: resources(
f"costs_{config_provider('costs', 'year')(w)}.csv"
),
co2_price=lambda w: resources("co2_price.csv") if "Ept" in w.opts else [],
output:
resources("networks/base_s_{clusters}_elec_l{ll}_{opts}.nc"),
resources("networks/base_s_{clusters}_elec_{opts}.nc"),
log:
logs("prepare_network_base_s_{clusters}_elec_l{ll}_{opts}.log"),
logs("prepare_network_base_s_{clusters}_elec_{opts}.log"),
benchmark:
benchmarks("prepare_network_base_s_{clusters}_elec_l{ll}_{opts}")
benchmarks("prepare_network_base_s_{clusters}_elec_{opts}")
threads: 1
resources:
mem_mb=4000,
Expand Down
18 changes: 9 additions & 9 deletions rules/build_sector.smk
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ rule time_aggregation:
drop_leap_day=config_provider("enable", "drop_leap_day"),
solver_name=config_provider("solving", "solver", "name"),
input:
network=resources("networks/base_s_{clusters}_elec_l{ll}_{opts}.nc"),
network=resources("networks/base_s_{clusters}_elec_{opts}.nc"),
hourly_heat_demand_total=lambda w: (
resources("hourly_heat_demand_total_base_s_{clusters}.nc")
if config_provider("sector", "heating")(w)
Expand All @@ -1011,15 +1011,15 @@ rule time_aggregation:
),
output:
snapshot_weightings=resources(
"snapshot_weightings_base_s_{clusters}_elec_l{ll}_{opts}_{sector_opts}.csv"
"snapshot_weightings_base_s_{clusters}_elec_{opts}_{sector_opts}.csv"
),
threads: 1
resources:
mem_mb=5000,
log:
logs("time_aggregation_base_s_{clusters}_elec_l{ll}_{opts}_{sector_opts}.log"),
logs("time_aggregation_base_s_{clusters}_elec_{opts}_{sector_opts}.log"),
benchmark:
benchmarks("time_aggregation_base_s_{clusters}_elec_l{ll}_{opts}_{sector_opts}")
benchmarks("time_aggregation_base_s_{clusters}_elec_{opts}_{sector_opts}")
conda:
"../envs/environment.yaml"
script:
Expand Down Expand Up @@ -1112,7 +1112,7 @@ rule prepare_sector_network:
**rules.cluster_gas_network.output,
**rules.build_gas_input_locations.output,
snapshot_weightings=resources(
"snapshot_weightings_base_s_{clusters}_elec_l{ll}_{opts}_{sector_opts}.csv"
"snapshot_weightings_base_s_{clusters}_elec_{opts}_{sector_opts}.csv"
),
retro_cost=lambda w: (
resources("retro_cost_base_s_{clusters}.csv")
Expand All @@ -1137,7 +1137,7 @@ rule prepare_sector_network:
)(w)
else []
),
network=resources("networks/base_s_{clusters}_elec_l{ll}_{opts}.nc"),
network=resources("networks/base_s_{clusters}_elec_{opts}.nc"),
eurostat="data/eurostat/Balances-April2023",
pop_weighted_energy_totals=resources(
"pop_weighted_energy_totals_s_{clusters}.csv"
Expand Down Expand Up @@ -1203,17 +1203,17 @@ rule prepare_sector_network:
),
output:
RESULTS
+ "prenetworks/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
+ "prenetworks/base_s_{clusters}_{opts}_{sector_opts}_{planning_horizons}.nc",
threads: 1
resources:
mem_mb=2000,
log:
RESULTS
+ "logs/prepare_sector_network_base_s_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.log",
+ "logs/prepare_sector_network_base_s_{clusters}_{opts}_{sector_opts}_{planning_horizons}.log",
benchmark:
(
RESULTS
+ "benchmarks/prepare_sector_network/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}"
+ "benchmarks/prepare_sector_network/base_s_{clusters}_{opts}_{sector_opts}_{planning_horizons}"
)
conda:
"../envs/environment.yaml"
Expand Down
15 changes: 7 additions & 8 deletions rules/collect.smk
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ rule cluster_networks:
rule prepare_elec_networks:
input:
expand(
resources("networks/base_s_{clusters}_elec_l{ll}_{opts}.nc"),
resources("networks/base_s_{clusters}_elec_{opts}.nc"),
**config["scenario"],
run=config["run"]["name"],
),
Expand All @@ -34,7 +34,7 @@ rule prepare_sector_networks:
input:
expand(
RESULTS
+ "prenetworks/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
+ "prenetworks/base_s_{clusters}_{opts}_{sector_opts}_{planning_horizons}.nc",
**config["scenario"],
run=config["run"]["name"],
),
Expand All @@ -43,7 +43,7 @@ rule prepare_sector_networks:
rule solve_elec_networks:
input:
expand(
RESULTS + "networks/base_s_{clusters}_elec_l{ll}_{opts}.nc",
RESULTS + "networks/base_s_{clusters}_elec_{opts}.nc",
**config["scenario"],
run=config["run"]["name"],
),
Expand All @@ -53,7 +53,7 @@ rule solve_sector_networks:
input:
expand(
RESULTS
+ "postnetworks/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
+ "postnetworks/base_s_{clusters}_{opts}_{sector_opts}_{planning_horizons}.nc",
**config["scenario"],
run=config["run"]["name"],
),
Expand All @@ -63,7 +63,7 @@ rule solve_sector_networks_perfect:
input:
expand(
RESULTS
+ "maps/base_s_{clusters}_l{ll}_{opts}_{sector_opts}-costs-all_{planning_horizons}.pdf",
+ "maps/base_s_{clusters}_{opts}_{sector_opts}-costs-all_{planning_horizons}.pdf",
**config["scenario"],
run=config["run"]["name"],
),
Expand All @@ -72,13 +72,12 @@ rule solve_sector_networks_perfect:
rule validate_elec_networks:
input:
expand(
RESULTS + "figures/.statistics_plots_base_s_{clusters}_elec_l{ll}_{opts}",
RESULTS + "figures/.statistics_plots_base_s_{clusters}_elec_{opts}",
**config["scenario"],
run=config["run"]["name"],
),
expand(
RESULTS
+ "figures/.validation_{kind}_plots_base_s_{clusters}_elec_l{ll}_{opts}",
RESULTS + "figures/.validation_{kind}_plots_base_s_{clusters}_elec_{opts}",
**config["scenario"],
run=config["run"]["name"],
kind=["production", "prices", "cross_border"],
Expand Down
2 changes: 1 addition & 1 deletion rules/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def solved_previous_horizon(w):

return (
RESULTS
+ "postnetworks/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_"
+ "postnetworks/base_s_{clusters}_{opts}_{sector_opts}_"
+ planning_horizon_p
+ ".nc"
)
Loading

0 comments on commit 98a18f2

Please sign in to comment.