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

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +8 -46
main.py CHANGED
@@ -73,46 +73,6 @@ class BuildSustain:
73
 
74
  # Initialize project data structure if not set
75
  if 'project_data' not in st.session_state:
76
- # Initialize materials library with Material objects
77
- materials_library = {}
78
- for k, m in SAMPLE_MATERIALS.items():
79
- try:
80
- category_str = m["category"].upper().replace("-", "_")
81
- if category_str not in MaterialCategory.__members__:
82
- logger.error(f"Invalid category for material {k}: {category_str}")
83
- continue
84
- materials_library[k] = Material(
85
- name=k,
86
- category=MaterialCategory[category_str],
87
- conductivity=m["thermal_properties"]["conductivity"],
88
- density=m["thermal_properties"]["density"],
89
- specific_heat=m["thermal_properties"]["specific_heat"],
90
- default_thickness=m["thickness_range"]["default"],
91
- embodied_carbon=m["embodied_carbon"],
92
- absorptivity=m.get("absorptivity", DEFAULT_MATERIAL_PROPERTIES["absorptivity"]),
93
- price=m["cost"]["material"],
94
- emissivity=m.get("emissivity", DEFAULT_MATERIAL_PROPERTIES["emissivity"]),
95
- is_library=True
96
- )
97
- except (KeyError, ValueError) as e:
98
- logger.error(f"Error processing material {k}: {str(e)}")
99
- continue
100
-
101
- # Initialize fenestrations library with GlazingMaterial objects
102
- fenestrations_library = {}
103
- for k, f in SAMPLE_FENESTRATIONS.items():
104
- try:
105
- fenestrations_library[k] = GlazingMaterial(
106
- name=k,
107
- shgc=f["performance"]["shgc"],
108
- u_value=f["performance"]["u_value"],
109
- h_o=f.get("h_o", DEFAULT_WINDOW_PROPERTIES["h_o"]),
110
- is_library=True
111
- )
112
- except KeyError as e:
113
- logger.error(f"Error processing fenestration {k}: Missing key {e}")
114
- continue
115
-
116
  st.session_state.project_data = {
117
  "project_name": "",
118
  "building_info": {
@@ -128,11 +88,11 @@ class BuildSustain:
128
  },
129
  "climate_data": {},
130
  "materials": {
131
- "library": materials_library,
132
  "project": {}
133
  },
134
  "fenestrations": {
135
- "library": fenestrations_library,
136
  "project": {}
137
  },
138
  "constructions": {
@@ -287,15 +247,17 @@ class BuildSustain:
287
  """
288
  # Clear materials library specific states when leaving that page
289
  if previous_page == "Material Library":
290
- # Clear materials and fenestrations editor states
291
  keys_to_clear = [
292
- "material_editor",
293
  "fenestration_editor",
294
- "material_form_state",
295
- "fenestration_form_state",
296
  "material_action",
297
  "fenestration_action",
298
  "materials_rerun_pending",
 
 
299
  "rerun_trigger",
300
  "active_tab"
301
  ]
 
73
 
74
  # Initialize project data structure if not set
75
  if 'project_data' not in st.session_state:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  st.session_state.project_data = {
77
  "project_name": "",
78
  "building_info": {
 
88
  },
89
  "climate_data": {},
90
  "materials": {
91
+ "library": dict(SAMPLE_MATERIALS),
92
  "project": {}
93
  },
94
  "fenestrations": {
95
+ "library": dict(SAMPLE_FENESTRATIONS),
96
  "project": {}
97
  },
98
  "constructions": {
 
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",
254
+ "material_saved",
255
+ "fenestration_saved",
256
  "material_action",
257
  "fenestration_action",
258
  "materials_rerun_pending",
259
+ "material_form_state",
260
+ "fenestration_form_state",
261
  "rerun_trigger",
262
  "active_tab"
263
  ]