Coverage for teaser/logic/buildingobjects/buildingphysics/layer.py: 84%

49 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2025-04-29 16:01 +0000

1# created June 2015 

2# by TEASER4 Development Team 

3 

4 

5import random 

6 

7 

8class Layer(object): 

9 """Layer class 

10 

11 This class holds information of a layer of a specific building element. 

12 

13 Parameters 

14 ---------- 

15 parent : BuildingElement 

16 The parent class of this object, the Building Element the layer 

17 belongs to. Allows for better control of hierarchical structures. If 

18 not None this adds the Layer to BuildingElement.layers. 

19 Default is None 

20 

21 

22 Attributes 

23 ---------- 

24 id : int 

25 Position (starting from 0 and the inner side) 

26 material : Material() 

27 Material class of TEASER 

28 thickness : float [m] 

29 Thickness of the layer 

30 """ 

31 

32 def __init__(self, parent=None, id=0, parent_position=None): 

33 """Constructor of Layer. 

34 

35 

36 """ 

37 self.parent = (parent, parent_position) 

38 self.internal_id = random.random() 

39 self.id = id 

40 self._material = None 

41 self._thickness = 0.0 

42 

43 @property 

44 def parent(self): 

45 return self.__parent 

46 

47 @parent.setter 

48 def parent(self, value): 

49 

50 if type(value) == tuple: 

51 position = value[1] 

52 value = value[0] 

53 else: 

54 position = None 

55 

56 if value is not None: 

57 

58 ass_error_1 = "Parent has to be an instance of a BE" 

59 

60 assert type(value).__name__ == "OuterWall" \ 

61 or type(value).__name__ == "Rooftop" \ 

62 or type(value).__name__ == "GroundFloor" \ 

63 or type(value).__name__ == "InnerWall" \ 

64 or type(value).__name__ == "Ceiling" \ 

65 or type(value).__name__ == "Floor" \ 

66 or type(value).__name__ == "InterzonalWall"\ 

67 or type(value).__name__ == "InterzonalCeiling"\ 

68 or type(value).__name__ == "InterzonalFloor"\ 

69 or type(value).__name__ == "Door" \ 

70 or type(value).__name__ == "Window", ass_error_1 

71 

72 self.__parent = value 

73 self.__parent.add_layer(self, position=position) 

74 

75 else: 

76 self.__parent = None 

77 

78 @property 

79 def material(self): 

80 return self._material 

81 

82 @material.setter 

83 def material(self, value): 

84 ass_error_1 = "Material has to be an instance of Material()" 

85 

86 assert type(value).__name__ == ("Material"), ass_error_1 

87 

88 self._material = value 

89 

90 @property 

91 def thickness(self): 

92 return self._thickness 

93 

94 @thickness.setter 

95 def thickness(self, value): 

96 

97 if isinstance(value, float): 

98 pass 

99 elif value is None: 

100 pass 

101 else: 

102 try: 

103 value = float(value) 

104 except: 

105 raise ValueError("Can't convert thickness to float") 

106 

107 if value is not None: 

108 self._thickness = float(value) 

109 

110 if self.material is not None and self.parent is not None: 

111 if vars(self.material)['_thermal_conduc'] != 0: 

112 self.parent.calc_ua_value()