Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -119,7 +119,7 @@ price_co2 = 0
119
 
120
 
121
  #technologies_no_invest = st.multiselect(label='Technolgy invest', options=i)
122
- technologies_no_invest = ['Electrolyzer','Biomass','RoR']
123
  # %%
124
  ### Variables
125
  m = Model()
@@ -141,13 +141,13 @@ m.add_objective(C_tot)
141
 
142
  ## Costs terms for objective function
143
  # Operational costs minus revenue for produced hydrogen
144
- C_op_sum = m.add_constraints((y * c_fuel_i/eff_i).sum()*dt*partial_year_factor == C_op, name = 'C_op_sum')
145
 
146
  # Investment costs
147
  C_inv_sum = m.add_constraints((K * c_inv_i).sum() == C_inv, name = 'C_inv_sum')
148
 
149
  ## Load serving
150
- loadserve_t = m.add_constraints(((y ).sum(dims = 'i') - (w ) - y_ch.sum(dims = 'i') == D_t.sel(t = t) ), name = 'load')
151
 
152
  ## Maximum capacity limit
153
  maxcap_i_t = m.add_constraints((y - K <= K_0_i), name = 'max_cap')
@@ -156,25 +156,25 @@ maxcap_i_t = m.add_constraints((y - K <= K_0_i), name = 'max_cap')
156
  maxcap_invest_i = m.add_constraints((K.sel(i = technologies_no_invest) <= 0), name = 'max_cap_invest')
157
 
158
  ## Maximum storage charging and discharging
159
- maxcha_iSto_t = m.add_constraints((y.sel(i = iSto) + y_ch.sel(i = iSto) - K.sel(i = iSto) <= K_0_i.sel(i = iSto)), name = 'max_cha')
160
 
161
  ## Maximum electrolyzer capacity
162
- ptg_prod_iPtG_t = m.add_constraints((y_ch.sel(i = iPtG) - K.sel(i = iPtG)<= K_0_i.sel(i = iPtG)), name = 'max_cha_ptg')
163
 
164
  ## Infeed of renewables
165
  infeed_iRes_t = m.add_constraints((y.sel(i = iRes) - s_t_r_iRes.sel(i = iRes).sel(t = t) * K.sel(i = iRes) <= s_t_r_iRes.sel(i = iRes).sel(t = t) * K_0_i.sel(i = iRes)), name = 'infeed')
166
 
167
- ## Maximum filling level restriction storage power plant --> Energy-to-Power-Ratio eingeführt. (JR)
168
  maxcapsto_iSto_t = m.add_constraints((l.sel(i = iSto) - K.sel(i = iSto) * e2p_iSto.sel(i = iSto) <= K_0_i.sel(i = iSto) * e2p_iSto.sel(i = iSto)), name = 'max_sto_filling')
169
 
170
- ## Filling level restriction hydro reservoir --> Ist Kreisbedingung erfüllt? (JR)
171
  filling_iHydro_t = m.add_constraints(l.sel(i = iHyRes) - l.sel(i = iHyRes).roll(t = -1) + y.sel(i = iHyRes) * dt == h_t.sel(t = t) * dt, name = 'filling_level_hydro')
172
 
173
- ## Filling level restriction other storages --> Ist Kreisbedingung erfüllt? (JR)
174
  filling_iSto_t = m.add_constraints(l.sel(i = iSto) - (l.sel(i = iSto).roll(t = -1) + (y.sel(i = iSto) ) * dt - y_ch.sel(i = iSto) * eff_i.sel(i = iSto) * dt) == 0, name = 'filling_level')
175
 
176
- ## CO2 limit --> ggf. hier auch mit Subset arbeiten (Technologien, die Brennstoff verbrauchen). (JR)
177
- CO2_limit = m.add_constraints(((y / eff_i) * co2_factor_i * dt).sum()* partial_year_factor <= l_co2*1_000_000 , name = 'CO2_limit')
178
 
179
 
180
  # %%
@@ -226,7 +226,7 @@ with colb1:
226
  # %%
227
 
228
  df_contr_marg = m.constraints['max_cap'].dual.to_dataframe().reset_index()
229
- df_contr_marg['dual'] = df_contr_marg['dual']/dt
230
  # %%
231
 
232
  fig = px.line(m.constraints['max_cap'].dual.to_dataframe().reset_index(), y='dual', x='t',title='contribution margin', color='i')
@@ -236,7 +236,7 @@ with colb2:
236
 
