Skip to content

Commit

Permalink
Fix usage of CHP-links for IES-optimal solution
Browse files Browse the repository at this point in the history
  • Loading branch information
KathiEsterl committed Nov 12, 2024
1 parent e7e952a commit 45ed559
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
4 changes: 1 addition & 3 deletions 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": 3, # abort criterion of iterative optimization, 'n_iter' or 'threshold'
"n_iter": 4, # 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 @@ -731,8 +731,6 @@ def run_etrago(args, json_path):
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
21 changes: 11 additions & 10 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 = 'central_gas_CHP' # p0 wird gesetzt, constraints bleiben an
carrier = 'KWK_AC'
else:
carrier = 'central_gas_CHP'

Expand All @@ -3502,7 +3502,7 @@ def add_line_with_costs_and_snommax(bus0, bus1, voltage, overhead=False):

# heat link
if x:
carrier_h = carrier + '_heat'
carrier_h = 'KWK_heat'
else:
carrier_h = carrier + '_heat'

Expand Down Expand Up @@ -3748,8 +3748,8 @@ def add_line_with_costs_and_snommax(bus0, bus1, voltage, overhead=False):

time_series_set['PV'] = (time_series_set['PV1'] + time_series_set['PV2']) / 0.03
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
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
time_series_set['SpK'] = time_series_set['SpK'] / 0.7
time_series_set['W_laden'] = time_series_set['W_laden'] / p_wsp_l
time_series_set['W_entladen'] = time_series_set['W_entladen'] / p_wsp_e
Expand All @@ -3758,20 +3758,21 @@ 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['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)]
self.network.storage_units_t['state_of_charge_set'].loc[:, bsp] = (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==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)]
self.network.links_t['p_set'].loc[:, ac] = (time_series_set['CHP_AC']).values[:len(self.network.snapshots)]
#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==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)]
self.network.links_t['p_set'].loc[:, heat] = (time_series_set['CHP_heat']).values[:len(self.network.snapshots)]
#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)]

spk = self.network.generators[self.network.generators.carrier=='SpK'].index[0]
self.network.generators_t['p_min_pu'].loc[:, spk] = 0.9 * (time_series_set['SpK']).values[:len(self.network.snapshots)]
Expand Down

0 comments on commit 45ed559

Please sign in to comment.