mabuseif commited on
Commit
75a775e
·
verified ·
1 Parent(s): a83027c

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +35 -8
main.py CHANGED
@@ -38,6 +38,30 @@ from app.materials_cost import display_materials_cost_page
38
  from app.m_c_data import SAMPLE_MATERIALS, SAMPLE_FENESTRATIONS, DEFAULT_MATERIAL_PROPERTIES, DEFAULT_WINDOW_PROPERTIES, SAMPLE_CONSTRUCTIONS
39
 
40
  class BuildSustain:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  def _initialize_session_state(self):
42
  """
43
  Initialize the session state structure if it doesn't exist.
@@ -47,7 +71,7 @@ class BuildSustain:
47
  if 'current_page' not in st.session_state:
48
  st.session_state.current_page = "Intro"
49
 
50
- # Initialize material library if not set
51
  if 'material_library' not in st.session_state:
52
  st.session_state.material_library = MaterialLibrary()
53
  logger.info("Initialized MaterialLibrary in session state")
@@ -97,7 +121,7 @@ class BuildSustain:
97
  "epw_filename": "",
98
  "typical_extreme_periods": {},
99
  "ground_temperatures": {},
100
- "ground_reflectivity": 0.2
101
  },
102
  "materials": {
103
  "library": dict(SAMPLE_MATERIALS),
@@ -132,24 +156,27 @@ class BuildSustain:
132
  "peak": 0,
133
  "summary_tables": {},
134
  "charts": {},
135
- "breakdown": {}
136
  },
137
  "heating": {
138
  "hourly": [],
139
  "peak": 0,
140
  "summary_tables": {},
141
  "charts": {},
142
- "breakdown": {}
143
  }
144
  },
145
- "hvac_settings": {}, # Removed operating_hours and system_type
146
- "sim_period": {
 
 
 
147
  "type": "Full Year",
148
  "start_date": None,
149
  "end_date": None,
150
  "base_temp": 18.3
151
  },
152
- "indoor_conditions": {
153
  "type": "Fixed Setpoints",
154
  "cooling_setpoint": {"temperature": 24.0, "rh": 50.0},
155
  "heating_setpoint": {"temperature": 20.0, "rh": 50.0},
@@ -408,4 +435,4 @@ if __name__ == "__main__":
408
  st.error(f"An error occurred: {str(e)}")
409
  logger.exception("Application error")
410
 
411
- sys.path.append(os.path.join(os.path.dirname(__file__), 'data'))
 
38
  from app.m_c_data import SAMPLE_MATERIALS, SAMPLE_FENESTRATIONS, DEFAULT_MATERIAL_PROPERTIES, DEFAULT_WINDOW_PROPERTIES, SAMPLE_CONSTRUCTIONS
39
 
40
  class BuildSustain:
41
+ """
42
+ Main class for the BuildSustain application.
43
+ Handles navigation, session state initialization, and module integration.
44
+ """
45
+
46
+ def __init__(self):
47
+ """
48
+ Initialize the BuildSustain application.
49
+ Sets up the page configuration and initializes session state if needed.
50
+ """
51
+ # Configure the Streamlit page
52
+ st.set_page_config(
53
+ page_title="BuildSustain",
54
+ page_icon="🌡️",
55
+ layout="wide",
56
+ initial_sidebar_state="expanded"
57
+ )
58
+
59
+ # Initialize session state if it doesn't exist
60
+ self._initialize_session_state()
61
+
62
+ # Set up the application layout
63
+ self.setup_layout()
64
+
65
  def _initialize_session_state(self):
66
  """
67
  Initialize the session state structure if it doesn't exist.
 
71
  if 'current_page' not in st.session_state:
72
  st.session_state.current_page = "Intro"
73
 
74
+ # Initialize material library if not set (Added to support hvac_loads.py)
75
  if 'material_library' not in st.session_state:
76
  st.session_state.material_library = MaterialLibrary()
77
  logger.info("Initialized MaterialLibrary in session state")
 
121
  "epw_filename": "",
122
  "typical_extreme_periods": {},
123
  "ground_temperatures": {},
124
+ "ground_reflectivity": 0.2 # Added for hvac_loads.py solar calculations
125
  },
126
  "materials": {
127
  "library": dict(SAMPLE_MATERIALS),
 
156
  "peak": 0,
157
  "summary_tables": {},
158
  "charts": {},
159
+ "breakdown": {} # Added to store detailed load components (e.g., conduction, solar)
160
  },
161
  "heating": {
162
  "hourly": [],
163
  "peak": 0,
164
  "summary_tables": {},
165
  "charts": {},
166
+ "breakdown": {} # Added to store detailed load components
167
  }
168
  },
169
+ "hvac_settings": { # Added to support hvac_loads.py
170
+ "operating_hours": [{"start": 8, "end": 18}],
171
+ "system_type": "Default"
172
+ },
173
+ "sim_period": { # Added to support hvac_loads.py
174
  "type": "Full Year",
175
  "start_date": None,
176
  "end_date": None,
177
  "base_temp": 18.3
178
  },
179
+ "indoor_conditions": { # Added to support hvac_loads.py
180
  "type": "Fixed Setpoints",
181
  "cooling_setpoint": {"temperature": 24.0, "rh": 50.0},
182
  "heating_setpoint": {"temperature": 20.0, "rh": 50.0},
 
435
  st.error(f"An error occurred: {str(e)}")
436
  logger.exception("Application error")
437
 
438
+ sys.path.append(os.path.join(os.path.dirname(__file__), 'data'))