99 lines
2.8 KiB
Python
99 lines
2.8 KiB
Python
"""
|
|
Storey module
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
from typing import List
|
|
import numpy as np
|
|
|
|
from city_model_structure.attributes.surface import Surface
|
|
from city_model_structure.attributes.thermal_boundary import ThermalBoundary
|
|
from city_model_structure.attributes.thermal_zone import ThermalZone
|
|
import helpers.constants as cte
|
|
|
|
|
|
class Storey:
|
|
# todo: rethink this class for buildings with windows
|
|
"""
|
|
Storey class
|
|
"""
|
|
def __init__(self, name, surfaces, neighbours):
|
|
# todo: the information of the parent surface is lost -> need to recover it
|
|
self._name = name
|
|
self._surfaces = surfaces
|
|
self._thermal_boundaries = None
|
|
self._virtual_surfaces = None
|
|
self._thermal_zone = None
|
|
self._neighbours = neighbours
|
|
|
|
@property
|
|
def name(self):
|
|
"""
|
|
Storey's name
|
|
:return: str
|
|
"""
|
|
return self._name
|
|
|
|
@property
|
|
def surfaces(self) -> List[Surface]:
|
|
"""
|
|
External surfaces enclosing the storey
|
|
:return: [Surface]
|
|
"""
|
|
return self._surfaces
|
|
|
|
@property
|
|
def neighbours(self):
|
|
"""
|
|
Neighbour storeys' names
|
|
:return: [str]
|
|
"""
|
|
return self._neighbours
|
|
|
|
@property
|
|
def thermal_boundaries(self) -> List[ThermalBoundary]:
|
|
"""
|
|
Thermal boundaries bounding the thermal zone
|
|
:return: [ThermalBoundary]
|
|
"""
|
|
# todo: it cannot be, it creates a loop between thermal boundaries and thermal zones
|
|
if self._thermal_boundaries is None:
|
|
self._thermal_boundaries = []
|
|
for surface in self.surfaces:
|
|
if surface.type != cte.INTERIOR_WALL or surface.type != cte.INTERIOR_SLAB:
|
|
# external thermal boundary -> only one thermal zone
|
|
delimits = [self.thermal_zone]
|
|
else:
|
|
# internal thermal boundary -> two thermal zones
|
|
grad = np.rad2deg(surface.inclination)
|
|
if grad >= 170:
|
|
delimits = [self.thermal_zone, self._neighbours[0]]
|
|
else:
|
|
delimits = [self._neighbours[1], self.thermal_zone]
|
|
self._thermal_boundaries.append(ThermalBoundary(surface, delimits))
|
|
return self._thermal_boundaries
|
|
|
|
@property
|
|
def virtual_surfaces(self) -> List[Surface]:
|
|
"""
|
|
Internal surfaces enclosing the thermal zone
|
|
:return: [Surface]
|
|
"""
|
|
if self._virtual_surfaces is None:
|
|
self._virtual_surfaces = []
|
|
for thermal_boundary in self.thermal_boundaries:
|
|
self._virtual_surfaces.append(thermal_boundary.virtual_internal_surface)
|
|
return self._virtual_surfaces
|
|
|
|
@property
|
|
def thermal_zone(self) -> ThermalZone:
|
|
"""
|
|
Thermal zone inside the storey
|
|
:return: ThermalZone
|
|
"""
|
|
if self._thermal_zone is None:
|
|
self._thermal_zone = ThermalZone(self.virtual_surfaces)
|
|
return self._thermal_zone
|