solved a problem with the number of storages in the calculation of ACH
This commit is contained in:
parent
fd215d9ae9
commit
82b72e78c7
|
@ -260,6 +260,9 @@ class Building(CityObject):
|
|||
Get building storeys number above ground
|
||||
:return: None or int
|
||||
"""
|
||||
if self._storeys_above_ground is None:
|
||||
if self.eave_height is not None and self.average_storey_height is not None:
|
||||
self._storeys_above_ground = int(self.eave_height / self.average_storey_height)
|
||||
return self._storeys_above_ground
|
||||
|
||||
@storeys_above_ground.setter
|
||||
|
|
|
@ -201,7 +201,6 @@ class NrcanPhysicsParameters:
|
|||
@staticmethod
|
||||
def _create_storeys(building, archetype, divide_in_storeys):
|
||||
building.average_storey_height = archetype.average_storey_height
|
||||
building.storeys_above_ground = 1
|
||||
thermal_zones = StoreysGeneration(building, building.internal_zones[0],
|
||||
divide_in_storeys=divide_in_storeys).thermal_zones
|
||||
building.internal_zones[0].thermal_zones = thermal_zones
|
||||
|
|
|
@ -188,7 +188,6 @@ class NrelPhysicsParameters:
|
|||
@staticmethod
|
||||
def _create_storeys(building, archetype, divide_in_storeys):
|
||||
building.average_storey_height = archetype.average_storey_height
|
||||
building.storeys_above_ground = 1
|
||||
thermal_zones = StoreysGeneration(building, building.internal_zones[0],
|
||||
divide_in_storeys=divide_in_storeys).thermal_zones
|
||||
building.internal_zones[0].thermal_zones = thermal_zones
|
||||
|
|
|
@ -49,18 +49,29 @@ class NrcanUsageParameters:
|
|||
logging.error(f'Building {building.name} has unknown usage archetype for usage: {comnet_usage_name}\n')
|
||||
continue
|
||||
|
||||
storeys = int(building.eave_height / building.average_storey_height)
|
||||
volume_per_area = building.volume / building.floor_area / storeys
|
||||
|
||||
for internal_zone in building.internal_zones:
|
||||
if internal_zone.area is None:
|
||||
raise Exception('Internal zone area not defined, ACH cannot be calculated')
|
||||
if internal_zone.volume is None:
|
||||
raise Exception('Internal zone volume not defined, ACH cannot be calculated')
|
||||
if internal_zone.area <= 0:
|
||||
raise Exception('Internal zone area is zero, ACH cannot be calculated')
|
||||
if len(building.internal_zones) > 1:
|
||||
volume_per_area = internal_zone.volume / internal_zone.area
|
||||
volume_per_area = 0
|
||||
if internal_zone.area is None:
|
||||
logging.error(f'Building {building.name} has internal zone area not defined, '
|
||||
f'ACH cannot be calculated for usage: {usage_name}\n')
|
||||
continue
|
||||
if internal_zone.volume is None:
|
||||
logging.error(f'Building {building.name} has internal zone volume not defined, '
|
||||
f'ACH cannot be calculated for usage: {usage_name}\n')
|
||||
continue
|
||||
if internal_zone.area <= 0:
|
||||
logging.error(f'Building {building.name} has internal zone area equal to 0, '
|
||||
f'ACH cannot be calculated for usage: {usage_name}\n')
|
||||
continue
|
||||
volume_per_area += internal_zone.volume / internal_zone.area
|
||||
else:
|
||||
if building.storeys_above_ground is None:
|
||||
logging.error(f'Building {building.name} no number of storeys assigned, '
|
||||
f'ACH cannot be calculated for usage: {usage_name}\n')
|
||||
continue
|
||||
volume_per_area = building.volume / building.floor_area / building.storeys_above_ground
|
||||
|
||||
usage = Usage()
|
||||
usage.name = usage_name
|
||||
self._assign_values(usage, archetype_usage, volume_per_area, building.cold_water_temperature)
|
||||
|
|
|
@ -38,9 +38,9 @@ class TestConstructionCatalog(TestCase):
|
|||
constructions = catalog.names('constructions')
|
||||
windows = catalog.names('windows')
|
||||
materials = catalog.names('materials')
|
||||
self.assertEqual(180, len(constructions['constructions']))
|
||||
self.assertEqual(36, len(windows['windows']))
|
||||
self.assertEqual(192, len(materials['materials']))
|
||||
self.assertEqual(540, len(constructions['constructions']))
|
||||
self.assertEqual(96, len(windows['windows']))
|
||||
self.assertEqual(552, len(materials['materials']))
|
||||
with self.assertRaises(ValueError):
|
||||
catalog.names('unknown')
|
||||
|
||||
|
|
|
@ -253,6 +253,7 @@ TestDBFactory
|
|||
control.database.delete_city(city_id)
|
||||
|
||||
@classmethod
|
||||
@unittest.skipIf(control.skip_test, control.skip_reason)
|
||||
def tearDownClass(cls):
|
||||
control.database.delete_application(control.application_uuid)
|
||||
control.database.delete_user(control.user_id)
|
||||
|
|
|
@ -91,9 +91,10 @@ class TestGeometryFactory(TestCase):
|
|||
|
||||
def _test_hft(self, file):
|
||||
_construction_keys = ['nrel']
|
||||
_usage_keys = ['comnet', 'nrcan']
|
||||
_usage_keys = ['comnet']
|
||||
for construction_key in _construction_keys:
|
||||
for usage_key in _usage_keys:
|
||||
print(construction_key, usage_key)
|
||||
# construction factory called first
|
||||
city = self._get_citygml(file)
|
||||
for building in city.buildings:
|
||||
|
@ -151,12 +152,10 @@ class TestGeometryFactory(TestCase):
|
|||
|
||||
def test_enrichment(self):
|
||||
"""
|
||||
Test enrichment of the city with different order and all possible combinations
|
||||
Test enrichment of the city with different orders
|
||||
:return: None
|
||||
"""
|
||||
file_1 = 'one_building_in_kelowna.gml'
|
||||
self._test_hft(file_1)
|
||||
file_2 = 'pluto_building.gml'
|
||||
self._test_pluto(file_2)
|
||||
file_3 = 'C40_Final.gml'
|
||||
self._test_hft(file_3)
|
||||
file_2 = 'C40_Final.gml'
|
||||
self._test_hft(file_2)
|
||||
|
|
|
@ -8,6 +8,7 @@ from pathlib import Path
|
|||
from unittest import TestCase
|
||||
|
||||
from hub.imports.geometry_factory import GeometryFactory
|
||||
from hub.imports.construction_factory import ConstructionFactory
|
||||
from hub.imports.usage_factory import UsageFactory
|
||||
from hub.helpers.dictionaries import Dictionaries
|
||||
|
||||
|
@ -53,20 +54,16 @@ class TestUsageFactory(TestCase):
|
|||
for internal_zone in building.internal_zones:
|
||||
if internal_zone.usages is not None:
|
||||
self.assertTrue(len(internal_zone.usages) > 0, 'usage zones are not defined')
|
||||
self.assertIsNone(internal_zone.thermal_zones, 'thermal zones are defined')
|
||||
self.assertIsNone(building.basement_heated, 'building basement_heated is not none')
|
||||
self.assertIsNone(building.attic_heated, 'building attic_heated is not none')
|
||||
self.assertIsNone(building.terrains, 'building terrains is not none')
|
||||
self.assertIsNotNone(building.year_of_construction, 'building year_of_construction is none')
|
||||
self.assertIsNotNone(building.function, 'building function is none')
|
||||
self.assertIsNone(building.average_storey_height, 'building average_storey_height is not none')
|
||||
self.assertIsNone(building.storeys_above_ground, 'building storeys_above_ground is not none')
|
||||
self.assertEqual(len(building.heating), 0, 'building heating is not none')
|
||||
self.assertEqual(len(building.cooling), 0, 'building cooling is not none')
|
||||
self.assertIsNotNone(building.eave_height, 'building eave height is none')
|
||||
self.assertIsNotNone(building.roof_type, 'building roof type is none')
|
||||
self.assertIsNotNone(building.floor_area, 'building floor_area is none')
|
||||
self.assertIsNone(building.households, 'building households is not none')
|
||||
|
||||
def _check_usage(self, usage):
|
||||
self.assertIsNotNone(usage.name, 'usage is none')
|
||||
|
@ -142,6 +139,7 @@ class TestUsageFactory(TestCase):
|
|||
function_field='CODE_UTILI',
|
||||
function_to_hub=Dictionaries().montreal_function_to_hub_function).city
|
||||
|
||||
ConstructionFactory('nrcan', city).enrich()
|
||||
UsageFactory('nrcan', city).enrich()
|
||||
self._check_buildings(city)
|
||||
for building in city.buildings:
|
||||
|
|
Loading…
Reference in New Issue
Block a user