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
|
|
|
|
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
|
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
from unittest import TestCase
|
|
|
|
from geometry.geometry_factory import GeometryFactory
|
2020-10-27 13:19:50 -04:00
|
|
|
from physics.physics_factory import PhysicsFactory
|
|
|
|
from usage.usage_factory import UsageFactory
|
2020-10-22 07:30:34 -04:00
|
|
|
from helpers.idf_helper import IdfHelper
|
2020-10-27 13:19:50 -04:00
|
|
|
from geomeppy import IDF
|
|
|
|
from esoreader import EsoFile
|
2020-10-21 15:23:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
2020-10-27 13:19:50 -04:00
|
|
|
def _get_city(self):
|
2020-10-21 15:23:06 -04:00
|
|
|
if self._city_gml is None:
|
|
|
|
file_path = (self._example_path / 'buildings.gml').resolve()
|
|
|
|
self._city_gml = GeometryFactory('citygml', file_path).city
|
2020-10-27 13:19:50 -04:00
|
|
|
PhysicsFactory('us_new_york', self._city_gml, base_path=self._example_path)
|
|
|
|
UsageFactory('us_new_york', self._city_gml)
|
2020-10-21 15:23:06 -04:00
|
|
|
return self._city_gml
|
|
|
|
|
2020-10-27 13:19:50 -04:00
|
|
|
def test_idf_blocks(self):
|
2020-10-21 15:23:06 -04:00
|
|
|
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()
|
2020-10-26 13:47:10 -04:00
|
|
|
_idf = IdfHelper(idf_file_path, idd_file_path, epw_file_path)
|
2020-10-27 13:19:50 -04:00
|
|
|
city = self._get_city()
|
2020-10-21 15:23:06 -04:00
|
|
|
for building in city.buildings:
|
2020-10-26 10:00:42 -04:00
|
|
|
_idf.add_block(building)
|
2020-10-27 13:19:50 -04:00
|
|
|
_idf.run(output_prefix='test_idf_blocks', output_directory="ep_outputs")
|
|
|
|
heating, cooling = IdfHelper.read_eso((Path(__file__).parent / 'ep_outputs/eplusout.eso'))
|
|
|
|
self.assertEqual(len(heating), 0)
|
2020-10-26 13:33:03 -04:00
|
|
|
|
2020-10-27 13:19:50 -04:00
|
|
|
def test_idf_surfaces(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 = IdfHelper(idf_file_path, idd_file_path, epw_file_path)
|
|
|
|
city = self._get_city()
|
|
|
|
for building in city.buildings:
|
|
|
|
_idf.add_surfaces(building)
|
|
|
|
_idf.run(output_prefix='test_idf_surfaces', output_directory="ep_outputs")
|
|
|
|
heating, cooling = IdfHelper.read_eso((Path(__file__).parent / 'ep_outputs/eplusout.eso'))
|
|
|
|
self.assertEqual(1, 1, "arent equal")
|
2020-10-26 13:33:03 -04:00
|
|
|
|
2020-10-27 13:19:50 -04:00
|
|
|
def test_tutorial_2(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.setiddname(str(idd_file_path), testing=True)
|
|
|
|
idf = IDF(str(idf_file_path))
|
|
|
|
idf.epw = str(epw_file_path)
|
|
|
|
idf.add_block(
|
|
|
|
name="Two storey",
|
|
|
|
coordinates=[(10, 0), (10, 5), (0, 5), (0, 0)],
|
|
|
|
height=6,
|
|
|
|
num_stories=2,
|
|
|
|
)
|
|
|
|
idf.add_block(
|
|
|
|
name="One storey", coordinates=[(10, 5), (10, 10), (0, 10), (0, 5)], height=3
|
|
|
|
)
|
|
|
|
idf.intersect_match()
|
|
|
|
idf.set_default_constructions()
|
|
|
|
# add a heating system
|
|
|
|
stat = idf.newidfobject(
|
|
|
|
"HVACTEMPLATE:THERMOSTAT",
|
|
|
|
Name="Zone Stat",
|
|
|
|
Constant_Heating_Setpoint=20,
|
|
|
|
Constant_Cooling_Setpoint=25,
|
|
|
|
)
|
|
|
|
for zone in idf.idfobjects["ZONE"]:
|
|
|
|
idf.newidfobject(
|
|
|
|
"HVACTEMPLATE:ZONE:IDEALLOADSAIRSYSTEM",
|
|
|
|
Zone_Name=zone.Name,
|
|
|
|
Template_Thermostat_Name=stat.Name,
|
|
|
|
)
|
|
|
|
# add some output variables
|
|
|
|
idf.newidfobject(
|
|
|
|
"OUTPUT:VARIABLE",
|
|
|
|
Variable_Name="Zone Ideal Loads Supply Air Total Heating Energy",
|
|
|
|
Reporting_Frequency="Hourly",
|
|
|
|
)
|
|
|
|
idf.newidfobject(
|
|
|
|
"OUTPUT:VARIABLE",
|
|
|
|
Variable_Name="Zone Ideal Loads Supply Air Total Cooling Energy",
|
|
|
|
Reporting_Frequency="Hourly",
|
|
|
|
)
|
|
|
|
# run a set of simulations, moving glazing from mostly on the South facade, to mostly on the North facade
|
|
|
|
north_wwr = [i / 10 for i in range(1, 10)]
|
|
|
|
south_wwr = [1 - wwr for wwr in north_wwr]
|
2020-10-26 10:00:42 -04:00
|
|
|
|
2020-10-27 13:19:50 -04:00
|
|
|
idf.run(
|
|
|
|
output_directory="ep_outputs",
|
|
|
|
expandobjects=True,
|
|
|
|
verbose="v",
|
|
|
|
)
|
|
|
|
results = []
|