correct idf factory

This commit is contained in:
Guille Gutierrez 2021-08-12 11:58:24 -04:00
parent 17477bc049
commit 7772d807dc
6 changed files with 57 additions and 39 deletions

View File

@ -67,9 +67,8 @@ class ExportsFactory:
Export the city to Energy+ idf format Export the city to Energy+ idf format
:return: :return:
""" """
# todo: this need to be generalized data_path = (Path(__file__).parent / '../tests/tests_data/').resolve()
data_path = Path('../libs_Final/tests/tests_data').resolve() Idf(self._city, self._path, (data_path / f'minimal.idf').resolve(), (data_path / f'energy+.idd').resolve(),
return Idf(self._city, self._path, (data_path / f'minimal.idf').resolve(), (data_path / f'energy+.idd').resolve(),
(data_path / f'montreal.epw').resolve()) (data_path / f'montreal.epw').resolve())
@property @property
@ -83,3 +82,9 @@ class ExportsFactory:
""" """
return getattr(self, self._export_type, lambda: None) return getattr(self, self._export_type, lambda: None)
def _debug_export(self):
"""
Export the city model structure to the given export type
:return: None
"""
self._idf()

View File

@ -5,6 +5,8 @@ Copyright © 2020 Project Author Soroush Samareh Abolhassani - soroush.samarehab
""" """
from geomeppy import IDF from geomeppy import IDF
from pathlib import Path from pathlib import Path
class Idf: class Idf:
_THERMOSTAT = 'HVACTEMPLATE:THERMOSTAT' _THERMOSTAT = 'HVACTEMPLATE:THERMOSTAT'
_IDEAL_LOAD_AIR_SYSTEM = 'HVACTEMPLATE:ZONE:IDEALLOADSAIRSYSTEM' _IDEAL_LOAD_AIR_SYSTEM = 'HVACTEMPLATE:ZONE:IDEALLOADSAIRSYSTEM'
@ -32,10 +34,10 @@ class Idf:
'residential': 'residential_building' 'residential': 'residential_building'
} }
def __init__(self, city, output_path, idf_file_path, idd_file_path, epw_file_path): def __init__(self, city, output_path, idf_file_path, idd_file_path, epw_file_path, export_type="Surfaces"):
self._city = city self._city = city
self._output_path = str(output_path.resolve()) self._output_path = str(output_path.resolve())
print(self._output_path) self._export_type = export_type
self._idd_file_path = str(idd_file_path) self._idd_file_path = str(idd_file_path)
self._idf_file_path = str(idf_file_path) self._idf_file_path = str(idf_file_path)
self._epw_file_path = str(epw_file_path) self._epw_file_path = str(epw_file_path)
@ -43,21 +45,21 @@ class Idf:
self._idf = IDF(self._idf_file_path, self._epw_file_path) self._idf = IDF(self._idf_file_path, self._epw_file_path)
self._export() self._export()
@staticmethod @staticmethod
def _matrix_to_list(points): def _matrix_to_list(points):
points_list = [] points_list = []
for point in points: for point in points:
point_tuple = (point[0], point[1], point[2]) point_tuple = (point[0], point[1], point[2])
points_list.append(point_tuple) points_list.append(point_tuple)
return points_list return points_list
@staticmethod @staticmethod
def _matrix_to_2d_list(points): def _matrix_to_2d_list(points):
points_list = [] points_list = []
for point in points: for point in points:
point_tuple = (point[0], point[1]) point_tuple = (point[0], point[1])
points_list.append(point_tuple) points_list.append(point_tuple)
return points_list return points_list
def _add_material(self, layer): def _add_material(self, layer):
for material in self._idf.idfobjects[self._MATERIAL]: for material in self._idf.idfobjects[self._MATERIAL]:
@ -125,7 +127,12 @@ class Idf:
for construction in self._idf.idfobjects[self._CONSTRUCTION]: for construction in self._idf.idfobjects[self._CONSTRUCTION]:
if construction.Name == thermal_boundary.construction_name: if construction.Name == thermal_boundary.construction_name:
return return
if thermal_boundary.layers is None:
for material in self._idf.idfobjects[self._MATERIAL]:
if material.Name == "DefaultMaterial":
return
self._idf.set_default_constructions()
return
for layer in thermal_boundary.layers: for layer in thermal_boundary.layers:
self._add_material(layer) self._add_material(layer)
layers = thermal_boundary.layers layers = thermal_boundary.layers
@ -194,28 +201,26 @@ class Idf:
Velocity_Squared_Term_Coefficient=0.0000000E+00 # todo: change it from usage catalog Velocity_Squared_Term_Coefficient=0.0000000E+00 # todo: change it from usage catalog
) )
def _export(self, export_type="Surfaces"): def _export(self):
""" """
Export the idf file into the given path Export the idf file into the given path
export type = "Surfaces|Block" export type = "Surfaces|Block"
""" """
print("called")
for building in self._city.buildings: for building in self._city.buildings:
print('add building')
for usage_zone in building.usage_zones: for usage_zone in building.usage_zones:
self._add_schedule(usage_zone, "Infiltration") self._add_schedule(usage_zone, "Infiltration")
self._add_schedule(usage_zone, "Lights") self._add_schedule(usage_zone, "Lights")
self._add_schedule(usage_zone, "Occupancy") self._add_schedule(usage_zone, "Occupancy")
self._add_zone(usage_zone) self._add_zone(usage_zone)
self._add_heating_system(usage_zone) self._add_heating_system(usage_zone)
self._add_construction(usage_zone) for thermal_zone in building.thermal_zones:
print('zone construction') for thermal_boundary in thermal_zone.bounded:
print('add surfaces') self._add_construction(thermal_boundary)
if export_type == "Surfaces":
if self._export_type == "Surfaces":
self._add_surfaces(building) self._add_surfaces(building)
else: else:
self._add_block(building) self._add_block(building)
print(' =out path', str(self._output_path))
self._idf.saveas(str(self._output_path)) self._idf.saveas(str(self._output_path))
def _add_block(self, building): def _add_block(self, building):

