Coverage for bim2sim/plugins/PluginOpenFOAM/bim2sim_openfoam/examples/e12_openfoam_auto_refinement.py: 0%

23 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2025-10-01 10:24 +0000

1import tempfile 

2from pathlib import Path 

3 

4import bim2sim 

5from bim2sim import Project, run_project, ConsoleDecisionHandler 

6from bim2sim.kernel.decision.decisionhandler import DebugDecisionHandler 

7from bim2sim.utilities.types import IFCDomain 

8 

9 

10def run_example_12(): 

11 """ 

12 Prepare an OpenFOAM case with ventilation and a radiator including 

13 automatic refinement adjustments. 

14 

15 This example runs a BPS with the EnergyPlus backend and a CFD simulation 

16 with the OpenFOAM backend. It specifies project 

17 directory and location of the IFC file. Then, it creates a bim2sim 

18 project with the EnergyPlus backend. Simulation settings are specified 

19 (EnergyPlus location needs to be specified according to your system, 

20 other settings are set to default if not specified otherwise), 

21 before the project is executed with the previously specified settings. 

22 

23 The EnergyPlus simulation is followed by the setup of the OpenFOAM 

24 CFD use case, which bases on the same IFC input as the previously set 

25 up EnergyPlus use case. 

26 """ 

27 # Create a temp directory for the project, feel free to use a "normal" 

28 # directory 

29 project_path = Path( 

30 tempfile.TemporaryDirectory(prefix='bim2sim_openfoam12_').name) 

31 

32 # Set the ifc path to use and define which domain the IFC belongs to 

33 ifc_paths = { 

34 IFCDomain.arch: 

35 Path(bim2sim.__file__).parent.parent / 

36 'test/resources/arch/ifc/AC20-FZK-Haus.ifc', 

37 } 

38 

39 # Create a project including the folder structure for the project with 

40 # energyplus as backend 

41 project = Project.create(project_path, ifc_paths, 'openfoam') 

42 

43 # set weather file data 

44 project.sim_settings.weather_file_path = ( 

45 Path(bim2sim.__file__).parent.parent / 

46 'test/resources/weather_files/DEU_NW_Aachen.105010_TMYx.epw') 

47 # Set the install path to your EnergyPlus installation according to your 

48 # system requirements 

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

50 

51 # Set other simulation settings, otherwise all settings are set to default 

52 project.sim_settings.cfd_export = True 

53 project.sim_settings.select_space_guid = '2RSCzLOBz4FAK$_wE8VckM' 

54 project.sim_settings.add_heating = True 

55 project.sim_settings.add_floorheating = False 

56 project.sim_settings.add_airterminals = True 

57 project.sim_settings.inlet_type = 'SimpleStlDiffusor' 

58 project.sim_settings.outlet_type = 'SimpleStlDiffusor' 

59 project.sim_settings.adjust_refinements = True 

60 answers = ('ArchiCAD', 'ArchiCAD', *('Single office',)*4) 

61 # Run the project with the ConsoleDecisionHandler. This allows interactive 

62 # input to answer upcoming questions regarding the imported IFC. 

63 run_project(project, DebugDecisionHandler(answers)) 

64 

65 

66if __name__ == '__main__': 

67 run_example_12()