237
 
238
  # %%
239
- df_Co2_price = pd.DataFrame({'CO2_Price': [float(m.constraints['CO2_limit'].dual.values)]})
240
 
241
  with colb2:
242
  st.write('CO2 Price ' + str(df_Co2_price))
 
119
 
120
 
121
  #technologies_no_invest = st.multiselect(label='Technolgy invest', options=i)
122
+ technologies_no_invest = ['Electrolyzer','Biomass','RoR','Hydro Water Reservoir']
123
  # %%
124
  ### Variables
125
  m = Model()
 
141
 
142
  ## Costs terms for objective function
143
  # Operational costs minus revenue for produced hydrogen
144
+ C_op_sum = m.add_constraints((y * c_fuel_i/eff_i).sum() * dt * partial_year_factor == C_op, name = 'C_op_sum')
145
 
146
  # Investment costs
147
  C_inv_sum = m.add_constraints((K * c_inv_i).sum() == C_inv, name = 'C_inv_sum')
148
 
149
  ## Load serving
150
+ loadserve_t = m.add_constraints((((y ).sum(dims = 'i') - (w ) - y_ch.sum(dims = 'i')) * dt == D_t.sel(t = t) * dt), name = 'load')
151
 
152
  ## Maximum capacity limit
153
  maxcap_i_t = m.add_constraints((y - K <= K_0_i), name = 'max_cap')
 
156
  maxcap_invest_i = m.add_constraints((K.sel(i = technologies_no_invest) <= 0), name = 'max_cap_invest')
157
 
158
  ## Maximum storage charging and discharging
159
+ maxcha_iSto_t = m.add_constraints((y.sel(i = iSto) + y_ch.sel(i = iSto) - K.sel(i = iSto) <= K_0_i.sel(i = iSto)), name = 'max_cha')
160
 
161
  ## Maximum electrolyzer capacity
162
+ ptg_prod_iPtG_t = m.add_constraints((y_ch.sel(i = iPtG) - K.sel(i = iPtG) <= K_0_i.sel(i = iPtG)), name = 'max_cha_ptg')
163
 
164
  ## Infeed of renewables
165
  infeed_iRes_t = m.add_constraints((y.sel(i = iRes) - s_t_r_iRes.sel(i = iRes).sel(t = t) * K.sel(i = iRes) <= s_t_r_iRes.sel(i = iRes).sel(t = t) * K_0_i.sel(i = iRes)), name = 'infeed')
166
 
167
+ ## Maximum filling level restriction storage power plant
168
  maxcapsto_iSto_t = m.add_constraints((l.sel(i = iSto) - K.sel(i = iSto) * e2p_iSto.sel(i = iSto) <= K_0_i.sel(i = iSto) * e2p_iSto.sel(i = iSto)), name = 'max_sto_filling')
169
 
170
+ ## Filling level restriction hydro reservoir
171
  filling_iHydro_t = m.add_constraints(l.sel(i = iHyRes) - l.sel(i = iHyRes).roll(t = -1) + y.sel(i = iHyRes) * dt == h_t.sel(t = t) * dt, name = 'filling_level_hydro')
172
 
173
+ ## Filling level restriction other storages
174
  filling_iSto_t = m.add_constraints(l.sel(i = iSto) - (l.sel(i = iSto).roll(t = -1) + (y.sel(i = iSto) ) * dt - y_ch.sel(i = iSto) * eff_i.sel(i = iSto) * dt) == 0, name = 'filling_level')
175
 
176
+ ## CO2 limit
177
+ CO2_limit = m.add_constraints(((y / eff_i) * co2_factor_i * dt).sum()* partial_year_factor <= l_co2 * 1_000_000 , name = 'CO2_limit')
178
 
179
 
180
  # %%
 
226
  # %%
227
 
228
  df_contr_marg = m.constraints['max_cap'].dual.to_dataframe().reset_index()
229
+ df_contr_marg['dual'] = df_contr_marg['dual'] / dt * (-1)
230
  # %%
231
 
232
  fig = px.line(m.constraints['max_cap'].dual.to_dataframe().reset_index(), y='dual', x='t',title='contribution margin', color='i')
 
236
 
237
 
238
  # %%
239
+ df_Co2_price = pd.DataFrame({'CO2_Price': [float(m.constraints['CO2_limit'].dual.values) * (-1)]})
240
 
241
  with colb2:
242
  st.write('CO2 Price ' + str(df_Co2_price))