Setup for energyplus calculations

This commit is contained in:
Koa Wells 2023-04-12 19:11:04 -04:00
parent 5deeb9c355
commit 4519d012a2
3 changed files with 33 additions and 5 deletions

View File

@ -47,7 +47,7 @@ class EnergyValidation:
while not min_m2_satisfied:
building_to_simulate.append(sorted_buildings[code_utili][random.randrange(
len(sorted_buildings[code_utili]))])
if building_to_simulate[0]['bldgarea'] < 500:
if building_to_simulate[0]['properties']['bldgarea'] < 500:
building_to_simulate.clear()
else:
min_m2_satisfied = True
@ -99,12 +99,13 @@ class EnergyValidation:
meb_time = datetime.datetime.now() - start
print(f"{building_id} meb time: {meb_time}\n")
#print('starting energy plus')
print(f'{building_id} starting energy plus')
EnergyBuildingsExportsFactory('idf', city, self.ep_folder).export()
idf_file = (self.tmp_folder / f'{city.name}.idf').resolve
#EP(self.ep_folder).run()
building_to_simulate.clear()
data_file = open('data/VMTrial_cleaned.geojson', 'r')
city = json.load(data_file)
buildings = city['features']

27
ep.py Normal file
View File

@ -0,0 +1,27 @@
import subprocess
from subprocess import SubprocessError, TimeoutExpired, CalledProcessError
import platform
class EP:
def __init__(self, file_path, output_file_path):
"""
SRA class
:param file_path: .idf file path
:param output_file_path: path to output the energyplus calculation
"""
self._file_path = file_path
self._output_file_path = output_file_path
if platform.system() == 'Linux':
self._executable = 'energyplus'
elif platform.system() == 'Windows':
self._executable = 'energyplus'
def run(self):
"""
Calls the software
"""
try:
subprocess.run([self._executable, str(self._file_path)], stdout=subprocess.DEVNULL)
except (SubprocessError, TimeoutExpired, CalledProcessError) as error:
raise Exception(error)

Binary file not shown.