From 928c73138f0e3add83ef17fcdb2153528a57bb3a Mon Sep 17 00:00:00 2001 From: LukasFrankenQ Date: Tue, 14 Nov 2023 01:35:37 +0000 Subject: [PATCH] fixed bug, first functional version --- config/config.default.yaml | 1 + rules/build_sector.smk | 4 +-- scripts/prepare_sector_network.py | 43 ++++++++++++++----------------- 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index 7bb75c40..3baf87a2 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -984,6 +984,7 @@ plotting: other: '#000000' geothermal: '#ba91b1' geothermal heat: '#ba91b1' + geothermal organic rankine cycle: '#ba91b1' AC: "#70af1d" AC-AC: "#70af1d" AC line: "#70af1d" diff --git a/rules/build_sector.smk b/rules/build_sector.smk index 85897789..169a6129 100644 --- a/rules/build_sector.smk +++ b/rules/build_sector.smk @@ -224,8 +224,8 @@ rule build_solar_thermal_profiles: output: solar_thermal=RESOURCES + "solar_thermal_{scope}_elec_s{simpl}_{clusters}.nc", resources: - mem_mb=20000, - threads: 16 + mem_mb=2000, + threads: 1 log: LOGS + "build_solar_thermal_profiles_{scope}_s{simpl}_{clusters}.log", benchmark: diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 5d6c40e8..e26dd39e 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -3338,9 +3338,8 @@ def add_enhanced_geothermal( # The orc cost are attributed to a separate link representing the ORC. egs_potentials["capital_cost"] = ( (egs_annuity + FOM / (1.0 + FOM)) - * (egs_potentials["CAPEX"] - costs.at["organice rankine cycle", "investment"]) + * (egs_potentials["CAPEX"] * 1000. - costs.at["organic rankine cycle", "investment"]) * Nyears - * 1000.0 ) assert ( egs_potentials["capital_cost"] > 0 @@ -3372,7 +3371,7 @@ def add_enhanced_geothermal( unit="MWh_th", ) - n.add( + n.madd( "Generator", spatial.geothermal_heat.nodes, bus=spatial.geothermal_heat.nodes, @@ -3412,46 +3411,44 @@ def add_enhanced_geothermal( else: appendix = " " + pd.Index(np.arange(len(bus_egs)).astype(str)) - bus_egs.index = np.arange(len(bus_egs)).astype(str) - - p_nom_max = bus_egs["p_nom_max"] - p_nom_max.index = f"{bus} enhanced geothermal" + appendix - - capital_cost = bus_egs["capital_cost"] - capital_cost.index = f"{bus} enhanced geothermal" + appendix - # add surface bus n.add( "Bus", - f"geothermal heat surface {bus}", - location=bus, + f"{bus} geothermal heat surface", ) + bus_egs.index = np.arange(len(bus_egs)).astype(str) + well_name = f"{bus} enhanced geothermal" + appendix + bus_eta = pd.concat( ( efficiency[bus].rename(idx) - for idx in f"{bus} enhanced geothermal" + appendix + for idx in well_name ), axis=1, ) + p_nom_max = bus_egs["p_nom_max"] + capital_cost = bus_egs["capital_cost"] + bus1 = pd.Series(f"{bus} geothermal heat surface", well_name) + n.madd( "Link", - f"{bus} enhanced geothermal" + appendix, + well_name, location=bus, bus0=spatial.geothermal_heat.nodes, - bus1=f"geothermal heat surface {bus}", + bus1=bus1, carrier="geothermal heat", p_nom_extendable=True, - p_nom_max=p_nom_max / efficiency, - capital_cost=capital_cost * efficiency, + p_nom_max=p_nom_max.set_axis(well_name) / efficiency_orc, + capital_cost=capital_cost.set_axis(well_name), efficiency=bus_eta, ) n.add( "Link", bus + " geothermal organic rankine cycle", - bus0=f"geothermal heat surface {bus}", + bus0=f"{bus} geothermal heat surface", bus1=bus, p_nom_extendable=True, carrier="geothermal organic rankine cycle", @@ -3463,7 +3460,7 @@ def add_enhanced_geothermal( n.add( "Link", bus + " geothermal heat district heat", - bus0=f"geothermal heat surface {bus}", + bus0=f"{bus} geothermal heat surface", bus1=bus + " urban central heat", carrier="geothermal district heat", capital_cost=plant_capital_cost @@ -3472,13 +3469,13 @@ def add_enhanced_geothermal( efficiency=efficiency_dh * 2.0, p_nom_extendable=True, ) - else: + elif as_chp and not bus + " urban central heat" in n.buses.index: n.links.at[bus + " geothermal organic rankine cycle", "efficiency"] = efficiency_orc if snakemake.params.sector["enhanced_geothermal_flexible"]: # this StorageUnit represents flexible operation using the geothermal reservoir. - # Hence, it is intuitively wrong to install it at the surface bus, + # Hence, it is counter-intuitive to install it at the surface bus, # this is however the more lean and computationally efficient solution. max_hours = snakemake.params.sector["enhanced_geothermal_reservoir_max_hours"] @@ -3488,7 +3485,7 @@ def add_enhanced_geothermal( n.add( "StorageUnit", bus + ' geothermal reservoir', - bus=f"geothermal heat surface {bus}", + bus=f"{bus} geothermal heat surface", carrier="geothermal heat", p_nom_extendable=True, p_min_pu=-1. - boost,