2021-08-11 12:25:52 -04:00
|
|
|
"""
|
|
|
|
C40 test
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
|
|
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
|
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
from unittest import TestCase
|
|
|
|
from imports.geometry_factory import GeometryFactory
|
|
|
|
from imports.construction_factory import ConstructionFactory
|
|
|
|
from imports.weather_factory import WeatherFactory
|
2021-08-11 16:38:06 -04:00
|
|
|
from exports.exports_factory import ExportsFactory
|
2021-08-11 12:25:52 -04:00
|
|
|
|
|
|
|
|
2021-08-27 12:51:30 -04:00
|
|
|
class TestC40(TestCase):
|
2021-08-11 12:25:52 -04:00
|
|
|
"""
|
|
|
|
C40 TestCase 1
|
|
|
|
"""
|
|
|
|
def setUp(self) -> None:
|
|
|
|
"""
|
|
|
|
Test setup
|
|
|
|
:return: None
|
|
|
|
"""
|
|
|
|
self._city_gml = None
|
|
|
|
self._example_path = (Path(__file__).parent / 'tests_data').resolve()
|
|
|
|
|
|
|
|
def _get_citygml(self, file):
|
|
|
|
if self._city_gml is None:
|
|
|
|
file_path = (self._example_path / file).resolve()
|
|
|
|
self._city_gml = GeometryFactory('citygml', file_path).city
|
|
|
|
self.assertIsNotNone(self._city_gml, 'city is none')
|
|
|
|
return self._city_gml
|
|
|
|
|
|
|
|
def test_c40_enrichment(self):
|
2021-08-27 12:51:30 -04:00
|
|
|
"""
|
|
|
|
Enrich the C40 building
|
|
|
|
"""
|
2021-08-11 12:25:52 -04:00
|
|
|
file = 'C40_Final.gml'
|
2021-08-11 14:19:36 -04:00
|
|
|
base_path = (Path(__file__).parent.parent / 'data' / 'weather').resolve()
|
|
|
|
weather_file_name = 'CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw'
|
2021-08-11 12:25:52 -04:00
|
|
|
city = self._get_citygml(file)
|
|
|
|
for building in city.buildings:
|
2021-08-27 12:51:30 -04:00
|
|
|
for thermal_zone in building.thermal_zones:
|
|
|
|
for thermal_boundary in thermal_zone.thermal_boundaries:
|
|
|
|
thermal_boundary.hi = 10
|
|
|
|
thermal_boundary.he = 25
|
|
|
|
for thermal_opening in thermal_boundary.thermal_openings:
|
|
|
|
thermal_opening.hi = 10
|
|
|
|
thermal_opening.he = 25
|
2021-08-11 14:19:36 -04:00
|
|
|
building.function = 'residential'
|
2021-08-11 12:25:52 -04:00
|
|
|
ConstructionFactory('nrel', city).enrich()
|
|
|
|
for building in city.buildings:
|
|
|
|
print(building.name, building.function, len(building.surfaces))
|
2021-08-11 14:19:36 -04:00
|
|
|
print(building.volume)
|
2021-08-27 12:51:30 -04:00
|
|
|
for thermal_zone in building.thermal_zones:
|
|
|
|
print(thermal_zone.volume)
|
|
|
|
print(thermal_zone.floor_area)
|
2021-08-11 12:25:52 -04:00
|
|
|
|
2021-08-11 14:19:36 -04:00
|
|
|
WeatherFactory('epw', city, base_path=base_path, file_name=weather_file_name).enrich()
|
2021-08-27 12:51:30 -04:00
|
|
|
ExportsFactory('idf', city, r'c:\Documents\idf').export()
|