From 350221f4c20020774afa80c91ba7cb731a66ca4c Mon Sep 17 00:00:00 2001 From: KathiEsterl Date: Mon, 11 Nov 2024 17:18:08 +0100 Subject: [PATCH] Adaptions for IES-optimal solution --- etrago/appl.py | 6 +++++- etrago/execute/__init__.py | 16 ++++++++++++++++ etrago/tools/utilities.py | 17 ++++++++--------- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/etrago/appl.py b/etrago/appl.py index 4a4e5d25..ce46af55 100644 --- a/etrago/appl.py +++ b/etrago/appl.py @@ -53,7 +53,7 @@ "gridversion": None, # None for model_draft or Version number "method": { # Choose method and settings for optimization "type": "lopf", # type of optimization, 'lopf', 'sclopf' or 'market_grid' - "n_iter": 1, # abort criterion of iterative optimization, 'n_iter' or 'threshold' + "n_iter": 3, # abort criterion of iterative optimization, 'n_iter' or 'threshold' "pyomo": True, # set if pyomo is used for model building "formulation": "pyomo", "market_zones": "status_quo", # only used if type='market_grid' @@ -727,8 +727,12 @@ def run_etrago(args, json_path): # start linear optimal powerflow calculations etrago.network.storage_units.cyclic_state_of_charge = True + bsp = etrago.network.storage_units[etrago.network.storage_units.carrier=='BSp'].index[0] + etrago.network.storage_units.at[bsp, 'cyclic_state_of_charge'] = False etrago.network.lines.loc[etrago.network.lines.r == 0.0, "r"] = 10 + + import pdb; pdb.set_trace() etrago.optimize() diff --git a/etrago/execute/__init__.py b/etrago/execute/__init__.py index 1beffd14..d5e5b601 100644 --- a/etrago/execute/__init__.py +++ b/etrago/execute/__init__.py @@ -312,6 +312,22 @@ def iterate_lopf( for i in range(1, (1 + n_iter)): run_lopf(etrago, extra_functionality, method) + + ### Eigenverbrauch BGA + if i == n_iter-1: + + AC_bus = etrago.network.generators[etrago.network.generators.carrier=='PV'].bus.values[0] + heat_bus = etrago.network.generators[etrago.network.generators.carrier=='SpK'].bus.values[0] + ac = etrago.network.loads[etrago.network.loads.bus==AC_bus].index[0] + he = etrago.network.loads[etrago.network.loads.bus==heat_bus].index[0] + + bga = etrago.network.generators[etrago.network.generators.carrier=='Biogas'].index[0] + faktor = (etrago.network.generators_t.p[bga].sum()*5 / 18720) + diff_el = 0.1 - (faktor*0.1) + diff_heat = 0.165 - (faktor*0.165) + + etrago.network.loads_t.p_set[ac] = etrago.network.loads_t.p_set[ac] - diff_el + etrago.network.loads_t.p_set[he] = etrago.network.loads_t.p_set[he] - diff_heat if args["csv_export"]: path_it = path + "/lopf_iteration_" + str(i) diff --git a/etrago/tools/utilities.py b/etrago/tools/utilities.py index 68c1a163..f5f1a54c 100755 --- a/etrago/tools/utilities.py +++ b/etrago/tools/utilities.py @@ -3479,7 +3479,7 @@ def add_line_with_costs_and_snommax(bus0, bus1, voltage, overhead=False): # CHP: AC link if x: - carrier = 'KWK_AC' + carrier = 'central_gas_CHP' # p0 wird gesetzt, constraints bleiben an else: carrier = 'central_gas_CHP' @@ -3502,14 +3502,14 @@ def add_line_with_costs_and_snommax(bus0, bus1, voltage, overhead=False): # heat link if x: - carrier = 'KWK_heat' + carrier_h = carrier + '_heat' else: - carrier = 'central_gas_CHP_heat' + carrier_h = carrier + '_heat' self.network.add( "Link", name=link_id, - carrier=carrier, + carrier=carrier_h, bus0=gas_bus, bus1=heat_bus2, p_nom_extendable=False, @@ -3747,7 +3747,6 @@ def add_line_with_costs_and_snommax(bus0, bus1, voltage, overhead=False): self.network.storage_units.at[bsp, 'cyclic_state_of_charge'] = False time_series_set['PV'] = (time_series_set['PV1'] + time_series_set['PV2']) / 0.03 - time_series_set['BSp'] = time_series_set['BSp'] / 0.018 time_series_set['BGA'] = (time_series_set['BGA1'] + time_series_set['BGA2'] - 0.625) / (2.762-0.625) time_series_set['CHP_AC'] = (time_series_set['CHP1_AC']+time_series_set['CHP2_AC']+time_series_set['CHP3_AC']) / 4.35 time_series_set['CHP_heat'] = (time_series_set['CHP1_heat']+time_series_set['CHP2_heat']+time_series_set['CHP3_heat']) / 4.35 @@ -3759,18 +3758,18 @@ def add_line_with_costs_and_snommax(bus0, bus1, voltage, overhead=False): self.network.generators_t['p_min_pu'].loc[:, pv] = 0.9 * (time_series_set['PV']).values[:len(self.network.snapshots)] self.network.generators_t['p_max_pu'].loc[:, pv] = 1.1 *(time_series_set['PV']).values[:len(self.network.snapshots)] - self.network.storage_units_t['p_min_pu'].loc[:, bsp] = 0.9 *(time_series_set['BSp']).values[:len(self.network.snapshots)] - self.network.storage_units_t['p_max_pu'].loc[:, bsp] = 1.1 * (time_series_set['BSp']).values[:len(self.network.snapshots)] + self.network.storage_units_t['state_of_charge_set'].loc[:, bsp] = 0.9 *(time_series_set['BSp']).values[:len(self.network.snapshots)] + self.network.storage_units_t['state_of_charge_set'].loc[:, bsp] = 1.1 * (time_series_set['BSp']).values[:len(self.network.snapshots)] bga = self.network.generators[self.network.generators.carrier=='Biogas'].index[0] self.network.generators_t['p_min_pu'].loc[:, bga] = 0.9 * (time_series_set['BGA']).values[:len(self.network.snapshots)] self.network.generators_t['p_max_pu'].loc[:, bga] = 1.1 * (time_series_set['BGA']).values[:len(self.network.snapshots)] - ac = self.network.links[self.network.links.scn_name!='status2019'][self.network.links.carrier=='KWK_AC'].index[0] + ac = self.network.links[self.network.links.scn_name!='status2019'][self.network.links.carrier==carrier].index[0] self.network.links_t['p_min_pu'].loc[:, ac] = 0.9 * (time_series_set['CHP_AC']).values[:len(self.network.snapshots)] self.network.links_t['p_max_pu'].loc[:, ac] = 1.1 * (time_series_set['CHP_AC']).values[:len(self.network.snapshots)] - heat = self.network.links[self.network.links.scn_name!='status2019'][self.network.links.carrier=='KWK_heat'].index[0] + heat = self.network.links[self.network.links.scn_name!='status2019'][self.network.links.carrier==carrier_h].index[0] self.network.links_t['p_min_pu'].loc[:, heat] = 0.9 * (time_series_set['CHP_heat']).values[:len(self.network.snapshots)] self.network.links_t['p_max_pu'].loc[:, heat] = 1.1 * (time_series_set['CHP_heat']).values[:len(self.network.snapshots)]