2023-03-20 14:28:17 -04:00
|
|
|
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
|
2023-05-18 11:33:14 -04:00
|
|
|
from hub.imports.energy_systems_factory import EnergySystemsFactory
|
2023-03-23 13:31:36 -04:00
|
|
|
from results import Results
|
|
|
|
from monthly_energy_balance_engine import MonthlyEnergyBalanceEngine
|
|
|
|
from sra_engine import SraEngine
|
2023-05-19 15:49:57 -04:00
|
|
|
from energy_systems_sizing import EnergySystemsSizing
|
2023-03-20 14:28:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
try:
|
2023-05-19 11:20:42 -04:00
|
|
|
file_path = (Path(__file__).parent / 'input_files' / 'selected_building_1517.geojson')
|
2023-03-20 14:28:17 -04:00
|
|
|
climate_reference_city = 'Montreal'
|
|
|
|
weather_file = 'CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw'
|
|
|
|
weather_format = 'epw'
|
|
|
|
construction_format = 'nrcan'
|
|
|
|
usage_format = 'nrcan'
|
2023-05-18 11:33:14 -04:00
|
|
|
energy_systems_format = 'montreal_custom'
|
2023-03-20 14:28:17 -04:00
|
|
|
attic_heated_case = 0
|
|
|
|
basement_heated_case = 1
|
|
|
|
|
|
|
|
out_path = (Path(__file__).parent / 'output_files')
|
2023-03-23 13:31:36 -04:00
|
|
|
tmp_folder = (Path(__file__).parent / 'tmp')
|
2023-03-20 14:28:17 -04:00
|
|
|
|
|
|
|
print('[simulation start]')
|
|
|
|
city = GeometryFactory('geojson',
|
|
|
|
path=file_path,
|
2023-05-01 16:38:44 -04:00
|
|
|
height_field='heightmax',
|
2023-03-20 14:28:17 -04:00
|
|
|
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
|
2023-03-23 13:31:36 -04:00
|
|
|
city.climate_file = (tmp_folder / f'{climate_reference_city}.cli').resolve()
|
2023-03-20 14:28:17 -04:00
|
|
|
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')
|
2023-05-19 15:49:57 -04:00
|
|
|
for building in city.buildings:
|
2023-05-29 14:58:51 -04:00
|
|
|
building.energy_systems_archetype_name = 'system 1 gas pv'
|
2023-05-19 15:49:57 -04:00
|
|
|
EnergySystemsFactory(energy_systems_format, city).enrich()
|
|
|
|
print('enrich systems... done')
|
2023-03-20 14:28:17 -04:00
|
|
|
|
|
|
|
print('exporting:')
|
2023-03-23 13:31:36 -04:00
|
|
|
sra_file = (tmp_folder / f'{city.name}_sra.xml').resolve()
|
|
|
|
SraEngine(city, sra_file, tmp_folder, weather_file)
|
2023-03-20 14:28:17 -04:00
|
|
|
print(' sra processed...')
|
|
|
|
|
2023-03-23 13:31:36 -04:00
|
|
|
MonthlyEnergyBalanceEngine(city, tmp_folder)
|
2023-03-20 14:28:17 -04:00
|
|
|
print(' insel processed...')
|
|
|
|
|
2023-05-19 15:49:57 -04:00
|
|
|
EnergySystemsSizing(city).enrich()
|
2023-05-18 11:33:14 -04:00
|
|
|
print(' energy systems dimensioning processed...')
|
|
|
|
|
2023-03-23 13:31:36 -04:00
|
|
|
results = Results(city, out_path)
|
|
|
|
results.print()
|
2023-05-18 11:33:14 -04:00
|
|
|
print('results printed...')
|
2023-03-23 13:31:36 -04:00
|
|
|
|
2023-03-20 14:28:17 -04:00
|
|
|
print('[simulation end]')
|
|
|
|
|
|
|
|
except Exception as ex:
|
|
|
|
print(ex)
|
|
|
|
print('error: ', ex)
|
|
|
|
print('[simulation abort]')
|