Coverage for bim2sim/plugins/PluginTEASER/bim2sim_teaser/examples/e1_simple_project_bps_teaser.py: 0%

40 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-03-12 17:09 +0000

1import tempfile 

2from pathlib import Path 

3 

4import bim2sim 

5from bim2sim import Project, run_project, ConsoleDecisionHandler 

6from bim2sim.utilities.types import IFCDomain, LOD, ZoningCriteria 

7from bim2sim.plugins.PluginTEASER.bim2sim_teaser import PluginTEASER 

8 

9def run_example_simple_building_teaser(): 

10 """Run a building performance simulation with the TEASER backend. 

11 

12 This example runs a BPS with the TEASER backend. Specifies project 

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

14 project with the TEASER backend. Sim settings are specified before the 

15 project is executed with the previously specified settings. 

16 """ 

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

18 # directory 

19 project_path = Path(tempfile.TemporaryDirectory( 

20 prefix='bim2sim_teaser_example_e1_').name) 

21 

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

23 ifc_paths = { 

24 IFCDomain.arch: 

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

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

27 } 

28 

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

30 # teaser as backend and no specified workflow (default workflow is taken) 

31 project = Project.create(project_path, ifc_paths, PluginTEASER) 

32 

33 # specify simulation settings (please have a look at the documentation of 

34 # all under concepts/sim_settings 

35 # combine spaces to thermal zones based on their usage 

36 project.sim_settings.zoning_criteria = ZoningCriteria.individual_spaces 

37 # use cooling 

38 project.sim_settings.cooling_tz_overwrite = True 

39 # use set points for heating and cooling from templates 

40 project.sim_settings.setpoints_from_template = True 

41 # overwrite existing layer structures and materials based on templates 

42 project.sim_settings.layers_and_materials = LOD.low 

43 # specify templates for the layer and material overwrite 

44 project.sim_settings.construction_class_walls = 'iwu_heavy' 

45 project.sim_settings.construction_class_windows = \ 

46 'Alu- oder Stahlfenster, Waermeschutzverglasung, zweifach' 

47 project.sim_settings.construction_class_doors = 'kfw_40' 

48 # set weather file data 

49 project.sim_settings.weather_file_path = ( 

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

51 'test/resources/weather_files/DEU_NW_Aachen.105010_TMYx.mos') 

52 # Run a simulation directly with dymola after model creation 

53 project.sim_settings.dymola_simulation = True 

54 project.sim_settings.create_plots = True 

55 # Select results to output: 

56 project.sim_settings.sim_results = [ 

57 "heat_demand_total", "cool_demand_total", 

58 "heat_demand_rooms", "cool_demand_rooms", 

59 "heat_energy_total", "cool_energy_total", 

60 "heat_energy_rooms", "cool_energy_rooms", 

61 "operative_temp_rooms", "air_temp_rooms", "air_temp_out", 

62 "infiltration_rooms" 

63 ] 

64 

65 # run the project with the ConsoleDecisionHandler. This allows interactive 

66 # input to answer upcoming decisions during the model creation process 

67 run_project(project, ConsoleDecisionHandler()) 

68 # have a look at the elements/elements that were created 

69 elements = project.playground.state['elements'] 

70 # we can filter the elements only for outer walls 

71 outer_walls = [] 

72 from bim2sim.elements.bps_elements import OuterWall 

73 for ele in elements.values(): 

74 if isinstance(ele, OuterWall): 

75 outer_walls.append(ele) 

76 # let's see what outer walls are found 

77 print(f"Found {len(outer_walls)}: {outer_walls}") 

78 # let's have a look at the layers and which were overwritten and enriched 

79 # due to project.sim_settings.layers_and_materials = LOD.low 

80 layer_set = outer_walls[0].layerset 

81 layer_0 = layer_set.layers[0] 

82 material = layer_0.material 

83 density = material.density 

84 spec_heat_capacity = material.spec_heat_capacity 

85 print(f"Density is: {density}") 

86 print(f"Specific heat capacity is {spec_heat_capacity}") 

87 # let's also get the final teaser project which can be manipulated further 

88 teaser_prj = project.playground.state['teaser_prj'] 

89 return project 

90 

91 

92if __name__ == '__main__': 

93 run_example_simple_building_teaser()