CJahns commited on
Commit
b003220
·
1 Parent(s): f22406d

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -24
app.py CHANGED
@@ -24,10 +24,25 @@ import streamlit as st
24
 
25
  # %%
26
 
27
- url_excel = r'Input_Jahr_2021.xlsx'
28
  url_excel = st.file_uploader(label = 'Excel Upload')
 
 
29
 
 
 
 
30
 
 
 
 
 
 
 
 
 
 
 
31
 
32
  # %% [markdown]
33
  # Read Sets
@@ -62,8 +77,8 @@ iHyRes = pd.Index(df_excel.iloc[0:1,10], name = 'iHyRes')
62
  # %%
63
  ### Parameters
64
  # CO2 limit (from slider)
65
- l_co2 = limit_co2.value
66
- p_co2 = price_co2.value
67
 
68
  # length of timesteps
69
  dt = 1
@@ -94,8 +109,8 @@ df_excel = df_excel.fillna(0)
94
  df_excel = df_excel.set_index('i')
95
  c_fuel_i = df_excel.iloc[:,0].to_xarray()
96
  # Apply slider value
97
- c_fuel_i.loc[dict(i = 'Fossil Gas')] = price_gas.value
98
- c_fuel_i.loc[dict(i = 'H2')] = price_h2.value
99
 
100
  # Other var. costs
101
  df_excel = pd.read_excel(url_excel, sheet_name = 'OtherVarCosts')
@@ -186,7 +201,7 @@ m.add_objective(C_tot)
186
 
187
  ## Costs terms for objective function
188
  # Operational costs minus revenue for produced hydrogen
189
- C_op_sum = m.add_constraints((y * c_var_i * dt).sum() - ((y_ch.sel(i = iPtG) / eff_i.sel(i = iPtG)) * price_h2.value * dt).sum() == C_op, name = 'C_op_sum')
190
 
191
  # Investment costs
192
  C_inv_sum = m.add_constraints((K * c_inv_i).sum() == C_inv, name = 'C_inv_sum')
@@ -222,18 +237,6 @@ m.solve(solver_name = 'highs')
222
 
223
 
224
 
225
- # %% [markdown]
226
- # Results
227
-
228
- # %%
229
-
230
- # %%
231
-
232
- m.solve(solver_name = 'highs',presolve = 'off',run_crossover = 'off',solver = 'ipm')
233
-
234
- # %%
235
- #m.solve(solver_name = 'highs', solver = 'ipm', log_file = 'solverlog.txt',run_crossover = 'off' )
236
-
237
  # %%
238
  # Read Objective from solution
239
  m.objective_value
@@ -247,7 +250,7 @@ df
247
 
248
  # %%
249
  # Read values
250
- Productionlevels = m.solution['y'].sel(r = 'DE').to_dataframe().reset_index()
251
 
252
  df = Productionlevels
253
  df
@@ -259,8 +262,3 @@ fig = px.line(df, x=df['t'], y=df['y'], color = df['i'])
259
  fig
260
 
261
  # %%
262
-
263
-
264
-
265
-
266
- #Productionlevels
 
24
 
25
  # %%
26
 
27
+ #url_excel = r'Input_Jahr_2021.xlsx'
28
  url_excel = st.file_uploader(label = 'Excel Upload')
29
+ if url_excel == None:
30
+ url_excel = r'Input_Jahr_2021.xlsx'
31
 
32
+ # # %%
33
+ # # Slider for gas price [€/MWh_th]
34
+ price_gas = st.slider(value=10, min_value=0, max_value=400, label="Natural gas price [€/MWh]", step=10)
35
 
36
+ # Slider for CO2 price [€/t]
37
+ price_co2 = st.slider(value=80, min_value=0, max_value=400, label="CO2 price [€/t CO2eq]", step=10)
38
+
39
+ # Slider for CO2 limit [mio. t]
40
+ limit_co2 = st.slider(value=400, min_value=0, max_value=750, label="CO2 limit [mio. t]", step=50)
41
+
42
+ # Slider for H2 price / usevalue [€/MWH_th]
43
+ price_h2 = st.slider(value=100, min_value=0, max_value=300, label="Hydrogen price [€/MWh]", step=10)
44
+
45
+ # %%
46
 
47
  # %% [markdown]
48
  # Read Sets
 
77
  # %%
78
  ### Parameters
79
  # CO2 limit (from slider)
80
+ l_co2 = limit_co2
81
+ p_co2 = price_co2
82
 
83
  # length of timesteps
84
  dt = 1
 
109
  df_excel = df_excel.set_index('i')
110
  c_fuel_i = df_excel.iloc[:,0].to_xarray()
111
  # Apply slider value
112
+ c_fuel_i.loc[dict(i = 'Fossil Gas')] = price_gas
113
+ c_fuel_i.loc[dict(i = 'H2')] = price_h2
114
 
115
  # Other var. costs
116
  df_excel = pd.read_excel(url_excel, sheet_name = 'OtherVarCosts')
 
201
 
202
  ## Costs terms for objective function
203
  # Operational costs minus revenue for produced hydrogen
204
+ C_op_sum = m.add_constraints((y * c_var_i * dt).sum() - ((y_ch.sel(i = iPtG) / eff_i.sel(i = iPtG)) * price_h2 * dt).sum() == C_op, name = 'C_op_sum')
205
 
206
  # Investment costs
207
  C_inv_sum = m.add_constraints((K * c_inv_i).sum() == C_inv, name = 'C_inv_sum')
 
237
 
238
 
239
 
 
 
 
 
 
 
 
 
 
 
 
 
240
  # %%
241
  # Read Objective from solution
242
  m.objective_value
 
250
 
251
  # %%
252
  # Read values
253
+ Productionlevels = m.solution['y'].to_dataframe().reset_index()
254
 
255
  df = Productionlevels
256
  df
 
262
  fig
263
 
264
  # %%