Idf surfaces connection

This commit is contained in:
Guille 2020-10-28 12:20:13 -04:00
parent e8758eb76d
commit c1b7d346bd
5 changed files with 53 additions and 60 deletions

View File

@ -35,7 +35,7 @@ class Building(CityObject):
self._function = function
self._lower_corner = lower_corner
self._average_storey_height = None
self._storeys_above_ground = 1
self._storeys_above_ground = None
self._foot_print = None
self._usage_zones = []
self._building_units = []

View File

@ -5,25 +5,19 @@ Copyright © 2020 Project Author Sanam Dabirian sanam.dabirian@mail.concordia.ca
"""
class facilities:
class Facility:
"""
facilities class
"""
def __init__(self, operation_schedules, convective_fraction, latent_fraction,
radiant_fraction, total_value_of_heat_dissipation):
"""
Constructor
"""
self._operation_schedules = operation_schedules
self._convective_fraction = convective_fraction
self._latent_fraction = latent_fraction
self._radiant_fraction = radiant_fraction
self._total_value_of_heat_dissipation = total_value_of_heat_dissipation
@property
def operation_schedules(self):
"""
@ -32,7 +26,7 @@ class facilities:
"""
return self._operation_schedules
@property
@property
def convective_fraction(self):
"""
Get convective fraction value
@ -62,4 +56,4 @@ class facilities:
Get heat dissipation value
:return: heat dissipation
"""
return self._total_value_of_heat_dissipation
return self._total_value_of_heat_dissipation

View File

@ -5,7 +5,7 @@ Copyright © 2020 Project Author Sanam Dabirian sanam.dabirian@mail.concordia.ca
"""
class hvac_facilities:
class HvacFacility:
"""
HVAC facilities class
"""

View File

@ -27,7 +27,7 @@ class IdfHelper:
self._idf = IDF(self._idf_file_path, self._epw_file_path)
self._idf.epw = self._epw_file_path
def add_heating_system(self, building):
def add_heating_system(self, building, zone = None):
for usage_zone in building.usage_zones:
thermostat_name = f'Thermostat {building.name}'
# todo: this will fail for more than one usage zone
@ -36,26 +36,14 @@ class IdfHelper:
Constant_Heating_Setpoint=usage_zone.heating_setpoint,
Constant_Cooling_Setpoint=usage_zone.cooling_setpoint
)
for zone in self._idf.idfobjects['ZONE']:
if zone.Name.find(building.name) != -1:
self._idf.newidfobject(self._IDEAL_LOAD_AIR_SYSTEM,
Zone_Name=zone.Name,
Template_Thermostat_Name=static_thermostat.Name
)
def add_heating_system2(self):
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,
)
if zone is None:
for zone in self._idf.idfobjects['ZONE']:
if zone.Name.find(building.name) != -1:
break
self._idf.newidfobject(self._IDEAL_LOAD_AIR_SYSTEM,
Zone_Name=zone.Name,
Template_Thermostat_Name=static_thermostat.Name
)
@staticmethod
def _matrix_to_list(points):
@ -79,12 +67,16 @@ class IdfHelper:
# self.add_heating_system(building)
def add_surfaces(self, building):
zone = self._idf.newidfobject('ZONE', Name=building.name)
# self.add_heating_system(building)
for surface in building.surfaces:
idf_surface = self.idf_surfaces[surface.type]
wall = self._idf.newidfobject(self._SURFACE, Name=surface.name, Surface_Type=idf_surface, Zone_Name=building.name)
wall.setcoords(IdfHelper._matrix_to_list(surface.points))
self.add_block(building)
for zone in self._idf.idfobjects['ZONE']:
if zone.Name.find(building.name) != -1:
for surface in building.surfaces:
idf_surface = self.idf_surfaces[surface.type]
wall = self._idf.newidfobject(self._SURFACE, Name=surface.name, Surface_Type=idf_surface, Zone_Name=zone.Name)
coordinates = IdfHelper._matrix_to_list(surface.points)
if len(coordinates) > 2:
wall.setcoords(coordinates)
# self.add_heating_system(building, zone)
def run(self, window_ratio=0.35, display_render=False, output_prefix=None, output_directory='tests'):
self._idf.intersect_match()
@ -94,11 +86,17 @@ class IdfHelper:
if display_render:
self._idf.view_model()
else:
self._idf.to_obj('ep_outputs/city.obj')
# Run
# self._idf.newidfobject("OUTPUT:METER", Key_Name="Heating:DistrictHeating", Reporting_Frequency="hourly")
# self._idf.newidfobject("OUTPUT:METER", Key_Name="Cooling:DistrictCooling", Reporting_Frequency="hourly")
self._idf.run(output_prefix=output_prefix, output_directory=output_directory)
# self._idf.to_obj('ep_outputs/city.obj')
print("match")
# Run
self._idf.newidfobject("OUTPUT:METER", Key_Name="Heating:DistrictHeating", Reporting_Frequency="hourly")
self._idf.newidfobject("OUTPUT:METER", Key_Name="Cooling:DistrictCooling", Reporting_Frequency="hourly")
try:
self._idf.run(output_prefix=output_prefix, output_directory=output_directory)
except:
print("exception launched")
print("completed!")
return
@staticmethod
def read_eso(eso_path):

View File

@ -10,7 +10,6 @@ from physics.physics_factory import PhysicsFactory
from usage.usage_factory import UsageFactory
from helpers.idf_helper import IdfHelper
from geomeppy import IDF
from esoreader import EsoFile
class TestIdf(TestCase):
@ -43,28 +42,32 @@ class TestIdf(TestCase):
for building in city.buildings:
_idf.add_block(building)
_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)
_idf.read_eso(str(self._example_path))
self.assertEqual(1, 2, "arent equal")
# todo: clean up the files
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")
print("prepare to run")
_idf.run(output_prefix='test_idf_surfaces', output_directory="ep_outputs")
print("done...")
self.assertEqual(1, 2, "arent equal")
# todo: clean up the files
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.setiddname(idd_file_path, testing=True)
idf = IDF(idf_file_path)
idf.epw = epw_file_path
idf.add_block(
name="Two storey",
coordinates=[(10, 0), (10, 5), (0, 5), (0, 0)],
@ -100,13 +103,11 @@ class TestIdf(TestCase):
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]
idf.set_wwr(0.4, construction="Project External Window")
idf.run(
output_directory="ep_outputs",
expandobjects=True,
verbose="v",
)
results = []
output_prefix=f"tutorial_2",
output_directory="ep_outputs",
expandobjects=True,
verbose="q",
)