Coverage for teaser/data/input/buildingelement_input_json.py: 81%

47 statements  

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

1"""This module contains function to load building element classes.""" 

2 

3from teaser.logic.buildingobjects.buildingphysics.layer import Layer 

4from teaser.logic.buildingobjects.buildingphysics.material import Material 

5import teaser.data.input.material_input_json as mat_input 

6import logging 

7 

8def load_type_element(element, year, construction, data_class, 

9 element_type=None, reverse_layers=False): 

10 """Load BuildingElement from json. 

11 

12 Loads typical building elements according to their construction year and 

13 their construction type from a JSON. The elements are created by using 

14 building characteristics from 

15 cite:`BundesministeriumfurVerkehrBauundStadtentwicklung.26.07.2007` and 

16 :cite:`KurzverfahrenIWU`, which is combined with normative material data 

17 from :cite:`VereinDeutscherIngenieure.2012b`. 

18 

19 Most of the elements for the KfW Efficiency House standards (TypeElements_KFW.json) were derived from the respective 

20 required U-value and the component catalog of the U-value online calculator https://www.ubakus.de/bauteilkatalog/. 

21 For the respective source of each element, the comment in the json file can be observed. 

22 

23 Parameters 

24 ---------- 

25 element : BuildingElement() 

26 Instance of BuildingElement or inherited Element of TEASER 

27 

28 year : int 

29 Year of construction 

30 

31 construction : str 

32 Construction type, code list ('iwu_heavy', 'iwu_light', 'tabula_de_standard', 'kfw_40', ...) 

33 

34 data_class : DataClass() 

35 DataClass containing the bindings for TypeBuildingElement and 

36 Material (typically this is the data class stored in prj.data, 

37 but the user can individually change that. 

38 

39 element_type : str 

40 Element type to load - only to specify if the data_class entry for a 

41 different type than type(element) is to be loaded, e.g. InnerWall 

42 instead of OuterWall 

43 

44 reverse_layers : bool 

45 defines if layer list should be reversed - this is necessary for zone 

46 borders to maintain consistency 

47 

48 """ 

49 element_binding = data_class.element_bind 

50 

51 if element_type is None: 

52 element_type = type(element).__name__ 

53 

54 for key, element_in in element_binding.items(): 

55 if ( 

56 element_in["building_age_group"][0] 

57 <= year 

58 <= element_in["building_age_group"][1] 

59 and element_in["construction_data"] == construction 

60 and key.startswith(element_type) 

61 ): 

62 _set_basic_data(element=element, element_in=element_in) 

63 for id, layer_in in ( 

64 element_in["layer"].items().__reversed__() 

65 if reverse_layers else element_in["layer"].items() 

66 ): 

67 layer = Layer(element) 

68 layer.id = id 

69 layer.thickness = layer_in["thickness"] 

70 material = Material(layer) 

71 mat_input.load_material_id( 

72 material, layer_in["material"]["material_id"], data_class 

73 ) 

74 return 

75 logging.warning(f"No database entry found for construction={construction}, " 

76 f"year{year}, element={type(element).__name__}") 

77 

78 

79def load_type_element_by_key(element, type_element_key, data_class, 

80 reverse_layers=False): 

81 """Load BuildingElement from json by key string. 

82 

83 Loads typical building elements according to their key string from a JSON. 

84 The elements are created by using building characteristics from 

85 cite:`BundesministeriumfurVerkehrBauundStadtentwicklung.26.07.2007` and 

86 :cite:`KurzverfahrenIWU`, which is combined with normative material data 

87 from :cite:`VereinDeutscherIngenieure.2012b`. 

88 

89 Parameters 

90 ---------- 

91 element : BuildingElement() 

92 Instance of BuildingElement or inherited Element of TEASER 

93 

94 type_element_key : str 

95 key string to the type element of the building characteristics sources 

96 

97 data_class : DataClass() 

98 DataClass containing the bindings for TypeBuildingElement and 

99 Material (typically this is the data class stored in prj.data, 

100 but the user can individually change that. 

101 

102 reverse_layers : bool 

103 defines if layer list should be reversed 

104 

105 """ 

106 element_binding = data_class.element_bind 

107 

108 element_in = element_binding[type_element_key] 

109 

110 _set_basic_data(element=element, element_in=element_in) 

111 for id, layer_in in ( 

112 element_in["layer"].items().__reversed__() 

113 if reverse_layers else element_in["layer"].items() 

114 ): 

115 layer = Layer(element) 

116 layer.id = id 

117 layer.thickness = layer_in["thickness"] 

118 material = Material(layer) 

119 mat_input.load_material_id( 

120 material, layer_in["material"]["material_id"], data_class 

121 ) 

122 

123 

124def _set_basic_data(element, element_in): 

125 """Set basic data for building elements. 

126 

127 Helper function to set basic data to the BuildingElement class. 

128 

129 Parameters 

130 ---------- 

131 element : BuildingElement 

132 BuildingElement 

133 element_in : 

134 json string of input data 

135 

136 """ 

137 element.building_age_group = element_in["building_age_group"] 

138 element.construction_data = element_in["construction_data"] 

139 element.inner_radiation = element_in["inner_radiation"] 

140 element.inner_convection = element_in["inner_convection"] 

141 

142 if ( 

143 type(element).__name__ == "OuterWall" 

144 or type(element).__name__ == "Rooftop" 

145 or type(element).__name__ == "Door" 

146 ): 

147 element.outer_radiation = element_in["outer_radiation"] 

148 element.outer_convection = element_in["outer_convection"] 

149 

150 elif type(element).__name__ == "Window": 

151 element.outer_radiation = element_in["outer_radiation"] 

152 element.outer_convection = element_in["outer_convection"] 

153 element.g_value = element_in["g_value"] 

154 element.a_conv = element_in["a_conv"] 

155 element.shading_g_total = element_in["shading_g_total"] 

156 element.shading_max_irr = element_in["shading_max_irr"] 

157 

158 if type(element).__name__.startswith("Interzonal"): 

159 element.outer_radiation = element_in["inner_radiation"] 

160 element.outer_convection = element_in["inner_convection"]