mabuseif commited on
Commit
b558e18
·
verified ·
1 Parent(s): c9450ea

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +47 -18
main.py CHANGED
@@ -86,7 +86,37 @@ class BuildSustain:
86
  "winter_indoor_design_rh": 50.0,
87
  "orientation_angle": 0.0
88
  },
89
- "climate_data": {},
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  "materials": {
91
  "library": dict(SAMPLE_MATERIALS),
92
  "project": {}
@@ -165,7 +195,7 @@ class BuildSustain:
165
  if 'debug_mode' not in st.session_state:
166
  st.session_state.debug_mode = False
167
 
168
- # Initialize module-specific rerun flags (for future modules that might need them)
169
  if 'module_rerun_flags' not in st.session_state:
170
  st.session_state.module_rerun_flags = {}
171
 
@@ -237,7 +267,7 @@ class BuildSustain:
237
  # Display the selected page content
238
  self.display_page(st.session_state.current_page)
239
 
240
- # Handle module-specific reruns (only if needed by specific modules)
241
  self._handle_module_reruns()
242
 
243
  def _handle_page_transition(self, previous_page: str, new_page: str):
@@ -247,7 +277,6 @@ class BuildSustain:
247
  """
248
  # Clear materials library specific states when leaving that page
249
  if previous_page == "Material Library":
250
- # Only clear materials library editor states
251
  keys_to_clear = [
252
  "material_editor",
253
  "fenestration_editor",
@@ -265,8 +294,20 @@ class BuildSustain:
265
  if key in st.session_state:
266
  st.session_state.pop(key, None)
267
 
268
- # Add similar cleanup for other modules as needed
269
- # This approach ensures each module's cleanup is isolated
 
 
 
 
 
 
 
 
 
 
 
 
270
 
271
  # Clear any module-specific rerun flags when changing pages
272
  st.session_state.module_rerun_flags = {}
@@ -292,40 +333,28 @@ class BuildSustain:
292
  page: The name of the page to display
293
  """
294
  if page == "Intro":
295
- # Call the implemented intro module
296
  display_intro_page()
297
  elif page == "Building Information":
298
- # Call the implemented building information module
299
  display_building_info_page()
300
  elif page == "Climate Data":
301
- # Call the implemented climate data module
302
  display_climate_page()
303
  elif page == "Material Library":
304
- # Call the implemented material library module
305
  display_materials_page()
306
  elif page == "Construction":
307
- # Call the implemented construction module
308
  display_construction_page()
309
  elif page == "Building Components":
310
- # Call the implemented components module
311
  display_components_page()
312
  elif page == "Internal Loads":
313
- # Call the implemented internal loads module
314
  display_internal_loads_page()
315
  elif page == "HVAC Loads":
316
- # Call the implemented HVAC loads module
317
  display_hvac_loads_page()
318
  elif page == "Building Energy":
319
- # Call the implemented building energy module
320
  display_building_energy_page()
321
  elif page == "Renewable Energy":
322
- # Call the implemented renewable energy module
323
  display_renewable_energy_page()
324
  elif page == "Embodied Energy":
325
- # Call the implemented embodied energy module
326
  display_embodied_energy_page()
327
  elif page == "Materials Cost":
328
- # Call the implemented materials cost module
329
  display_materials_cost_page()
330
  else:
331
  st.error(f"Unknown page: {page}")
 
86
  "winter_indoor_design_rh": 50.0,
87
  "orientation_angle": 0.0
88
  },
89
+ "climate_data": {
90
+ "id": "",
91
+ "location": {
92
+ "city": "",
93
+ "state_province": "",
94
+ "country": "",
95
+ "source": "",
96
+ "wmo": "",
97
+ "latitude": 0.0,
98
+ "longitude": 0.0,
99
+ "timezone": 0.0,
100
+ "elevation": 0.0
101
+ },
102
+ "design_conditions": {
103
+ "winter_design_temp": 0.0,
104
+ "summer_design_temp_db": 30.0,
105
+ "summer_design_temp_wb": 25.0,
106
+ "heating_degree_days": 0,
107
+ "cooling_degree_days": 0,
108
+ "monthly_average_temps": [20.0] * 12,
109
+ "monthly_average_radiation": [150.0] * 12,
110
+ "summer_daily_range": 8.0,
111
+ "wind_speed": 3.0,
112
+ "pressure": 101325.0
113
+ },
114
+ "climate_zone": "",
115
+ "hourly_data": [],
116
+ "epw_filename": "",
117
+ "typical_extreme_periods": {},
118
+ "ground_temperatures": {}
119
+ },
120
  "materials": {
121
  "library": dict(SAMPLE_MATERIALS),
122
  "project": {}
 
195
  if 'debug_mode' not in st.session_state:
196
  st.session_state.debug_mode = False
197
 
198
+ # Initialize module-specific rerun flags
199
  if 'module_rerun_flags' not in st.session_state:
200
  st.session_state.module_rerun_flags = {}
201
 
 
267
  # Display the selected page content
268
  self.display_page(st.session_state.current_page)
269
 
270
+ # Handle module-specific reruns
271
  self._handle_module_reruns()
272
 
273
  def _handle_page_transition(self, previous_page: str, new_page: str):
 
277
  """
278
  # Clear materials library specific states when leaving that page
279
  if previous_page == "Material Library":
 
280
  keys_to_clear = [
281
  "material_editor",
282
  "fenestration_editor",
 
294
  if key in st.session_state:
295
  st.session_state.pop(key, None)
296
 
297
+ # Clear climate data specific states when leaving the Climate Data page
298
+ if previous_page == "Climate Data":
299
+ keys_to_clear = [
300
+ "data_source",
301
+ "projection_country",
302
+ "projection_state",
303
+ "location",
304
+ "rcp",
305
+ "year",
306
+ "climate_tab"
307
+ ]
308
+ for key in keys_to_clear:
309
+ if key in st.session_state:
310
+ st.session_state.pop(key, None)
311
 
312
  # Clear any module-specific rerun flags when changing pages
313
  st.session_state.module_rerun_flags = {}
 
333
  page: The name of the page to display
334
  """
335
  if page == "Intro":
 
336
  display_intro_page()
337
  elif page == "Building Information":
 
338
  display_building_info_page()
339
  elif page == "Climate Data":
 
340
  display_climate_page()
341
  elif page == "Material Library":
 
342
  display_materials_page()
343
  elif page == "Construction":
 
344
  display_construction_page()
345
  elif page == "Building Components":
 
346
  display_components_page()
347
  elif page == "Internal Loads":
 
348
  display_internal_loads_page()
349
  elif page == "HVAC Loads":
 
350
  display_hvac_loads_page()
351
  elif page == "Building Energy":
 
352
  display_building_energy_page()
353
  elif page == "Renewable Energy":
 
354
  display_renewable_energy_page()
355
  elif page == "Embodied Energy":
 
356
  display_embodied_energy_page()
357
  elif page == "Materials Cost":
 
358
  display_materials_cost_page()
359
  else:
360
  st.error(f"Unknown page: {page}")