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
« 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
5import random
8class Layer(object):
9 """Layer class
11 This class holds information of a layer of a specific building element.
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
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 """
32 def __init__(self, parent=None, id=0, parent_position=None):
33 """Constructor of Layer.
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
43 @property
44 def parent(self):
45 return self.__parent
47 @parent.setter
48 def parent(self, value):
50 if type(value) == tuple:
51 position = value[1]
52 value = value[0]
53 else:
54 position = None
56 if value is not None:
58 ass_error_1 = "Parent has to be an instance of a BE"
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
72 self.__parent = value
73 self.__parent.add_layer(self, position=position)
75 else:
76 self.__parent = None
78 @property
79 def material(self):
80 return self._material
82 @material.setter
83 def material(self, value):
84 ass_error_1 = "Material has to be an instance of Material()"
86 assert type(value).__name__ == ("Material"), ass_error_1
88 self._material = value
90 @property
91 def thickness(self):
92 return self._thickness
94 @thickness.setter
95 def thickness(self, value):
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")
107 if value is not None:
108 self._thickness = float(value)
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()