Change bounded to thermal_boundaries and overall code quality review
This commit is contained in:
parent
8636f4693c
commit
53a7e259e4
|
@ -8,9 +8,8 @@ contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from typing import List
|
from typing import List
|
||||||
import numpy as np
|
|
||||||
import math
|
import math
|
||||||
|
import numpy as np
|
||||||
from city_model_structure.building_demand.surface import Surface
|
from city_model_structure.building_demand.surface import Surface
|
||||||
from city_model_structure.building_demand.thermal_zone import ThermalZone
|
from city_model_structure.building_demand.thermal_zone import ThermalZone
|
||||||
from city_model_structure.building_demand.usage_zone import UsageZone
|
from city_model_structure.building_demand.usage_zone import UsageZone
|
||||||
|
@ -304,7 +303,6 @@ class Building(CityObject):
|
||||||
"""
|
"""
|
||||||
number_of_storeys, height = self._calculate_number_storeys_and_height(self.average_storey_height, self.eave_height,
|
number_of_storeys, height = self._calculate_number_storeys_and_height(self.average_storey_height, self.eave_height,
|
||||||
self.storeys_above_ground)
|
self.storeys_above_ground)
|
||||||
|
|
||||||
number_of_storeys = 1
|
number_of_storeys = 1
|
||||||
if not self._divide_in_storeys or number_of_storeys == 1:
|
if not self._divide_in_storeys or number_of_storeys == 1:
|
||||||
return [Storey('storey_0', self.surfaces, [None, None], self.volume)]
|
return [Storey('storey_0', self.surfaces, [None, None], self.volume)]
|
||||||
|
@ -368,8 +366,7 @@ class Building(CityObject):
|
||||||
sys.stderr.write('Warning: not enough information to divide building into storeys, '
|
sys.stderr.write('Warning: not enough information to divide building into storeys, '
|
||||||
'either number of storeys or average storey height must be provided.\n')
|
'either number of storeys or average storey height must be provided.\n')
|
||||||
return 0, 0
|
return 0, 0
|
||||||
else:
|
number_of_storeys = int(storeys_above_ground)
|
||||||
number_of_storeys = int(storeys_above_ground)
|
|
||||||
height = eave_height / number_of_storeys
|
height = eave_height / number_of_storeys
|
||||||
else:
|
else:
|
||||||
height = float(average_storey_height)
|
height = float(average_storey_height)
|
||||||
|
@ -409,17 +406,9 @@ class Building(CityObject):
|
||||||
self._floor_area += surface.perimeter_polygon.area
|
self._floor_area += surface.perimeter_polygon.area
|
||||||
return self._floor_area
|
return self._floor_area
|
||||||
|
|
||||||
@property
|
|
||||||
def pv_plus_hp_installation(self):
|
|
||||||
return self._pv_plus_hp_installation
|
|
||||||
|
|
||||||
@pv_plus_hp_installation.setter
|
|
||||||
def pv_plus_hp_installation(self, value):
|
|
||||||
self._pv_plus_hp_installation = value
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _intersections_to_coordinates(edges_list):
|
def _intersections_to_coordinates(edges_list):
|
||||||
# todo: this method is horrible, the while loop needs to be improved
|
# todo: this method is too complex, the while loop needs to be improved
|
||||||
points = [Point(edges_list[0][0]), Point(edges_list[0][1])]
|
points = [Point(edges_list[0][0]), Point(edges_list[0][1])]
|
||||||
found_edges = []
|
found_edges = []
|
||||||
j = 0
|
j = 0
|
||||||
|
|
|
@ -18,7 +18,7 @@ class ThermalZone:
|
||||||
"""
|
"""
|
||||||
def __init__(self, thermal_boundaries, volume):
|
def __init__(self, thermal_boundaries, volume):
|
||||||
self._floor_area = None
|
self._floor_area = None
|
||||||
self._bounded = thermal_boundaries
|
self._thermal_boundaries = thermal_boundaries
|
||||||
self._is_mechanically_ventilated = None
|
self._is_mechanically_ventilated = None
|
||||||
self._additional_thermal_bridge_u_value = None
|
self._additional_thermal_bridge_u_value = None
|
||||||
self._effective_thermal_capacity = None
|
self._effective_thermal_capacity = None
|
||||||
|
@ -56,19 +56,19 @@ class ThermalZone:
|
||||||
"""
|
"""
|
||||||
if self._floor_area is None:
|
if self._floor_area is None:
|
||||||
self._floor_area = 0
|
self._floor_area = 0
|
||||||
for thermal_boundary in self.bounded:
|
for thermal_boundary in self.thermal_boundaries:
|
||||||
s = thermal_boundary.surface
|
s = thermal_boundary.surface
|
||||||
if s.type == 'Ground':
|
if s.type == 'Ground':
|
||||||
self._floor_area += s.perimeter_polygon.area
|
self._floor_area += s.perimeter_polygon.area
|
||||||
return self._floor_area
|
return self._floor_area
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def bounded(self) -> List[ThermalBoundary]:
|
def thermal_boundaries(self) -> List[ThermalBoundary]:
|
||||||
"""
|
"""
|
||||||
Get thermal boundaries bounding with the thermal zone
|
Get thermal boundaries bounding with the thermal zone
|
||||||
:return: [ThermalBoundary]
|
:return: [ThermalBoundary]
|
||||||
"""
|
"""
|
||||||
return self._bounded
|
return self._thermal_boundaries
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def additional_thermal_bridge_u_value(self):
|
def additional_thermal_bridge_u_value(self):
|
||||||
|
|
|
@ -313,7 +313,7 @@ class EnergyAde:
|
||||||
|
|
||||||
def _thermal_boundaries(self, city, thermal_zone):
|
def _thermal_boundaries(self, city, thermal_zone):
|
||||||
thermal_boundaries = []
|
thermal_boundaries = []
|
||||||
for thermal_boundary in thermal_zone.bounded:
|
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||||
thermal_boundary_dic = {
|
thermal_boundary_dic = {
|
||||||
'@gml:id': f'GML_{uuid.uuid4()}',
|
'@gml:id': f'GML_{uuid.uuid4()}',
|
||||||
'gml:name': f'{thermal_boundary.construction_name}',
|
'gml:name': f'{thermal_boundary.construction_name}',
|
||||||
|
|
|
@ -237,7 +237,7 @@ class Idf:
|
||||||
# self._add_infiltration(usage_zone)
|
# self._add_infiltration(usage_zone)
|
||||||
# self._add_occupancy(usage_zone)
|
# self._add_occupancy(usage_zone)
|
||||||
for thermal_zone in building.thermal_zones:
|
for thermal_zone in building.thermal_zones:
|
||||||
for thermal_boundary in thermal_zone.bounded:
|
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||||
self._add_construction(thermal_boundary)
|
self._add_construction(thermal_boundary)
|
||||||
|
|
||||||
if self._export_type == "Surfaces":
|
if self._export_type == "Surfaces":
|
||||||
|
@ -254,7 +254,7 @@ class Idf:
|
||||||
|
|
||||||
for surface in self._idf.idfobjects[self._SURFACE]:
|
for surface in self._idf.idfobjects[self._SURFACE]:
|
||||||
for thermal_zone in building.thermal_zones:
|
for thermal_zone in building.thermal_zones:
|
||||||
for boundary in thermal_zone.bounded:
|
for boundary in thermal_zone.thermal_boundaries:
|
||||||
if surface.Type == self.idf_surfaces[boundary.surface.type]:
|
if surface.Type == self.idf_surfaces[boundary.surface.type]:
|
||||||
surface.Construction_Name = boundary.construction_name
|
surface.Construction_Name = boundary.construction_name
|
||||||
break
|
break
|
||||||
|
@ -266,7 +266,7 @@ class Idf:
|
||||||
|
|
||||||
def _add_surfaces(self, building):
|
def _add_surfaces(self, building):
|
||||||
for thermal_zone in building.thermal_zones:
|
for thermal_zone in building.thermal_zones:
|
||||||
for boundary in thermal_zone.bounded:
|
for boundary in thermal_zone.thermal_boundaries:
|
||||||
idf_surface_type = self.idf_surfaces[boundary.surface.type]
|
idf_surface_type = self.idf_surfaces[boundary.surface.type]
|
||||||
for usage_zone in thermal_zone.usage_zones:
|
for usage_zone in thermal_zone.usage_zones:
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ class CaPhysicsParameters(NrelPhysicsInterface):
|
||||||
thermal_zone.indirectly_heated_area_ratio = archetype.indirectly_heated_area_ratio
|
thermal_zone.indirectly_heated_area_ratio = archetype.indirectly_heated_area_ratio
|
||||||
thermal_zone.infiltration_rate_system_on = archetype.infiltration_rate_system_on
|
thermal_zone.infiltration_rate_system_on = archetype.infiltration_rate_system_on
|
||||||
thermal_zone.infiltration_rate_system_off = archetype.infiltration_rate_system_off
|
thermal_zone.infiltration_rate_system_off = archetype.infiltration_rate_system_off
|
||||||
for thermal_boundary in thermal_zone.bounded:
|
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||||
construction_type = ConstructionHelper.nrcan_construction_types[thermal_boundary.type]
|
construction_type = ConstructionHelper.nrcan_construction_types[thermal_boundary.type]
|
||||||
thermal_boundary_archetype = self._search_construction_in_archetype(archetype, construction_type)
|
thermal_boundary_archetype = self._search_construction_in_archetype(archetype, construction_type)
|
||||||
thermal_boundary.u_value = thermal_boundary_archetype.overall_u_value
|
thermal_boundary.u_value = thermal_boundary_archetype.overall_u_value
|
||||||
|
|
|
@ -59,7 +59,7 @@ class UsPhysicsParameters(NrelPhysicsInterface):
|
||||||
thermal_zone.indirectly_heated_area_ratio = archetype.indirectly_heated_area_ratio
|
thermal_zone.indirectly_heated_area_ratio = archetype.indirectly_heated_area_ratio
|
||||||
thermal_zone.infiltration_rate_system_on = archetype.infiltration_rate_system_on
|
thermal_zone.infiltration_rate_system_on = archetype.infiltration_rate_system_on
|
||||||
thermal_zone.infiltration_rate_system_off = archetype.infiltration_rate_system_off
|
thermal_zone.infiltration_rate_system_off = archetype.infiltration_rate_system_off
|
||||||
for thermal_boundary in thermal_zone.bounded:
|
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||||
construction_type = ConstructionHelper.nrel_construction_types[thermal_boundary.type]
|
construction_type = ConstructionHelper.nrel_construction_types[thermal_boundary.type]
|
||||||
thermal_boundary_archetype = self._search_construction_in_archetype(archetype, construction_type)
|
thermal_boundary_archetype = self._search_construction_in_archetype(archetype, construction_type)
|
||||||
if thermal_boundary_archetype.outside_solar_absorptance is not None:
|
if thermal_boundary_archetype.outside_solar_absorptance is not None:
|
||||||
|
|
|
@ -37,7 +37,7 @@ class MyTestCase(TestCase):
|
||||||
city = self._get_citygml(file)
|
city = self._get_citygml(file)
|
||||||
for building in city.buildings:
|
for building in city.buildings:
|
||||||
for tz in building.thermal_zones:
|
for tz in building.thermal_zones:
|
||||||
for tb in tz.bounded:
|
for tb in tz.thermal_boundaries:
|
||||||
tb.hi = 10
|
tb.hi = 10
|
||||||
tb.he = 25
|
tb.he = 25
|
||||||
for opening in tb.thermal_openings:
|
for opening in tb.thermal_openings:
|
||||||
|
|
|
@ -41,7 +41,7 @@ class TestConstructionFactory(TestCase):
|
||||||
for building in city.buildings:
|
for building in city.buildings:
|
||||||
building.function = GeometryHelper.pluto_to_function[building.function]
|
building.function = GeometryHelper.pluto_to_function[building.function]
|
||||||
for tz in building.thermal_zones:
|
for tz in building.thermal_zones:
|
||||||
for tb in tz.bounded:
|
for tb in tz.thermal_boundaries:
|
||||||
tb.hi = 10
|
tb.hi = 10
|
||||||
tb.he = 25
|
tb.he = 25
|
||||||
for opening in tb.thermal_openings:
|
for opening in tb.thermal_openings:
|
||||||
|
@ -60,8 +60,8 @@ class TestConstructionFactory(TestCase):
|
||||||
self.assertIsNotNone(thermal_zone.indirectly_heated_area_ratio, 'indirectly_heated_area_ratio is none')
|
self.assertIsNotNone(thermal_zone.indirectly_heated_area_ratio, 'indirectly_heated_area_ratio is none')
|
||||||
self.assertIsNotNone(thermal_zone.infiltration_rate_system_on, 'infiltration_rate_system_on is none')
|
self.assertIsNotNone(thermal_zone.infiltration_rate_system_on, 'infiltration_rate_system_on is none')
|
||||||
self.assertIsNotNone(thermal_zone.infiltration_rate_system_off, 'infiltration_rate_system_off is none')
|
self.assertIsNotNone(thermal_zone.infiltration_rate_system_off, 'infiltration_rate_system_off is none')
|
||||||
self.assertIsNotNone(thermal_zone.bounded, 'bounded is none')
|
self.assertIsNotNone(thermal_zone.thermal_boundaries, 'thermal_boundaries is none')
|
||||||
for thermal_boundary in thermal_zone.bounded:
|
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||||
if thermal_boundary.surface.type is not 'Ground':
|
if thermal_boundary.surface.type is not 'Ground':
|
||||||
self.assertIsNotNone(thermal_boundary.outside_solar_absorptance, 'outside_solar_absorptance is none')
|
self.assertIsNotNone(thermal_boundary.outside_solar_absorptance, 'outside_solar_absorptance is none')
|
||||||
self.assertIsNotNone(thermal_boundary.window_ratio, 'window_ratio is none')
|
self.assertIsNotNone(thermal_boundary.window_ratio, 'window_ratio is none')
|
||||||
|
@ -85,8 +85,8 @@ class TestConstructionFactory(TestCase):
|
||||||
self.assertIsNotNone(thermal_zone.indirectly_heated_area_ratio, 'indirectly_heated_area_ratio is none')
|
self.assertIsNotNone(thermal_zone.indirectly_heated_area_ratio, 'indirectly_heated_area_ratio is none')
|
||||||
self.assertIsNotNone(thermal_zone.infiltration_rate_system_on, 'infiltration_rate_system_on is none')
|
self.assertIsNotNone(thermal_zone.infiltration_rate_system_on, 'infiltration_rate_system_on is none')
|
||||||
self.assertIsNotNone(thermal_zone.infiltration_rate_system_off, 'infiltration_rate_system_off is none')
|
self.assertIsNotNone(thermal_zone.infiltration_rate_system_off, 'infiltration_rate_system_off is none')
|
||||||
self.assertIsNotNone(thermal_zone.bounded, 'bounded is none')
|
self.assertIsNotNone(thermal_zone.thermal_boundaries, 'thermal_boundaries is none')
|
||||||
self.assertIsNot(len(thermal_zone.bounded), 0, 'no boundaries of thermal_zone defined')
|
self.assertIsNot(len(thermal_zone.thermal_boundaries), 0, 'no boundaries of thermal_zone defined')
|
||||||
for thermal_boundary in thermal_zone.bounded:
|
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||||
self.assertIsNotNone(thermal_boundary.outside_solar_absorptance, 'outside_solar_absorptance is none')
|
self.assertIsNotNone(thermal_boundary.outside_solar_absorptance, 'outside_solar_absorptance is none')
|
||||||
self.assertIsNotNone(thermal_boundary.window_ratio, 'window_ratio is none')
|
self.assertIsNotNone(thermal_boundary.window_ratio, 'window_ratio is none')
|
||||||
|
|
|
@ -108,7 +108,7 @@ class TestGeometryFactory(TestCase):
|
||||||
for building in city.buildings:
|
for building in city.buildings:
|
||||||
self.assertIsNot(len(building.thermal_zones), 0, 'no building thermal_zones defined')
|
self.assertIsNot(len(building.thermal_zones), 0, 'no building thermal_zones defined')
|
||||||
for thermal_zone in building.thermal_zones:
|
for thermal_zone in building.thermal_zones:
|
||||||
self.assertIsNotNone(thermal_zone.bounded, 'thermal_zone bounded is none')
|
self.assertIsNotNone(thermal_zone.thermal_boundaries, 'thermal_zone thermal_boundaries is none')
|
||||||
self.assertIsNotNone(thermal_zone.floor_area, 'thermal_zone floor_area is none')
|
self.assertIsNotNone(thermal_zone.floor_area, 'thermal_zone floor_area is none')
|
||||||
self.assertIsNone(thermal_zone.additional_thermal_bridge_u_value,
|
self.assertIsNone(thermal_zone.additional_thermal_bridge_u_value,
|
||||||
'thermal_zone additional_thermal_bridge_u_value is not none')
|
'thermal_zone additional_thermal_bridge_u_value is not none')
|
||||||
|
@ -133,8 +133,8 @@ class TestGeometryFactory(TestCase):
|
||||||
for building in city.buildings:
|
for building in city.buildings:
|
||||||
self.assertIsNot(len(building.thermal_zones), 0, 'no building thermal_zones defined')
|
self.assertIsNot(len(building.thermal_zones), 0, 'no building thermal_zones defined')
|
||||||
for thermal_zone in building.thermal_zones:
|
for thermal_zone in building.thermal_zones:
|
||||||
self.assertIsNot(len(thermal_zone.bounded), 0, 'no building thermal_boundaries defined')
|
self.assertIsNot(len(thermal_zone.thermal_boundaries), 0, 'no building thermal_boundaries defined')
|
||||||
for thermal_boundary in thermal_zone.bounded:
|
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||||
print(thermal_boundary.surface.type)
|
print(thermal_boundary.surface.type)
|
||||||
print(thermal_boundary.surface.area_above_ground)
|
print(thermal_boundary.surface.area_above_ground)
|
||||||
self.assertIsNotNone(thermal_boundary.surface, 'thermal_boundary surface is none')
|
self.assertIsNotNone(thermal_boundary.surface, 'thermal_boundary surface is none')
|
||||||
|
@ -154,8 +154,8 @@ class TestGeometryFactory(TestCase):
|
||||||
for building in city.buildings:
|
for building in city.buildings:
|
||||||
self.assertIsNot(len(building.thermal_zones), 0, 'no building thermal_zones defined')
|
self.assertIsNot(len(building.thermal_zones), 0, 'no building thermal_zones defined')
|
||||||
for thermal_zone in building.thermal_zones:
|
for thermal_zone in building.thermal_zones:
|
||||||
self.assertIsNot(len(thermal_zone.bounded), 0, 'no building thermal_boundaries defined')
|
self.assertIsNot(len(thermal_zone.thermal_boundaries), 0, 'no building thermal_boundaries defined')
|
||||||
for thermal_boundary in thermal_zone.bounded:
|
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||||
for thermal_opening in thermal_boundary.thermal_openings:
|
for thermal_opening in thermal_boundary.thermal_openings:
|
||||||
self.assertIsNone(thermal_opening.frame_ratio, 'thermal_opening frame_ratio was initialized')
|
self.assertIsNone(thermal_opening.frame_ratio, 'thermal_opening frame_ratio was initialized')
|
||||||
self.assertIsNone(thermal_opening.g_value, 'thermal_opening g_value was initialized')
|
self.assertIsNone(thermal_opening.g_value, 'thermal_opening g_value was initialized')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user