From eb32b7b3e6ed6feb816445d37ad642ccc10e09b8 Mon Sep 17 00:00:00 2001 From: Pilar Date: Wed, 11 Aug 2021 16:38:06 -0400 Subject: [PATCH] added volume to thermal_zones --- city_model_structure/building.py | 13 +++++++++---- city_model_structure/building_demand/storey.py | 13 +++++++++++-- city_model_structure/building_demand/surface.py | 11 ----------- .../building_demand/thermal_zone.py | 12 ++---------- non_functional_tests/test_C40.py | 7 +++++-- 5 files changed, 27 insertions(+), 29 deletions(-) diff --git a/city_model_structure/building.py b/city_model_structure/building.py index 9f459037..0728ad2f 100644 --- a/city_model_structure/building.py +++ b/city_model_structure/building.py @@ -301,17 +301,17 @@ class Building(CityObject): """ number_of_storeys, height = self._calculate_number_storeys_and_height(self.average_storey_height, self.eave_height, self.storeys_above_ground) - number_of_storeys = 1 if number_of_storeys == 0: raise Exception(f'Number of storeys cannot be 0') if number_of_storeys == 1: - return [Storey('storey_0', self.surfaces, [None, None])] + return [Storey('storey_0', self.surfaces, [None, None], self.volume)] storeys = [] surfaces_child_last_storey = [] rest_surfaces = [] + total_volume = 0 for i in range(0, number_of_storeys-1): name = 'storey_' + str(i) surfaces_child = [] @@ -345,10 +345,15 @@ class Building(CityObject): polygon = Polygon(coordinates) ceiling = Surface(polygon, polygon, surface_type=cte.INTERIOR_SLAB) surfaces_child.append(ceiling) - storeys.append(Storey(name, surfaces_child, neighbours)) + volume = ceiling.area_above_ground * height + total_volume += volume + storeys.append(Storey(name, surfaces_child, neighbours, volume)) name = 'storey_' + str(number_of_storeys-1) neighbours = ['storey_' + str(number_of_storeys-2), None] - storeys.append(Storey(name, surfaces_child_last_storey, neighbours)) + volume = self.volume - total_volume + if volume < 0: + raise Exception('Error in storeys creation, volume of last storey cannot be lower that 0') + storeys.append(Storey(name, surfaces_child_last_storey, neighbours, volume)) return storeys @staticmethod diff --git a/city_model_structure/building_demand/storey.py b/city_model_structure/building_demand/storey.py index 602806be..9c83545b 100644 --- a/city_model_structure/building_demand/storey.py +++ b/city_model_structure/building_demand/storey.py @@ -19,7 +19,7 @@ class Storey: """ Storey class """ - def __init__(self, name, surfaces, neighbours): + def __init__(self, name, surfaces, neighbours, volume): # todo: the information of the parent surface is lost -> need to recover it self._name = name self._surfaces = surfaces @@ -27,6 +27,7 @@ class Storey: self._virtual_surfaces = None self._thermal_zone = None self._neighbours = neighbours + self._volume = volume @property def name(self): @@ -94,5 +95,13 @@ class Storey: :return: ThermalZone """ if self._thermal_zone is None: - self._thermal_zone = ThermalZone(self.thermal_boundaries) + self._thermal_zone = ThermalZone(self.thermal_boundaries, self.volume) return self._thermal_zone + + @property + def volume(self): + """ + Storey's volume + :return: float + """ + return self._volume diff --git a/city_model_structure/building_demand/surface.py b/city_model_structure/building_demand/surface.py index 028ec372..cf892c46 100644 --- a/city_model_structure/building_demand/surface.py +++ b/city_model_structure/building_demand/surface.py @@ -12,7 +12,6 @@ from city_model_structure.attributes.polygon import Polygon from city_model_structure.attributes.plane import Plane from city_model_structure.attributes.point import Point from city_model_structure.energy_systems.pv_system import PvSystem -from city_model_structure.building_demand.thermal_boundary import ThermalBoundary import helpers.constants as cte @@ -268,16 +267,6 @@ class Surface: self._inverse = Surface(new_solid_polygon, new_perimeter_polygon, new_holes_polygons, cte.VIRTUAL_INTERNAL) return self._inverse - @property - def associated_thermal_boundary(self) -> ThermalBoundary: - """ - Thermal boundary associated to this surface considered as the external face - :return: ThermalBoundary - """ - if self._thermal_boundary is None: - self._thermal_boundary = ThermalBoundary(self, delimits) - return self._thermal_boundary - def shared_surfaces(self): # todo: check https://trimsh.org/trimesh.collision.html as an option to implement this method raise NotImplementedError diff --git a/city_model_structure/building_demand/thermal_zone.py b/city_model_structure/building_demand/thermal_zone.py index b88a1d86..40aee9ca 100644 --- a/city_model_structure/building_demand/thermal_zone.py +++ b/city_model_structure/building_demand/thermal_zone.py @@ -16,7 +16,7 @@ class ThermalZone: """ ThermalZone class """ - def __init__(self, thermal_boundaries): + def __init__(self, thermal_boundaries, volume): self._floor_area = None self._bounded = thermal_boundaries self._is_mechanically_ventilated = None @@ -26,7 +26,7 @@ class ThermalZone: self._infiltration_rate_system_on = None self._infiltration_rate_system_off = None self._usage_zones = None - self._volume = None + self._volume = volume self._volume_geometry = None self._id = None self._is_heated = False @@ -208,14 +208,6 @@ class ThermalZone: """ return self._volume - @volume.setter - def volume(self, value): - """ - Set thermal zone volume - :param value: float - """ - self._volume = value - @property def volume_geometry(self) -> Polyhedron: """ diff --git a/non_functional_tests/test_C40.py b/non_functional_tests/test_C40.py index 317f83a1..0e6e5635 100644 --- a/non_functional_tests/test_C40.py +++ b/non_functional_tests/test_C40.py @@ -8,7 +8,7 @@ from unittest import TestCase from imports.geometry_factory import GeometryFactory from imports.construction_factory import ConstructionFactory from imports.weather_factory import WeatherFactory -# from exports.exports_factory import ExportsFactory +from exports.exports_factory import ExportsFactory class MyTestCase(TestCase): @@ -48,6 +48,9 @@ class MyTestCase(TestCase): for building in city.buildings: print(building.name, building.function, len(building.surfaces)) print(building.volume) + for tz in building.thermal_zones: + print(tz.volume) + print(tz.floor_area) WeatherFactory('epw', city, base_path=base_path, file_name=weather_file_name).enrich() - #ExportsFactory('idf', city, 'c:\Documents\idf').export() \ No newline at end of file + ExportsFactory('idf', city, 'c:\Documents\idf').export()