from pathlib import Path from hub.imports.geometry_factory import GeometryFactory from hub.imports.construction_factory import ConstructionFactory from hub.imports.usage_factory import UsageFactory from hub.imports.weather_factory import WeatherFactory from simplified_radiosity_algorithm import SimplifiedRadiosityAlgorithm from monthly_energy_balance import MonthlyEnergyBalance from hub.helpers.dictionaries import Dictionaries try: file_path = (Path(__file__).parent / 'input_files' / 'neighbours.geojson') climate_reference_city = 'Montreal' weather_file = 'CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw' weather_format = 'epw' construction_format = 'nrcan' usage_format = 'nrcan' attic_heated_case = 0 basement_heated_case = 1 out_path = (Path(__file__).parent / 'output_files') print('[simulation start]') city = GeometryFactory('geojson', path=file_path, height_field='citygml_me', year_of_construction_field='ANNEE_CONS', function_field='CODE_UTILI', function_to_hub=Dictionaries().montreal_function_to_hub_function).city city.climate_reference_city = climate_reference_city city.climate_file = (Path(__file__).parent / 'tmp' / f'{climate_reference_city}.cli').resolve() print(f'city created from {file_path}') WeatherFactory(weather_format, city, file_name=weather_file).enrich() print('enrich weather... done') ConstructionFactory(construction_format, city).enrich() print('enrich constructions... done') UsageFactory(usage_format, city).enrich() print('enrich usage... done') print('exporting:') sra = SimplifiedRadiosityAlgorithm(city, Path(__file__).parent, weather_file) print(' sra exported...') sra.call_sra(weather_format, keep_files=True) sra.set_irradiance_surfaces(city) sra.set_irradiance_surfaces(city, mode=1) print(' sra processed...') MonthlyEnergyBalance(city, out_path, attic_heated_case, basement_heated_case, weather_format) print(' insel processed...') print('[simulation end]') except Exception as ex: print(ex) print('error: ', ex) print('[simulation abort]')