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

33 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 """OpenFOAM simulation, run a preconditioned transient simulation. 

12 

13 Prepare an OpenFOAM case with ventilation and a radiator including 

14 meshing and running the simulation on linux. 

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 tempfile.tempdir = '/mnt/sim/SimData/CFD-temp' 

30 project_path = Path( 

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

32 

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

34 ifc_paths = { 

35 IFCDomain.arch: 

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

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

38 } 

39 

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

41 # energyplus as backend 

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

43 

44 # set weather file data 

45 project.sim_settings.weather_file_path = ( 

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

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

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

49 # system requirements 

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

51 

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

53 project.sim_settings.cfd_export = True 

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

55 project.sim_settings.add_heating = True 

56 project.sim_settings.add_floorheating = False 

57 project.sim_settings.add_airterminals = True 

58 project.sim_settings.simulation_type = 'combined' 

59 project.sim_settings.steady_iterations = 7000 

60 project.sim_settings.run_meshing = True 

61 project.sim_settings.run_cfd_simulation = True 

62 project.sim_settings.add_furniture = True 

63 project.sim_settings.add_people = True 

64 project.sim_settings.add_comfort = True 

65 project.sim_settings.furniture_setting = 'Classroom' 

66 project.sim_settings.furniture_amount = 4 

67 project.sim_settings.people_amount = 3 

68 project.sim_settings.people_setting = 'Seated' 

69 project.sim_settings.output_keys = ['output_outdoor_conditions', 

70 'output_zone_temperature', 

71 'output_zone', 'output_infiltration', 

72 'output_meters', 

73 'output_internal_gains'] 

74 # project.sim_settings.level_heat_balance = False 

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

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

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

78 run_project(project, DebugDecisionHandler(answers)) 

79 

80 

81if __name__ == '__main__': 

82 run_example_12()