summer_course_2024/scripts/ep_workflow.py

46 lines
1.2 KiB
Python
Raw Normal View History

2024-07-15 19:17:59 -04:00
import glob
2024-08-01 11:59:21 -04:00
import os
2024-07-15 19:17:59 -04:00
import sys
from pathlib import Path
2024-08-01 11:59:21 -04:00
import csv
2024-07-15 19:17:59 -04:00
from hub.exports.energy_building_exports_factory import EnergyBuildingsExportsFactory
from hub.imports.results_factory import ResultFactory
sys.path.append('./')
2024-08-01 11:59:21 -04:00
def energy_plus_workflow(city, output_path):
2024-07-15 19:17:59 -04:00
try:
2024-08-01 11:59:21 -04:00
# city = city
out_path = output_path
files = glob.glob(f'{out_path}/*')
# for file in files:
# if file != '.gitignore':
# os.remove(file)
2024-07-15 19:17:59 -04:00
area = 0
2024-08-01 11:59:21 -04:00
volume = 0
2024-07-15 19:17:59 -04:00
for building in city.buildings:
2024-08-01 11:59:21 -04:00
volume = building.volume
2024-07-15 19:17:59 -04:00
for ground in building.grounds:
area += ground.perimeter_polygon.area
print('exporting:')
_idf = EnergyBuildingsExportsFactory('idf', city, out_path).export()
print(' idf exported...')
_idf.run()
2024-08-01 11:59:21 -04:00
2024-07-15 19:17:59 -04:00
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()
2024-08-01 11:59:21 -04:00
2024-07-15 19:17:59 -04:00
except Exception as ex:
print(ex)
print('error: ', ex)
print('[simulation abort]')
sys.stdout.flush()