Coverage for teaser/examples/e6_generate_building.py: 98%

125 statements  

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

1# # Example 7: Generate single building 

2# This module contains an example that shows to create a building not using 

3# the archetype approach but adding all information separately. In this example 

4# we import all needed modules and classes where we need it in the code. For you 

5# application we suggest to use PEP008 and import them at the beginning of the 

6# script. 

7# You can run this example using the [jupyter-notebook](https://mybinder.org/v2/gh/RWTH-EBC/TEASER/main?labpath=docs%2Fjupyter_notebooks) 

8 

9 

10 

11def example_create_building(): 

12 """This function demonstrates generating a building adding all 

13 information separately""" 

14 

15 # First step: Import the TEASER API (called Project) into your Python module 

16 

17 from teaser.project import Project 

18 from teaser.data.utilities import ConstructionData 

19 from teaser.data.dataclass import DataClass 

20 

21 # To use the API, instantiate the Project class and rename the project. 

22 

23 prj = Project() 

24 prj.name = "BuildingExample" 

25 prj.data = DataClass(construction_data=ConstructionData.iwu_heavy) 

26 

27 # Instantiate a Building class and set the Project API as a parent to 

28 # this building. This will automatically add this building and all its 

29 # future changes to the project. This is helpful as we can use the data 

30 # base and API functions (like explained in e2 - e5). We also set some 

31 # building parameters. Be careful: Dymola does not like whitespaces in 

32 # names and filenames, thus we will delete them anyway in TEASER. 

33 

34 from teaser.logic.buildingobjects.building import Building 

35 

36 bldg = Building(parent=prj) 

37 bldg.name = "SuperExampleBuilding" 

38 bldg.street_name = "AwesomeAvenue42" 

39 bldg.city = "46325FantasticTown" 

40 bldg.year_of_construction = 2015 

41 bldg.number_of_floors = 1 

42 bldg.height_of_floors = 3.5 

43 

44 # Instantiate a ThermalZone class and set the Building as a parent of it. 

45 # Set some parameters of the thermal zone. Be careful: Dymola does not 

46 # like whitespaces in names and filenames, thus we will delete them 

47 # anyway in TEASER. 

48 

49 from teaser.logic.buildingobjects.thermalzone import ThermalZone 

50 

51 tz = ThermalZone(parent=bldg) 

52 tz.name = "LivingRoom" 

53 tz.area = 140.0 

54 tz.volume = tz.area * bldg.number_of_floors * bldg.height_of_floors 

55 

56 # Instantiate BoundaryConditions and load conditions for `Living`. 

57 

58 from teaser.logic.buildingobjects.useconditions \ 

59 import UseConditions 

60 

61 tz.use_conditions = UseConditions(parent=tz) 

62 tz.use_conditions.load_use_conditions("Living", prj.data) 

63 

64 # Define two building elements reflecting a pitched roof (south = 180° and 

65 # north = 0°). Setting the the ThermalZone as a parent will automatically 

66 # assign this element to the thermal zone. We also set names, tilt and 

67 # coefficients for heat transfer on the inner and outer side of the 

68 # roofs. If the building has a flat roof, please use -1 as 

69 # orientation. Please read the docs to get more information on these 

70 # parameters. 

71 

72 from teaser.logic.buildingobjects.buildingphysics.rooftop import Rooftop 

73 

74 roof_south = Rooftop(parent=tz) 

75 roof_south.name = "Roof_South" 

76 roof_south.area = 75.0 

77 roof_south.orientation = 180.0 

78 roof_south.tilt = 55.0 

79 roof_south.inner_convection = 1.7 

80 roof_south.outer_convection = 20.0 

81 roof_south.inner_radiation = 5.0 

82 roof_south.outer_radiation = 5.0 

83 

84 roof_north = Rooftop(parent=tz) 

85 roof_north.name = "Roof_North" 

86 roof_north.area = 75.0 

87 roof_north.orientation = 0.0 

88 roof_north.tilt = 55.0 

89 roof_north.inner_convection = 1.7 

90 roof_north.outer_convection = 20.0 

91 roof_north.inner_radiation = 5.0 

92 roof_north.outer_radiation = 5.0 

93 

94 # To define the wall constructions we need to instantiate Layer and 

95 # Material objects and set attributes. id indicates the order of wall 

96 # construction from inside to outside (so 0 is on the inner surface). You 

97 # need to set this value! 

98 

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

100 

101 # First layer south 

102 

103 layer_s1 = Layer(parent=roof_south, id=0) 

104 layer_s1.thickness = 0.3 

105 

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

107 

108 material_s1 = Material(layer_s1) 

109 material_s1.name = "Insulation" 

110 material_s1.density = 120.0 

111 material_s1.heat_capac = 0.04 

112 material_s1.thermal_conduc = 1.0 

113 

114 # Second layer south 

115 

116 layer_s2 = Layer(parent=roof_south, id=1) 

117 layer_s2.thickness = 0.15 

118 

119 material_s2 = Material(layer_s2) 

120 material_s2.name = "Tile" 

121 material_s2.density = 1400.0 

122 material_s2.heat_capac = 0.6 

123 material_s2.thermal_conduc = 2.5 

124 

125 # First layer north 

126 

