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 hub.helpers.dictionaries import Dictionaries from hub.imports.energy_systems_factory import EnergySystemsFactory from results import Results from monthly_energy_balance_engine import MonthlyEnergyBalanceEngine from sra_engine import SraEngine from energy_systems_sizing import EnergySystemsSizing try: file_path = (Path(__file__).parent / 'input_files' / 'selected_building_1517.geojson') climate_reference_city = 'Montreal' weather_file = 'CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw' weather_format = 'epw' construction_format = 'nrcan' usage_format = 'nrcan' energy_systems_format = 'montreal_custom' attic_heated_case = 0 basement_heated_case = 1 out_path = (Path(__file__).parent / 'output_files') tmp_folder = (Path(__file__).parent / 'tmp') print('[simulation start]') city = GeometryFactory('geojson', path=file_path, height_field='heightmax', 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 = (tmp_folder / 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') for building in city.buildings: building.energy_systems_archetype_name = 'system 1 gas pv' EnergySystemsFactory(energy_systems_format, city).enrich() print('enrich systems... done') print('exporting:') sra_file = (tmp_folder / f'{city.name}_sra.xml').resolve() SraEngine(city, sra_file, tmp_folder, weather_file) print(' sra processed...') MonthlyEnergyBalanceEngine(city, tmp_folder) print(' insel processed...') EnergySystemsSizing(city).enrich() print(' energy systems dimensioning processed...') results = Results(city, out_path) results.print() print('results printed...') print('[simulation end]') except Exception as ex: print(ex) print('error: ', ex) print('[simulation abort]')