Skip to content

Commit

Permalink
Adaptions for IES-optimal solution
Browse files Browse the repository at this point in the history
  • Loading branch information
KathiEsterl committed Nov 11, 2024
1 parent 9232dc7 commit 350221f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
6 changes: 5 additions & 1 deletion etrago/appl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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()

Expand Down
16 changes: 16 additions & 0 deletions etrago/execute/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 8 additions & 9 deletions etrago/tools/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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)]

Expand Down

0 comments on commit 350221f

Please sign in to comment.