diff --git a/doc/release_notes.rst b/doc/release_notes.rst index 786eb602..e912da2d 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -11,6 +11,8 @@ Release Notes Upcoming Release ================ +* Bugfix for passing function arguments in rule :mod:`solve_operations_network`. + * Represent Kosovo (XK) as separate country. * Added data on the locations and capacities of ammonia plants in Europe. diff --git a/rules/solve_electricity.smk b/rules/solve_electricity.smk index 389687a0..e2dbe42e 100644 --- a/rules/solve_electricity.smk +++ b/rules/solve_electricity.smk @@ -41,6 +41,13 @@ rule solve_network: rule solve_operations_network: params: options=config_provider("solving", "options"), + solving=config_provider("solving"), + foresight=config_provider("foresight"), + 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, input: network=RESULTS + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc", output: diff --git a/scripts/solve_network.py b/scripts/solve_network.py index 99f7b575..c70d4d3c 100644 --- a/scripts/solve_network.py +++ b/scripts/solve_network.py @@ -1055,8 +1055,8 @@ def extra_functionality(n, snapshots): if config["sector"]["enhanced_geothermal"]["enable"]: add_flexible_egs_constraint(n) - if snakemake.params.custom_extra_functionality: - source_path = snakemake.params.custom_extra_functionality + if n.params.custom_extra_functionality: + source_path = n.params.custom_extra_functionality assert os.path.exists(source_path), f"{source_path} does not exist" sys.path.append(os.path.dirname(source_path)) module_name = os.path.splitext(os.path.basename(source_path))[0] @@ -1065,7 +1065,7 @@ def extra_functionality(n, snapshots): custom_extra_functionality(n, snapshots, snakemake) -def solve_network(n, config, solving, **kwargs): +def solve_network(n, config, params, solving, **kwargs): set_of_options = solving["solver"]["options"] cf_solving = solving["options"] @@ -1093,6 +1093,7 @@ def solve_network(n, config, solving, **kwargs): # add to network for extra_functionality n.config = config + n.params = params if rolling_horizon and snakemake.rule == "solve_operations_network": kwargs["horizon"] = cf_solving.get("horizon", 365) @@ -1165,6 +1166,7 @@ if __name__ == "__main__": n = solve_network( n, config=snakemake.config, + params=snakemake.params, solving=snakemake.params.solving, log_fn=snakemake.log.solver, ) diff --git a/scripts/solve_operations_network.py b/scripts/solve_operations_network.py index bd4ce7aa..4336c3a7 100644 --- a/scripts/solve_operations_network.py +++ b/scripts/solve_operations_network.py @@ -49,7 +49,13 @@ if __name__ == "__main__": n.optimize.fix_optimal_capacities() n = prepare_network(n, solve_opts, config=snakemake.config) - n = solve_network(n, config=snakemake.config, log_fn=snakemake.log.solver) + n = solve_network( + n, + config=snakemake.config, + params=snakemake.params, + solving=snakemake.params.solving, + log_fn=snakemake.log.solver, + ) n.meta = dict(snakemake.config, **dict(wildcards=dict(snakemake.wildcards))) n.export_to_netcdf(snakemake.output[0])