Coverage for bim2sim/plugins/PluginEnergyPlus/test/integration/test_energyplus.py: 0%
259 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-12 17:09 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-12 17:09 +0000
1import sys
2import unittest
3from shutil import copyfile, copytree, rmtree
4from pathlib import Path
6import os
8from energyplus_regressions.diffs import math_diff, table_diff
9from energyplus_regressions.diffs.thresh_dict import ThreshDict
11import bim2sim
12from bim2sim.kernel.decision.decisionhandler import DebugDecisionHandler
13from bim2sim.utilities.test import IntegrationBase
14from bim2sim.utilities.types import IFCDomain
16# raise unittest.SkipTest("Integration tests not reliable for automated use")
17sample_root = Path(__file__).parent.parent.parent / 'test/resources/arch/ifc'
18DEBUG_ENERGYPLUS = False
21class IntegrationBaseEP(IntegrationBase):
22 # HACK: We have to remember stderr because eppy resets it currently.
23 def setUp(self):
24 self.old_stderr = sys.stderr
25 self.working_dir = os.getcwd()
26 super().setUp()
28 def tearDown(self):
29 if DEBUG_ENERGYPLUS: # copy EP-results to home directory for further debugging.
30 if not os.path.exists(Path.home() / 'idf'):
31 os.mkdir(Path.home() / 'idf')
32 ifc_name = str(os.listdir(self.project.paths.ifc)[0].split('.ifc')[0])
33 temp_dir = Path(self.project.paths.export) / 'EnergyPlus'/\
34 'SimResults'/self.project.name
35 debug_dir = Path.home() / 'idf' / Path(ifc_name + '_EP-results/')
36 if os.path.exists(debug_dir):
37 rmtree(debug_dir)
38 copytree(temp_dir, debug_dir)
39 try:
40 copyfile(Path(self.project.paths.export)
41 / Path(ifc_name + "_combined_STL.stl"),
42 str(debug_dir) + '/' + str(ifc_name) + "_combined_STL.stl")
43 copyfile(Path(self.project.paths.export)
44 / Path(ifc_name + "_space_combined_STL.stl"),
45 str(debug_dir) + '/' + str(ifc_name) + "_space_combined_STL.stl")
46 except:
47 print('No STL for CFD found. ')
48 copyfile(str(debug_dir) + "/eplusout.expidf",
49 str(debug_dir) + "/eplusout.idf")
50 os.chdir(self.working_dir)
51 sys.stderr = self.old_stderr
52 super().tearDown()
55 def model_domain_path(self) -> str:
56 return 'arch'
58 def weather_file_path(self) -> Path:
59 return (self.test_resources_path() /
60 'weather_files/DEU_NW_Aachen.105010_TMYx.epw')
63class TestEPIntegration(IntegrationBaseEP, unittest.TestCase):
64 """
65 Integration tests for multiple IFC example files.
66 Tested are both original IFC files and files from Eric Fichter's Space Boundary Generation tool.
67 """
68 @unittest.skip("")
69 def test_base_01_FZK_design_day(self):
70 """Test Original IFC File from FZK-Haus (KIT)"""
71 ifc_names = {IFCDomain.arch: 'AC20-FZK-Haus.ifc'}
72 project = self.create_project(ifc_names, 'energyplus')
73 project.sim_settings.create_external_elements = True
74 project.sim_settings.split_bounds = True
75 project.sim_settings.add_shadings = True
76 project.sim_settings.split_shadings = True
77 project.sim_settings.run_full_simulation = True
78 # project.sim_settings.ep_install_path = 'C://EnergyPlusV9-4-0/'
80 answers = (project.sim_settings.split_bounds,
81 project.sim_settings.add_shadings,
82 project.sim_settings.split_shadings,
83 project.sim_settings.run_full_simulation)
84 handler = DebugDecisionHandler(answers)
85 for decision, answer in handler.decision_answer_mapping(project.run()):
86 decision.value = answer
87 self.assertEqual(0, handler.return_value)
89 @unittest.skip("")
90 def test_base_02_FZK_full_run(self):
91 """Test Original IFC File from FZK-Haus (KIT)"""
92 ifc_names = {IFCDomain.arch: 'AC20-FZK-Haus.ifc'}
93 project = self.create_project(ifc_names, 'energyplus')
94 project.sim_settings.create_external_elements = True
95 project.sim_settings.run_full_simulation = True
96 answers = ()
97 handler = DebugDecisionHandler(answers)
98 return_code = handler.handle(project.run())
99 self.assertEqual(0, return_code)
101 # @unittest.skip("")
102 def test_base_03_FZK_SB_design_day(self):
103 """Test IFC File from FZK-Haus (KIT) with generated Space Boundaries"""
104 # ifc_names = {IFCDomain.arch: 'AC20-FZK-Haus_with_SB44.ifc'}
105 ifc_names = {IFCDomain.arch: 'AC20-FZK-Haus_with_SB55.ifc'}
106 project = self.create_project(ifc_names, 'energyplus')
107 project.sim_settings.create_external_elements = True
108 project.sim_settings.prj_custom_usages = Path(
109 bim2sim.__file__).parent.parent / \
110 "test/resources/arch/custom_usages/" \
111 "customUsagesAC20-FZK-Haus_with_SB55.json"
112 # project.sim_settings.ep_install_path = 'C://EnergyPlusV9-4-0/'
113 answers = ('Other',)
114 handler = DebugDecisionHandler(answers)
115 return_code = handler.handle(project.run())
116 self.assertEqual(0, return_code)
118 @unittest.skip("")
119 def test_base_04_FZK_SB_full_run(self):
120 """Test IFC File from FZK-Haus (KIT) with generated Space Boundaries"""
121 # ifc_names = {IFCDomain.arch: 'AC20-FZK-Haus_with_SB44.ifc'}
122 ifc_names = {IFCDomain.arch: 'AC20-FZK-Haus_with_SB55.ifc'}
123 project = self.create_project(ifc_names, 'energyplus')
124 project.sim_settings.create_external_elements = True
125 project.sim_settings.run_full_simulation = True
126 project.sim_settings.prj_use_conditions = Path(
127 bim2sim.__file__).parent.parent / \
128 "test/resources/arch/custom_usages/" \
129 "UseConditionsAC20-FZK-Haus_with_SB55.json"
130 project.sim_settings.prj_custom_usages = Path(
131 bim2sim.__file__).parent.parent / \
132 "test/resources/arch/custom_usages/" \
133 "customUsagesAC20-FZK-Haus_with_SB55.json"
134 answers = ('Other',)
135 handler = DebugDecisionHandler(answers)
136 return_code = handler.handle(project.run())
137 self.assertEqual(0, return_code)
139 # @unittest.skip("")
140 def test_base_05_KIT_Inst_design_day(self):
141 """Test Original IFC File from Institute (KIT)"""
142 ifc_names = {IFCDomain.arch: 'AC20-Institute-Var-2.ifc'}
143 project = self.create_project(ifc_names, 'energyplus')
144 project.sim_settings.create_external_elements = True
145 answers = (2015,)
146 # project.sim_settings.ep_install_path = 'C://EnergyPlusV9-4-0/'
148 handler = DebugDecisionHandler(answers)
149 for decision, answer in handler.decision_answer_mapping(project.run()):
150 decision.value = answer
151 self.assertEqual(0, handler.return_value,
152 "Project did not finish successfully.")
154 @unittest.skip("")
155 def test_base_06_KIT_Inst_full_run(self):
156 """Test Original IFC File from Institute (KIT)"""
157 ifc_names = {IFCDomain.arch: 'AC20-Institute-Var-2.ifc'}
158 project = self.create_project(ifc_names, 'energyplus')
159 project.sim_settings.create_external_elements = True
160 project.sim_settings.run_full_simulation = True
161 answers = (2015, )
162 handler = DebugDecisionHandler(answers)
163 return_code = handler.handle(project.run())
164 self.assertEqual(0, return_code)
166 # @unittest.skip("Skipped due to performance for CI")
167 def test_base_07_KIT_Inst_SB_design_day(self):
168 """Test IFC File from Institute (KIT) with generated Space Boundaries"""
169 ifc_names = {IFCDomain.arch: 'AC20-Institute-Var-2_with_SB-1-0.ifc'}
170 project = self.create_project(ifc_names, 'energyplus')
171 project.sim_settings.create_external_elements = True
172 # project.sim_settings.ep_install_path = 'C://EnergyPlusV9-4-0/'
174 project.sim_settings.prj_custom_usages = Path(
175 bim2sim.__file__).parent.parent / \
176 "test/resources/arch/custom_usages/" \
177 "customUsagesAC20-Institute-Var-2_with_SB-1-0.json"
178 answers = ('Other', 2015)
179 handler = DebugDecisionHandler(answers)
180 return_code = handler.handle(project.run())
181 self.assertEqual(0, return_code)
183 @unittest.skip("Skipped due to performance for CI")
184 def test_base_08_KIT_Inst_SB_full_run(self):
185 """Test IFC File from Institute (KIT) with generated Space Boundaries"""
186 ifc_names = {IFCDomain.arch: 'AC20-Institute-Var-2_with_SB-1-0.ifc'}
187 project = self.create_project(ifc_names, 'energyplus')
188 project.sim_settings.create_external_elements = True
189 project.sim_settings.run_full_simulation = True
190 project.sim_settings.prj_custom_usages = Path(
191 bim2sim.__file__).parent.parent / \
192 "test/resources/arch/custom_usages/" \
193 "customUsagesAC20-Institute-Var-2_with_SB-1-0.json"
194 answers = ('Other', 2015)
195 handler = DebugDecisionHandler(answers)
196 return_code = handler.handle(project.run())
197 self.assertEqual(0, return_code)
199 @unittest.skip("")
200 def test_DigitalHub_SB89(self):
201 """Test DigitalHub IFC, includes regression test"""
202 ifc_names = {IFCDomain.arch: 'FM_ARC_DigitalHub_with_SB89.ifc'}
203 project = self.create_project(ifc_names, 'energyplus')
204 project.sim_settings.create_external_elements = True
205 project.sim_settings.cooling_tz_overwrite = True
206 project.sim_settings.construction_class_windows = \
207 'Waermeschutzverglasung, dreifach'
208 project.sim_settings.prj_use_conditions = Path(
209 bim2sim.__file__).parent.parent / \
210 "test/resources/arch/custom_usages/" \
211 "UseConditionsFM_ARC_DigitalHub.json"
212 project.sim_settings.prj_custom_usages = Path(
213 bim2sim.__file__).parent.parent / \
214 "test/resources/arch/custom_usages/" \
215 "customUsagesFM_ARC_DigitalHub_with_SB89.json"
216 space_boundary_genenerator = 'Other'
217 handle_proxies = (*(None,)*12,)
218 construction_year = 2015
219 project.sim_settings.split_bounds = False
220 project.sim_settings.add_shadings = True
221 project.sim_settings.split_shadings = False
222 project.sim_settings.run_full_simulation = False
223 # project.sim_settings.ep_install_path = 'C://EnergyPlusV9-4-0/'
224 answers = (space_boundary_genenerator,
225 *handle_proxies,
226 construction_year,
227 project.sim_settings.split_bounds,
228 project.sim_settings.add_shadings,
229 project.sim_settings.split_shadings,
230 project.sim_settings.run_full_simulation)
231 handler = DebugDecisionHandler(answers)
232 return_code = handler.handle(project.run())
233 self.assertEqual(0, return_code)
235 @unittest.skip("Skipped due to performance for CI")
236 def test_base_09_DH_design_day(self):
237 """Test DigitalHub IFC"""
238 ifc_names = {IFCDomain.arch: 'FM_ARC_DigitalHub_fixed002.ifc'}
239 project = self.create_project(ifc_names, 'energyplus')
240 project.sim_settings.create_external_elements = True
241 project.sim_settings.prj_use_conditions = Path(
242 bim2sim.__file__).parent.parent / \
243 "test/resources/arch/custom_usages/" \
244 "UseConditionsFM_ARC_DigitalHub.json"
245 project.sim_settings.prj_custom_usages = Path(
246 bim2sim.__file__).parent.parent / \
247 "test/resources/arch/custom_usages/" \
248 "customUsagesFM_ARC_DigitalHub_fixed002.json"
249 space_boundary_genenerator = 'Other'
250 handle_proxies = (*(None,)*12,)
251 construction_year = 2015
252 project.sim_settings.split_bounds = True
253 project.sim_settings.add_shadings = True
254 project.sim_settings.split_shadings = True
255 project.sim_settings.run_full_simulation = True
256 answers = (space_boundary_genenerator,
257 *handle_proxies,
258 construction_year,
259 project.sim_settings.split_bounds,
260 project.sim_settings.add_shadings,
261 project.sim_settings.split_shadings,
262 project.sim_settings.run_full_simulation)
263 handler = DebugDecisionHandler(answers)
264 return_code = handler.handle(project.run())
265 self.assertEqual(0, return_code)
267 # @unittest.skip("Skipped due to performance for CI")
268 def test_base_13_EDC_SB_design_day(self):
269 """Test KIT KHH 3 storey IFC with generated Space Boundaries"""
270 ifc_names = {IFCDomain.arch: 'KIT-EDC_with_SB.ifc'}
271 project = self.create_project(ifc_names, 'energyplus')
272 project.sim_settings.create_external_elements = True
273 project.sim_settings.split_bounds = True
274 project.sim_settings.add_shadings = True
275 project.sim_settings.split_shadings = True
276 project.sim_settings.run_full_simulation = False
277 # project.sim_settings.ep_install_path = 'C://EnergyPlusV9-4-0/'
279 project.sim_settings.prj_custom_usages = Path(
280 bim2sim.__file__).parent.parent / \
281 "test/resources/arch/custom_usages/" \
282 "customUsagesKIT-EDC_with_SB.json"
283 answers = ('Other', 'Other', 2015)
284 handler = DebugDecisionHandler(answers)
285 return_code = handler.handle(project.run())
286 self.assertEqual(0, return_code)
288 @unittest.skip("Skipped due to performance for CI")
289 def test_base_14_EDC_SB_full_run(self):
290 """Test KIT KHH 3 storey IFC with generated Space Boundaries"""
291 ifc_names = {IFCDomain.arch: 'KIT-EDC_with_SB.ifc'}
292 project = self.create_project(ifc_names, 'energyplus')
293 project.sim_settings.create_external_elements = True
294 project.sim_settings.split_bounds = True
295 project.sim_settings.add_shadings = True
296 project.sim_settings.split_shadings = True
297 project.sim_settings.run_full_simulation = True
298 project.sim_settings.prj_custom_usages = Path(
299 bim2sim.__file__).parent.parent / \
300 "test/resources/arch/custom_usages/" \
301 "customUsagesKIT-EDC_with_SB.json"
302 answers = ('Other', 'Other', 2015)
303 handler = DebugDecisionHandler(answers)
304 return_code = handler.handle(project.run())
305 self.assertEqual(0, return_code)
307 @unittest.skip("Not fully implemented yet")
308 def test_base_17_ERC_design_day(self):
309 """Test ERC Main Building"""
310 ifc_names = {IFCDomain.arch: '26.05space_modified.ifc'}
311 project = self.create_project(ifc_names, 'energyplus')
312 project.sim_settings.create_external_elements = True
313 project.sim_settings.split_bounds = True
314 project.sim_settings.add_shadings = True
315 project.sim_settings.split_shadings = True
316 project.sim_settings.run_full_simulation = False
317 answers = ('Autodesk Revit',
318 *('Single office',)*5)
319 handler = DebugDecisionHandler(answers)
320 return_code = handler.handle(project.run())
321 self.assertEqual(0, return_code)
323 @unittest.skip("Not fully implemented yet")
324 def test_base_19_linear_SB_design_day(self):
325 """Test Linear Building with generated Space Boundaries"""
326 # ifc_names = {IFCDomain.arch: 'Office_Building_Architectural_IFC_export_with_SB.ifc'}
327 ifc_names = {IFCDomain.arch: 'Linear_V01.ifc'}
328 project = self.create_project(ifc_names, 'energyplus')
329 project.sim_settings.create_external_elements = True
330 project.sim_settings.split_bounds = True
331 project.sim_settings.add_shadings = True
332 project.sim_settings.split_shadings = True
333 project.sim_settings.run_full_simulation = False
334 answers = ('Other', *('Single office',)*71, 2015)
335 handler = DebugDecisionHandler(answers)
336 for decision, answer in handler.decision_answer_mapping(project.run()):
337 decision.value = answer
338 self.assertEqual(0, handler.return_value)
340 @unittest.skip("Not fully implemented yet")
341 def test_base_20_olabarri_design_day(self):
342 """Test Original IFC File from FZK-Haus (KIT)"""
343 ifc_names = {IFCDomain.arch: 'Olabarri_49.ifc'}
344 project = self.create_project(ifc_names, 'energyplus')
345 project.sim_settings.create_external_elements = True
346 project.sim_settings.split_bounds = True
347 project.sim_settings.add_shadings = True
348 project.sim_settings.split_shadings = True
349 project.sim_settings.run_full_simulation = False
350 answers = ('Other', *("Single office",) * 7, 2015)
351 handler = DebugDecisionHandler(answers)
352 return_code = handler.handle(project.run())
353 self.assertEqual(0, return_code)
355 @unittest.skip('')
356 def test_base_21_graz_einschichtig_full(self):
357 """Test Testobjekt_einschichtig.ifc from Graz"""
358 ifc_names = {IFCDomain.arch: 'Testobjekt_einschichtig.ifc'}
359 project = self.create_project(ifc_names, 'energyplus')
360 project.sim_settings.create_external_elements = True
361 project.sim_settings.split_bounds = True
362 project.sim_settings.add_shadings = True
363 project.sim_settings.split_shadings = True
364 project.sim_settings.run_full_simulation = False
365 answers = ('Single office', 2015)
366 handler = DebugDecisionHandler(answers)
367 return_code = handler.handle(project.run())
368 self.assertEqual(0, return_code)
370 @unittest.skip('')
371 def test_base_22_graz_mehrschichtig_full(self):
372 """Test Testobjekt_mehrschichtig.ifc from Graz"""
373 ifc_names = {IFCDomain.arch: 'Testobjekt_mehrschichtig.ifc'}
374 project = self.create_project(ifc_names, 'energyplus')
375 project.sim_settings.create_external_elements = True
376 project.sim_settings.split_bounds = True
377 project.sim_settings.add_shadings = True
378 project.sim_settings.split_shadings = True
379 project.sim_settings.run_full_simulation = False
380 answers = ('Single office', 2015)
381 handler = DebugDecisionHandler(answers)
382 return_code = handler.handle(project.run())
383 self.assertEqual(0, return_code)
386if __name__ == '__main__':
387 unittest.main()