Add code comment to the classes

This commit is contained in:
Guille Gutierrez 2020-06-10 13:08:51 -04:00
parent e0224c229c
commit de16e01677
9 changed files with 603 additions and 582 deletions

View File

@ -1,22 +0,0 @@
import trimesh
from helpers.geometry import Geometry as Geo
import stl
import numpy as np
# example triangle
vertices = [[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
#faces = [[0, 1, 2], [1, 3, 2], [1, 5, 3], [5, 7, 3], [0, 4, 1], [4, 5, 1], [4, 6, 5], [5, 6, 7], [0, 2, 4], [2, 6, 4],
# [3, 7, 6], [2, 3, 6]]
# example rectangle
faces = [[0, 1, 3, 2], [1, 5, 7, 3], [0, 4, 5, 1], [4, 6, 7, 5], [0, 2, 6, 4], [3, 7, 6, 2]]
mesh = trimesh.Trimesh(vertices=vertices, faces=faces)
normal_plane = [0, 0, 1]
point_plane = [0, 0, 2]
mesh_result = Geo.divide_mesh_by_plane(mesh, normal_plane, point_plane)
for mesh in mesh_result:
print(len(mesh.vertices), len(mesh.faces))

View File

@ -9,8 +9,11 @@ from helpers.geometry import Geometry
class Polyhedron:
"""
Polyhedron class
"""
def __init__(self, surfaces):
self._surfaces = [s for s in surfaces]
self._surfaces = list(surfaces)
self._polygons = [s.polygon for s in surfaces]
self._polyhedron = None
self._volume = None
@ -27,7 +30,11 @@ class Polyhedron:
return -1
@property
def vertices(self):
def vertices(self) -> np.ndarray:
"""
Polyhedron vertices
:return: np.ndarray(int)
"""
if self._vertices is None:
vertices, self._vertices = [], []
[vertices.extend(s.points) for s in self._surfaces]
@ -44,7 +51,11 @@ class Polyhedron:
return self._vertices
@property
def faces(self):
def faces(self) -> np.ndarray:
"""
Polyhedron faces
:return: np.ndarray([int])
"""
if self._faces is None:
self._faces = []
for s in self._surfaces:
@ -67,13 +78,26 @@ class Polyhedron:
@property
def volume(self):
"""
Polyhedron volume in cubic meters
:return: float
"""
if self._volume is None:
self._volume, cog, inertia = self._polyhedron_mesh.get_mass_properties()
return self._volume
@property
def max_z(self):
"""
Polyhedron maximal z value
:return: float
"""
return self._polyhedron_mesh.z.max()
def save(self, full_path):
"""
Export the polyhedron to stl given file
:param full_path: str
:return: None
"""
self._polyhedron_mesh.save(full_path)

View File

@ -3,13 +3,18 @@ ThermalZone module
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
"""
from __future__ import annotations
from typing import List
from typing import List, TypeVar
from city_model_structure.usage_zone import UsageZone
from city_model_structure.surface import Surface
from helpers.configuration import Configuration
ThermalBoundary = TypeVar('ThermalBoundary')
class ThermalZone:
"""
ThermalZone class
"""
def __init__(self, surfaces):
self._surfaces = surfaces
self._floor_area = None
@ -25,14 +30,26 @@ class ThermalZone:
@property
def heated(self):
"""
Get thermal zone heated flag
:return: Boolean
"""
return self._heated
@property
def cooled(self):
"""
Get thermal zone cooled flag
:return: Boolean
"""
return self._cooled
@property
def floor_area(self):
"""
Get thermal zone floor area in m2
:return: float
"""
if self._floor_area is None:
self._floor_area = 0
for s in self._surfaces:
@ -41,61 +58,128 @@ class ThermalZone:
return self._floor_area
@property
def bounded(self) -> List['ThermalBoundary']:
def bounded(self) -> List[ThermalBoundary]:
"""
Get thermal boundaries bounding with the thermal zone
:return: [ThermalBoundary]
"""
return self._bounded
@bounded.setter
def bounded(self, value):
"""
Set thermal boundaries bounding with the thermal zone
:param value: [ThermalBoundary]
:return: None
"""
self._bounded = value
@property
def surfaces(self):
def surfaces(self) -> List[Surface]:
"""
Get thermal zone surfaces
:return: [Surface]
"""
return self._surfaces
@property
def additional_thermal_bridge_u_value(self):
"""
Get thermal zone additional thermal bridge u value
:return: float
"""
return self._additional_thermal_bridge_u_value
@additional_thermal_bridge_u_value.setter
def additional_thermal_bridge_u_value(self, value):
"""
Set thermal zone additional thermal bridge u value
:param value: float
:return: None
"""
self._additional_thermal_bridge_u_value = value
@property
def effective_thermal_capacity(self):
"""
Get thermal zone effective thermal capacity
:return: float
"""
return self._effective_thermal_capacity
@effective_thermal_capacity.setter
def effective_thermal_capacity(self, value):
"""
Set thermal zone effective thermal capacity
:param value: float
:return: None
"""
self._effective_thermal_capacity = value
@property
def indirectly_heated_area_ratio(self):
"""
Get thermal zone indirectly heated area ratio
:return: float
"""
return self._indirectly_heated_area_ratio
@indirectly_heated_area_ratio.setter
def indirectly_heated_area_ratio(self, value):
"""
Set thermal zone indirectly heated area ratio
:param value: float
:return: None
"""
self._indirectly_heated_area_ratio = value
@property
def infiltration_rate_system_on(self):
"""
Get thermal zone infiltration rate system on in air changes per hour
:return: float
"""
return self._infiltration_rate_system_on
@infiltration_rate_system_on.setter
def infiltration_rate_system_on(self, value):
"""
Set thermal zone infiltration rate system on in air changes per hour
:param value: float
:return: None
"""
self._infiltration_rate_system_on = value
@property
def infiltration_rate_system_off(self):
"""
Get thermal zone infiltration rate system off in air changes per hour
:return: float
"""
return self._infiltration_rate_system_off
@infiltration_rate_system_off.setter
def infiltration_rate_system_off(self, value):
"""
Set thermal zone infiltration rate system on in air changes per hour
:param value: float
:return: None
"""
self._infiltration_rate_system_off = value
@property
def usage_zones(self) -> List[UsageZone]:
"""
Get thermal zone usage zones
:return: [UsageZone]
"""
return self._usage_zones
@usage_zones.setter
def usage_zones(self, values):
"""
Set thermal zone usage zones
:param values: [UsageZone]
:return: None
"""
self._usage_zones = values

View File

@ -1,83 +0,0 @@
"""
Window module
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
"""
class Window:
"""
Window class
"""
def __init__(self):
self._conductivity = None
self._solar_transmittance_at_normal_incidence = None
self._front_side_solar_reflectance_at_normal_incidence = None
self._back_side_solar_reflectance_at_normal_incidence = None
self._frame_ratio = None
self._thickness_m = None
self._shgc = None
@property
def conductivity(self):
"""
Get window conductivity in W/mK
:return: float
"""
return self._conductivity
@conductivity.setter
def conductivity(self, value):
self._conductivity = value
@property
def solar_transmittance_at_normal_incidence(self):
return self._solar_transmittance_at_normal_incidence
@solar_transmittance_at_normal_incidence.setter
def solar_transmittance_at_normal_incidence(self, value):
self._solar_transmittance_at_normal_incidence = value
@property
def front_side_solar_reflectance_at_normal_incidence(self):
return self._front_side_solar_reflectance_at_normal_incidence
@front_side_solar_reflectance_at_normal_incidence.setter
def front_side_solar_reflectance_at_normal_incidence(self, value):
self._front_side_solar_reflectance_at_normal_incidence = value
@property
def back_side_solar_reflectance_at_normal_incidence(self):
return self._back_side_solar_reflectance_at_normal_incidence
@back_side_solar_reflectance_at_normal_incidence.setter
def back_side_solar_reflectance_at_normal_incidence(self, value):
self._back_side_solar_reflectance_at_normal_incidence = value
@property
def frame_ratio(self):
return self._frame_ratio
@frame_ratio.setter
def frame_ratio(self, value):
self._frame_ratio = value
@frame_ratio.setter
def frame_ratio(self, value):
self._frame_ratio = value
@property
def thickness_m(self):
return self._thickness_m
@thickness_m.setter
def thickness_m(self, value):
self._thickness_m = value
@property
def shgc(self):
return self._shgc
@shgc.setter
def shgc(self, value):
self._shgc = value

View File

@ -7,8 +7,8 @@ h_e = 25 # W/m2K
frame_ratio = 0
[thermal_zones]
heated = True
cooled = True
heated = true
cooled = true
additional_thermal_bridge_u_value = 0
indirectly_heated_area_ratio = 0
infiltration_rate_system_on = 0

View File

@ -10,7 +10,7 @@ from pathlib import Path
class Configuration:
def __init__(self):
base_path = Path().resolve().parent
config_file = Path(base_path / 'config/configuration.ini').resolve()
config_file = Path(base_path / 'libs/config/configuration.ini').resolve()
self._config = configparser.ConfigParser()
self._config.read(config_file)

View File

@ -230,5 +230,10 @@ class UsPlutoToFunction:
}
@staticmethod
def function(pluto):
return UsPlutoToFunction.building_function[pluto]
def function(building_pluto_function):
"""
Get nrel function from the given pluto function
:param building_pluto_function: str
:return: str
"""
return UsPlutoToFunction.building_function[building_pluto_function]

View File

@ -6,7 +6,10 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc
class UsFunctionToUsage:
building_usage = {
"""
UsFunctionToUsage class
"""
_building_usage = {
'full service restaurant': 'restaurant',
'highrise apartment': 'residential',
'hospital': 'health care',
@ -28,6 +31,9 @@ class UsFunctionToUsage:
@staticmethod
def usage(building_function):
return UsFunctionToUsage.building_usage[building_function]
"""
Get the usage for the given building function
:param building_function: str
:return: str
"""
return UsFunctionToUsage._building_usage[building_function]

View File

@ -7,7 +7,10 @@ from usage.usage_feeders.helpers.us_function_to_usage import UsFunctionToUsage
class UsPlutoToUsage:
building_function = {
"""
UsPlutoToUsage class
"""
_building_function = {
'A0': 'single family house',
'A1': 'single family house',
'A2': 'single family house',
@ -231,6 +234,10 @@ class UsPlutoToUsage:
}
@staticmethod
def usage(pluto):
nrel_function = UsPlutoToUsage.building_function[pluto]
return UsFunctionToUsage.building_usage[nrel_function]
def usage(building_pluto_function):
"""
Get the nrel usage for the given building pluto function
:param building_pluto_function: str
:return: str
"""
return UsFunctionToUsage.usage(UsPlutoToUsage._building_function[building_pluto_function])