diff --git a/README.md b/README.md index a2da05ca1..de06f833f 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Before running any analysis with scenarios, the rule `build_scenarios` must be e snakemake -call build_scenarios -f or in case of using the public database - + snakemake -call build_scenarios --configfile=config/config.public.yaml -f Note that the hierarchy of scenario files is the following: `scenarios.automated.yaml` > (any `explicitly specified --configfiles`) > `config.yaml `> `config.default.yaml `Changes in the file `scenarios.manual.yaml `are only taken into account if the rule `build_scenarios` is executed. diff --git a/config/config.default.yaml b/config/config.default.yaml index c2ec2ce4f..1fe8d262d 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -909,7 +909,7 @@ solving: skip_iterations: true rolling_horizon: false seed: 123 - custom_extra_functionality: "../data/custom_extra_functionality.py" + custom_extra_functionality: "../scripts/pypsa-de/additional_functionality.py" # io_api: "direct" # Increases performance but only supported for the highs and gurobi solvers # options that go into the optimize function track_iterations: false diff --git a/rules/solve_myopic.smk b/rules/solve_myopic.smk index 52d3b3524..8a07d0954 100644 --- a/rules/solve_myopic.smk +++ b/rules/solve_myopic.smk @@ -114,9 +114,6 @@ rule solve_sector_network_myopic: "sector", "co2_sequestration_potential", default=200 ), custom_extra_functionality=input_custom_extra_functionality, - # custom_extra_functionality=os.path.join( - # os.path.dirname(workflow.snakefile), "scripts/pypsa-de/additional_functionality.py" - # ), energy_year=config_provider("energy", "energy_totals_year"), input: network=RESULTS diff --git a/scripts/pypsa-de/additional_functionality.py b/scripts/pypsa-de/additional_functionality.py index 38d8e017d..464c92aed 100644 --- a/scripts/pypsa-de/additional_functionality.py +++ b/scripts/pypsa-de/additional_functionality.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- - import logging +import sys import pandas as pd from xarray import DataArray @@ -51,7 +51,7 @@ def add_capacity_limits(n, investment_year, limits_capacity, sense="maximum"): lhs = nom.sum() - cname = f"capacity_{sense}-{ct}-{c.name}-{carrier.replace(' ','-')}" + cname = f"capacity_{sense}-{ct}-{c.name}-{carrier.replace(' ', '-')}" if cname in n.global_constraints.index: logger.warning( @@ -163,7 +163,7 @@ def h2_import_limits(n, investment_year, limits_volume_max): for ct in limits_volume_max["h2_import"]: limit = limits_volume_max["h2_import"][ct][investment_year] * 1e6 - logger.info(f"limiting H2 imports in {ct} to {limit/1e6} TWh/a") + logger.info(f"limiting H2 imports in {ct} to {limit / 1e6} TWh/a") pipeline_carrier = [ "H2 pipeline", "H2 pipeline (Kernnetz)", @@ -222,7 +222,7 @@ def h2_production_limits(n, investment_year, limits_volume_min, limits_volume_ma limit_upper = limits_volume_max["electrolysis"][ct][investment_year] * 1e6 logger.info( - f"limiting H2 electrolysis in DE between {limit_lower/1e6} and {limit_upper/1e6} TWh/a" + f"limiting H2 electrolysis in DE between {limit_lower / 1e6} and {limit_upper / 1e6} TWh/a" ) production = n.links[ @@ -271,7 +271,7 @@ def electricity_import_limits(n, investment_year, limits_volume_max): for ct in limits_volume_max["electricity_import"]: limit = limits_volume_max["electricity_import"][ct][investment_year] * 1e6 - logger.info(f"limiting electricity imports in {ct} to {limit/1e6} TWh/a") + logger.info(f"limiting electricity imports in {ct} to {limit / 1e6} TWh/a") incoming_line = n.lines.index[ (n.lines.carrier == "AC") @@ -374,7 +374,7 @@ def add_co2limit_country(n, limit_countries, snakemake, debug=False): ] logger.info( - f"For {ct} adding following link carriers to port {port} CO2 constraint: {n.links.loc[links,'carrier'].unique()}" + f"For {ct} adding following link carriers to port {port} CO2 constraint: {n.links.loc[links, 'carrier'].unique()}" ) if port == "0": @@ -602,7 +602,7 @@ def add_h2_derivate_limit(n, investment_year, limits_volume_max): for ct in limits_volume_max["h2_derivate_import"]: limit = limits_volume_max["h2_derivate_import"][ct][investment_year] * 1e6 - logger.info(f"limiting H2 derivate imports in {ct} to {limit/1e6} TWh/a") + logger.info(f"limiting H2 derivate imports in {ct} to {limit / 1e6} TWh/a") incoming = n.links.loc[ [