Spaces:
Sleeping
Sleeping
Update utils/ctf_calculations.py
Browse files- utils/ctf_calculations.py +14 -4
utils/ctf_calculations.py
CHANGED
@@ -115,14 +115,14 @@ class CTFCalculator:
|
|
115 |
@staticmethod
|
116 |
def _hash_construction(construction: Dict[str, Any]) -> str:
|
117 |
"""Generate a unique hash for a construction based on its properties.
|
118 |
-
|
119 |
Args:
|
120 |
-
construction: Dictionary containing construction properties (name, layers).
|
121 |
-
|
122 |
Returns:
|
123 |
str: SHA-256 hash of the construction properties.
|
124 |
"""
|
125 |
-
hash_input = f"{construction.get('name', '')}"
|
126 |
layers = construction.get('layers', [])
|
127 |
for layer in layers:
|
128 |
material_name = layer.get('material', '')
|
@@ -189,6 +189,16 @@ class CTFCalculator:
|
|
189 |
if not component_type:
|
190 |
logger.warning(f"Invalid component type '{comp_type_str}' for component '{component.get('name', 'Unknown')}'. Returning zero CTFs.")
|
191 |
return CTFCoefficients(X=[0.0], Y=[0.0], Z=[0.0], F=[0.0])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
|
193 |
# Skip CTF for WINDOW, SKYLIGHT as per ASHRAE; return zero coefficients
|
194 |
if component_type in [ComponentType.WINDOW, ComponentType.SKYLIGHT]:
|
|
|
115 |
@staticmethod
|
116 |
def _hash_construction(construction: Dict[str, Any]) -> str:
|
117 |
"""Generate a unique hash for a construction based on its properties.
|
118 |
+
|
119 |
Args:
|
120 |
+
construction: Dictionary containing construction properties (name, layers, adiabatic).
|
121 |
+
|
122 |
Returns:
|
123 |
str: SHA-256 hash of the construction properties.
|
124 |
"""
|
125 |
+
hash_input = f"{construction.get('name', '')}{construction.get('adiabatic', False)}"
|
126 |
layers = construction.get('layers', [])
|
127 |
for layer in layers:
|
128 |
material_name = layer.get('material', '')
|
|
|
189 |
if not component_type:
|
190 |
logger.warning(f"Invalid component type '{comp_type_str}' for component '{component.get('name', 'Unknown')}'. Returning zero CTFs.")
|
191 |
return CTFCoefficients(X=[0.0], Y=[0.0], Z=[0.0], F=[0.0])
|
192 |
+
|
193 |
+
# Validate adiabatic and ground_contact mutual exclusivity
|
194 |
+
if component.get('adiabatic', False) and component.get('ground_contact', False):
|
195 |
+
logger.warning(f"Component {component.get('name', 'Unknown')} has both adiabatic and ground_contact set to True. Treating as adiabatic, setting ground_contact to False.")
|
196 |
+
component['ground_contact'] = False
|
197 |
+
|
198 |
+
# Skip CTF for adiabatic components
|
199 |
+
if component.get('adiabatic', False):
|
200 |
+
logger.info(f"Skipping CTF calculation for adiabatic {component_type.value} component '{component.get('name', 'Unknown')}'. Returning zero coefficients.")
|
201 |
+
return CTFCoefficients(X=[0.0], Y=[0.0], Z=[0.0], F=[0.0])
|
202 |
|
203 |
# Skip CTF for WINDOW, SKYLIGHT as per ASHRAE; return zero coefficients
|
204 |
if component_type in [ComponentType.WINDOW, ComponentType.SKYLIGHT]:
|