2020-10-21 15:23:06 -04:00
|
|
|
"""
|
|
|
|
TestOccupancyFactory test and validate the city model structure occupancy parameters
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
2020-10-22 07:30:34 -04:00
|
|
|
Copyright © 2020 Project Author Soroush Samareh Abolhassani - soroush.samarehabolhassani@mail.concordia.ca
|
2020-10-21 15:23:06 -04:00
|
|
|
"""
|
2020-10-21 14:38:19 -04:00
|
|
|
from geomeppy import IDF
|
|
|
|
import esoreader
|
2020-10-21 15:23:06 -04:00
|
|
|
from pathlib import Path
|
2020-10-21 14:38:19 -04:00
|
|
|
|
|
|
|
|
2020-10-22 07:30:34 -04:00
|
|
|
class IdfHelper:
|
2020-10-26 10:00:42 -04:00
|
|
|
idf_surfaces = {
|
|
|
|
'Wall': 'wall',
|
|
|
|
'Ground': 'floor',
|
|
|
|
'Roof': 'roof'
|
|
|
|
}
|
2020-10-21 14:38:19 -04:00
|
|
|
|
2020-10-22 07:55:40 -04:00
|
|
|
def __init__(self, idf_file_path, idd_file_path, epw_file_path, eso_file_path):
|
|
|
|
self._idd_file_path = str(idd_file_path)
|
|
|
|
self._idf_file_path = str(idf_file_path)
|
|
|
|
self._epw_file_path = str(epw_file_path)
|
|
|
|
self._eso_file_path = str(eso_file_path)
|
|
|
|
IDF.setiddname(self._idd_file_path)
|
|
|
|
self._idf = IDF(self._idf_file_path)
|
2020-10-26 10:00:42 -04:00
|
|
|
self._idf.epw = self._epw_file_path
|
2020-10-22 07:55:40 -04:00
|
|
|
self._eso_file_path = str((Path.cwd() / 'eplusout.eso').resolve())
|
|
|
|
|
|
|
|
def add_zone(self, building_name):
|
2020-10-26 10:00:42 -04:00
|
|
|
|
2020-10-22 07:55:40 -04:00
|
|
|
self._idf.newidfobject(key='ZONE', Name=building_name, Ceiling_Height='autocalculate', Volume='autocalculate',
|
2020-10-26 10:00:42 -04:00
|
|
|
Floor_Area='autocalculate', Part_of_Total_Floor_Area='yes', )
|
|
|
|
self._idf.newidfobject("HVACTEMPLATE:ZONE:IDEALLOADSAIRSYSTEM", Zone_Name=building_name,
|
|
|
|
Template_Thermostat_Name='', Outdoor_Air_Method="DetailedSpecification", )
|
|
|
|
|
|
|
|
def add_heating_system(self):
|
|
|
|
self._idf.intersect_match()
|
|
|
|
self._idf.set_default_constructions()
|
|
|
|
stat = self._idf.newidfobject(
|
|
|
|
"HVACTEMPLATE:THERMOSTAT",
|
|
|
|
Name="Zone Stat",
|
|
|
|
Constant_Heating_Setpoint=20,
|
|
|
|
Constant_Cooling_Setpoint=25,
|
|
|
|
)
|
|
|
|
for zone in self._idf.idfobjects["ZONE"]:
|
|
|
|
self._idf.newidfobject("HVACTEMPLATE:ZONE:IDEALLOADSAIRSYSTEM",
|
|
|
|
Zone_Name=zone.Name,
|
|
|
|
Template_Thermostat_Name=stat.Name
|
|
|
|
)
|
2020-10-22 07:55:40 -04:00
|
|
|
|
2020-10-23 15:49:04 -04:00
|
|
|
@staticmethod
|
|
|
|
def _matrix_to_list(points):
|
|
|
|
points_list = []
|
|
|
|
for point in points:
|
|
|
|
point_tuple = (point[0], point[1], point[2])
|
|
|
|
points_list.append(point_tuple)
|
2020-10-26 10:00:42 -04:00
|
|
|
print(points_list)
|
2020-10-23 15:49:04 -04:00
|
|
|
return points_list
|
|
|
|
|
2020-10-26 10:00:42 -04:00
|
|
|
@staticmethod
|
|
|
|
def _matrix_to_2d_list(points):
|
|
|
|
points_list = []
|
|
|
|
for point in points:
|
|
|
|
point_tuple = (point[0], point[1])
|
|
|
|
points_list.append(point_tuple)
|
|
|
|
points_list.reverse()
|
|
|
|
return points_list
|
|
|
|
|
|
|
|
def add_block(self, building):
|
|
|
|
_points = IdfHelper._matrix_to_2d_list(building.foot_print.points)
|
|
|
|
self._idf.add_block(name=building.name, coordinates=_points,
|
|
|
|
height=building.max_height, num_stories=building.storeys_above_ground)
|
|
|
|
|
|
|
|
def add_surfaces(self, building):
|
|
|
|
for surface in building.surfaces:
|
|
|
|
wall = self._idf.newidfobject('BUILDINGSURFACE:DETAILED', Name=surface.name,
|
|
|
|
Surface_Type=self.idf_surfaces[surface.type], Zone_Name=building.name)
|
|
|
|
wall.setcoords(IdfHelper._matrix_to_list(surface.ground_points))
|
2020-10-22 07:55:40 -04:00
|
|
|
|
2020-10-23 15:49:04 -04:00
|
|
|
def run(self, window_ratio=0.35, display_render=False):
|
2020-10-26 10:00:42 -04:00
|
|
|
|
2020-10-22 07:55:40 -04:00
|
|
|
self._idf.set_wwr(window_ratio)
|
2020-10-26 10:00:42 -04:00
|
|
|
# self._idf.translate_to_origin()
|
|
|
|
|
2020-10-23 15:49:04 -04:00
|
|
|
if display_render:
|
|
|
|
self._idf.view_model()
|
2020-10-26 10:00:42 -04:00
|
|
|
else:
|
|
|
|
self._idf.to_obj('city.obj')
|
2020-10-22 07:55:40 -04:00
|
|
|
# Run
|
2020-10-26 10:00:42 -04:00
|
|
|
self._idf.newidfobject("OUTPUT:METER", Key_Name="Heating:DistrictHeating", Reporting_Frequency="hourly", )
|
|
|
|
self._idf.newidfobject("OUTPUT:METER", Key_Name="Cooling:DistrictCooling", Reporting_Frequency="hourly", )
|
2020-10-22 07:55:40 -04:00
|
|
|
self._idf.run()
|
2020-10-26 10:00:42 -04:00
|
|
|
"""
|
2020-10-22 07:55:40 -04:00
|
|
|
dd, data = esoreader.read(self._eso_file_path)
|
|
|
|
list_values = [v for v in data.values()]
|
|
|
|
heating = [(float(x)) / 3600000.0 for x in list_values[0]]
|
|
|
|
cooling = [(float(x)) / 3600000.0 for x in list_values[1]]
|
2020-10-23 15:49:04 -04:00
|
|
|
print("text")
|
2020-10-22 07:55:40 -04:00
|
|
|
return heating, cooling
|
2020-10-26 10:00:42 -04:00
|
|
|
"""
|