Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post-merge snakemake.params #663

Merged
merged 26 commits into from Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1758076
test param in add_electricity
virio-andreyana May 11, 2023
aa50ea4
fix add_electricity mistake
virio-andreyana May 11, 2023
1fc48d8
using python algorithm to edit rules and script
virio-andreyana May 15, 2023
61893c3
fixing build_electricity.smk and retrieve.smk
virio-andreyana May 15, 2023
8208ac0
convert param back to config for "logging" and "run", made "enable" m…
virio-andreyana May 17, 2023
8af1fe5
replace the word "config" to "params" in functions
virio-andreyana May 17, 2023
6366dc4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 17, 2023
d97a543
missing a coma in build_electricity.smk
virio-andreyana May 17, 2023
c043100
add more params in simplify_network.py
virio-andreyana May 19, 2023
216a02f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 19, 2023
28d3968
Merge branch 'master' into post-merge-param
virio-andreyana May 19, 2023
1c73bb0
add params for solve_network
virio-andreyana May 27, 2023
ead87af
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 27, 2023
e581ca9
made params more specific
virio-andreyana May 27, 2023
f3e8fe2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 27, 2023
b67a009
using higher keys for industries
virio-andreyana May 31, 2023
83ff639
amend solve_network
virio-andreyana Jun 2, 2023
0f5bb8b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 2, 2023
8dbcca5
minor fixes in solve_network.py
virio-andreyana Jun 3, 2023
d6057cb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 3, 2023
862e547
Merge branch 'master' into post-merge-param
FabianHofmann Jun 14, 2023
12b9356
add info to release_notes
virio-andreyana Jun 14, 2023
45cac01
adjust param accessing in cluster, simplify and build_elec script
FabianHofmann Jun 14, 2023
1d10073
review params implementation; reproduce objective values in CI
FabianHofmann Jun 15, 2023
27eea27
harmonize params names
FabianHofmann Jun 15, 2023
a17647a
add_electricity: fix cost ref
FabianHofmann Jun 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
63 changes: 63 additions & 0 deletions rules/build_electricity.smk
Expand Up @@ -19,6 +19,10 @@ if config["enable"].get("prepare_links_p_nom", False):


rule build_electricity_demand:
params:
snapshots=config["snapshots"],
countries=config["countries"],
load=config["load"],
input:
ancient("data/load_raw.csv"),
output:
Expand All @@ -34,6 +38,10 @@ rule build_electricity_demand:


rule build_powerplants:
params:
powerplants_filter=config["electricity"]["powerplants_filter"],
custom_powerplants=config["electricity"]["custom_powerplants"],
countries=config["countries"],
input:
base_network=RESOURCES + "networks/base.nc",
custom_powerplants="data/custom_powerplants.csv",
Expand Down Expand Up @@ -79,6 +87,8 @@ rule base_network:


rule build_shapes:
params:
countries=config["countries"],
input:
naturalearth=ancient("data/bundle/naturalearth/ne_10m_admin_0_countries.shp"),
eez=ancient("data/bundle/eez/World_EEZ_v8_2014.shp"),
Expand All @@ -104,6 +114,8 @@ rule build_shapes:


rule build_bus_regions:
params:
countries=config["countries"],
input:
country_shapes=RESOURCES + "country_shapes.geojson",
offshore_shapes=RESOURCES + "offshore_shapes.geojson",
Expand All @@ -125,6 +137,9 @@ rule build_bus_regions:
if config["enable"].get("build_cutout", False):

rule build_cutout:
params:
snapshots=config["snapshots"],
cutouts=config["atlite"]["cutouts"],
input:
regions_onshore=RESOURCES + "regions_onshore.geojson",
regions_offshore=RESOURCES + "regions_offshore.geojson",
Expand Down Expand Up @@ -186,6 +201,8 @@ rule build_ship_raster:


rule build_renewable_profiles:
params:
renewable=config["renewable"],
input:
base_network=RESOURCES + "networks/base.nc",
corine=ancient("data/bundle/corine/g250_clc06_V18_5.tif"),
Expand Down Expand Up @@ -235,6 +252,10 @@ rule build_renewable_profiles:


