Spaces:
Sleeping
Sleeping
Update app/main.py
Browse files- app/main.py +19 -6
app/main.py
CHANGED
@@ -279,6 +279,19 @@ class HVACCalculator:
|
|
279 |
|
280 |
return True, "Valid load."
|
281 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
def display_internal_loads(self):
|
283 |
st.title("Internal Loads")
|
284 |
|
@@ -775,7 +788,7 @@ class HVACCalculator:
|
|
775 |
group=wall.wall_group,
|
776 |
orientation=wall.orientation.value,
|
777 |
hour=design_loads['design_hour'],
|
778 |
-
latitude=
|
779 |
solar_absorptivity=wall.solar_absorptivity,
|
780 |
month=outdoor_conditions['month'].lower()
|
781 |
),
|
@@ -803,7 +816,7 @@ class HVACCalculator:
|
|
803 |
group=roof.roof_group,
|
804 |
orientation=roof.orientation.value,
|
805 |
hour=design_loads['design_hour'],
|
806 |
-
latitude=
|
807 |
solar_absorptivity=roof.solar_absorptivity,
|
808 |
month=outdoor_conditions['month'].lower()
|
809 |
),
|
@@ -847,11 +860,11 @@ class HVACCalculator:
|
|
847 |
'shading_device': window.shading_device,
|
848 |
'shading_coefficient': window.shading_coefficient,
|
849 |
'scl': self.cooling_calculator.ashrae_tables.get_scl(
|
850 |
-
latitude=
|
851 |
month=outdoor_conditions['month'].lower(),
|
852 |
orientation=window.orientation.value,
|
853 |
hour=design_loads['design_hour']
|
854 |
-
),
|
855 |
'load': load_dict['total'] / 1000
|
856 |
})
|
857 |
|
@@ -905,11 +918,11 @@ class HVACCalculator:
|
|
905 |
'drapery_type': skylight.drapery_type if hasattr(skylight, 'drapery_type') else 'None',
|
906 |
'shading_coefficient': skylight.shading_coefficient,
|
907 |
'scl': self.cooling_calculator.ashrae_tables.get_scl(
|
908 |
-
latitude=
|
909 |
month=outdoor_conditions['month'].lower(),
|
910 |
orientation='Horizontal',
|
911 |
hour=design_loads['design_hour']
|
912 |
-
),
|
913 |
'load': load_dict['total'] / 1000
|
914 |
})
|
915 |
|
|
|
279 |
|
280 |
return True, "Valid load."
|
281 |
|
282 |
+
def parse_latitude(self, latitude: Any) -> float:
|
283 |
+
"""Parse latitude from string or float to float value."""
|
284 |
+
try:
|
285 |
+
if isinstance(latitude, (int, float)):
|
286 |
+
return float(latitude)
|
287 |
+
if isinstance(latitude, str):
|
288 |
+
lat_str = latitude.strip().upper().replace('N', '').replace('S', '')
|
289 |
+
return float(lat_str)
|
290 |
+
raise ValueError("Invalid latitude format")
|
291 |
+
except (ValueError, AttributeError) as e:
|
292 |
+
st.error(f"Invalid latitude: {latitude}. Using default 32.0.")
|
293 |
+
return 32.0 # Default to 32N
|
294 |
+
|
295 |
def display_internal_loads(self):
|
296 |
st.title("Internal Loads")
|
297 |
|
|
|
788 |
group=wall.wall_group,
|
789 |
orientation=wall.orientation.value,
|
790 |
hour=design_loads['design_hour'],
|
791 |
+
latitude=self.parse_latitude(outdoor_conditions['latitude']),
|
792 |
solar_absorptivity=wall.solar_absorptivity,
|
793 |
month=outdoor_conditions['month'].lower()
|
794 |
),
|
|
|
816 |
group=roof.roof_group,
|
817 |
orientation=roof.orientation.value,
|
818 |
hour=design_loads['design_hour'],
|
819 |
+
latitude=self.parse_latitude(outdoor_conditions['latitude']),
|
820 |
solar_absorptivity=roof.solar_absorptivity,
|
821 |
month=outdoor_conditions['month'].lower()
|
822 |
),
|
|
|
860 |
'shading_device': window.shading_device,
|
861 |
'shading_coefficient': window.shading_coefficient,
|
862 |
'scl': self.cooling_calculator.ashrae_tables.get_scl(
|
863 |
+
latitude=self.parse_latitude(outdoor_conditions['latitude']),
|
864 |
month=outdoor_conditions['month'].lower(),
|
865 |
orientation=window.orientation.value,
|
866 |
hour=design_loads['design_hour']
|
867 |
+
) * 3.15459, # Convert Btu/h-ft² to W/m²
|
868 |
'load': load_dict['total'] / 1000
|
869 |
})
|
870 |
|
|
|
918 |
'drapery_type': skylight.drapery_type if hasattr(skylight, 'drapery_type') else 'None',
|
919 |
'shading_coefficient': skylight.shading_coefficient,
|
920 |
'scl': self.cooling_calculator.ashrae_tables.get_scl(
|
921 |
+
latitude=self.parse_latitude(outdoor_conditions['latitude']),
|
922 |
month=outdoor_conditions['month'].lower(),
|
923 |
orientation='Horizontal',
|
924 |
hour=design_loads['design_hour']
|
925 |
+
) * 3.15459, # Convert Btu/h-ft² to W/m²
|
926 |
'load': load_dict['total'] / 1000
|
927 |
})
|
928 |
|