pypsa-eur/rules/solve_perfect.smk

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

174 lines
6.6 KiB
Plaintext
Raw Normal View History

2023-04-03 14:09:50 +00:00
# SPDX-FileCopyrightText: : 2023 The PyPSA-Eur Authors
#
# 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"),
2023-04-03 14:09:50 +00:00
input:
network=RESULTS
+ "prenetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
powerplants=resources("powerplants.csv"),
busmap_s=resources("busmap_elec_s{simpl}.csv"),
busmap=resources("busmap_elec_s{simpl}_{clusters}.csv"),
clustered_pop_layout=resources("pop_layout_elec_s{simpl}_{clusters}.csv"),
2024-02-16 10:17:00 +00:00
costs=resources("costs_{}.csv".format(
config_provider("scenario", "planning_horizons", 0)(w)
2024-02-16 10:17:00 +00:00
)),
cop_soil_total=resources("cop_soil_total_elec_s{simpl}_{clusters}.nc"),
cop_air_total=resources("cop_air_total_elec_s{simpl}_{clusters}.nc"),
existing_heating_distribution=resources(
"existing_heating_distribution_elec_s{simpl}_{clusters}_{planning_horizons}.csv"
),
2023-04-03 14:09:50 +00:00
existing_heating="data/existing_infrastructure/existing_heating_raw.csv",
existing_solar="data/existing_infrastructure/solar_capacity_IRENA.csv",
existing_onwind="data/existing_infrastructure/onwind_capacity_IRENA.csv",
existing_offwind="data/existing_infrastructure/offwind_capacity_IRENA.csv",
output:
RESULTS
+ "prenetworks-brownfield/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
wildcard_constraints:
planning_horizons=config_provider("scenario", "planning_horizons", 0), #only applies to baseyear
2023-04-03 14:09:50 +00:00
threads: 1
resources:
mem_mb=2000,
log:
logs(
"add_existing_baseyear_elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.log"
),
2023-04-03 14:09:50 +00:00
benchmark:
benchmarks(
"add_existing_baseyear/elec_s{simpl}_{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/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{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"),
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/"
2023-04-03 15:39:47 +00:00
+ "elec_s{simpl}_{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
2023-04-05 13:44:01 +00:00
+ "prenetworks-brownfield/elec_s{simpl}_{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{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}.log"
),
2023-04-03 14:09:50 +00:00
benchmark:
benchmarks(
"prepare_perfect_foresight{simpl}_{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", 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
2023-04-05 08:41:21 +00:00
+ "prenetworks-brownfield/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_brownfield_all_years.nc",
2024-02-16 10:17:00 +00:00
costs=resources("costs_2030.csv"),
2023-08-22 09:01:51 +00:00
config=RESULTS + "config.yaml",
2023-04-03 14:09:50 +00:00
output:
2023-04-03 15:39:47 +00:00
RESULTS
2023-04-05 08:41:21 +00:00
+ "postnetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_brownfield_all_years.nc",
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
2023-04-05 08:41:21 +00:00
+ "logs/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_brownfield_all_years_solver.log",
2023-04-03 15:39:47 +00:00
python=RESULTS
2023-04-05 08:41:21 +00:00
+ "logs/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_brownfield_all_years_python.log",
2023-04-03 15:39:47 +00:00
memory=RESULTS
2023-04-05 08:41:21 +00:00
+ "logs/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_brownfield_all_years_memory.log",
2023-04-03 14:09:50 +00:00
benchmark:
benchmarks(
"solve_sector_network/elec_s{simpl}_{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_{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}": RESULTS
+ f"postnetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_brownfield_all_years.nc"
for simpl in config_provider("scenario", "simpl")(w)
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"