Coverage for bim2sim / plugins / PluginComfort / test / integration / test_comfort.py: 0%

178 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2025-12-18 09:34 +0000

1import sys 

2import unittest 

3from shutil import copyfile, copytree, rmtree 

4from pathlib import Path 

5 

6import os 

7 

8import bim2sim 

9from bim2sim.kernel.decision.decisionhandler import DebugDecisionHandler 

10from bim2sim.utilities.test import IntegrationBase 

11from bim2sim.utilities.types import IFCDomain 

12 

13# raise unittest.SkipTest("Integration tests not reliable for automated use") 

14sample_root = Path(__file__).parent.parent.parent / 'test/resources/arch/ifc' 

15DEBUG_COMFORT = False 

16 

17 

18class IntegrationBaseComfort(IntegrationBase): 

19 # HACK: We have to remember stderr because eppy resets it currently. 

20 def setUp(self): 

21 self.old_stderr = sys.stderr 

22 self.working_dir = os.getcwd() 

23 super().setUp() 

24 

25 def tearDown(self): 

26 if DEBUG_COMFORT: # copy EP-results to home directory for further 

27 # debugging. 

28 if not os.path.exists(Path.home() / 'idf'): 

29 os.mkdir(Path.home() / 'idf') 

30 ifc_name = str(os.listdir(self.project.paths.ifc)[0].split('.ifc')[0]) 

31 temp_dir = Path(self.project.paths.export) / 'EnergyPlus'/\ 

32 'SimResults'/self.project.name 

33 debug_dir = Path.home() / 'idf' / Path(ifc_name + '_EP-results/') 

34 if os.path.exists(debug_dir): 

35 rmtree(debug_dir) 

36 copytree(temp_dir, debug_dir) 

37 try: 

38 copyfile(Path(self.project.paths.export) 

39 / Path(ifc_name + "_combined_STL.stl"), 

40 str(debug_dir) + '/' + str(ifc_name) + "_combined_STL.stl") 

41 copyfile(Path(self.project.paths.export) 

42 / Path(ifc_name + "_space_combined_STL.stl"), 

43 str(debug_dir) + '/' + str(ifc_name) + "_space_combined_STL.stl") 

44 except: 

45 print('No STL for CFD found. ') 

46 copyfile(str(debug_dir) + "/eplusout.expidf", 

47 str(debug_dir) + "/eplusout.idf") 

48 os.chdir(self.working_dir) 

49 sys.stderr = self.old_stderr 

50 super().tearDown() 

51 

52 def model_domain_path(self) -> str: 

53 return 'arch' 

54 

55 def weather_file_path(self) -> Path: 

56 return (self.test_resources_path() / 

57 'weather_files/DEU_NW_Aachen.105010_TMYx.epw') 

58 

59 

60class TestComfortIntegration(IntegrationBaseComfort, unittest.TestCase): 

61 """ 

62 Integration tests for multiple IFC example files. 

63 Tested are both original IFC files and files from Eric Fichter's Space Boundary Generation tool. 

64 """ 

65 # @unittest.skip("") 

66 def test_base_01_FZK_full_run(self): 

67 """Test Original IFC File from FZK-Haus (KIT)""" 

68 ifc_names = {IFCDomain.arch: 'AC20-FZK-Haus.ifc'} 

69 project = self.create_project(ifc_names, 'comfort') 

70 project.sim_settings.create_external_elements = True 

71 project.sim_settings.split_bounds = True 

72 project.sim_settings.add_shadings = True 

73 project.sim_settings.split_shadings = True 

74 project.sim_settings.run_full_simulation = True 

75 project.sim_settings.rename_plot_keys = True 

76 project.sim_settings.create_plots = True 

77 # project.sim_settings.ep_install_path = 'C://EnergyPlusV9-4-0/' 

78 answers = () 

79 handler = DebugDecisionHandler(answers) 

80 for decision, answer in handler.decision_answer_mapping(project.run()): 

81 decision.value = answer 

82 self.assertEqual(0, handler.return_value) 

83 

84 @unittest.skip("") 

85 def test_base_02_FZK_design_day(self): 

86 """Test Original IFC File from FZK-Haus (KIT)""" 

87 ifc_names = {IFCDomain.arch: 'AC20-FZK-Haus.ifc'} 

88 project = self.create_project(ifc_names, 'comfort') 

89 project.sim_settings.run_full_simulation = False 

90 # project.sim_settings.ep_install_path = 'C://EnergyPlusV9-4-0/' 

91 answers = () 

92 handler = DebugDecisionHandler(answers) 

93 return_code = handler.handle(project.run()) 

94 self.assertEqual(0, return_code) 

95 

96 # @unittest.skip("") 

97 def test_base_03_FZK_SB_design_day(self): 

98 """Test IFC File from FZK-Haus (KIT) with generated Space Boundaries""" 

99 # ifc_names = {IFCDomain.arch: 'AC20-FZK-Haus_with_SB44.ifc'} 

