From e2119d622967e68dba63ba9357b49f736be32d9b Mon Sep 17 00:00:00 2001 From: Fabian Date: Wed, 26 Apr 2023 15:37:46 +0200 Subject: [PATCH] fix unit_commitment function and file, add it to config.validation --- config/config.validation.yaml | 3 +++ rules/solve_electricity.smk | 1 + scripts/solve_network.py | 8 +++----- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/config/config.validation.yaml b/config/config.validation.yaml index 2dde7267..54d59122 100644 --- a/config/config.validation.yaml +++ b/config/config.validation.yaml @@ -334,6 +334,8 @@ solar_thermal: # only relevant for foresight = myopic or perfect existing_capacities: + unit_commitment: true # if unit commitment (UC) for conventional power plants is used + # UC is only applied to extendable plants if linearized UC is used grouping_years_power: [1980, 1985, 1990, 1995, 2000, 2005, 2010, 2015, 2020, 2025, 2030] grouping_years_heat: [1980, 1985, 1990, 1995, 2000, 2005, 2010, 2015, 2019] # these should not extend 2020 threshold_capacity: 10 @@ -612,6 +614,7 @@ solving: options: formulation: kirchhoff clip_p_max_pu: 1.e-2 + linearized_unit_commitment: true load_shedding: false noisy_costs: true skip_iterations: true diff --git a/rules/solve_electricity.smk b/rules/solve_electricity.smk index 8ddeca92..5ab087b8 100644 --- a/rules/solve_electricity.smk +++ b/rules/solve_electricity.smk @@ -5,6 +5,7 @@ rule solve_network: input: + unit_commitment_file="data/unit_commitment.csv", network=RESOURCES + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc", output: network=RESULTS + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc", diff --git a/scripts/solve_network.py b/scripts/solve_network.py index 0dbf8c8e..615e8508 100644 --- a/scripts/solve_network.py +++ b/scripts/solve_network.py @@ -144,7 +144,7 @@ def add_co2_sequestration_limit(n, limit=200): def prepare_network(n, solve_opts=None, config=None): if snakemake.config["existing_capacities"]["unit_commitment"]: - add_unit_committment(n) + add_unit_commitment(n, snakemake.input.unit_commitment_params) if "clip_p_max_pu" in solve_opts: for df in ( @@ -594,14 +594,12 @@ def extra_functionality(n, snapshots): add_pipe_retrofit_constraint(n) -def add_unit_committment(n): +def add_unit_commitment(n, fn): """ Add unit commitment. """ c = "Link" if ("sector_opts" in snakemake.wildcards.keys()) else "Generator" - uc_data = pd.read_csv( - "/home/lisa/Documents/pypsa-eur/data/unit_committment.csv", index_col=0 - ) + uc_data = pd.read_csv(fn, index_col=0) for attr in uc_data.index: n.df(c)[attr] = n.df(c)["carrier"].map(uc_data.loc[attr])