Spaces:
Sleeping
Sleeping
Update app/main.py
Browse files- app/main.py +17 -13
app/main.py
CHANGED
@@ -17,7 +17,7 @@ import uuid
|
|
17 |
|
18 |
# Import application modules
|
19 |
from app.building_info_form import BuildingInfoForm
|
20 |
-
from app.component_selection import ComponentSelectionInterface, Orientation, ComponentType, Wall, Roof, Floor, Window, Door, Skylight,
|
21 |
from app.results_display import ResultsDisplay
|
22 |
from app.data_validation import DataValidation
|
23 |
from app.data_persistence import DataPersistence
|
@@ -213,7 +213,11 @@ class HVACCalculator:
|
|
213 |
return False, f"Ground temperature for {comp.name} must be between -10°C and 40°C"
|
214 |
if getattr(comp, 'perimeter', 0) < 0:
|
215 |
return False, f"Perimeter for {comp.name} cannot be negative"
|
216 |
-
# NEW: Validate
|
|
|
|
|
|
|
|
|
217 |
if component_type in ['windows', 'skylights']:
|
218 |
if getattr(comp, 'shgc', 0) <= 0:
|
219 |
return False, f"Invalid SHGC for {component_type}: {comp.name}"
|
@@ -758,19 +762,19 @@ class HVACCalculator:
|
|
758 |
month=outdoor_conditions['month'],
|
759 |
hour=design_loads['design_hour'],
|
760 |
latitude=outdoor_conditions['latitude'],
|
761 |
-
|
762 |
)
|
763 |
results['detailed_loads']['walls'].append({
|
764 |
'name': wall.name,
|
765 |
'orientation': wall.orientation.value,
|
766 |
'area': wall.area,
|
767 |
'u_value': wall.u_value,
|
768 |
-
'
|
769 |
'cltd': self.cooling_calculator.ashrae_tables.calculate_corrected_cltd_wall(
|
770 |
wall_group=wall.wall_group,
|
771 |
orientation=wall.orientation.value,
|
772 |
hour=design_loads['design_hour'],
|
773 |
-
|
774 |
month=outdoor_conditions['month'],
|
775 |
latitude=outdoor_conditions['latitude'],
|
776 |
indoor_temp=indoor_conditions['temperature'],
|
@@ -787,18 +791,18 @@ class HVACCalculator:
|
|
787 |
month=outdoor_conditions['month'],
|
788 |
hour=design_loads['design_hour'],
|
789 |
latitude=outdoor_conditions['latitude'],
|
790 |
-
|
791 |
)
|
792 |
results['detailed_loads']['roofs'].append({
|
793 |
'name': roof.name,
|
794 |
'orientation': roof.orientation.value,
|
795 |
'area': roof.area,
|
796 |
'u_value': roof.u_value,
|
797 |
-
'
|
798 |
'cltd': self.cooling_calculator.ashrae_tables.calculate_corrected_cltd_roof(
|
799 |
roof_group=roof.roof_group,
|
800 |
hour=design_loads['design_hour'],
|
801 |
-
|
802 |
month=outdoor_conditions['month'],
|
803 |
latitude=outdoor_conditions['latitude'],
|
804 |
indoor_temp=indoor_conditions['temperature'],
|
@@ -809,7 +813,7 @@ class HVACCalculator:
|
|
809 |
|
810 |
for window in building_components.get('windows', []):
|
811 |
# NEW: Apply drapery adjustment
|
812 |
-
adjusted_shgc = self.
|
813 |
base_shgc=window.shgc,
|
814 |
glazing_type=window.glazing_type,
|
815 |
drapery_type=window.drapery_type if hasattr(window, 'drapery_type') else None
|
@@ -870,7 +874,7 @@ class HVACCalculator:
|
|
870 |
|
871 |
# NEW: Skylights
|
872 |
for skylight in building_components.get('skylights', []):
|
873 |
-
adjusted_shgc = self.
|
874 |
base_shgc=skylight.shgc,
|
875 |
glazing_type=skylight.glazing_type,
|
876 |
drapery_type=skylight.drapery_type if hasattr(skylight, 'drapery_type') else None
|
@@ -1186,7 +1190,7 @@ class HVACCalculator:
|
|
1186 |
'orientation': wall.orientation.value,
|
1187 |
'area': wall.area,
|
1188 |
'u_value': wall.u_value,
|
1189 |
-
'
|
1190 |
'delta_t': delta_t,
|
1191 |
'load': load / 1000
|
1192 |
})
|
@@ -1202,7 +1206,7 @@ class HVACCalculator:
|
|
1202 |
'orientation': roof.orientation.value,
|
1203 |
'area': roof.area,
|
1204 |
'u_value': roof.u_value,
|
1205 |
-
'
|
1206 |
'delta_t': delta_t,
|
1207 |
'load': load / 1000
|
1208 |
})
|
@@ -1216,7 +1220,7 @@ class HVACCalculator:
|
|
1216 |
results['detailed_loads']['floors'].append({
|
1217 |
'name': floor.name,
|
1218 |
'area': floor.area,
|
1219 |
-
'u_value': floor.area,
|
1220 |
'delta_t': indoor_conditions['temperature'] - outdoor_conditions['ground_temperature'],
|
1221 |
'load': load / 1000
|
1222 |
})
|
|
|
17 |
|
18 |
# Import application modules
|
19 |
from app.building_info_form import BuildingInfoForm
|
20 |
+
from app.component_selection import ComponentSelectionInterface, Orientation, ComponentType, Wall, Roof, Floor, Window, Door, Skylight, GlazingType, FrameType # CHANGED: Removed SurfaceColor
|
21 |
from app.results_display import ResultsDisplay
|
22 |
from app.data_validation import DataValidation
|
23 |
from app.data_persistence import DataPersistence
|
|
|
213 |
return False, f"Ground temperature for {comp.name} must be between -10°C and 40°C"
|
214 |
if getattr(comp, 'perimeter', 0) < 0:
|
215 |
return False, f"Perimeter for {comp.name} cannot be negative"
|
216 |
+
# NEW: Validate solar absorptivity for walls and roofs
|
217 |
+
if component_type in ['walls', 'roofs']:
|
218 |
+
if not 0.1 <= getattr(comp, 'solar_absorptivity', 0.6) <= 1.0:
|
219 |
+
return False, f"Invalid solar absorptivity for {component_type}: {comp.name} (must be 0.1-1.0)"
|
220 |
+
# Validate enhanced window/skylight properties
|
221 |
if component_type in ['windows', 'skylights']:
|
222 |
if getattr(comp, 'shgc', 0) <= 0:
|
223 |
return False, f"Invalid SHGC for {component_type}: {comp.name}"
|
|
|
762 |
month=outdoor_conditions['month'],
|
763 |
hour=design_loads['design_hour'],
|
764 |
latitude=outdoor_conditions['latitude'],
|
765 |
+
solar_absorptivity=wall.solar_absorptivity # CHANGED: Replaced surface_color with solar_absorptivity
|
766 |
)
|
767 |
results['detailed_loads']['walls'].append({
|
768 |
'name': wall.name,
|
769 |
'orientation': wall.orientation.value,
|
770 |
'area': wall.area,
|
771 |
'u_value': wall.u_value,
|
772 |
+
'solar_absorptivity': wall.solar_absorptivity, # CHANGED: Replaced surface_color
|
773 |
'cltd': self.cooling_calculator.ashrae_tables.calculate_corrected_cltd_wall(
|
774 |
wall_group=wall.wall_group,
|
775 |
orientation=wall.orientation.value,
|
776 |
hour=design_loads['design_hour'],
|
777 |
+
solar_absorptivity=wall.solar_absorptivity, # CHANGED: Pass solar_absorptivity directly
|
778 |
month=outdoor_conditions['month'],
|
779 |
latitude=outdoor_conditions['latitude'],
|
780 |
indoor_temp=indoor_conditions['temperature'],
|
|
|
791 |
month=outdoor_conditions['month'],
|
792 |
hour=design_loads['design_hour'],
|
793 |
latitude=outdoor_conditions['latitude'],
|
794 |
+
solar_absorptivity=roof.solar_absorptivity # CHANGED: Replaced surface_color with solar_absorptivity
|
795 |
)
|
796 |
results['detailed_loads']['roofs'].append({
|
797 |
'name': roof.name,
|
798 |
'orientation': roof.orientation.value,
|
799 |
'area': roof.area,
|
800 |
'u_value': roof.u_value,
|
801 |
+
'solar_absorptivity': roof.solar_absorptivity, # CHANGED: Replaced surface_color
|
802 |
'cltd': self.cooling_calculator.ashrae_tables.calculate_corrected_cltd_roof(
|
803 |
roof_group=roof.roof_group,
|
804 |
hour=design_loads['design_hour'],
|
805 |
+
solar_absorptivity=roof.solar_absorptivity, # CHANGED: Pass solar_absorptivity directly
|
806 |
month=outdoor_conditions['month'],
|
807 |
latitude=outdoor_conditions['latitude'],
|
808 |
indoor_temp=indoor_conditions['temperature'],
|
|
|
813 |
|
814 |
for window in building_components.get('windows', []):
|
815 |
# NEW: Apply drapery adjustment
|
816 |
+
adjusted_shgc = self.drapery.adjust_shgc( # CHANGED: Fixed typo (drapery_system to drapery)
|
817 |
base_shgc=window.shgc,
|
818 |
glazing_type=window.glazing_type,
|
819 |
drapery_type=window.drapery_type if hasattr(window, 'drapery_type') else None
|
|
|
874 |
|
875 |
# NEW: Skylights
|
876 |
for skylight in building_components.get('skylights', []):
|
877 |
+
adjusted_shgc = self.drapery.adjust_shgc( # CHANGED: Fixed typo (drapery_system to drapery)
|
878 |
base_shgc=skylight.shgc,
|
879 |
glazing_type=skylight.glazing_type,
|
880 |
drapery_type=skylight.drapery_type if hasattr(skylight, 'drapery_type') else None
|
|
|
1190 |
'orientation': wall.orientation.value,
|
1191 |
'area': wall.area,
|
1192 |
'u_value': wall.u_value,
|
1193 |
+
'solar_absorptivity': wall.solar_absorptivity, # CHANGED: Replaced surface_color
|
1194 |
'delta_t': delta_t,
|
1195 |
'load': load / 1000
|
1196 |
})
|
|
|
1206 |
'orientation': roof.orientation.value,
|
1207 |
'area': roof.area,
|
1208 |
'u_value': roof.u_value,
|
1209 |
+
'solar_absorptivity': roof.solar_absorptivity, # CHANGED: Replaced surface_color
|
1210 |
'delta_t': delta_t,
|
1211 |
'load': load / 1000
|
1212 |
})
|
|
|
1220 |
results['detailed_loads']['floors'].append({
|
1221 |
'name': floor.name,
|
1222 |
'area': floor.area,
|
1223 |
+
'u_value': floor.area, # CHANGED: Fixed typo (u_value was incorrectly set to area)
|
1224 |
'delta_t': indoor_conditions['temperature'] - outdoor_conditions['ground_temperature'],
|
1225 |
'load': load / 1000
|
1226 |
})
|