Squashed commit of the following:

commit a2b82195b872bae11a9e247c53756ca3ae512362
Author: Fabian Neumann <fabian.neumann@outlook.de>
Date:   Fri Aug 30 16:13:36 2024 +0200

    minor adjustments

commit 4f9eb04fec4534abbef10fedd4d9b5c34f064670
Merge: 7b525a51 bf2d82a3
Author: Fabian Neumann <fabian.neumann@outlook.de>
Date:   Fri Aug 30 16:08:58 2024 +0200

    Merge branch 'master' into master

commit 7b525a515a36a4ebb248280546583ac843f6b277
Merge: d9033374 a357ba11
Author: danielelerede-oet <daniele.lerede@openenergytransition.org>
Date:   Mon Aug 26 13:21:06 2024 +0200

    Merge branch 'master' into master

commit d9033374e4bf0bb70df0828743b9aab69c0cbb27
Author: danielelerede-oet <daniele.lerede@openenergytransition.org>
Date:   Mon Aug 26 10:34:27 2024 +0200

    Update scripts/solve_network.py

    Co-authored-by: Fabian Neumann <fabian.neumann@outlook.de>

commit 98e6c5b0f152ca7e064b3c80be26f50040628388
Author: danielelerede-oet <daniele.lerede@openenergytransition.org>
Date:   Mon Aug 26 10:34:21 2024 +0200

    Update scripts/solve_network.py

    Co-authored-by: Fabian Neumann <fabian.neumann@outlook.de>

commit be19a2ba2401a2815c09e74d2add24461b3fe2aa
Author: danielelerede-oet <daniele.lerede@openenergytransition.org>
Date:   Mon Aug 26 10:34:15 2024 +0200

    Update scripts/solve_operations_network.py

    Co-authored-by: Fabian Neumann <fabian.neumann@outlook.de>

commit 8093eaa399cfea62d1ef93ec4ed5ed46bf5dcc6d
Author: danielelerede-oet <daniele.lerede@openenergytransition.org>
Date:   Mon Aug 26 10:34:08 2024 +0200

    Update scripts/solve_network.py

    Co-authored-by: Fabian Neumann <fabian.neumann@outlook.de>

commit 746d1761accbe44d3a851430b94844fe3ab43d72
Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date:   Wed Aug 21 15:29:12 2024 +0000

    [pre-commit.ci] auto fixes from pre-commit.com hooks

    for more information, see https://pre-commit.ci

commit f46fdee7f7ceeb9040ee73123fa4a3bd1aa14a56
Author: Daniele Lerede <daniele.lerede@openenergytransition.org>
Date:   Wed Aug 21 17:11:32 2024 +0200

    fix solve_operations_network
This commit is contained in:
Fabian Neumann 2024-08-30 16:15:34 +02:00
parent bf2d82a384
commit 0df54bc370
4 changed files with 21 additions and 4 deletions

View File

@ -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.

View File

@ -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:

View File

@ -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,
)

View File

@ -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])