Corrected IDF helper, there are a bug related to the ep+ can not be executed directly from python in linux (more test are needed) a possible work around it's to call the console directly instead using "run function"
This commit is contained in:
parent
ec5b5f626c
commit
75ff0bd800
|
@ -114,3 +114,6 @@ class Polyhedron:
|
|||
:return: None
|
||||
"""
|
||||
self._polyhedron_mesh.export(full_path)
|
||||
|
||||
def show(self):
|
||||
self._polyhedron_mesh.show()
|
|
@ -80,6 +80,11 @@ class CityObject:
|
|||
full_path = (Path(path) / (self._name + '.stl')).resolve()
|
||||
self._polyhedron.export(full_path)
|
||||
|
||||
def show(self):
|
||||
if self._polyhedron is None:
|
||||
self._polyhedron = Polyhedron(self.surfaces)
|
||||
self._polyhedron.show()
|
||||
|
||||
@property
|
||||
def max_height(self):
|
||||
"""
|
||||
|
|
|
@ -27,23 +27,20 @@ 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, zone = None):
|
||||
def add_heating_system(self, building):
|
||||
for usage_zone in building.usage_zones:
|
||||
thermostat_name = f'Thermostat {building.name}'
|
||||
# todo: this will fail for more than one usage zone
|
||||
static_thermostat = self._idf.newidfobject(self._THERMOSTAT,
|
||||
Name=thermostat_name,
|
||||
Constant_Heating_Setpoint=usage_zone.heating_setpoint,
|
||||
Constant_Cooling_Setpoint=usage_zone.cooling_setpoint
|
||||
Constant_Cooling_Setpoint=usage_zone.cooling_setpoint,
|
||||
)
|
||||
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
|
||||
)
|
||||
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,)
|
||||
|
||||
@staticmethod
|
||||
def _matrix_to_list(points):
|
||||
|
@ -63,8 +60,11 @@ class IdfHelper:
|
|||
|
||||
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)
|
||||
# self.add_heating_system(building)
|
||||
self._idf.add_block(name=building.name, coordinates=_points, height=building.max_height,
|
||||
num_stories=int(building.storeys_above_ground))
|
||||
# self._idf.intersect_match()
|
||||
# self._idf.set_default_constructions()
|
||||
self.add_heating_system(building)
|
||||
|
||||
def add_surfaces(self, building):
|
||||
self.add_block(building)
|
||||
|
@ -74,28 +74,28 @@ class IdfHelper:
|
|||
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)
|
||||
if surface.area <= 0:
|
||||
print(surface.area)
|
||||
wall.setcoords(coordinates)
|
||||
|
||||
def run(self, window_ratio=0.35, display_render=False, output_prefix=None, output_directory='tests'):
|
||||
def run(self, window_ratio=0.35, display_render=False, output_prefix=None, output_directory='tests', keep_file=None):
|
||||
self._idf.intersect_match()
|
||||
self._idf.set_default_constructions()
|
||||
self._idf.set_wwr(window_ratio, construction="Project External Window")
|
||||
self._idf.translate_to_origin()
|
||||
if display_render:
|
||||
self._idf.view_model()
|
||||
else:
|
||||
# self._idf.to_obj('ep_outputs/city.obj')
|
||||
print("match")
|
||||
|
||||
# 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")
|
||||
try:
|
||||
self._idf.run(output_prefix=output_prefix, output_directory=output_directory)
|
||||
except:
|
||||
print("exception launched")
|
||||
print("completed!")
|
||||
#self._idf.newidfobject("OUTPUT:METER", Key_Name="Heating:DistrictHeating", Reporting_Frequency="hourly")
|
||||
#self._idf.newidfobject("OUTPUT:METER", Key_Name="Cooling:DistrictCooling", Reporting_Frequency="hourly")
|
||||
if keep_file is not None:
|
||||
idf_path = (keep_file / 'in.idf').resolve()
|
||||
print(str(idf_path))
|
||||
self._idf.saveas(str(idf_path))
|
||||
self._idf.run(output_prefix=output_prefix, output_directory=output_directory, expandobjects=True)
|
||||
return
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -52,4 +52,6 @@ kiwisolver~=1.2.0
|
|||
zipp~=3.1.0
|
||||
requests~=2.24.0
|
||||
esoreader~=1.2.3
|
||||
geomeppy~=0.11.8
|
||||
geomeppy~=0.11.8
|
||||
pyglet~=1.5.8
|
||||
networkx~=2.5
|
|
@ -9,7 +9,6 @@ from factories.geometry_factory import GeometryFactory
|
|||
from factories.physics_factory import PhysicsFactory
|
||||
from factories.usage_factory import UsageFactory
|
||||
from helpers.idf_helper import IdfHelper
|
||||
from geomeppy import IDF
|
||||
|
||||
|
||||
class TestIdf(TestCase):
|
||||
|
@ -24,10 +23,11 @@ class TestIdf(TestCase):
|
|||
"""
|
||||
self._city_gml = None
|
||||
self._example_path = (Path(__file__).parent.parent / 'tests_data').resolve()
|
||||
self._output_path = (Path(__file__).parent / 'ep_outputs').resolve()
|
||||
|
||||
def _get_city(self):
|
||||
if self._city_gml is None:
|
||||
file_path = (self._example_path / 'attributes.gml').resolve()
|
||||
file_path = (self._example_path / 'buildings.gml').resolve()
|
||||
self._city_gml = GeometryFactory('citygml', file_path).city
|
||||
PhysicsFactory('us_new_york', self._city_gml, base_path=self._example_path)
|
||||
UsageFactory('us_new_york', self._city_gml)
|
||||
|
@ -41,7 +41,8 @@ class TestIdf(TestCase):
|
|||
city = self._get_city()
|
||||
for building in city.buildings:
|
||||
_idf.add_block(building)
|
||||
_idf.run(output_prefix='test_idf_blocks', output_directory="ep_outputs")
|
||||
break
|
||||
_idf.run(output_prefix='test_idf_blocks', output_directory="ep_outputs", keep_file=self._output_path)
|
||||
_idf.read_eso(str(self._example_path))
|
||||
self.assertEqual(1, 2, "arent equal")
|
||||
# todo: clean up the files
|
||||
|
@ -55,59 +56,6 @@ class TestIdf(TestCase):
|
|||
city = self._get_city()
|
||||
for building in city.buildings:
|
||||
_idf.add_surfaces(building)
|
||||
print("prepare to run")
|
||||
_idf.run(output_prefix='test_idf_surfaces', output_directory="ep_outputs")
|
||||
print("done...")
|
||||
_idf.run(output_prefix='test_idf_surfaces', output_directory="ep_outputs", keep_file=self._output_path)
|
||||
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(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)],
|
||||
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",
|
||||
)
|
||||
|
||||
idf.set_wwr(0.4, construction="Project External Window")
|
||||
idf.run(
|
||||
output_prefix=f"tutorial_2",
|
||||
output_directory="ep_outputs",
|
||||
expandobjects=True,
|
||||
verbose="q",
|
||||
)
|
Loading…
Reference in New Issue
Block a user