### ===================================================================================================================
### CLASS: RefWallIP
### ===================================================================================================================
# Copyright ©VIIA 2024
### ===================================================================================================================
### 1. Import modules
### ===================================================================================================================
# General imports
from typing import Dict, Union
# References for functions and classes in the rhdhv_fem package
from rhdhv_fem.shapes import Wall
from rhdhv_fem.fem_math import fem_compare_values, fem_smaller
# References for functions and classes in the viiaPackage
from viiapackage.reference_approach.reference_wall.current_wall import CurrentWall
from viiapackage.reference_approach.reference_wall.ref_wall import RefWall
### ===================================================================================================================
### 2. Ref wall ip class
### ===================================================================================================================
[docs]class RefWallIP(RefWall):
""" Class for the data of the reference walls. These are compared to the current wall."""
# Class property for the current wall referenced
current_wall: CurrentWall = None
[docs] def __init__(self, wall: Wall, measures: str):
"""
Input:
- wall (Wall): Object reference of the wall from the reference object. Should be an instance of Wall class.
- measures (str): All the measures in string format that have been applied to the object.
"""
# z-top
self.__z_top = wall.contour.get_min_max()['z-max']
super().__init__(wall=wall, measures=measures, name=wall.name, width=wall.get_width())
@property
def score_thickness(self) -> float:
""" Method of 'RefWallIP' to calculate score for comparison of the thickness of the walls."""
if fem_compare_values(abs((self.thickness - self.current_wall.thickness / 1E3) /
self.current_wall.thickness / 1E3) * 100, 0.0):
return 100
elif fem_smaller(
abs((self.thickness - self.current_wall.thickness / 1E3) / self.current_wall.thickness / 1E3) * 100,
0.2):
return 90
else:
return 0
@property
def score_width(self) -> float:
""" Method of 'RefWallIP' to calculate score for comparison of the width of the walls."""
if fem_compare_values(abs((self.width - self.current_wall.width) / self.current_wall.width) * 100, 0.0):
return 100
elif fem_compare_values(abs((self.width - self.current_wall.width) / self.current_wall.width) * 100, 0.2):
return 90
else:
return 0
@property
def score_height(self) -> float:
""" Method of 'RefWallIP' to calculate score for comparison of the height of the walls."""
if fem_compare_values(abs((self.height - self.current_wall.height) / self.current_wall.height) * 100, 0.0):
return 100
elif fem_smaller(abs((self.height - self.current_wall.height) / self.current_wall.height) * 100, 0.2):
return 90
else:
return 0
@property
def z_top(self):
""" Returns the z-coordinate of the top-side of the wall of the reference object, in [m]."""
return self.__z_top
@property
def score_z_coordinate_top(self) -> float:
""" Method of 'RefWallIP' to calculate score for comparison of the z-coordinate of the top of the walls."""
return max([100 - abs((self.z_top - self.current_wall.z_top) / self.current_wall.z_top) * 100, 0])
@property
def score_layer(self):
"""Method of RefWallIP to determine the score of the wall based on its layer compared to the current wall"""
if self.layer == self.current_wall.layer:
return 100
else:
return 0
@property
def score_density(self) -> float:
""" Method of 'RefWallIP' to calculate score for comparison of the density of the walls."""
return max([100 - abs((self.density - self.current_wall.density) / self.current_wall.density) * 100, 0])
@property
def score_material(self) -> float:
""" Method of 'RefWallIP' to calculate score for comparison of the material of the walls."""
# Check if materials are the same (and lin_check)
if self.current_wall.material in self.material:
if ('LIN' in self.current_wall.material) == ('LIN' in self.material):
return 100
return 50
return 0
@property
def score_wall_type(self) -> float:
""" Method of 'RefWallIP' to calculate score for comparison of the wall-type (inner or facade) of the walls."""
if self.wall_type == self.current_wall.wall_type:
return 100
return 0
@property
def score(self) -> float:
""" Method of 'RefWallIP' to calculate total score for comparison of the current wall and reference wall."""
scores = [score for score in [
self.score_thickness, self.score_width, self.score_height, self.score_density,
self.score_material, self.score_wall_type, self.score_layer] if score is not None]
return sum(scores) / len(scores)
[docs] def to_report(self) -> Dict[str, Union[str, float]]:
""" Method of 'RefWallIP' to convert data for the report."""
return {
'Object part': self.objectpart,
'Wall name': self.name,
'Layer': self.layer,
'Wall ID': self.wall_id,
'Material': self.material,
'Density [kg/m3]': self.density,
'Thickness [mm]': self.thickness * 1000,
'Width [m]': self.width,
'Height [m]': self.height,
'Wall type': self.wall_type,
'Measures in object part': self.measures}
[docs] def to_score(self) -> Dict[str, Union[str, float]]:
""" Method of 'RefWallIP' to score the wall."""
return {
'Score: thickness': self.score_thickness,
'Score: width': self.score_width,
'Score: height': self.score_height,
'Score: density': self.score_density,
'Score: material': self.score_material,
'Score: wall type': self.score_wall_type,
'Score: layer': self.score_layer,
'Total Score': self.score}
[docs] def to_table(self) -> Dict[str, Union[str, float]]:
""" Method of 'RefWallIP' to convert data for a table."""
return {
'objectpart': self.objectpart,
'name': self.name,
'layer': self.layer,
'wall_ID': self.wall_id,
'material': self.material,
'density': self.density,
'thickness': self.thickness,
'width': self.width,
'height': self.height,
'wall_type': self.wall_type}
### ===================================================================================================================
### 3. End of script
### ===================================================================================================================