Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
f0be55b279
|
@ -19,42 +19,19 @@ class Polygon:
|
|||
Polygon class
|
||||
"""
|
||||
|
||||
# def __init__(self, points):
|
||||
def __init__(self, coordinates):
|
||||
|
||||
self._area = None
|
||||
# self._points = points
|
||||
self._points = None
|
||||
self._points_list = None
|
||||
self._normal = None
|
||||
self._inverse = None
|
||||
self._edges = None
|
||||
# self._coordinates = None
|
||||
self._coordinates = coordinates
|
||||
self._triangles = None
|
||||
self._vertices = None
|
||||
self._faces = None
|
||||
|
||||
# @property
|
||||
# def points(self) -> List[Point]:
|
||||
# """
|
||||
# List of points belonging to the polygon [[x, y, z],...]
|
||||
# :return: List[Point]
|
||||
# """
|
||||
# return self._points
|
||||
#
|
||||
# @property
|
||||
# def coordinates(self) -> List[np.ndarray]:
|
||||
# """
|
||||
# List of points in the shape of its coordinates belonging to the polygon [[x, y, z],...]
|
||||
# :return: np.array
|
||||
# """
|
||||
# if self._coordinates is None:
|
||||
# self._coordinates = []
|
||||
# for point in self.points:
|
||||
# self._coordinates.append(np.array(point.coordinates))
|
||||
# return self._coordinates
|
||||
#
|
||||
@property
|
||||
def points(self) -> List[Point]:
|
||||
"""
|
||||
|
|
|
@ -67,9 +67,8 @@ class ExportsFactory:
|
|||
Export the city to Energy+ idf format
|
||||
:return:
|
||||
"""
|
||||
# todo: this need to be generalized
|
||||
data_path = Path('../libs_Final/tests/tests_data').resolve()
|
||||
return Idf(self._city, self._path, (data_path / f'minimal.idf').resolve(), (data_path / f'energy+.idd').resolve(),
|
||||
data_path = (Path(__file__).parent / '../tests/tests_data/').resolve()
|
||||
Idf(self._city, self._path, (data_path / f'minimal.idf').resolve(), (data_path / f'energy+.idd').resolve(),
|
||||
(data_path / f'montreal.epw').resolve())
|
||||
|
||||
@property
|
||||
|
@ -83,3 +82,9 @@ class ExportsFactory:
|
|||
"""
|
||||
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()
|
||||
|
|
|
@ -5,6 +5,8 @@ Copyright © 2020 Project Author Soroush Samareh Abolhassani - soroush.samarehab
|
|||
"""
|
||||
from geomeppy import IDF
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class Idf:
|
||||
_THERMOSTAT = 'HVACTEMPLATE:THERMOSTAT'
|
||||
_IDEAL_LOAD_AIR_SYSTEM = 'HVACTEMPLATE:ZONE:IDEALLOADSAIRSYSTEM'
|
||||
|
@ -32,10 +34,10 @@ class Idf:
|
|||
'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._output_path = str(output_path.resolve())
|
||||
print(self._output_path)
|
||||
self._export_type = export_type
|
||||
self._idd_file_path = str(idd_file_path)
|
||||
self._idf_file_path = str(idf_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._export()
|
||||
|
||||
@staticmethod
|
||||
def _matrix_to_list(points):
|
||||
points_list = []
|
||||
for point in points:
|
||||
point_tuple = (point[0], point[1], point[2])
|
||||
points_list.append(point_tuple)
|
||||
return points_list
|
||||
@staticmethod
|
||||
def _matrix_to_list(points):
|
||||
points_list = []
|
||||
for point in points:
|
||||
point_tuple = (point[0], point[1], point[2])
|
||||
points_list.append(point_tuple)
|
||||
return points_list
|
||||
|
||||
@staticmethod
|
||||
def _matrix_to_2d_list(points):
|
||||
points_list = []
|
||||
for point in points:
|
||||
point_tuple = (point[0], point[1])
|
||||
points_list.append(point_tuple)
|
||||
return points_list
|
||||
@staticmethod
|
||||
def _matrix_to_2d_list(points):
|
||||
points_list = []
|
||||
for point in points:
|
||||
point_tuple = (point[0], point[1])
|
||||
points_list.append(point_tuple)
|
||||
return points_list
|
||||
|
||||
def _add_material(self, layer):
|
||||
for material in self._idf.idfobjects[self._MATERIAL]:
|
||||
|
@ -126,6 +128,12 @@ class Idf:
|
|||
if construction.Name == thermal_boundary.construction_name:
|
||||
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:
|
||||
self._add_material(layer)
|
||||
layers = thermal_boundary.layers
|
||||
|
@ -146,7 +154,7 @@ class Idf:
|
|||
def _add_thermostat(self, usage_zone):
|
||||
thermostat_name = f'Thermostat {usage_zone.usage}'
|
||||
for thermostat in self._idf.idfobjects[self._THERMOSTAT]:
|
||||
if thermostat == thermostat_name:
|
||||
if thermostat.Name == thermostat_name:
|
||||
return thermostat
|
||||
return self._idf.newidfobject(self._THERMOSTAT,
|
||||
Name=thermostat_name,
|
||||
|
@ -154,6 +162,9 @@ class Idf:
|
|||
Constant_Cooling_Setpoint=usage_zone.cooling_setpoint)
|
||||
|
||||
def _add_heating_system(self, usage_zone):
|
||||
for air_system in self._idf.idfobjects[self._IDEAL_LOAD_AIR_SYSTEM]:
|
||||
if air_system.Zone_Name == usage_zone.id:
|
||||
return
|
||||
thermostat = self._add_thermostat(usage_zone)
|
||||
# todo: doesn't the air system have name?
|
||||
self._idf.newidfobject(self._IDEAL_LOAD_AIR_SYSTEM,
|
||||
|
@ -194,28 +205,26 @@ class Idf:
|
|||
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 type = "Surfaces|Block"
|
||||
"""
|
||||
print("called")
|
||||
for building in self._city.buildings:
|
||||
print('add building')
|
||||
for usage_zone in building.usage_zones:
|
||||
self._add_schedule(usage_zone, "Infiltration")
|
||||
self._add_schedule(usage_zone, "Lights")
|
||||
self._add_schedule(usage_zone, "Occupancy")
|
||||
self._add_zone(usage_zone)
|
||||
self._add_heating_system(usage_zone)
|
||||
self._add_construction(usage_zone)
|
||||
print('zone construction')
|
||||
print('add surfaces')
|
||||
if export_type == "Surfaces":
|
||||
for thermal_zone in building.thermal_zones:
|
||||
for thermal_boundary in thermal_zone.bounded:
|
||||
self._add_construction(thermal_boundary)
|
||||
|
||||
if self._export_type == "Surfaces":
|
||||
self._add_surfaces(building)
|
||||
else:
|
||||
self._add_block(building)
|
||||
print(' =out path', str(self._output_path))
|
||||
self._idf.saveas(str(self._output_path))
|
||||
|
||||
def _add_block(self, building):
|
||||
|
@ -243,6 +252,6 @@ class Idf:
|
|||
surface = self._idf.newidfobject(self._SURFACE, Name=f'{boundary.surface.name}',
|
||||
Surface_Type=idf_surface, Zone_Name=usage_zone.id,
|
||||
Construction_Name=boundary.construction_name)
|
||||
coordinates = self._matrix_to_list(boundary.surface.coordinates)
|
||||
coordinates = self._matrix_to_list(boundary.surface.solid_polygon.coordinates)
|
||||
surface.setcoords(coordinates)
|
||||
self._idf.intersect_match()
|
||||
|
|
|
@ -7,6 +7,8 @@ import sys
|
|||
|
||||
from imports.construction.nrel_physics_interface import NrelPhysicsInterface
|
||||
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):
|
||||
|
|
|
@ -68,6 +68,7 @@ class UsPhysicsParameters(NrelPhysicsInterface):
|
|||
thermal_boundary.outside_visible_absorptance = thermal_boundary_archetype.outside_visible_absorptance
|
||||
thermal_boundary.construction_name = thermal_boundary_archetype.construction_name
|
||||
thermal_boundary.window_ratio = thermal_boundary_archetype.window_ratio
|
||||
thermal_boundary.layers = []
|
||||
for layer_archetype in thermal_boundary_archetype.layers:
|
||||
layer = Layer()
|
||||
layer.thickness = layer_archetype.thickness
|
||||
|
@ -82,6 +83,7 @@ class UsPhysicsParameters(NrelPhysicsInterface):
|
|||
material.visible_absorptance = layer_archetype.visible_absorptance
|
||||
material.thermal_resistance = layer_archetype.thermal_resistance
|
||||
layer.material = material
|
||||
thermal_boundary.layers.append(layer)
|
||||
for thermal_opening in thermal_boundary.thermal_openings:
|
||||
if thermal_boundary_archetype.thermal_opening is not None:
|
||||
thermal_opening_archetype = thermal_boundary_archetype.thermal_opening
|
||||
|
|
|
@ -32,3 +32,10 @@ class ConstructionFactory:
|
|||
:return: None
|
||||
"""
|
||||
getattr(self, self._handler, lambda: None)()
|
||||
|
||||
def _enrich_debug(self):
|
||||
"""
|
||||
Enrich the city with the construction information
|
||||
:return: None
|
||||
"""
|
||||
self._nrel()
|
||||
|
|
|
@ -90,7 +90,6 @@ class CityGml:
|
|||
building_parts = []
|
||||
for part in city_object['consistsOfBuildingPart']:
|
||||
building = self._create_building(part['BuildingPart'])
|
||||
print(f'add city building part {building.name}')
|
||||
self._city.add_city_object(building)
|
||||
building_parts.append(building)
|
||||
return PartsConsistingBuilding(name, building_parts)
|
||||
|
|
|
@ -7,6 +7,8 @@ from pathlib import Path
|
|||
from imports.usage.hft_usage_parameters import HftUsageParameters
|
||||
from imports.usage.ca_usage_parameters import CaUsageParameters
|
||||
|
||||
# todo: handle missing lambda and rise error.
|
||||
|
||||
|
||||
class UsageFactory:
|
||||
"""
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<bldg:consistsOfBuildingPart>
|
||||
<bldg:BuildingPart gml:id="B-6">
|
||||
<bldg:function>residential</bldg:function>
|
||||
<bldg:yearOfConstruction>2020</bldg:yearOfConstruction>
|
||||
<bldg:yearOfConstruction>1996</bldg:yearOfConstruction>
|
||||
<bldg:measuredHeight uom="m">12.822875976562045</bldg:measuredHeight>
|
||||
<bldg:storeysAboveGround>2</bldg:storeysAboveGround>
|
||||
<bldg:storeyHeightsAboveGround uom="m">4.5</bldg:storeyHeightsAboveGround>
|
||||
|
@ -136,7 +136,7 @@
|
|||
<bldg:consistsOfBuildingPart>
|
||||
<bldg:BuildingPart gml:id="B-4">
|
||||
<bldg:function>residential</bldg:function>
|
||||
<bldg:yearOfConstruction>2020</bldg:yearOfConstruction>
|
||||
<bldg:yearOfConstruction>1996</bldg:yearOfConstruction>
|
||||
<bldg:measuredHeight uom="m">17.09716796875</bldg:measuredHeight>
|
||||
<bldg:storeysAboveGround>2</bldg:storeysAboveGround>
|
||||
<bldg:storeyHeightsAboveGround uom="m">6</bldg:storeyHeightsAboveGround>
|
||||
|
@ -261,7 +261,7 @@
|
|||
<bldg:consistsOfBuildingPart>
|
||||
<bldg:BuildingPart gml:id="B-3">
|
||||
<bldg:function>residential</bldg:function>
|
||||
<bldg:yearOfConstruction>2020</bldg:yearOfConstruction>
|
||||
<bldg:yearOfConstruction>1996</bldg:yearOfConstruction>
|
||||
<bldg:measuredHeight uom="m">6.411376953125</bldg:measuredHeight>
|
||||
<bldg:storeysAboveGround>1</bldg:storeysAboveGround>
|
||||
<bldg:storeyHeightsAboveGround uom="m">4.5</bldg:storeyHeightsAboveGround>
|
||||
|
@ -674,7 +674,7 @@
|
|||
<bldg:consistsOfBuildingPart>
|
||||
<bldg:BuildingPart gml:id="B-2">
|
||||
<bldg:function>residential</bldg:function>
|
||||
<bldg:yearOfConstruction>2020</bldg:yearOfConstruction>
|
||||
<bldg:yearOfConstruction>1996</bldg:yearOfConstruction>
|
||||
<bldg:measuredHeight uom="m">6.411376953125</bldg:measuredHeight>
|
||||
<bldg:storeysAboveGround>1</bldg:storeysAboveGround>
|
||||
<bldg:storeyHeightsAboveGround uom="m">4.5</bldg:storeyHeightsAboveGround>
|
||||
|
@ -943,7 +943,7 @@
|
|||
<bldg:consistsOfBuildingPart>
|
||||
<bldg:BuildingPart gml:id="B-5">
|
||||
<bldg:function>residential</bldg:function>
|
||||
<bldg:yearOfConstruction>2020</bldg:yearOfConstruction>
|
||||
<bldg:yearOfConstruction>1996</bldg:yearOfConstruction>
|
||||
<bldg:measuredHeight uom="m">6.411437988281023</bldg:measuredHeight>
|
||||
<bldg:storeysAboveGround>1</bldg:storeysAboveGround>
|
||||
<bldg:storeyHeightsAboveGround uom="m">4.5</bldg:storeyHeightsAboveGround>
|
||||
|
@ -1068,7 +1068,7 @@
|
|||
<bldg:consistsOfBuildingPart>
|
||||
<bldg:BuildingPart gml:id="B-1">
|
||||
<bldg:function>residential</bldg:function>
|
||||
<bldg:yearOfConstruction>2020</bldg:yearOfConstruction>
|
||||
<bldg:yearOfConstruction>1996</bldg:yearOfConstruction>
|
||||
<bldg:measuredHeight uom="m">6.411376953125</bldg:measuredHeight>
|
||||
<bldg:storeysAboveGround>1</bldg:storeysAboveGround>
|
||||
<bldg:storeyHeightsAboveGround uom="m">4.5</bldg:storeyHeightsAboveGround>
|
||||
|
@ -1197,7 +1197,7 @@
|
|||
<bldg:consistsOfBuildingPart>
|
||||
<bldg:BuildingPart gml:id="C-1">
|
||||
<bldg:function>residential</bldg:function>
|
||||
<bldg:yearOfConstruction>2020</bldg:yearOfConstruction>
|
||||
<bldg:yearOfConstruction>1996</bldg:yearOfConstruction>
|
||||
<bldg:measuredHeight uom="m">14.532531738281023</bldg:measuredHeight>
|
||||
<bldg:storeysAboveGround>3</bldg:storeysAboveGround>
|
||||
<bldg:storeyHeightsAboveGround uom="m">3.4</bldg:storeyHeightsAboveGround>
|
||||
|
@ -1880,7 +1880,7 @@
|
|||
<bldg:consistsOfBuildingPart>
|
||||
<bldg:BuildingPart gml:id="C-2">
|
||||
<bldg:function>residential</bldg:function>
|
||||
<bldg:yearOfConstruction>2020</bldg:yearOfConstruction>
|
||||
<bldg:yearOfConstruction>1996</bldg:yearOfConstruction>
|
||||
<bldg:measuredHeight uom="m">7.002624511718977</bldg:measuredHeight>
|
||||
<bldg:storeysAboveGround>1</bldg:storeysAboveGround>
|
||||
<bldg:storeyHeightsAboveGround uom="m">5</bldg:storeyHeightsAboveGround>
|
||||
|
@ -2081,7 +2081,7 @@
|
|||
<bldg:consistsOfBuildingPart>
|
||||
<bldg:BuildingPart gml:id="A-1">
|
||||
<bldg:function>residential</bldg:function>
|
||||
<bldg:yearOfConstruction>2020</bldg:yearOfConstruction>
|
||||
<bldg:yearOfConstruction>1996</bldg:yearOfConstruction>
|
||||
<bldg:measuredHeight uom="m">24.220886230468977</bldg:measuredHeight>
|
||||
<bldg:storeysAboveGround>5</bldg:storeysAboveGround>
|
||||
<bldg:storeyHeightsAboveGround uom="m">3.4</bldg:storeyHeightsAboveGround>
|
||||
|
@ -3106,7 +3106,7 @@
|
|||
<bldg:consistsOfBuildingPart>
|
||||
<bldg:BuildingPart gml:id="A-2">
|
||||
<bldg:function>residential</bldg:function>
|
||||
<bldg:yearOfConstruction>2020</bldg:yearOfConstruction>
|
||||
<bldg:yearOfConstruction>1996</bldg:yearOfConstruction>
|
||||
<bldg:measuredHeight uom="m">7.002685546875</bldg:measuredHeight>
|
||||
<bldg:storeysAboveGround>1</bldg:storeysAboveGround>
|
||||
<bldg:storeyHeightsAboveGround uom="m">5</bldg:storeyHeightsAboveGround>
|
||||
|
|
Loading…
Reference in New Issue
Block a user