drzg commited on
Commit
9cb62bc
·
1 Parent(s): 5d67778

working new current demands

Browse files
Files changed (1) hide show
  1. src/pages/potential_analysis.py +54 -53
src/pages/potential_analysis.py CHANGED
@@ -2218,62 +2218,11 @@ def get_stream_info(stream):
2218
  # Get processes from session state
2219
  processes = st.session_state.get('processes', [])
2220
 
2221
- # Current Demands Section
2222
- with st.expander("Current Energy Demands (They can be added to calculate the improvement with respect to the status quo)", expanded=False):
2223
- # Create stream options once
2224
- stream_options = []
2225
- for idx, process in enumerate(processes):
2226
- for stream_idx, stream in enumerate(process.get('streams', [])):
2227
- stream_name = stream.get('name', f'Stream {stream_idx + 1} in {process.get('name', f'Subprocess {idx + 1}')}')
2228
- stream_options.append((idx, stream_idx, stream_name))
2229
-
2230
- all_stream_names = [name for _, _, name in stream_options]
2231
-
2232
- # Initialize selected_streams for the first demand if empty
2233
- if not st.session_state['current_energy_demands'][0]['selected_streams']:
2234
- st.session_state['current_energy_demands'][0]['selected_streams'] = all_stream_names.copy()
2235
-
2236
- # Display each demand
2237
- demands_to_remove = []
2238
- for i, demand in enumerate(st.session_state['current_energy_demands']):
2239
- st.markdown(f"**Demand Set {i+1}**")
2240
-
2241
- col1, col2, col3 = st.columns([2, 2, 1])
2242
- with col1:
2243
- demand['heat_demand'] = st.number_input(f"Heat Demand (kW) - Set {i+1}", min_value=0.0, step=0.1, value=demand['heat_demand'], key=f"heat_{i}")
2244
- with col2:
2245
- demand['cooling_demand'] = st.number_input(f"Cooling Demand (kW) - Set {i+1}", min_value=0.0, step=0.1, value=demand['cooling_demand'], key=f"cooling_{i}")
2246
- with col3:
2247
- if i > 0: # Don't allow deleting the first demand
2248
- if st.button("🗑️", key=f"delete_{i}"):
2249
- demands_to_remove.append(i)
2250
-
2251
- demand['selected_streams'] = st.multiselect(
2252
- f"Streams - Set {i+1}",
2253
- all_stream_names,
2254
- default=demand['selected_streams'] if demand['selected_streams'] else all_stream_names,
2255
- key=f"streams_{i}"
2256
- )
2257
- st.markdown("---")
2258
-
2259
- # Remove demands marked for deletion
2260
- for i in reversed(demands_to_remove):
2261
- st.session_state['current_energy_demands'].pop(i)
2262
-
2263
- # Add new demand button
2264
- if st.button("➕ Add Demand Set"):
2265
- st.session_state['current_energy_demands'].append({
2266
- 'heat_demand': 0.0,
2267
- 'cooling_demand': 0.0,
2268
- 'selected_streams': all_stream_names.copy()
2269
- })
2270
- st.rerun()
2271
-
2272
  if not processes:
2273
  st.info("No processes found. Please add processes in the Data Collection page first.")
2274
  else:
2275
- # Create side-by-side layout: streams on left, map on right
2276
- streams_col, map_col = st.columns([1, 1])
2277
 
2278
  # Left column: Display streams with selection checkboxes
2279
  with streams_col:
@@ -2326,6 +2275,58 @@ else:
2326
  else:
2327
  stream_cols_inner[2].caption("(incomplete data)")
2328
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2329
  # Right column: Display map with process circles
2330
  with map_col:
2331
  st.markdown("**🗺️ Georeferencing**")
 
2218
  # Get processes from session state
2219
  processes = st.session_state.get('processes', [])
2220
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2221
  if not processes:
2222
  st.info("No processes found. Please add processes in the Data Collection page first.")
2223
  else:
2224
+ # Create side-by-side layout: streams on left, demands in middle, map on right
2225
+ streams_col, demands_col, map_col = st.columns([0.7, 0.8, 1.2])
2226
 
2227
  # Left column: Display streams with selection checkboxes
2228
  with streams_col:
 
2275
  else:
2276
  stream_cols_inner[2].caption("(incomplete data)")
2277
 
2278
+ # Middle column: Current Energy Demands
2279
+ with demands_col:
2280
+ with st.expander("Current energy demand set", expanded=False):
2281
+ # Create stream options once
2282
+ stream_options = []
2283
+ for idx, process in enumerate(processes):
2284
+ for stream_idx, stream in enumerate(process.get('streams', [])):
2285
+ stream_name = stream.get('name', f'Stream {stream_idx + 1} in {process.get('name', f'Subprocess {idx + 1}')}')
2286
+ stream_options.append((idx, stream_idx, stream_name))
2287
+
2288
+ all_stream_names = [name for _, _, name in stream_options]
2289
+
2290
+ # Initialize selected_streams for the first demand if empty
2291
+ if not st.session_state['current_energy_demands'][0]['selected_streams']:
2292
+ st.session_state['current_energy_demands'][0]['selected_streams'] = all_stream_names.copy()
2293
+
2294
+ # Display each demand
2295
+ demands_to_remove = []
2296
+ for i, demand in enumerate(st.session_state['current_energy_demands']):
2297
+ st.markdown(f"**Demand Set {i+1}**")
2298
+
2299
+ col1, col2, col3 = st.columns([2, 2, 1])
2300
+ with col1:
2301
+ demand['heat_demand'] = st.number_input(f"Heat Demand (kW) - Set {i+1}", min_value=0.0, step=0.1, value=demand['heat_demand'], key=f"heat_{i}")
2302
+ with col2:
2303
+ demand['cooling_demand'] = st.number_input(f"Cooling Demand (kW) - Set {i+1}", min_value=0.0, step=0.1, value=demand['cooling_demand'], key=f"cooling_{i}")
2304
+ with col3:
2305
+ if i > 0: # Don't allow deleting the first demand
2306
+ if st.button("🗑️", key=f"delete_{i}"):
2307
+ demands_to_remove.append(i)
2308
+
2309
+ demand['selected_streams'] = st.multiselect(
2310
+ f"Streams - Set {i+1}",
2311
+ all_stream_names,
2312
+ default=demand['selected_streams'] if demand['selected_streams'] else all_stream_names,
2313
+ key=f"streams_{i}"
2314
+ )
2315
+ st.markdown("---")
2316
+
2317
+ # Remove demands marked for deletion
2318
+ for i in reversed(demands_to_remove):
2319
+ st.session_state['current_energy_demands'].pop(i)
2320
+
2321
+ # Add new demand button
2322
+ if st.button("➕ Add Demand Set"):
2323
+ st.session_state['current_energy_demands'].append({
2324
+ 'heat_demand': 0.0,
2325
+ 'cooling_demand': 0.0,
2326
+ 'selected_streams': all_stream_names.copy()
2327
+ })
2328
+ st.rerun()
2329
+
2330
  # Right column: Display map with process circles
2331
  with map_col:
2332
  st.markdown("**🗺️ Georeferencing**")