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
|
|
|
|
|
|
|
|
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:
|
2024-09-19 21:10:26 -04:00
|
|
|
print("building", building.name)
|
2024-09-17 00:19:23 -04:00
|
|
|
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:
|
|
|
|
if wall_u_value and thermal_boundary.type == cte.WALL:
|
2024-09-19 21:10:26 -04:00
|
|
|
print("old_u_value", thermal_boundary.u_value)
|
|
|
|
self._change_thermal_resistance(thermal_boundary, wall_u_value)
|
2024-09-17 00:37:42 -04:00
|
|
|
thermal_boundary.u_value = wall_u_value
|
|
|
|
elif roof_u_value 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
|
|
|
|
elif ground_u_value and thermal_boundary.type == cte.GROUND:
|
2024-09-19 21:10:26 -04:00
|
|
|
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 21:10:26 -04:00
|
|
|
|
|
|
|
|
|
|
|
def _change_thermal_resistance(self, thermal_boundary, u_value):
|
|
|
|
old_u_value =thermal_boundary.u_value
|
|
|
|
new_u_value = u_value
|
|
|
|
if new_u_value < old_u_value:
|
|
|
|
delta_r = 1/(old_u_value - new_u_value)
|
|
|
|
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:
|
|
|
|
pass
|
|
|
|
|
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':
|
|
|
|
self.apply_retrofit(wall_u_value=0.15, roof_u_value=0.08, ground_u_value=0.1)
|