100 ifc_names = {IFCDomain.arch: 'AC20-FZK-Haus_with_SB55.ifc'} 

101 project = self.create_project(ifc_names, 'comfort') 

102 project.sim_settings.create_external_elements = True 

103 project.sim_settings.prj_custom_usages = Path( 

104 bim2sim.__file__).parent.parent / \ 

105 "test/resources/arch/custom_usages/" \ 

106 "customUsagesAC20-FZK-Haus_with_SB55.json" 

107 # project.sim_settings.ep_install_path = 'C://EnergyPlusV9-4-0/' 

108 answers = ('Other',) 

109 handler = DebugDecisionHandler(answers) 

110 return_code = handler.handle(project.run()) 

111 self.assertEqual(0, return_code) 

112 

113 @unittest.skip("") 

114 def test_base_04_FZK_SB_full_run(self): 

115 """Test IFC File from FZK-Haus (KIT) with generated Space Boundaries""" 

116 # ifc_names = {IFCDomain.arch: 'AC20-FZK-Haus_with_SB44.ifc'} 

117 ifc_names = {IFCDomain.arch: 'AC20-FZK-Haus_with_SB55.ifc'} 

118 project = self.create_project(ifc_names, 'comfort') 

119 project.sim_settings.create_external_elements = True 

120 project.sim_settings.run_full_simulation = True 

121 project.sim_settings.prj_use_conditions = Path( 

122 bim2sim.__file__).parent.parent / \ 

123 "test/resources/arch/custom_usages/" \ 

124 "UseConditionsAC20-FZK-Haus_with_SB55.json" 

125 project.sim_settings.prj_custom_usages = Path( 

126 bim2sim.__file__).parent.parent / \ 

127 "test/resources/arch/custom_usages/" \ 

128 "customUsagesAC20-FZK-Haus_with_SB55.json" 

129 answers = ('Other',) 

130 handler = DebugDecisionHandler(answers) 

131 return_code = handler.handle(project.run()) 

132 self.assertEqual(0, return_code) 

133 

134 # @unittest.skip("") 

135 def test_base_05_KIT_Inst_design_day(self): 

136 """Test Original IFC File from Institute (KIT)""" 

137 ifc_names = {IFCDomain.arch: 'AC20-Institute-Var-2.ifc'} 

138 project = self.create_project(ifc_names, 'comfort') 

139 project.sim_settings.create_external_elements = True 

140 answers = (2015,) 

141 # project.sim_settings.ep_install_path = 'C://EnergyPlusV9-4-0/' 

142 handler = DebugDecisionHandler(answers) 

143 for decision, answer in handler.decision_answer_mapping(project.run()): 

144 decision.value = answer 

145 self.assertEqual(0, handler.return_value, 

146 "Project did not finish successfully.") 

147 

148 @unittest.skip("") 

149 def test_base_06_KIT_Inst_full_run(self): 

150 """Test Original IFC File from Institute (KIT)""" 

151 ifc_names = {IFCDomain.arch: 'AC20-Institute-Var-2.ifc'} 

152 project = self.create_project(ifc_names, 'comfort') 

153 project.sim_settings.create_external_elements = True 

154 project.sim_settings.run_full_simulation = True 

155 answers = (2015, ) 

156 handler = DebugDecisionHandler(answers) 

157 return_code = handler.handle(project.run()) 

158 self.assertEqual(0, return_code) 

159 

160 @unittest.skip("Skipped due to performance for CI") 

161 def test_base_07_KIT_Inst_SB_design_day(self): 

162 """Test IFC File from Institute (KIT) with generated Space Boundaries""" 

163 ifc_names = {IFCDomain.arch: 'AC20-Institute-Var-2_with_SB-1-0.ifc'} 

164 project = self.create_project(ifc_names, 'comfort') 

165 project.sim_settings.create_external_elements = True 

166 # project.sim_settings.ep_install_path = 'C://EnergyPlusV9-4-0/' 

167 project.sim_settings.prj_custom_usages = Path( 

168 bim2sim.__file__).parent.parent / \ 

169 "test/resources/arch/custom_usages/" \ 

170 "customUsagesAC20-Institute-Var-2_with_SB-1-0.json" 

171 answers = ('Other', 2015) 

172 handler = DebugDecisionHandler(answers) 

173 return_code = handler.handle(project.run()) 

174 self.assertEqual(0, return_code) 

175 

176 @unittest.skip("Skipped due to performance for CI") 

177 def test_base_08_KIT_Inst_SB_full_run(self): 

178 """Test IFC File from Institute (KIT) with generated Space Boundaries""" 

179 ifc_names = {IFCDomain.arch: 'AC20-Institute-Var-2_with_SB-1-0.ifc'} 

180 project = self.create_project(ifc_names, 'comfort') 

181 project.sim_settings.create_external_elements = True 

182 project.sim_settings.run_full_simulation = True 

183 project.sim_settings.prj_custom_usages = Path( 

184 bim2sim.__file__).parent.parent / \ 

