Add idf base class corrections and test files

This commit is contained in:
Guille 2020-10-21 15:23:06 -04:00
parent fc43166171
commit ab42ea4ac4
4 changed files with 64 additions and 18 deletions

View File

@ -20,6 +20,7 @@ from city_model_structure.city_object import CityObject
from city_model_structure.building_unit import BuildingUnit
from city_model_structure.schedule_value import ScheduleValue
class Building(CityObject):
"""
Building(CityObject) class

View File

@ -1,37 +1,42 @@
"""
TestOccupancyFactory test and validate the city model structure occupancy parameters
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Sourush ....
"""
from geomeppy import IDF
import matplotlib.pyplot as plt
import esoreader
from pathlib import Path
class IDF:
class Idf:
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)
self._idf=IDF(idf_file_path)
self._IDF.setiddname(idd_file_path)
self._idf.epw=epw_file_path
IDF.setiddname(idd_file_path)
self._idf = IDF(idf_file_path)
self._idf.epw = epw_file_path
self._eso_file_path = str((Path.cwd() / 'eplusout.eso').resolve())
def add_zone(self, building_name):
self._idf.newidfobject('ZONE', Name=building_name, Ceiling_Height='autocalculate', Volume='autocalculate',Floor_Area='autocalculate',Part_of_Total_Floor_Area='yes',)
IDF.newidfobject('ZONE', Name=building_name, Ceiling_Height='autocalculate', Volume='autocalculate',
Floor_Area='autocalculate', Part_of_Total_Floor_Area='yes',)
def add_surface(self, surface, building_name):
self._idf.newidfobject('BUILDINGSURFACE:DETAILED', Name=surface.name, Surface_Type = surface.type, Zone_Name=building_name,)
self._idf.newidfobject('BUILDINGSURFACE:DETAILED', Name=surface.name, Surface_Type = surface.type,
Zone_Name=building_name,)
self.wall.setcoords(surface.points_list.toList())
def run(self,window_ratio=0.35):
def run(self, window_ratio=0.35):
self._idf.set_default_constructions()
self._idf.intersect_match()
self._idf.set_wwr(window_ratio)
self._idf.translate_to_origin()
self._idf.view_model()
self._idf.newidfobject("HVACTEMPLATE:THERMOSTAT", Name="Zone Stat", Constant_Heating_Setpoint=20, Constant_Cooling_Setpoint=24,)
for zone in idf.idfobjects["ZONE"]:
for zone in self._idf.idfobjects["ZONE"]:
self._idf.newidfobject("HVACTEMPLATE:ZONE:IDEALLOADSAIRSYSTEM", Zone_Name=zone.Name, Template_Thermostat_Name=stat.Name, Outdoor_Air_Method="DetailedSpecification",)
# Run
self._idf.run()

46
tests/test_idf.py Normal file
View File

@ -0,0 +1,46 @@
"""
TestOccupancyFactory test and validate the city model structure occupancy parameters
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
"""
import os
from pathlib import Path
from unittest import TestCase
from geometry.geometry_factory import GeometryFactory
from helpers.idf import Idf
class TestIdf(TestCase):
"""
Test IDF Class
"""
def setUp(self) -> None:
"""
Test setup
:return: None
"""
self._city_gml = None
self._example_path = (Path(__file__).parent.parent / 'tests_data').resolve()
def _get_citygml(self):
if self._city_gml is None:
file_path = (self._example_path / 'buildings.gml').resolve()
self._city_gml = GeometryFactory('citygml', file_path).city
self.assertIsNotNone(self._city_gml, 'city is none')
return self._city_gml
def test_idf_run(self):
idd_file_path = (self._example_path / 'energy+.idd').resolve()
idf_file_path = (self._example_path / 'minimal.idf').resolve()
epw_file_path = (self._example_path / 'montreal.epw').resolve()
_idf = Idf(idf_file_path, idd_file_path, epw_file_path, self._example_path)
city = self._get_citygml()
for building in city.buildings:
_idf.add_zone(building.name)
for surface in building.surfaces:
_idf.add_surface(surface, building.name)
_idf.run()

View File

@ -425,12 +425,6 @@
</cityObjectMember>
<cityObjectMember>
<Building id="GBP__15">
<stringAttribute name="PLUTO_year_built">
<value>2045</value>
</stringAttribute>
<stringAttribute name="PLUTO_building_class">
<value>C1</value>
</stringAttribute>
<lod1Solid>
<Solid srsName="EPSG:32118" srsDimension="3">
<exterior>
@ -620,7 +614,7 @@
</Solid>
</lod1Solid>
<yearOfConstruction>2045</yearOfConstruction>
<function>I1</function>
<function>C1</function>
</Building>
</cityObjectMember>
</CityModel>