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.helpers.dictionaries import Dictionaries
|
2023-05-18 11:33:14 -04:00
|
|
|
from hub.imports.energy_systems_factory import EnergySystemsFactory
|
2023-06-01 14:12:15 -04:00
|
|
|
import hub.helpers.constants as cte
|
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-03-20 14:28:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
try:
|
2024-01-29 11:46:06 -05:00
|
|
|
file_path = (Path(__file__).parent / 'input_files' / 'output_buildings.geojson')
|
2023-03-20 14:28:17 -04:00
|
|
|
construction_format = 'nrcan'
|
2023-08-11 15:44:25 -04:00
|
|
|
usage_format = 'nrcan'
|
2023-05-18 11:33:14 -04:00
|
|
|
energy_systems_format = 'montreal_custom'
|
2023-03-20 14:28:17 -04:00
|
|
|
|
2023-06-07 14:48:21 -04:00
|
|
|
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,
|
2024-01-29 11:46:06 -05:00
|
|
|
height_field='height',
|
|
|
|
year_of_construction_field='year_of_construction',
|
|
|
|
function_field='function',
|
2023-08-11 15:44:25 -04:00
|
|
|
function_to_hub=Dictionaries().montreal_function_to_hub_function).city
|
2023-07-11 16:35:13 -04:00
|
|
|
|
2023-03-20 14:28:17 -04:00
|
|
|
print(f'city created from {file_path}')
|
|
|
|
ConstructionFactory(construction_format, city).enrich()
|
|
|
|
print('enrich constructions... done')
|
|
|
|
UsageFactory(usage_format, city).enrich()
|
|
|
|
print('enrich usage... done')
|
2023-11-16 15:51:58 -05:00
|
|
|
i = 1
|
|
|
|
x = len(city.buildings)
|
2023-05-19 15:49:57 -04:00
|
|
|
for building in city.buildings:
|
2023-11-16 15:51:58 -05:00
|
|
|
if i < x:
|
|
|
|
building.energy_systems_archetype_name = 'system 1 gas'
|
|
|
|
else:
|
|
|
|
building.energy_systems_archetype_name = 'system 6 gas'
|
|
|
|
i = i + 1
|
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-08-11 15:44:25 -04:00
|
|
|
SraEngine(city, tmp_folder)
|
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-06-01 14:12:15 -04:00
|
|
|
for building in city.buildings:
|
|
|
|
for energy_system in building.energy_systems:
|
|
|
|
if cte.HEATING in energy_system.demand_types:
|
2023-06-07 14:48:21 -04:00
|
|
|
energy_system.generation_system.heat_power = building.heating_peak_load[cte.YEAR][0]
|
2023-06-01 14:12:15 -04:00
|
|
|
if cte.COOLING in energy_system.demand_types:
|
2023-06-07 14:48:21 -04:00
|
|
|
energy_system.generation_system.cooling_power = building.cooling_peak_load[cte.YEAR][0]
|
2023-05-18 11:33:14 -04:00
|
|
|
|
2023-06-01 14:12:15 -04:00
|
|
|
print('importing results:')
|
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]')
|