Spaces:
Sleeping
Sleeping
Update app/main.py
Browse files- app/main.py +30 -3
app/main.py
CHANGED
@@ -647,7 +647,10 @@ class HVACCalculator:
|
|
647 |
}
|
648 |
|
649 |
# Validate latitude using cooling_calculator
|
650 |
-
|
|
|
|
|
|
|
651 |
|
652 |
# Format conditions
|
653 |
outdoor_conditions = {
|
@@ -809,6 +812,14 @@ class HVACCalculator:
|
|
809 |
'latitude': outdoor_conditions['latitude'],
|
810 |
'solar_absorptivity': wall.solar_absorptivity
|
811 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
812 |
results['detailed_loads']['walls'].append({
|
813 |
'name': wall.name,
|
814 |
'orientation': wall.orientation.value,
|
@@ -820,7 +831,7 @@ class HVACCalculator:
|
|
820 |
group=wall.wall_group,
|
821 |
orientation=wall.orientation.value,
|
822 |
hour=design_loads['design_hour'],
|
823 |
-
latitude=
|
824 |
solar_absorptivity=wall.solar_absorptivity
|
825 |
),
|
826 |
'load': load / 1000
|
@@ -828,6 +839,10 @@ class HVACCalculator:
|
|
828 |
except TypeError as te:
|
829 |
st.error(f"Type error in wall CLTD calculation for {wall.name}: {str(te)}")
|
830 |
return False, f"Type error in wall CLTD calculation: {str(te)}", {}
|
|
|
|
|
|
|
|
|
831 |
|
832 |
for roof in building_components.get('roofs', []):
|
833 |
try:
|
@@ -850,6 +865,14 @@ class HVACCalculator:
|
|
850 |
'latitude': outdoor_conditions['latitude'],
|
851 |
'solar_absorptivity': roof.solar_absorptivity
|
852 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
853 |
results['detailed_loads']['roofs'].append({
|
854 |
'name': roof.name,
|
855 |
'orientation': roof.orientation.value,
|
@@ -861,7 +884,7 @@ class HVACCalculator:
|
|
861 |
group=roof.roof_group,
|
862 |
orientation=roof.orientation.value,
|
863 |
hour=design_loads['design_hour'],
|
864 |
-
latitude=
|
865 |
solar_absorptivity=roof.solar_absorptivity
|
866 |
),
|
867 |
'load': load / 1000
|
@@ -869,6 +892,10 @@ class HVACCalculator:
|
|
869 |
except TypeError as te:
|
870 |
st.error(f"Type error in roof CLTD calculation for {roof.name}: {str(te)}")
|
871 |
return False, f"Type error in roof CLTD calculation: {str(te)}", {}
|
|
|
|
|
|
|
|
|
872 |
|
873 |
for window in building_components.get('windows', []):
|
874 |
adjusted_shgc = self.drapery.adjust_shgc(
|
|
|
647 |
}
|
648 |
|
649 |
# Validate latitude using cooling_calculator
|
650 |
+
raw_latitude = location.get('latitude', '32N')
|
651 |
+
latitude = self.cooling_calculator.validate_latitude(raw_latitude)
|
652 |
+
if st.session_state.get('debug_mode', False):
|
653 |
+
st.write(f"Debug: Raw latitude: {raw_latitude}, Validated latitude: {latitude}")
|
654 |
|
655 |
# Format conditions
|
656 |
outdoor_conditions = {
|
|
|
812 |
'latitude': outdoor_conditions['latitude'],
|
813 |
'solar_absorptivity': wall.solar_absorptivity
|
814 |
})
|
815 |
+
try:
|
816 |
+
lat_value = float(outdoor_conditions['latitude'].replace('N', ''))
|
817 |
+
if st.session_state.get('debug_mode', False):
|
818 |
+
st.write(f"Debug: Converted wall latitude {outdoor_conditions['latitude']} to {lat_value} for get_cltd")
|
819 |
+
except ValueError:
|
820 |
+
lat_value = 32.0
|
821 |
+
if st.session_state.get('debug_mode', False):
|
822 |
+
st.error(f"Invalid latitude format in wall load: {outdoor_conditions['latitude']}. Defaulting to 32.0")
|
823 |
results['detailed_loads']['walls'].append({
|
824 |
'name': wall.name,
|
825 |
'orientation': wall.orientation.value,
|
|
|
831 |
group=wall.wall_group,
|
832 |
orientation=wall.orientation.value,
|
833 |
hour=design_loads['design_hour'],
|
834 |
+
latitude=lat_value,
|
835 |
solar_absorptivity=wall.solar_absorptivity
|
836 |
),
|
837 |
'load': load / 1000
|
|
|
839 |
except TypeError as te:
|
840 |
st.error(f"Type error in wall CLTD calculation for {wall.name}: {str(te)}")
|
841 |
return False, f"Type error in wall CLTD calculation: {str(te)}", {}
|
842 |
+
except Exception as e:
|
843 |
+
if st.session_state.get('debug_mode', False):
|
844 |
+
st.error(f"Error in wall CLTD calculation for {wall.name}: {str(e)}")
|
845 |
+
return False, f"Error in wall CLTD calculation: {str(e)}", {}
|
846 |
|
847 |
for roof in building_components.get('roofs', []):
|
848 |
try:
|
|
|
865 |
'latitude': outdoor_conditions['latitude'],
|
866 |
'solar_absorptivity': roof.solar_absorptivity
|
867 |
})
|
868 |
+
try:
|
869 |
+
lat_value = float(outdoor_conditions['latitude'].replace('N', ''))
|
870 |
+
if st.session_state.get('debug_mode', False):
|
871 |
+
st.write(f"Debug: Converted roof latitude {outdoor_conditions['latitude']} to {lat_value} for get_cltd")
|
872 |
+
except ValueError:
|
873 |
+
lat_value = 32.0
|
874 |
+
if st.session_state.get('debug_mode', False):
|
875 |
+
st.error(f"Invalid latitude format in roof load: {outdoor_conditions['latitude']}. Defaulting to 32.0")
|
876 |
results['detailed_loads']['roofs'].append({
|
877 |
'name': roof.name,
|
878 |
'orientation': roof.orientation.value,
|
|
|
884 |
group=roof.roof_group,
|
885 |
orientation=roof.orientation.value,
|
886 |
hour=design_loads['design_hour'],
|
887 |
+
latitude=lat_value,
|
888 |
solar_absorptivity=roof.solar_absorptivity
|
889 |
),
|
890 |
'load': load / 1000
|
|
|
892 |
except TypeError as te:
|
893 |
st.error(f"Type error in roof CLTD calculation for {roof.name}: {str(te)}")
|
894 |
return False, f"Type error in roof CLTD calculation: {str(te)}", {}
|
895 |
+
except Exception as e:
|
896 |
+
if st.session_state.get('debug_mode', False):
|
897 |
+
st.error(f"Error in roof CLTD calculation for {roof.name}: {str(e)}")
|
898 |
+
return False, f"Error in roof CLTD calculation: {str(e)}", {}
|
899 |
|
900 |
for window in building_components.get('windows', []):
|
901 |
adjusted_shgc = self.drapery.adjust_shgc(
|