Spaces:
Sleeping
Sleeping
Update app/hvac_loads.py
Browse files- app/hvac_loads.py +24 -23
app/hvac_loads.py
CHANGED
@@ -1172,25 +1172,21 @@ def display_hvac_loads_page():
|
|
1172 |
lighting_systems = internal_loads.get("lighting", [])
|
1173 |
equipment_systems = internal_loads.get("equipment", [])
|
1174 |
|
1175 |
-
# Calculate
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
default_lighting_convective = lighting_convective_total / lighting_count
|
1183 |
-
default_lighting_radiative = lighting_radiative_total / lighting_count
|
1184 |
|
1185 |
-
# Calculate
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
default_equipment_convective = equipment_convective_total / equipment_count
|
1193 |
-
default_equipment_radiative = equipment_radiative_total / equipment_count
|
1194 |
|
1195 |
with col1:
|
1196 |
air_velocity = st.number_input(
|
@@ -1210,7 +1206,7 @@ def display_hvac_loads_page():
|
|
1210 |
"Lighting Convective Fraction",
|
1211 |
min_value=0.0,
|
1212 |
max_value=1.0,
|
1213 |
-
value=
|
1214 |
step=0.01,
|
1215 |
key="hvac_lighting_convective"
|
1216 |
)
|
@@ -1220,20 +1216,22 @@ def display_hvac_loads_page():
|
|
1220 |
"Lighting Radiative Fraction",
|
1221 |
min_value=0.0,
|
1222 |
max_value=1.0,
|
1223 |
-
value=
|
1224 |
step=0.01,
|
1225 |
key="hvac_lighting_radiative"
|
1226 |
)
|
1227 |
# Validate lighting fractions sum to 1.0
|
1228 |
if abs(lighting_convective_fraction + lighting_radiative_fraction - 1.0) > 0.01:
|
1229 |
st.error("Lighting convective and radiative fractions must sum to 1.0.")
|
|
|
|
|
1230 |
|
1231 |
with col4:
|
1232 |
equipment_convective_fraction = st.number_input(
|
1233 |
"Equipment Convective Fraction",
|
1234 |
min_value=0.0,
|
1235 |
max_value=1.0,
|
1236 |
-
value=
|
1237 |
step=0.01,
|
1238 |
key="hvac_equipment_convective"
|
1239 |
)
|
@@ -1243,15 +1241,18 @@ def display_hvac_loads_page():
|
|
1243 |
"Equipment Radiative Fraction",
|
1244 |
min_value=0.0,
|
1245 |
max_value=1.0,
|
1246 |
-
value=
|
1247 |
step=0.01,
|
1248 |
key="hvac_equipment_radiative"
|
1249 |
)
|
1250 |
# Validate equipment fractions sum to 1.0
|
1251 |
if abs(equipment_convective_fraction + equipment_radiative_fraction - 1.0) > 0.01:
|
1252 |
st.error("Equipment convective and radiative fractions must sum to 1.0.")
|
|
|
|
|
1253 |
|
1254 |
if st.button("Save Internal Loads Conditions"):
|
|
|
1255 |
st.session_state.project_data["internal_loads_conditions"].update({
|
1256 |
"air_velocity": air_velocity,
|
1257 |
"lighting_convective_fraction": lighting_convective_fraction,
|
@@ -1268,7 +1269,7 @@ def display_hvac_loads_page():
|
|
1268 |
system["convective_fraction"] = equipment_convective_fraction
|
1269 |
system["radiative_fraction"] = equipment_radiative_fraction
|
1270 |
st.success("Internal loads conditions saved successfully.")
|
1271 |
-
logger.info("Internal loads conditions updated in session state")
|
1272 |
|
1273 |
# Calculate HVAC Loads
|
1274 |
if st.button("Calculate HVAC Loads"):
|
|
|
1172 |
lighting_systems = internal_loads.get("lighting", [])
|
1173 |
equipment_systems = internal_loads.get("equipment", [])
|
1174 |
|
1175 |
+
# Calculate default lighting fractions from lighting systems
|
1176 |
+
if lighting_systems:
|
1177 |
+
lighting_convective_avg = sum(system.get("convective_fraction", 0.5) for system in lighting_systems) / len(lighting_systems)
|
1178 |
+
lighting_radiative_avg = sum(system.get("radiative_fraction", 0.5) for system in lighting_systems) / len(lighting_systems)
|
1179 |
+
else:
|
1180 |
+
lighting_convective_avg = st.session_state.project_data["internal_loads_conditions"].get("lighting_convective_fraction", 0.5)
|
1181 |
+
lighting_radiative_avg = st.session_state.project_data["internal_loads_conditions"].get("lighting_radiative_fraction", 0.5)
|
|
|
|
|
1182 |
|
1183 |
+
# Calculate default equipment fractions from equipment systems
|
1184 |
+
if equipment_systems:
|
1185 |
+
equipment_convective_avg = sum(system.get("convective_fraction", 0.5) for system in equipment_systems) / len(equipment_systems)
|
1186 |
+
equipment_radiative_avg = sum(system.get("radiative_fraction", 0.5) for system in equipment_systems) / len(equipment_systems)
|
1187 |
+
else:
|
1188 |
+
equipment_convective_avg = st.session_state.project_data["internal_loads_conditions"].get("equipment_convective_fraction", 0.5)
|
1189 |
+
equipment_radiative_avg = st.session_state.project_data["internal_loads_conditions"].get("equipment_radiative_fraction", 0.5)
|
|
|
|
|
1190 |
|
1191 |
with col1:
|
1192 |
air_velocity = st.number_input(
|
|
|
1206 |
"Lighting Convective Fraction",
|
1207 |
min_value=0.0,
|
1208 |
max_value=1.0,
|
1209 |
+
value=lighting_convective_avg,
|
1210 |
step=0.01,
|
1211 |
key="hvac_lighting_convective"
|
1212 |
)
|
|
|
1216 |
"Lighting Radiative Fraction",
|
1217 |
min_value=0.0,
|
1218 |
max_value=1.0,
|
1219 |
+
value=lighting_radiative_avg,
|
1220 |
step=0.01,
|
1221 |
key="hvac_lighting_radiative"
|
1222 |
)
|
1223 |
# Validate lighting fractions sum to 1.0
|
1224 |
if abs(lighting_convective_fraction + lighting_radiative_fraction - 1.0) > 0.01:
|
1225 |
st.error("Lighting convective and radiative fractions must sum to 1.0.")
|
1226 |
+
lighting_radiative_fraction = 1.0 - lighting_convective_fraction # Auto-correct radiative fraction
|
1227 |
+
st.warning(f"Adjusted Lighting Radiative Fraction to {lighting_radiative_fraction:.2f} to ensure sum equals 1.0.")
|
1228 |
|
1229 |
with col4:
|
1230 |
equipment_convective_fraction = st.number_input(
|
1231 |
"Equipment Convective Fraction",
|
1232 |
min_value=0.0,
|
1233 |
max_value=1.0,
|
1234 |
+
value=equipment_convective_avg,
|
1235 |
step=0.01,
|
1236 |
key="hvac_equipment_convective"
|
1237 |
)
|
|
|
1241 |
"Equipment Radiative Fraction",
|
1242 |
min_value=0.0,
|
1243 |
max_value=1.0,
|
1244 |
+
value=equipment_radiative_avg,
|
1245 |
step=0.01,
|
1246 |
key="hvac_equipment_radiative"
|
1247 |
)
|
1248 |
# Validate equipment fractions sum to 1.0
|
1249 |
if abs(equipment_convective_fraction + equipment_radiative_fraction - 1.0) > 0.01:
|
1250 |
st.error("Equipment convective and radiative fractions must sum to 1.0.")
|
1251 |
+
equipment_radiative_fraction = 1.0 - equipment_convective_fraction # Auto-correct radiative fraction
|
1252 |
+
st.warning(f"Adjusted Equipment Radiative Fraction to {equipment_radiative_fraction:.2f} to ensure sum equals 1.0.")
|
1253 |
|
1254 |
if st.button("Save Internal Loads Conditions"):
|
1255 |
+
# Update internal loads conditions in session state
|
1256 |
st.session_state.project_data["internal_loads_conditions"].update({
|
1257 |
"air_velocity": air_velocity,
|
1258 |
"lighting_convective_fraction": lighting_convective_fraction,
|
|
|
1269 |
system["convective_fraction"] = equipment_convective_fraction
|
1270 |
system["radiative_fraction"] = equipment_radiative_fraction
|
1271 |
st.success("Internal loads conditions saved successfully.")
|
1272 |
+
logger.info("Internal loads conditions updated in session state.")
|
1273 |
|
1274 |
# Calculate HVAC Loads
|
1275 |
if st.button("Calculate HVAC Loads"):
|