hub/city_model_structure/building_demand/thermal_zone.py

217 lines
5.8 KiB
Python
Raw Normal View History

2020-10-28 13:42:58 -04:00
"""
ThermalZone module
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
Contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
2020-10-28 13:42:58 -04:00
"""
import uuid
2021-09-14 13:46:48 -04:00
from typing import List, TypeVar, Union
from city_model_structure.building_demand.usage_zone import UsageZone
2021-09-14 13:46:48 -04:00
import ast
2020-10-28 13:42:58 -04:00
ThermalBoundary = TypeVar('ThermalBoundary')
2021-03-16 12:19:35 -04:00
Polyhedron = TypeVar('Polyhedron')
2020-10-28 13:42:58 -04:00
class ThermalZone:
"""
ThermalZone class
"""
2021-08-11 16:38:06 -04:00
def __init__(self, thermal_boundaries, volume):
2020-10-28 13:42:58 -04:00
self._floor_area = None
self._thermal_boundaries = thermal_boundaries
2021-03-16 12:19:35 -04:00
self._is_mechanically_ventilated = None
self._additional_thermal_bridge_u_value = None
2020-10-28 13:42:58 -04:00
self._effective_thermal_capacity = None
self._indirectly_heated_area_ratio = None
self._infiltration_rate_system_on = None
2020-10-28 13:42:58 -04:00
self._infiltration_rate_system_off = None
2021-08-11 15:11:00 -04:00
self._usage_zones = []
2021-08-11 16:38:06 -04:00
self._volume = volume
2021-03-16 12:19:35 -04:00
self._volume_geometry = None
self._id = None
self._ordinate_number = None
@property
def id(self):
"""
Get thermal zone id, an universally unique identifier randomly generated
:return: str
"""
if self._id is None:
self._id = uuid.uuid4()
return self._id
2021-03-16 12:19:35 -04:00
@property
2021-09-14 13:46:48 -04:00
def is_mechanically_ventilated(self) -> Union[None, bool]:
2021-03-16 12:19:35 -04:00
"""
Get thermal zone mechanical ventilation flag
2021-09-14 13:46:48 -04:00
:return: None or Boolean
2021-03-16 12:19:35 -04:00
"""
return self._is_mechanically_ventilated
2021-09-14 13:46:48 -04:00
@is_mechanically_ventilated.setter
def is_mechanically_ventilated(self, value):
"""
Set thermal zone mechanical ventilation flag
:param value: Boolean
"""
if value is not None:
self._is_mechanically_ventilated = ast.literal_eval(value)
2020-10-28 13:42:58 -04:00
@property
def floor_area(self):
"""
Get thermal zone floor area in m2
2020-10-28 13:42:58 -04:00
:return: float
"""
if self._floor_area is None:
self._floor_area = 0
for thermal_boundary in self.thermal_boundaries:
s = thermal_boundary.surface
2020-10-28 13:42:58 -04:00
if s.type == 'Ground':
self._floor_area += s.perimeter_polygon.area
2020-10-28 13:42:58 -04:00
return self._floor_area
@property
def thermal_boundaries(self) -> List[ThermalBoundary]:
2020-10-28 13:42:58 -04:00
"""
Get thermal boundaries bounding with the thermal zone
:return: [ThermalBoundary]
"""
return self._thermal_boundaries
2020-10-28 13:42:58 -04:00
@property
2021-09-14 13:46:48 -04:00
def additional_thermal_bridge_u_value(self) -> Union[None, float]:
2020-10-28 13:42:58 -04:00
"""
Get thermal zone additional thermal bridge u value W/m2K
2021-09-14 13:46:48 -04:00
:return: None or float
2020-10-28 13:42:58 -04:00
"""
return self._additional_thermal_bridge_u_value
@additional_thermal_bridge_u_value.setter
def additional_thermal_bridge_u_value(self, value):
"""
Set thermal zone additional thermal bridge u value W/m2K
:param value: float
"""
2021-09-14 13:46:48 -04:00
if value is not None:
self._additional_thermal_bridge_u_value = float(value)
2020-10-28 13:42:58 -04:00
@property
2021-09-14 13:46:48 -04:00
def effective_thermal_capacity(self) -> Union[None, float]:
2020-10-28 13:42:58 -04:00
"""
Get thermal zone effective thermal capacity in J/m2K
2021-09-14 13:46:48 -04:00
:return: None or float
2020-10-28 13:42:58 -04:00
"""
return self._effective_thermal_capacity
@effective_thermal_capacity.setter
def effective_thermal_capacity(self, value):
"""
Set thermal zone effective thermal capacity in J/m2K
2020-10-28 13:42:58 -04:00
:param value: float
"""
2021-09-14 13:46:48 -04:00
if value is not None:
self._effective_thermal_capacity = float(value)
2020-10-28 13:42:58 -04:00
@property
2021-09-14 13:46:48 -04:00
def indirectly_heated_area_ratio(self) -> Union[None, float]:
2020-10-28 13:42:58 -04:00
"""
Get thermal zone indirectly heated area ratio
2021-09-14 13:46:48 -04:00
:return: None or float
2020-10-28 13:42:58 -04:00
"""
return self._indirectly_heated_area_ratio
@indirectly_heated_area_ratio.setter
def indirectly_heated_area_ratio(self, value):
"""
Set thermal zone indirectly heated area ratio
:param value: float
"""
2021-09-14 13:46:48 -04:00
if value is not None:
self._indirectly_heated_area_ratio = float(value)
2020-10-28 13:42:58 -04:00
@property
2021-09-14 13:46:48 -04:00
def infiltration_rate_system_on(self) -> Union[None, float]:
2020-10-28 13:42:58 -04:00
"""
Get thermal zone infiltration rate system on in air changes per hour (ACH)
2021-09-14 13:46:48 -04:00
:return: None or float
2020-10-28 13:42:58 -04:00
"""
return self._infiltration_rate_system_on
@infiltration_rate_system_on.setter
def infiltration_rate_system_on(self, value):
"""
Set thermal zone infiltration rate system on in air changes per hour (ACH)
2020-10-28 13:42:58 -04:00
:param value: float
"""
2021-09-14 13:46:48 -04:00
if value is not None:
self._infiltration_rate_system_on = float(value)
2020-10-28 13:42:58 -04:00
@property
2021-09-14 13:46:48 -04:00
def infiltration_rate_system_off(self) -> Union[None, float]:
2020-10-28 13:42:58 -04:00
"""
Get thermal zone infiltration rate system off in air changes per hour (ACH)
2021-09-14 13:46:48 -04:00
:return: None or float
2020-10-28 13:42:58 -04:00
"""
return self._infiltration_rate_system_off
@infiltration_rate_system_off.setter
def infiltration_rate_system_off(self, value):
"""
Set thermal zone infiltration rate system on in air changes per hour (ACH)
2020-10-28 13:42:58 -04:00
:param value: float
"""
2021-09-14 13:46:48 -04:00
if value is not None:
self._infiltration_rate_system_off = float(value)
2020-10-28 13:42:58 -04:00
@property
def usage_zones(self) -> List[UsageZone]:
"""
Get thermal zone usage zones
2020-10-28 13:42:58 -04:00
:return: [UsageZone]
"""
return self._usage_zones
@usage_zones.setter
def usage_zones(self, values):
"""
Set thermal zone usage zones
2020-10-28 13:42:58 -04:00
:param values: [UsageZone]
"""
self._usage_zones = values
@property
def volume(self):
"""
Get thermal zone volume
:return: float
"""
return self._volume
2021-03-16 12:19:35 -04:00
@property
def volume_geometry(self) -> Polyhedron:
"""
Get the polyhedron defined by the thermal zone
:return: Polyhedron
"""
return self._volume_geometry
@property
2021-09-14 13:46:48 -04:00
def ordinate_number(self) -> Union[None, int]:
"""
Get the order in which the thermal_zones need to be enumerated
2021-09-14 13:46:48 -04:00
:return: None or int
"""
return self._ordinate_number
@ordinate_number.setter
def ordinate_number(self, value):
"""
Set a specific order of the zones to be called
:param value: int
"""
2021-09-14 13:46:48 -04:00
if value is not None:
self._ordinate_number = int(value)