rule build_hydro_profile:
params:
hydro=config["renewable"]["hydro"],
countries=config["countries"],
renewable=config["renewable"],
virio-andreyana marked this conversation as resolved.
Show resolved Hide resolved
input:
country_shapes=RESOURCES + "country_shapes.geojson",
eia_hydro_generation="data/eia_hydro_annual_generation.csv",
Expand All @@ -252,6 +273,14 @@ rule build_hydro_profile:


rule add_electricity:
params:
length_factor=config["lines"]["length_factor"],
scaling_factor=config["load"]["scaling_factor"],
countries=config["countries"],
renewable=config["renewable"],
electricity=config["electricity"],
conventional=config.get("conventional", {}),
costs=config["costs"],
input:
**{
f"profile_{tech}": RESOURCES + f"profile_{tech}.nc"
Expand Down Expand Up @@ -287,6 +316,18 @@ rule add_electricity:


rule simplify_network:
params:
clustering=config["clustering"],
max_hours=config["electricity"]["max_hours"],
costs=config["costs"],
renewable=config["renewable"],
length_factor=config["lines"]["length_factor"],
p_max_pu=config["links"].get("p_max_pu", 1.0),
exclude_carriers=config["clustering"]["simplify_network"].get(
"exclude_carriers", []
),
focus_weights=config.get("focus_weights", None),
solver_name=config["solving"]["solver"]["name"],
input:
network=RESOURCES + "networks/elec.nc",
tech_costs=COSTS,
Expand All @@ -312,6 +353,15 @@ rule simplify_network:


rule cluster_network:
params:
solver_name=config["solving"]["solver"]["name"],
max_hours=config["electricity"]["max_hours"],
conventional_carriers=config["electricity"].get("conventional_carriers", []),
costs=config["costs"],
length_factor=config["lines"]["length_factor"],
renewable=config["renewable"],
clustering=config["clustering"],
custom_busmap=config["enable"].get("custom_busmap", False),
input:
network=RESOURCES + "networks/elec_s{simpl}.nc",
regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}.geojson",
Expand Down Expand Up @@ -343,6 +393,10 @@ rule cluster_network:


rule add_extra_components:
params:
costs=config["costs"],
ext_carriers=config["electricity"]["extendable_carriers"],
max_hours=config["electricity"]["max_hours"],
input:
network=RESOURCES + "networks/elec_s{simpl}_{clusters}.nc",
tech_costs=COSTS,
Expand All @@ -362,6 +416,15 @@ rule add_extra_components:


rule prepare_network:
params:
links=config["links"],
lines=config["lines"],
solver_name=config["solving"]["solver"]["name"],
co2base=config["electricity"]["co2base"],
co2limit=config["electricity"]["co2limit"],
gaslimit=config["electricity"].get("gaslimit"),
max_hours=config["electricity"]["max_hours"],
costs=config["costs"],
input:
RESOURCES + "networks/elec_s{simpl}_{clusters}_ec.nc",
tech_costs=COSTS,
Expand Down
120 changes: 120 additions & 0 deletions rules/build_sector.smk
Expand Up @@ -140,6 +140,8 @@ if not (config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]):


rule build_heat_demands:
params:
snapshots=config["snapshots"],
input:
pop_layout=RESOURCES + "pop_layout_{scope}.nc",
regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
Expand All @@ -160,6 +162,8 @@ rule build_heat_demands:


rule build_temperature_profiles:
params:
snapshots=config["snapshots"],
input:
pop_layout=RESOURCES + "pop_layout_{scope}.nc",
regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
Expand All @@ -181,6 +185,8 @@ rule build_temperature_profiles:


rule build_cop_profiles:
params:
heat_pump_sink_T=config["sector"]["heat_pump_sink_T"],
input:
temp_soil_total=RESOURCES + "temp_soil_total_elec_s{simpl}_{clusters}.nc",
temp_soil_rural=RESOURCES + "temp_soil_rural_elec_s{simpl}_{clusters}.nc",
Expand Down Expand Up @@ -208,6 +214,9 @@ rule build_cop_profiles:


