pypsa-eur/rules/solve_perfect.smk

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

177 lines
6.7 KiB
Plaintext
Raw Normal View History

2024-02-19 15:21:48 +00:00
# SPDX-FileCopyrightText: : 2023-2024 The PyPSA-Eur Authors
2023-04-03 14:09:50 +00:00
#
# SPDX-License-Identifier: MIT
rule add_existing_baseyear:
2023-08-22 09:01:51 +00:00
params:
baseyear=config_provider("scenario", "planning_horizons", 0),
sector=config_provider("sector"),
existing_capacities=config_provider("existing_capacities"),
costs=config_provider("costs"),
heat_pump_sources=config_provider("sector", "heat_pump_sources"),
2024-09-11 13:06:32 +00:00
energy_totals_year=config_provider("energy", "energy_totals_year"),
2023-04-03 14:09:50 +00:00
input:
network=RESULTS
+ "prenetworks/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
powerplants=resources("powerplants_s_{clusters}.csv"),
busmap_s=resources("busmap_base_s.csv"),
busmap=resources("busmap_base_s_{clusters}.csv"),
clustered_pop_layout=resources("pop_layout_base_s_{clusters}.csv"),
costs=lambda w: resources(
"costs_{}.csv".format(
config_provider("scenario", "planning_horizons", 0)(w)
)
2024-02-16 10:17:00 +00:00
),
cop_profiles=resources("cop_profiles_base_s_{clusters}.nc"),
existing_heating_distribution=resources(
"existing_heating_distribution_base_s_{clusters}_{planning_horizons}.csv"
),
2023-04-03 14:09:50 +00:00
existing_heating="data/existing_infrastructure/existing_heating_raw.csv",
2024-09-03 11:34:27 +00:00
heating_efficiencies=resources("heating_efficiencies.csv"),
2023-04-03 14:09:50 +00:00
output:
RESULTS
+ "prenetworks-brownfield/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
2023-04-03 14:09:50 +00:00
wildcard_constraints:
planning_horizons=config["scenario"]["planning_horizons"][0], #only applies to baseyear
2023-04-03 14:09:50 +00:00
threads: 1
resources:
2024-04-02 14:48:37 +00:00
mem_mb=config_provider("solving", "mem_mb"),
runtime=config_provider("solving", "runtime", default="24h"),
2023-04-03 14:09:50 +00:00
log:
logs(
"add_existing_baseyear_base_s_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.log"
),
2023-04-03 14:09:50 +00:00
benchmark:
benchmarks(
"add_existing_baseyear/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}"
)
2023-04-03 14:09:50 +00:00
conda:
"../envs/environment.yaml"
script:
"../scripts/add_existing_baseyear.py"
def input_network_year(w):
return {
f"network_{year}": RESULTS
+ "prenetworks/base_s_{clusters}_l{ll}_{opts}_{sector_opts}"
+ f"_{year}.nc"
for year in config_provider("scenario", "planning_horizons")(w)[1:]
}
2023-04-03 14:09:50 +00:00
rule prepare_perfect_foresight:
params:
costs=config_provider("costs"),
time_resolution=config_provider("clustering", "temporal", "sector"),
2023-04-03 14:09:50 +00:00
input:
unpack(input_network_year),
2023-04-03 14:09:50 +00:00
brownfield_network=lambda w: (
2023-04-03 15:39:47 +00:00
RESULTS
2023-04-05 08:41:21 +00:00
+ "prenetworks-brownfield/"
+ "base_s_{clusters}_l{ll}_{opts}_{sector_opts}_"
+ "{}.nc".format(
str(config_provider("scenario", "planning_horizons", 0)(w))
)
2023-04-03 14:09:50 +00:00
),
output:
2023-04-03 15:39:47 +00:00
RESULTS
+ "prenetworks-brownfield/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_brownfield_all_years.nc",
2023-04-03 14:09:50 +00:00
threads: 2
resources:
mem_mb=10000,
log:
logs("prepare_perfect_foresight_{clusters}_l{ll}_{opts}_{sector_opts}.log"),
2023-04-03 14:09:50 +00:00
benchmark:
benchmarks("prepare_perfect_foresight_{clusters}_l{ll}_{opts}_{sector_opts}")
2023-04-03 14:09:50 +00:00
conda:
"../envs/environment.yaml"
script:
"../scripts/prepare_perfect_foresight.py"
2023-04-03 15:39:47 +00:00
rule solve_sector_network_perfect:
2023-08-23 11:23:27 +00:00
params:
solving=config_provider("solving"),
foresight=config_provider("foresight"),
sector=config_provider("sector"),
planning_horizons=config_provider("scenario", "planning_horizons"),
co2_sequestration_potential=config_provider(
"sector", "co2_sequestration_potential", default=200
),
custom_extra_functionality=input_custom_extra_functionality,
2023-04-03 14:09:50 +00:00
input:
2023-04-03 15:39:47 +00:00
network=RESULTS
+ "prenetworks-brownfield/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_brownfield_all_years.nc",
2024-02-16 10:17:00 +00:00
costs=resources("costs_2030.csv"),
2023-04-03 14:09:50 +00:00
output:
network=RESULTS
+ "postnetworks/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_brownfield_all_years.nc",
config=RESULTS
+ "configs/config.base_s_{clusters}_l{ll}_{opts}_{sector_opts}_brownfield_all_years.yaml",
threads: solver_threads
2023-04-03 14:09:50 +00:00
resources:
mem_mb=config_provider("solving", "mem"),
2023-04-03 15:39:47 +00:00
shadow:
"shallow"
log:
solver=RESULTS
+ "logs/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_brownfield_all_years_solver.log",
2023-04-03 15:39:47 +00:00
python=RESULTS
+ "logs/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_brownfield_all_years_python.log",
2023-04-03 15:39:47 +00:00
memory=RESULTS
+ "logs/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_brownfield_all_years_memory.log",
2023-04-03 14:09:50 +00:00
benchmark:
(
RESULTS
+ "benchmarks/solve_sector_network/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_brownfield_all_years}"
)
2023-04-03 14:09:50 +00:00
conda:
"../envs/environment.yaml"
2023-04-03 15:39:47 +00:00
script:
"../scripts/solve_network.py"
2023-04-03 14:09:50 +00:00
def input_networks_make_summary_perfect(w):
return {
f"networks_s_{clusters}_l{ll}_{opts}_{sector_opts}": RESULTS
+ f"postnetworks/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_brownfield_all_years.nc"
for clusters in config_provider("scenario", "clusters")(w)
for opts in config_provider("scenario", "opts")(w)
for sector_opts in config_provider("scenario", "sector_opts")(w)
for ll in config_provider("scenario", "ll")(w)
}
2023-04-03 14:09:50 +00:00
rule make_summary_perfect:
input:
unpack(input_networks_make_summary_perfect),
2024-02-16 10:17:00 +00:00
costs=resources("costs_2020.csv"),
2023-04-03 14:09:50 +00:00
output:
2023-04-05 08:41:21 +00:00
nodal_costs=RESULTS + "csvs/nodal_costs.csv",
nodal_capacities=RESULTS + "csvs/nodal_capacities.csv",
nodal_cfs=RESULTS + "csvs/nodal_cfs.csv",
cfs=RESULTS + "csvs/cfs.csv",
costs=RESULTS + "csvs/costs.csv",
capacities=RESULTS + "csvs/capacities.csv",
curtailment=RESULTS + "csvs/curtailment.csv",
energy=RESULTS + "csvs/energy.csv",
supply=RESULTS + "csvs/supply.csv",
supply_energy=RESULTS + "csvs/supply_energy.csv",
prices=RESULTS + "csvs/prices.csv",
weighted_prices=RESULTS + "csvs/weighted_prices.csv",
market_values=RESULTS + "csvs/market_values.csv",
price_statistics=RESULTS + "csvs/price_statistics.csv",
metrics=RESULTS + "csvs/metrics.csv",
co2_emissions=RESULTS + "csvs/co2_emissions.csv",
2023-04-03 14:09:50 +00:00
threads: 2
resources:
mem_mb=10000,
log:
logs("make_summary_perfect.log"),
2023-04-03 14:09:50 +00:00
benchmark:
benchmarks("make_summary_perfect")
2023-04-03 14:09:50 +00:00
conda:
"../envs/environment.yaml"
2023-04-03 15:39:47 +00:00
script:
"../scripts/make_summary_perfect.py"