From 09af96e7b25cbc17449053a24da4ff7e760dff60 Mon Sep 17 00:00:00 2001 From: Davide Fioriti <67809479+davide-f@users.noreply.github.com> Date: Mon, 16 Sep 2024 14:02:08 +0200 Subject: [PATCH] Merge pull request #1076 from davide-f/fix_csp * Bugfix for csp buses: add buses one for generator * Add release note * Drop csp from tutorial and default configs * Add comment by Emmanuel: check csp in renewable_carriers --- config.default.yaml | 2 +- config.tutorial.yaml | 2 +- doc/release_notes.rst | 2 ++ scripts/add_extra_components.py | 22 ++++++++++++++-------- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/config.default.yaml b/config.default.yaml index 42cac019e..5b7f6fb7c 100644 --- a/config.default.yaml +++ b/config.default.yaml @@ -155,7 +155,7 @@ electricity: custom_powerplants: false # "false" use only powerplantmatching (ppm) data, "merge" combines ppm and custom powerplants, "replace" use only custom powerplants conventional_carriers: [nuclear, oil, OCGT, CCGT, coal, lignite, geothermal, biomass] - renewable_carriers: [solar, csp, onwind, offwind-ac, offwind-dc, hydro] + renewable_carriers: [solar, onwind, offwind-ac, offwind-dc, hydro] estimate_renewable_capacities: stats: "irena" # False, = greenfield expansion, 'irena' uses IRENA stats to add expansion limits diff --git a/config.tutorial.yaml b/config.tutorial.yaml index 0b966a798..0fc8a37c5 100644 --- a/config.tutorial.yaml +++ b/config.tutorial.yaml @@ -169,7 +169,7 @@ electricity: custom_powerplants: false # "false" use only powerplantmatching (ppm) data, "merge" combines ppm and custom powerplants, "replace" use only custom powerplants conventional_carriers: [nuclear, oil, OCGT, CCGT, coal, lignite, geothermal, biomass] - renewable_carriers: [solar, csp, onwind, offwind-ac, offwind-dc, hydro] + renewable_carriers: [solar, onwind, offwind-ac, offwind-dc, hydro] estimate_renewable_capacities: stats: "irena" # False, = greenfield expansion, 'irena' uses IRENA stats to add expansion limits diff --git a/doc/release_notes.rst b/doc/release_notes.rst index 1c7e14771..3d0537917 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -21,6 +21,8 @@ E.g. if a new rule becomes available describe how to use it `snakemake -j1 run_t * Remove unused `countries_codes` argument from `load_GDP` function in `build_shapes.py` script, which was not being called as intended with positional arguments `PR #1069 `__ * Fixed problematic float parsing (`_parse_float`) in `clean_osm_data.py` to make sure all OSM lines are correctly accounted for `PR #1089 `__ +* Fix minor bug for advanced csp implementation `PR #1076 `__ + PyPSA-Earth 0.4.0 ================= diff --git a/scripts/add_extra_components.py b/scripts/add_extra_components.py index 29c57e60c..1a2c71b0a 100644 --- a/scripts/add_extra_components.py +++ b/scripts/add_extra_components.py @@ -184,17 +184,23 @@ def attach_stores(n, costs, config): marginal_cost=costs.at["battery inverter", "marginal_cost"], ) - if ("csp" in config["renewable"].keys()) and ( + if ("csp" in elec_opts["renewable_carriers"]) and ( config["renewable"]["csp"]["csp_model"] == "advanced" ): - # add buses for csp - n.madd("Bus", buses_i + " csp", carrier="csp", **bus_sub_dict) + # get CSP generators and their buses + csp_gens = n.generators.query("carrier == 'csp'") + buses_csp_gens = n.buses.loc[csp_gens.bus] + + csp_buses_i = csp_gens.index + c_buses_i = csp_gens.bus.values - csp_buses_i = n.buses.index[n.buses.index.str.contains("csp")] + csp_bus_sub_dict = {k: buses_csp_gens[k].values for k in ["x", "y", "country"]} + + # add buses for csp + n.madd("Bus", csp_buses_i, carrier="csp", **csp_bus_sub_dict) # change bus of existing csp generators - old_csp_bus_vector = buses_i + " csp" - n.generators.loc[old_csp_bus_vector, "bus"] = csp_buses_i + n.generators.loc[csp_gens.index, "bus"] = csp_buses_i # add stores for csp n.madd( @@ -213,7 +219,7 @@ def attach_stores(n, costs, config): "Link", csp_buses_i, bus0=csp_buses_i, - bus1=buses_i, + bus1=c_buses_i, carrier="csp", efficiency=costs.at["csp-tower", "efficiency"], capital_cost=costs.at["csp-tower", "capital_cost"], @@ -268,7 +274,7 @@ def attach_hydrogen_pipelines(n, costs, config): from _helpers import mock_snakemake os.chdir(os.path.dirname(os.path.abspath(__file__))) - snakemake = mock_snakemake("add_extra_components", simpl="", clusters=10) + snakemake = mock_snakemake("add_extra_components", simpl="", clusters="20flex") configure_logging(snakemake) n = pypsa.Network(snakemake.input.network)