View File

@ -7,6 +7,8 @@ import sys
from imports.construction.nrel_physics_interface import NrelPhysicsInterface from imports.construction.nrel_physics_interface import NrelPhysicsInterface
from imports.construction.helpers.construction_helper import ConstructionHelper from imports.construction.helpers.construction_helper import ConstructionHelper
from city_model_structure.building_demand.layer import Layer
from city_model_structure.building_demand.material import Material
class CaPhysicsParameters(NrelPhysicsInterface): class CaPhysicsParameters(NrelPhysicsInterface):

View File

@ -32,3 +32,10 @@ class ConstructionFactory:
:return: None :return: None
""" """
getattr(self, self._handler, lambda: None)() getattr(self, self._handler, lambda: None)()
def _enrich_debug(self):
"""
Enrich the city with the construction information
:return: None
"""
self._nrcan()

View File

@ -90,7 +90,6 @@ class CityGml:
building_parts = [] building_parts = []
for part in city_object['consistsOfBuildingPart']: for part in city_object['consistsOfBuildingPart']:
building = self._create_building(part['BuildingPart']) building = self._create_building(part['BuildingPart'])
print(f'add city building part {building.name}')
self._city.add_city_object(building) self._city.add_city_object(building)
building_parts.append(building) building_parts.append(building)
return PartsConsistingBuilding(name, building_parts) return PartsConsistingBuilding(name, building_parts)

View File