rule build_solar_thermal_profiles:
params:
snapshots=config["snapshots"],
solar_thermal=config["solar_thermal"],
input:
pop_layout=RESOURCES + "pop_layout_{scope}.nc",
regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
Expand All @@ -228,6 +237,9 @@ rule build_solar_thermal_profiles:


rule build_energy_totals:
params:
countries=config["countries"],
energy=config["energy"],
input:
nuts3_shapes=RESOURCES + "nuts3_shapes.geojson",
co2="data/eea/UNFCCC_v23.csv",
Expand All @@ -253,6 +265,8 @@ rule build_energy_totals:


rule build_biomass_potentials:
params:
biomass=config["biomass"],
input:
enspreso_biomass=HTTP.remote(
"https://cidportal.jrc.ec.europa.eu/ftp/jrc-opendata/ENSPRESO/ENSPRESO_BIOMASS.xlsx",
Expand Down Expand Up @@ -315,6 +329,8 @@ if not config["sector"]["biomass_transport"]:
if config["sector"]["regional_co2_sequestration_potential"]["enable"]:

rule build_sequestration_potentials:
params:
co2seq_potential=config["sector"]["regional_co2_sequestration_potential"],
input:
sequestration_potential=HTTP.remote(
"https://raw.githubusercontent.com/ericzhou571/Co2Storage/main/resources/complete_map_2020_unit_Mt.geojson",
Expand Down Expand Up @@ -368,6 +384,8 @@ rule build_salt_cavern_potentials:


rule build_ammonia_production:
params:
countries=config["countries"],
input:
usgs="data/myb1-2017-nitro.xls",
output:
Expand All @@ -386,6 +404,42 @@ rule build_ammonia_production:


rule build_industry_sector_ratios:
params:
industry={
virio-andreyana marked this conversation as resolved.
Show resolved Hide resolved
"H2_DRI": config["industry"]["H2_DRI"],
"elec_DRI": config["industry"]["elec_DRI"],
"HVC_production_today": config["industry"]["HVC_production_today"],
"petrochemical_process_emissions": config["industry"][
"petrochemical_process_emissions"
],
"NH3_process_emissions": config["industry"]["NH3_process_emissions"],
"MWh_CH4_per_tNH3_SMR": config["industry"]["MWh_CH4_per_tNH3_SMR"],
"MWh_elec_per_tNH3_SMR": config["industry"]["MWh_elec_per_tNH3_SMR"],
"chlorine_production_today": config["industry"][
"chlorine_production_today"
],
"MWh_H2_per_tCl": config["industry"]["MWh_H2_per_tCl"],
"MWh_elec_per_tCl": config["industry"]["MWh_elec_per_tCl"],
"methanol_production_today": config["industry"][
"methanol_production_today"
],
"MWh_CH4_per_tMeOH": config["industry"]["MWh_CH4_per_tMeOH"],
"MWh_elec_per_tMeOH": config["industry"]["MWh_elec_per_tMeOH"],
"MWh_elec_per_tHVC_mechanical_recycling": config["industry"][
"MWh_elec_per_tHVC_mechanical_recycling"
],
"MWh_elec_per_tHVC_chemical_recycling": config["industry"][
"MWh_elec_per_tHVC_chemical_recycling"
],
"MWh_NH3_per_tNH3": config["industry"]["MWh_NH3_per_tNH3"],
"MWh_H2_per_tNH3_electrolysis": config["industry"][
"MWh_H2_per_tNH3_electrolysis"
],
"MWh_elec_per_tNH3_electrolysis": config["industry"][
"MWh_elec_per_tNH3_electrolysis"
],
},
sector_amonia=config["sector"].get("ammonia", False),
input:
ammonia_production=RESOURCES + "ammonia_production.csv",
idees="data/jrc-idees-2015",
Expand All @@ -405,6 +459,18 @@ rule build_industry_sector_ratios:


rule build_industrial_production_per_country:
params:
industry={
"reference_year": config["industry"]["reference_year"],
"HVC_production_today": config["industry"]["HVC_production_today"],
"chlorine_production_today": config["industry"][
"chlorine_production_today"
],
"methanol_production_today": config["industry"][
"methanol_production_today"
],
},
countries=config["countries"],
input:
ammonia_production=RESOURCES + "ammonia_production.csv",
jrc="data/jrc-idees-2015",
Expand All @@ -426,6 +492,19 @@ rule build_industrial_production_per_country:


rule build_industrial_production_per_country_tomorrow:
params:
industry={
virio-andreyana marked this conversation as resolved.
Show resolved Hide resolved
"St_primary_fraction": config["industry"]["St_primary_fraction"],
"DRI_fraction": config["industry"]["DRI_fraction"],
"Al_primary_fraction": config["industry"]["Al_primary_fraction"],
"HVC_mechanical_recycling_fraction": config["industry"][
"HVC_mechanical_recycling_fraction"
],
"HVC_chemical_recycling_fraction": config["industry"][
"HVC_chemical_recycling_fraction"
],
"HVC_primary_fraction": config["industry"]["HVC_primary_fraction"],
},
input:
industrial_production_per_country=RESOURCES
+ "industrial_production_per_country.csv",
Expand All @@ -450,6 +529,9 @@ rule build_industrial_production_per_country_tomorrow:


rule build_industrial_distribution_key:
params:
hotmaps_locate_missing=config["industry"].get("hotmaps_locate_missing", False),
countries=config["countries"],
input:
regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
clustered_pop_layout=RESOURCES + "pop_layout_elec_s{simpl}_{clusters}.csv",
Expand Down Expand Up @@ -524,6 +606,14 @@ rule build_industrial_energy_demand_per_node:


rule build_industrial_energy_demand_per_country_today:
params:
countries=config["countries"],
industry={
virio-andreyana marked this conversation as resolved.
Show resolved Hide resolved
"reference_year": config["industry"].get("reference_year", 2015),
"MWh_CH4_per_tNH3_SMR": config["industry"]["MWh_CH4_per_tNH3_SMR"],
"MWh_elec_per_tNH3_SMR": config["industry"]["MWh_elec_per_tNH3_SMR"],
"MWh_NH3_per_tNH3": config["industry"]["MWh_NH3_per_tNH3"],
},
input:
jrc="data/jrc-idees-2015",
ammonia_production=RESOURCES + "ammonia_production.csv",
Expand Down Expand Up @@ -570,6 +660,9 @@ rule build_industrial_energy_demand_per_node_today:
if config["sector"]["retrofitting"]["retro_endogen"]:

rule build_retro_cost:
params:
retrofitting=config["sector"]["retrofitting"],
countries=config["countries"],
input:
building_stock="data/retro/data_building_stock.csv",
data_tabula="data/retro/tabula-calculator-calcsetbuilding.csv",
Expand Down Expand Up @@ -640,6 +733,9 @@ rule build_shipping_demand:


rule build_transport_demand:
params:
snapshots=config["snapshots"],
sector=config["sector"],
input:
clustered_pop_layout=RESOURCES + "pop_layout_elec_s{simpl}_{clusters}.csv",
pop_weighted_energy_totals=RESOURCES
Expand All @@ -666,6 +762,30 @@ rule build_transport_demand:

rule prepare_sector_network:
params:
co2_budget=config["co2_budget"],
solver_name=config["solving"]["solver"]["name"],
conventional_carriers=config["existing_capacities"]["conventional_carriers"],
foresight=config["foresight"],
costs=config["costs"],
sector=config["sector"],
industry={
virio-andreyana marked this conversation as resolved.
Show resolved Hide resolved
"MWh_elec_per_tNH3_electrolysis": config["industry"][
"MWh_elec_per_tNH3_electrolysis"
],
"MWh_NH3_per_tNH3": config["industry"]["MWh_NH3_per_tNH3"],
"MWh_H2_per_tNH3_electrolysis": config["industry"][
"MWh_H2_per_tNH3_electrolysis"
],
"MWh_NH3_per_MWh_H2_cracker": config["industry"][
"MWh_NH3_per_MWh_H2_cracker"
],
},
pypsa_eur=config["pypsa_eur"],
length_factor=config["lines"]["length_factor"],
planning_horizons=config["scenario"]["planning_horizons"],
countries=config["countries"],
emissions_scope=config["energy"]["emissions"],
report_year=config["energy"]["eurostat_report_year"],
RDIR=RDIR,
input:
**build_retro_cost_output,
Expand Down