127 layer_n1 = Layer(parent=roof_north, id=0) 

128 layer_n1.thickness = 0.3 

129 

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

131 

132 material_n1 = Material(layer_n1) 

133 material_n1.name = "Insulation" 

134 material_n1.density = 120.0 

135 material_n1.heat_capac = 0.04 

136 material_n1.thermal_conduc = 1.0 

137 

138 # Second layer north 

139 

140 layer_n2 = Layer(parent=roof_north, id=1) 

141 layer_n2.thickness = 0.15 

142 

143 material_n2 = Material(layer_n2) 

144 material_n2.name = "Tile" 

145 material_n2.density = 1400.0 

146 material_n2.heat_capac = 0.6 

147 material_n2.thermal_conduc = 2.5 

148 

149 # Another option is to use the database for typical wall constructions, 

150 # but set area, tilt, orientation individually. To simplify code, 

151 # we save individual information for exterior walls, interior walls into 

152 # dictionaries. 

153 # outer walls 

154 # {'name_of_wall': [area, tilt, orientation]} 

155 # interior walls 

156 # {'name_of_wall': [area, tilt, orientation]} 

157 

158 from teaser.logic.buildingobjects.buildingphysics.outerwall import OuterWall 

159 

160 out_wall_dict = {"OuterWall_north": [10.0, 90.0, 0.0], 

161 "OuterWall_east": [14.0, 90.0, 90.0], 

162 "OuterWall_south": [10.0, 90.0, 180.0], 

163 "OuterWall_west": [14.0, 90.0, 270.0]} 

164 

165 # For ground floors the orientation is always -2 

166 

167 ground_floor_dict = {"GroundFloor": [100.0, 0.0, -2]} 

168 

169 from teaser.logic.buildingobjects.buildingphysics.innerwall import InnerWall 

170 

171 in_wall_dict = {"InnerWall1": [10.0], 

172 "InnerWall2": [14.0], 

173 "InnerWall3": [10.0]} 

174 

175 for key, value in out_wall_dict.items(): 

176 # Instantiate class, key is the name 

177 out_wall = OuterWall(parent=tz) 

178 out_wall.name = key 

179 # Use load_type_element() function of the building element, and pass 

180 # over the year of construction of the building and the type of 

181 # construction (in this case `heavy`). 

182 

183 out_wall.load_type_element( 

184 year=bldg.year_of_construction, 

185 construction='iwu_heavy') 

186 

187 # area, tilt and orientation need to be set individually. 

188 

189 out_wall.area = value[0] 

190 out_wall.tilt = value[1] 

191 out_wall.orientation = value[2] 

192 

193 # Repeat the procedure for inner walls and ground floors 

194 

195 for key, value in in_wall_dict.items(): 

196 

197 in_wall = InnerWall(parent=tz) 

198 in_wall.name = key 

199 in_wall.load_type_element( 

200 year=bldg.year_of_construction, 

201 construction='iwu_heavy') 

202 in_wall.area = value[0] 

203 

204 from teaser.logic.buildingobjects.buildingphysics.groundfloor import \ 

205 GroundFloor 

206 

207 for key, value in ground_floor_dict.items(): 

208 

209 ground = GroundFloor(parent=tz) 

210 ground.name = key 

211 ground.load_type_element( 

212 year=bldg.year_of_construction, 

213 construction='iwu_heavy') 

214 ground.area = value[0] 

215 ground.tilt = value[1] 

216 ground.orientation = value[2] 

217 

218 from teaser.logic.buildingobjects.buildingphysics.window import Window 

219 

220 win_dict = {"Window_east": [5.0, 90.0, 90.0], 

221 "Window_south": [8.0, 90.0, 180.0], 

222 "Window_west": [5.0, 90.0, 270.0]} 

223 

224 for key, value in win_dict.items(): 

225 

226 win = Window(parent=tz) 

227 win.name = key 

228 win.area = value[0] 

229 win.tilt = value[1] 

230 win.orientation = value[2] 

231 

232 # Additional to the already known attributes the window has 

233 # additional attributes. Window.g_value describes the solar gain 

234 # through windows, a_conv the convective heat transmission due to 

235 # absorption of the window on the inner side. shading_g_total and 

236 # shading_max_irr refers to the shading (solar gain reduction of the 

237 # shading and shading_max_irr the threshold of irradiance to 

238 # automatically apply shading). 

239 

240 win.inner_convection = 1.7 

241 win.inner_radiation = 5.0 

242 win.outer_convection = 20.0 

243 win.outer_radiation = 5.0 

244 win.g_value = 0.789 

245 win.a_conv = 0.03 

246 win.shading_g_total = 0.0 

247 win.shading_max_irr = 180.0 

248 

249 # One equivalent layer for windows 

250 

251 win_layer = Layer(parent=win) 

252 win_layer.id = 1 

253 win_layer.thickness = 0.024 

254 

255 # Material for glass 

256 

257 win_material = Material(win_layer) 

258 win_material.name = "GlasWindow" 

259 win_material.thermal_conduc = 0.067 

260 win_material.transmittance = 0.9 

261 return prj 

262 

263 

264if __name__ == '__main__': 

265 example_create_building() 

266 print("Example 6: That's it :)")