mirror of
https://rs-loy-gitlab.concordia.ca/PMAU/DynamicBuildingSimulation.git
synced 2024-12-22 21:15:43 -05:00
70 lines
2.7 KiB
Python
70 lines
2.7 KiB
Python
"""
|
|
Populate city
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es
|
|
"""
|
|
|
|
from imports.construction_factory import ConstructionFactory
|
|
from imports.usage_factory import UsageFactory
|
|
from imports.schedules_factory import SchedulesFactory
|
|
|
|
|
|
class Populate:
|
|
def __init__(self, city):
|
|
self._city = city
|
|
self._populated_city = None
|
|
self._errors = []
|
|
|
|
@property
|
|
def errors(self):
|
|
return self._errors
|
|
|
|
def populated_city(self, construction_format, usage_format, schedules_format):
|
|
if self._populated_city is None:
|
|
self._errors = []
|
|
print('original:', len(self._city.buildings))
|
|
|
|
# Step 2.1: Thermal parameters
|
|
ConstructionFactory(construction_format, self._city).enrich()
|
|
for building in self._city.buildings:
|
|
# infiltration_rate_system_off is a mandatory parameter.
|
|
# If it is not returned, extract the building from the calculation list
|
|
if building.thermal_zones[0].infiltration_rate_system_off is None:
|
|
self._city.remove_city_object(building)
|
|
if self._city.buildings is None:
|
|
self._errors.append('no archetype found per construction')
|
|
self._populated_city = self._city
|
|
return self._populated_city
|
|
print('enriched with construction:', len(self._city.buildings))
|
|
|
|
# Step 2.2: Usage parameters
|
|
UsageFactory(usage_format, self._city).enrich()
|
|
for building in self._city.buildings:
|
|
# At least one thermal zone must be created.
|
|
# If it is not created, extract the building from the calculation list
|
|
if len(building.usage_zones) <= 0:
|
|
self._city.remove_city_object(building)
|
|
if self._city.buildings is None:
|
|
self._errors.append('no archetype found per usage')
|
|
self._populated_city = self._city
|
|
return self._populated_city
|
|
print('enriched with usage:', len(self._city.buildings))
|
|
|
|
# Step 2.3: Schedules parameters
|
|
SchedulesFactory(schedules_format, self._city).enrich()
|
|
for building in self._city.buildings:
|
|
counter_schedules = 0
|
|
for usage_zone in building.usage_zones:
|
|
# At least one schedule must be created at each thermal zone.
|
|
# If it is not created, extract the building from the calculation list
|
|
if len(usage_zone.schedules) > 0:
|
|
counter_schedules += 1
|
|
if counter_schedules < len(building.usage_zones):
|
|
self._city.remove_city_object(building)
|
|
if self._city.buildings is None:
|
|
self._errors.append('no archetype found per usage')
|
|
self._populated_city = self._city
|
|
print('enriched with occupancy:', len(self._city.buildings))
|
|
|
|
return self._populated_city
|