@ -11,7 +11,7 @@
<bldg:consistsOfBuildingPart> <bldg:consistsOfBuildingPart>
<bldg:BuildingPart gml:id="B-6"> <bldg:BuildingPart gml:id="B-6">
<bldg:function>residential</bldg:function> <bldg:function>residential</bldg:function>
<bldg:yearOfConstruction>2020</bldg:yearOfConstruction> <bldg:yearOfConstruction>1996</bldg:yearOfConstruction>
<bldg:measuredHeight uom="m">12.822875976562045</bldg:measuredHeight> <bldg:measuredHeight uom="m">12.822875976562045</bldg:measuredHeight>
<bldg:storeysAboveGround>2</bldg:storeysAboveGround> <bldg:storeysAboveGround>2</bldg:storeysAboveGround>
<bldg:storeyHeightsAboveGround uom="m">4.5</bldg:storeyHeightsAboveGround> <bldg:storeyHeightsAboveGround uom="m">4.5</bldg:storeyHeightsAboveGround>
@ -136,7 +136,7 @@
<bldg:consistsOfBuildingPart> <bldg:consistsOfBuildingPart>
<bldg:BuildingPart gml:id="B-4"> <bldg:BuildingPart gml:id="B-4">
<bldg:function>residential</bldg:function> <bldg:function>residential</bldg:function>
<bldg:yearOfConstruction>2020</bldg:yearOfConstruction> <bldg:yearOfConstruction>1996</bldg:yearOfConstruction>
<bldg:measuredHeight uom="m">17.09716796875</bldg:measuredHeight> <bldg:measuredHeight uom="m">17.09716796875</bldg:measuredHeight>
<bldg:storeysAboveGround>2</bldg:storeysAboveGround> <bldg:storeysAboveGround>2</bldg:storeysAboveGround>
<bldg:storeyHeightsAboveGround uom="m">6</bldg:storeyHeightsAboveGround> <bldg:storeyHeightsAboveGround uom="m">6</bldg:storeyHeightsAboveGround>
@ -261,7 +261,7 @@
<bldg:consistsOfBuildingPart> <bldg:consistsOfBuildingPart>
<bldg:BuildingPart gml:id="B-3"> <bldg:BuildingPart gml:id="B-3">
<bldg:function>residential</bldg:function> <bldg:function>residential</bldg:function>
<bldg:yearOfConstruction>2020</bldg:yearOfConstruction> <bldg:yearOfConstruction>1996</bldg:yearOfConstruction>
<bldg:measuredHeight uom="m">6.411376953125</bldg:measuredHeight> <bldg:measuredHeight uom="m">6.411376953125</bldg:measuredHeight>
<bldg:storeysAboveGround>1</bldg:storeysAboveGround> <bldg:storeysAboveGround>1</bldg:storeysAboveGround>
<bldg:storeyHeightsAboveGround uom="m">4.5</bldg:storeyHeightsAboveGround> <bldg:storeyHeightsAboveGround uom="m">4.5</bldg:storeyHeightsAboveGround>
@ -674,7 +674,7 @@
<bldg:consistsOfBuildingPart> <bldg:consistsOfBuildingPart>
<bldg:BuildingPart gml:id="B-2"> <bldg:BuildingPart gml:id="B-2">
<bldg:function>residential</bldg:function> <bldg:function>residential</bldg:function>
<bldg:yearOfConstruction>2020</bldg:yearOfConstruction> <bldg:yearOfConstruction>1996</bldg:yearOfConstruction>
<bldg:measuredHeight uom="m">6.411376953125</bldg:measuredHeight> <bldg:measuredHeight uom="m">6.411376953125</bldg:measuredHeight>
<bldg:storeysAboveGround>1</bldg:storeysAboveGround> <bldg:storeysAboveGround>1</bldg:storeysAboveGround>
<bldg:storeyHeightsAboveGround uom="m">4.5</bldg:storeyHeightsAboveGround> <bldg:storeyHeightsAboveGround uom="m">4.5</bldg:storeyHeightsAboveGround>
@ -943,7 +943,7 @@
<bldg:consistsOfBuildingPart> <bldg:consistsOfBuildingPart>
<bldg:BuildingPart gml:id="B-5"> <bldg:BuildingPart gml:id="B-5">
<bldg:function>residential</bldg:function> <bldg:function>residential</bldg:function>
<bldg:yearOfConstruction>2020</bldg:yearOfConstruction> <bldg:yearOfConstruction>1996</bldg:yearOfConstruction>
<bldg:measuredHeight uom="m">6.411437988281023</bldg:measuredHeight> <bldg:measuredHeight uom="m">6.411437988281023</bldg:measuredHeight>
<bldg:storeysAboveGround>1</bldg:storeysAboveGround> <bldg:storeysAboveGround>1</bldg:storeysAboveGround>
<bldg:storeyHeightsAboveGround uom="m">4.5</bldg:storeyHeightsAboveGround> <bldg:storeyHeightsAboveGround uom="m">4.5</bldg:storeyHeightsAboveGround>
@ -1068,7 +1068,7 @@
<bldg:consistsOfBuildingPart> <bldg:consistsOfBuildingPart>
<bldg:BuildingPart gml:id="B-1"> <bldg:BuildingPart gml:id="B-1">
<bldg:function>residential</bldg:function> <bldg:function>residential</bldg:function>
<bldg:yearOfConstruction>2020</bldg:yearOfConstruction> <bldg:yearOfConstruction>1996</bldg:yearOfConstruction>
<bldg:measuredHeight uom="m">6.411376953125</bldg:measuredHeight> <bldg:measuredHeight uom="m">6.411376953125</bldg:measuredHeight>
<bldg:storeysAboveGround>1</bldg:storeysAboveGround> <bldg:storeysAboveGround>1</bldg:storeysAboveGround>
<bldg:storeyHeightsAboveGround uom="m">4.5</bldg:storeyHeightsAboveGround> <bldg:storeyHeightsAboveGround uom="m">4.5</bldg:storeyHeightsAboveGround>
@ -1197,7 +1197,7 @@
<bldg:consistsOfBuildingPart> <bldg:consistsOfBuildingPart>
<bldg:BuildingPart gml:id="C-1"> <bldg:BuildingPart gml:id="C-1">
<bldg:function>residential</bldg:function> <bldg:function>residential</bldg:function>
<bldg:yearOfConstruction>2020</bldg:yearOfConstruction> <bldg:yearOfConstruction>1996</bldg:yearOfConstruction>
<bldg:measuredHeight uom="m">14.532531738281023</bldg:measuredHeight> <bldg:measuredHeight uom="m">14.532531738281023</bldg:measuredHeight>
<bldg:storeysAboveGround>3</bldg:storeysAboveGround> <bldg:storeysAboveGround>3</bldg:storeysAboveGround>
<bldg:storeyHeightsAboveGround uom="m">3.4</bldg:storeyHeightsAboveGround> <bldg:storeyHeightsAboveGround uom="m">3.4</bldg:storeyHeightsAboveGround>
@ -1880,7 +1880,7 @@
<bldg:consistsOfBuildingPart> <bldg:consistsOfBuildingPart>
<bldg:BuildingPart gml:id="C-2"> <bldg:BuildingPart gml:id="C-2">
<bldg:function>residential</bldg:function> <bldg:function>residential</bldg:function>
<bldg:yearOfConstruction>2020</bldg:yearOfConstruction> <bldg:yearOfConstruction>1996</bldg:yearOfConstruction>
<bldg:measuredHeight uom="m">7.002624511718977</bldg:measuredHeight> <bldg:measuredHeight uom="m">7.002624511718977</bldg:measuredHeight>
<bldg:storeysAboveGround>1</bldg:storeysAboveGround> <bldg:storeysAboveGround>1</bldg:storeysAboveGround>
<bldg:storeyHeightsAboveGround uom="m">5</bldg:storeyHeightsAboveGround> <bldg:storeyHeightsAboveGround uom="m">5</bldg:storeyHeightsAboveGround>
@ -2081,7 +2081,7 @@
<bldg:consistsOfBuildingPart> <bldg:consistsOfBuildingPart>
<bldg:BuildingPart gml:id="A-1"> <bldg:BuildingPart gml:id="A-1">
<bldg:function>residential</bldg:function> <bldg:function>residential</bldg:function>
<bldg:yearOfConstruction>2020</bldg:yearOfConstruction> <bldg:yearOfConstruction>1996</bldg:yearOfConstruction>
<bldg:measuredHeight uom="m">24.220886230468977</bldg:measuredHeight> <bldg:measuredHeight uom="m">24.220886230468977</bldg:measuredHeight>
<bldg:storeysAboveGround>5</bldg:storeysAboveGround> <bldg:storeysAboveGround>5</bldg:storeysAboveGround>
<bldg:storeyHeightsAboveGround uom="m">3.4</bldg:storeyHeightsAboveGround> <bldg:storeyHeightsAboveGround uom="m">3.4</bldg:storeyHeightsAboveGround>
@ -3106,7 +3106,7 @@
<bldg:consistsOfBuildingPart> <bldg:consistsOfBuildingPart>
<bldg:BuildingPart gml:id="A-2"> <bldg:BuildingPart gml:id="A-2">
<bldg:function>residential</bldg:function> <bldg:function>residential</bldg:function>
<bldg:yearOfConstruction>2020</bldg:yearOfConstruction> <bldg:yearOfConstruction>1996</bldg:yearOfConstruction>
<bldg:measuredHeight uom="m">7.002685546875</bldg:measuredHeight> <bldg:measuredHeight uom="m">7.002685546875</bldg:measuredHeight>
<bldg:storeysAboveGround>1</bldg:storeysAboveGround> <bldg:storeysAboveGround>1</bldg:storeysAboveGround>
<bldg:storeyHeightsAboveGround uom="m">5</bldg:storeyHeightsAboveGround> <bldg:storeyHeightsAboveGround uom="m">5</bldg:storeyHeightsAboveGround>