2022-06-09 15:40:43 -04:00
|
|
|
import glob
|
|
|
|
import os
|
2022-03-24 09:22:39 -04:00
|
|
|
import sys
|
|
|
|
from pathlib import Path
|
|
|
|
import csv
|
2023-03-21 14:27:37 -04:00
|
|
|
from hub.exports.energy_building_exports_factory import EnergyBuildingsExportsFactory
|
2023-12-05 10:43:45 -05:00
|
|
|
from hub.imports.results_factory import ResultFactory
|
2022-12-16 09:39:09 -05:00
|
|
|
|
2023-03-21 14:27:37 -04:00
|
|
|
sys.path.append('./')
|
2022-03-24 09:22:39 -04:00
|
|
|
|
2023-12-20 15:33:50 -05:00
|
|
|
|
|
|
|
def energy_plus_workflow(city):
|
|
|
|
try:
|
|
|
|
# city = city
|
|
|
|
out_path = (Path(__file__).parent.parent / 'out_files')
|
|
|
|
files = glob.glob(f'{out_path}/*')
|
|
|
|
|
|
|
|
for file in files:
|
|
|
|
if file != '.gitignore':
|
|
|
|
os.remove(file)
|
|
|
|
area = 0
|
|
|
|
volume = 0
|
|
|
|
for building in city.buildings:
|
|
|
|
volume = building.volume
|
|
|
|
for ground in building.grounds:
|
|
|
|
area += ground.perimeter_polygon.area
|
|
|
|
|
|
|
|
print('exporting:')
|
|
|
|
_idf = EnergyBuildingsExportsFactory('idf', city, out_path).export()
|
|
|
|
print(' idf exported...')
|
|
|
|
_idf.run()
|
|
|
|
|
|
|
|
csv_file = str((out_path / f'{city.name}_out.csv').resolve())
|
|
|
|
eso_file = str((out_path / f'{city.name}_out.eso').resolve())
|
|
|
|
idf_file = str((out_path / f'{city.name}.idf').resolve())
|
|
|
|
obj_file = str((out_path / f'{city.name}.obj').resolve())
|
|
|
|
ResultFactory('energy_plus_multiple_buildings', city, out_path).enrich()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
except Exception as ex:
|
|
|
|
print(ex)
|
|
|
|
print('error: ', ex)
|
|
|
|
print('[simulation abort]')
|
|
|
|
sys.stdout.flush()
|