185 "test/resources/arch/custom_usages/" \ 

186 "customUsagesAC20-Institute-Var-2_with_SB-1-0.json" 

187 answers = ('Other', 2015) 

188 handler = DebugDecisionHandler(answers) 

189 return_code = handler.handle(project.run()) 

190 self.assertEqual(0, return_code) 

191 

192 @unittest.skip("") 

193 def test_DigitalHub_SB89(self): 

194 """Test DigitalHub IFC, includes regression test""" 

195 ifc_names = {IFCDomain.arch: 'FM_ARC_DigitalHub_with_SB89.ifc'} 

196 project = self.create_project(ifc_names, 'comfort') 

197 project.sim_settings.create_external_elements = True 

198 project.sim_settings.cooling_tz_overwrite = True 

199 project.sim_settings.construction_class_windows = \ 

200 'Waermeschutzverglasung, dreifach' 

201 project.sim_settings.prj_use_conditions = Path( 

202 bim2sim.__file__).parent.parent / \ 

203 "test/resources/arch/custom_usages/" \ 

204 "UseConditionsFM_ARC_DigitalHub.json" 

205 project.sim_settings.prj_custom_usages = Path( 

206 bim2sim.__file__).parent.parent / \ 

207 "test/resources/arch/custom_usages/" \ 

208 "customUsagesFM_ARC_DigitalHub_with_SB89.json" 

209 space_boundary_genenerator = 'Other' 

210 handle_proxies = (*(None,)*12,) 

211 construction_year = 2015 

212 project.sim_settings.split_bounds = False 

213 project.sim_settings.add_shadings = True 

214 project.sim_settings.split_shadings = False 

215 project.sim_settings.run_full_simulation = False 

216 answers = (space_boundary_genenerator, 

217 *handle_proxies, 

218 construction_year, 

219 project.sim_settings.split_bounds, 

220 project.sim_settings.add_shadings, 

221 project.sim_settings.split_shadings, 

222 project.sim_settings.run_full_simulation) 

223 handler = DebugDecisionHandler(answers) 

224 return_code = handler.handle(project.run()) 

225 self.assertEqual(0, return_code) 

226 

227 @unittest.skip("Skipped due to performance for CI") 

228 def test_base_09_DH_design_day(self): 

229 """Test DigitalHub IFC""" 

230 ifc_names = {IFCDomain.arch: 'FM_ARC_DigitalHub_fixed002.ifc'} 

231 project = self.create_project(ifc_names, 'comfort') 

232 project.sim_settings.create_external_elements = True 

233 project.sim_settings.prj_use_conditions = Path( 

234 bim2sim.__file__).parent.parent / \ 

235 "test/resources/arch/custom_usages/" \ 

236 "UseConditionsFM_ARC_DigitalHub.json" 

237 project.sim_settings.prj_custom_usages = Path( 

238 bim2sim.__file__).parent.parent / \ 

239 "test/resources/arch/custom_usages/" \ 

240 "customUsagesFM_ARC_DigitalHub_fixed002.json" 

241 space_boundary_genenerator = 'Other' 

242 handle_proxies = (*(None,)*12,) 

243 construction_year = 2015 

244 project.sim_settings.split_bounds = True 

245 project.sim_settings.add_shadings = True 

246 project.sim_settings.split_shadings = True 

247 project.sim_settings.run_full_simulation = True 

248 answers = (space_boundary_genenerator, 

249 *handle_proxies, 

250 construction_year, 

251 project.sim_settings.split_bounds, 

252 project.sim_settings.add_shadings, 

253 project.sim_settings.split_shadings, 

254 project.sim_settings.run_full_simulation) 

255 handler = DebugDecisionHandler(answers) 

256 return_code = handler.handle(project.run()) 

257 self.assertEqual(0, return_code) 

258 

259 # @unittest.skip("Skipped due to performance for CI") 

260 def test_base_13_EDC_SB_design_day(self): 

261 """Test KIT KHH 3 storey IFC with generated Space Boundaries""" 

262 ifc_names = {IFCDomain.arch: 'KIT-EDC_with_SB.ifc'} 

263 project = self.create_project(ifc_names, 'comfort') 

264 project.sim_settings.create_external_elements = True 

265 project.sim_settings.split_bounds = True 

266 project.sim_settings.add_shadings = True 

267 project.sim_settings.split_shadings = True 

268 project.sim_settings.run_full_simulation = False 

269 # project.sim_settings.ep_install_path = 'C://EnergyPlusV9-4-0/' 

270 

271 project.sim_settings.prj_custom_usages = Path( 

272 bim2sim.__file__).parent.parent / \ 

273 "test/resources/arch/custom_usages/" \ 

274 "customUsagesKIT-EDC_with_SB.json" 

275 answers = ('Other', 'Other', 2015) 

276 handler = DebugDecisionHandler(answers) 

277 return_code = handler.handle(project.run()) 

278 self.assertEqual(0, return_code) 

279 

280 

281 

282if __name__ == '__main__': 

283 unittest.main()