2024-09-17 00:19:23 -04:00
|
|
|
from hub.city_model_structure.building import Building
|
|
|
|
from hub.city_model_structure.city import City
|
|
|
|
import hub.helpers.constants as cte
|
2024-09-19 23:36:49 -04:00
|
|
|
import copy
|
2024-09-17 00:19:23 -04:00
|
|
|
|
|
|
|
class RetrofitFactory:
|
|
|
|
def __init__(self, retrofit_type, city):
|
|
|
|
self._retrofit_type = retrofit_type
|
|
|
|
self._city = city
|
|
|
|
|
|
|
|
def apply_retrofit(self, wall_u_value=None, roof_u_value=None, ground_u_value=None):
|
|
|
|
for building in self._city.buildings:
|
|
|
|
self._apply_retrofit_to_building(building, wall_u_value, roof_u_value, ground_u_value)
|
|
|
|
|
|
|
|
def _apply_retrofit_to_building(self, building: Building, wall_u_value, roof_u_value, ground_u_value):
|
2024-09-17 00:37:42 -04:00
|
|
|
for thermal_zone in building.thermal_zones_from_internal_zones:
|
|
|
|
for thermal_boundary in thermal_zone.thermal_boundaries:
|
2024-09-19 23:36:49 -04:00
|
|
|
if wall_u_value is not None and thermal_boundary.type == cte.WALL and thermal_boundary.u_value > wall_u_value:
|
2024-09-19 21:10:26 -04:00
|
|
|
self._change_thermal_resistance(thermal_boundary, wall_u_value)
|
2024-09-19 23:36:49 -04:00
|
|
|
print("u_value",thermal_boundary.u_value)
|
|
|
|
thermal_boundary.u_value = wall_u_value
|
|
|
|
elif roof_u_value is not None and thermal_boundary.type == cte.ROOF:
|
2024-09-19 21:10:26 -04:00
|
|
|
self._change_thermal_resistance(thermal_boundary, roof_u_value)
|
2024-09-17 00:37:42 -04:00
|
|
|
thermal_boundary.u_value = roof_u_value
|
2024-09-19 23:36:49 -04:00
|
|
|
elif ground_u_value is not None and thermal_boundary.type == cte.GROUND:
|
|
|
|
self._change_thermal_resistance(thermal_boundary, ground_u_value)
|
2024-09-17 00:37:42 -04:00
|
|
|
thermal_boundary.u_value = ground_u_value
|
2024-09-19 23:36:49 -04:00
|
|
|
print("thermal_boundary.u_value",thermal_boundary.u_value, thermal_boundary.type)
|
2024-09-19 21:10:26 -04:00
|
|
|
|
2024-09-19 23:36:49 -04:00
|
|
|
def _change_thermal_resistance(self, thermal_boundary, new_u_value):
|
|
|
|
|
|
|
|
old_u_value = thermal_boundary.u_value
|
|
|
|
new_u_value = new_u_value
|
2024-09-19 21:10:26 -04:00
|
|
|
if new_u_value < old_u_value:
|
2024-09-19 23:36:49 -04:00
|
|
|
delta_r = (1 / new_u_value) - (1 / old_u_value)
|
2024-09-19 21:10:26 -04:00
|
|
|
for layer in thermal_boundary.layers:
|
|
|
|
if "virtual_no_mass" in layer.material_name.lower():
|
|
|
|
new_thermal_resistance = layer.thermal_resistance + delta_r
|
|
|
|
layer.thermal_resistance = new_thermal_resistance
|
|
|
|
else:
|
2024-09-19 23:36:49 -04:00
|
|
|
print("New U-value:", new_u_value, "is not less than old U-value:", old_u_value, "for thermal boundary type:", thermal_boundary.type)
|
2024-09-17 00:19:23 -04:00
|
|
|
|
|
|
|
def enrich(self):
|
|
|
|
# This method can be expanded to include different retrofit strategies
|
|
|
|
if self._retrofit_type == 'basic':
|
2024-09-19 21:10:26 -04:00
|
|
|
self.apply_retrofit(wall_u_value=0.247, roof_u_value=0.138, ground_u_value=0.156)
|
|
|
|
elif self._retrofit_type == 'advanced':
|
2024-09-19 23:36:49 -04:00
|
|
|
self.apply_retrofit(wall_u_value=0.11, roof_u_value=0.08, ground_u_value=0.1)
|