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

41 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.kernel.decision.decisionhandler import DebugDecisionHandler 

7from bim2sim.tasks import common, bps 

8from bim2sim.utilities.common_functions import download_library 

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

10from bim2sim.plugins.PluginTEASER.bim2sim_teaser import PluginTEASER, \ 

11 LoadLibrariesTEASER 

12import bim2sim.plugins.PluginTEASER.bim2sim_teaser.task as teaser_task 

13 

14 

15def run_serialize_teaser_project_example(): 

16 """Serialize a TEASER Project for further use.""" 

17 # Create the default logging to for quality log and bim2sim main log 

18 # (see logging documentation for more information) 

19 project_path = Path( 

20 tempfile.TemporaryDirectory(prefix='bim2sim_example1').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-Institute-Var-2.ifc', 

27 } 

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

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

30 project = Project.create(project_path, ifc_paths, 'teaser') 

31 

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

33 # all under concepts/sim_settings 

34 # combine spaces to thermal zones based on their usage 

35 

36 

37 

38 project.sim_settings.zoning_criteria = ZoningCriteria.usage 

39 # use cooling 

40 project.sim_settings.cooling_tz_overwrite = False 

41 project.sim_settings.setpoints_from_template = True 

42 

43 project.sim_settings.ahu_heating_overwrite = True 

44 project.sim_settings.ahu_cooling_overwrite = True 

45 project.sim_settings.ahu_heat_recovery_overwrite = True 

46 

47 # overwrite existing layer structures and materials based on templates 

48 project.sim_settings.layers_and_materials = LOD.low 

49 # specify templates for the layer and material overwrite 

50 project.sim_settings.construction_class_walls = 'heavy' 

51 project.sim_settings.construction_class_windows = \ 

52 'Alu- oder Stahlfenster, Waermeschutzverglasung, zweifach' 

53 

54 # set weather file data 

55 project.sim_settings.weather_file_path = ( 

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

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

58 # Run a simulation directly with dymola after model creation 

59 project.sim_settings.dymola_simulation = True 

60 # Make sure that AixLib modelica library exist on machine by cloning it and 

61 # setting the path of it as a sim_setting 

62 repo_url = "https://github.com/RWTH-EBC/AixLib.git" 

63 branch_name = "main" 

64 repo_name = "AixLib" 

65 path_aixlib = ( 

66 Path(bim2sim.__file__).parent.parent / "local" / f"library_{repo_name}") 

67 download_library(repo_url, branch_name, path_aixlib) 

68 project.sim_settings.path_aixlib = path_aixlib / repo_name / 'package.mo' 

69 

70 # Select results to output: 

71 project.sim_settings.sim_results = [ 

72 "heat_demand_total", "cool_demand_total", 

73 "heat_demand_rooms", "cool_demand_rooms", 

74 "heat_energy_total", "cool_energy_total", 

75 "heat_energy_rooms", "cool_energy_rooms", 

76 "operative_temp_rooms", "air_temp_rooms", "air_temp_out", 

77 "internal_gains_machines_rooms", "internal_gains_persons_rooms", 

78 "internal_gains_lights_rooms", 

79 "heat_set_rooms", 

80 "cool_set_rooms" 

81 ] 

82 project.sim_settings.prj_custom_usages = (Path( 

83 bim2sim.__file__).parent.parent / 

84 "test/resources/arch/custom_usages/" 

85 "customUsagesAC20-Institute-Var-2_with_SB-1-0.json") 

86 # create plots based on the results after simulation 

87 project.sim_settings.create_plots = True 

88 project.plugin_cls.default_tasks = [ 

89 common.LoadIFC, 

90 common.CreateElementsOnIfcTypes, 

91 bps.CreateSpaceBoundaries, 

92 bps.AddSpaceBoundaries2B, 

93 bps.CorrectSpaceBoundaries, 

94 common.CreateRelations, 

95 bps.DisaggregationCreationAndTypeCheck, 

96 bps.EnrichMaterial, 

97 bps.EnrichUseConditions, 

98 bps.CombineThermalZones, 

99 common.Weather, 

100 LoadLibrariesTEASER, 

101 teaser_task.CreateTEASER, 

102 teaser_task.SerializeTEASER, 

103 ] 

104 answers = (2015,) 

105 handler = DebugDecisionHandler(answers) 

106 handler.handle(project.run()) 

107 

108 # return the export path and the path of the serialized project json file 

109 return (project.paths.export, 

110 project.paths.export / 

111 f"TEASER/serialized_teaser/{project.name}.json") 

112 

113 

114if __name__ == '__main__': 

115 run_serialize_teaser_project_example()