nrel_physics_interface.py: fixed a bug due to a refactor
polygon.py: fixed an error due to normal = 0 that created an infinite loop simplified_radiosity_algorithm.py: added list of target buildings names to be simulated
This commit is contained in:
parent
e77f6890f4
commit
31b5a26256
|
@ -126,6 +126,8 @@ class Polygon:
|
|||
alpha = 0
|
||||
if len(points) == 3:
|
||||
return cross_product
|
||||
if np.linalg.norm(cross_product) == 0:
|
||||
return cross_product
|
||||
alpha += self._angle(vector_2, vector_3, cross_product)
|
||||
for i in range(0, len(points)-4):
|
||||
vector_1 = points[i+1] - point_origin
|
||||
|
@ -169,12 +171,17 @@ class Polygon:
|
|||
# it could be a very good substitute of this method
|
||||
points_list = self.points_list
|
||||
normal = self.normal
|
||||
if np.linalg.norm(normal) == 0:
|
||||
sys.stderr.write(f'Not able to triangulate polygon\n')
|
||||
return [self]
|
||||
# are points concave or convex?
|
||||
total_points_list, concave_points, convex_points = self._starting_lists(points_list, normal)
|
||||
|
||||
# list of ears
|
||||
ears = []
|
||||
while len(concave_points) > 3 or len(convex_points) != 0:
|
||||
j = 0
|
||||
while (len(concave_points) > 3 or len(convex_points) != 0) and j < 100:
|
||||
j += 1
|
||||
for i in range(0, len(concave_points)):
|
||||
ear = self._triangle(points_list, total_points_list, concave_points[i])
|
||||
rest_points = []
|
||||
|
@ -208,6 +215,9 @@ class Polygon:
|
|||
if len(total_points_list) <= 3 and len(convex_points) > 0:
|
||||
sys.stderr.write(f'Not able to triangulate polygon\n')
|
||||
return [self]
|
||||
if j >= 100:
|
||||
sys.stderr.write(f'Not able to triangulate polygon\n')
|
||||
return [self]
|
||||
last_ear = self._triangle(points_list, total_points_list, concave_points[1])
|
||||
ears.append(last_ear)
|
||||
return ears
|
||||
|
|
|
@ -25,14 +25,22 @@ class SimplifiedRadiosityAlgorithm:
|
|||
z = point[2] - self._city.lower_corner[2]
|
||||
return [x, y, z]
|
||||
|
||||
def _export(self):
|
||||
def _export(self, target_buildings_names=None):
|
||||
buildings = []
|
||||
for building_index, building in enumerate(self._city.buildings):
|
||||
if target_buildings_names is None:
|
||||
target_buildings_names = []
|
||||
simulate = 'true'
|
||||
else:
|
||||
simulate = 'false'
|
||||
for name in target_buildings_names:
|
||||
if building.name == name:
|
||||
simulate = 'true'
|
||||
building_dict = {
|
||||
'@Name': f'{building.name}',
|
||||
'@id': f'{building_index}',
|
||||
'@key': f'{building.name}',
|
||||
'@Simulate': 'True'
|
||||
'@Simulate': f'{simulate}'
|
||||
}
|
||||
walls, roofs, floors = [], [], []
|
||||
for surface in building.surfaces:
|
||||
|
|
|
@ -59,7 +59,7 @@ class NrelPhysicsInterface:
|
|||
raise Exception(f'infiltration rate for ventilation when system on units = {units}, expected ACH')
|
||||
|
||||
thermal_boundary_archetypes = []
|
||||
for construction in archetype['construction']['construction']:
|
||||
for construction in archetype['constructions']['construction']:
|
||||
construction_type = construction['@type']
|
||||
construction_id = construction['@id']
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user