Coverage for bim2sim / plugins / PluginTEASER / bim2sim_teaser / examples / e1_simple_project_bps_teaser.py: 0%
47 statements
« prev ^ index » next coverage.py v7.13.0, created at 2025-12-18 09:34 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2025-12-18 09:34 +0000
1import tempfile
2from pathlib import Path
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
8from bim2sim.utilities.common_functions import download_library
10def run_example_simple_building_teaser():
11 """Run a building performance simulation with the TEASER backend.
13 This example runs a BPS with the TEASER backend. Specifies project
14 directory and location of the IFC file. Then, it creates a bim2sim
15 project with the TEASER backend. Sim settings are specified before the
16 project is executed with the previously specified settings.
17 """
18 # Create a temp directory for the project, feel free to use a "normal"
19 # directory
20 project_path = Path(tempfile.TemporaryDirectory(
21 prefix='bim2sim_teaser_example_e1_').name)
23 # Set the ifc path to use and define which domain the IFC belongs to
24 ifc_paths = {
25 IFCDomain.arch:
26 Path(bim2sim.__file__).parent.parent /
27 'test/resources/arch/ifc/AC20-FZK-Haus.ifc',
28 }
30 # Create a project including the folder structure for the project with
31 # teaser as backend and no specified workflow (default workflow is taken)
32 project = Project.create(project_path, ifc_paths, PluginTEASER)
34 # specify simulation settings (please have a look at the documentation of
35 # all under concepts/sim_settings
36 # combine spaces to thermal zones based on their usage
37 project.sim_settings.zoning_criteria = ZoningCriteria.individual_spaces
38 # use cooling
39 project.sim_settings.cooling_tz_overwrite = True
40 # use set points for heating and cooling from templates
41 project.sim_settings.setpoints_from_template = True
42 # overwrite existing layer structures and materials based on templates
43 project.sim_settings.layers_and_materials = LOD.low
44 # specify templates for the layer and material overwrite
45 project.sim_settings.construction_class_walls = 'iwu_heavy'
46 project.sim_settings.construction_class_windows = \
47 'Alu- oder Stahlfenster, Waermeschutzverglasung, zweifach'
48 project.sim_settings.construction_class_doors = 'kfw_40'
49 # set weather file data
50 project.sim_settings.weather_file_path = (
51 Path(bim2sim.__file__).parent.parent /
52 'test/resources/weather_files/DEU_NW_Aachen.105010_TMYx.mos')
53 # Run a simulation directly with dymola after model creation
54 project.sim_settings.dymola_simulation = True
55 # Make sure that AixLib modelica library exist on machine by cloning it and
56 # setting the path of it as a sim_setting
57 repo_url = "https://github.com/RWTH-EBC/AixLib.git"
58 branch_name = "main"
59 repo_name = "AixLib"
60 path_aixlib = Path(r"D:\01_Git\bim2sim\local\library_AixLib")
61 # path_aixlib = (
62 # Path(bim2sim.__file__).parent.parent / "local" / f"library_{repo_name}")
63 download_library(repo_url, branch_name, path_aixlib)
64 project.sim_settings.path_aixlib = path_aixlib / repo_name / 'package.mo'
66 project.sim_settings.create_plots = True
67 # Select results to output:
68 project.sim_settings.sim_results = [
69 "heat_demand_total", "cool_demand_total",
70 "heat_demand_rooms", "cool_demand_rooms",
71 "heat_energy_total", "cool_energy_total",
72 "heat_energy_rooms", "cool_energy_rooms",
73 "operative_temp_rooms", "air_temp_rooms", "air_temp_out",
74 "infiltration_rooms"
75 ]
77 # run the project with the ConsoleDecisionHandler. This allows interactive
78 # input to answer upcoming decisions during the model creation process
79 run_project(project, ConsoleDecisionHandler())
80 # have a look at the elements/elements that were created
81 elements = project.playground.state['elements']
82 # we can filter the elements only for outer walls
83 outer_walls = []
84 from bim2sim.elements.bps_elements import OuterWall
85 for ele in elements.values():
86 if isinstance(ele, OuterWall):
87 outer_walls.append(ele)
88 # let's see what outer walls are found
89 print(f"Found {len(outer_walls)}: {outer_walls}")
90 # let's have a look at the layers and which were overwritten and enriched
91 # due to project.sim_settings.layers_and_materials = LOD.low
92 layer_set = outer_walls[0].layerset
93 layer_0 = layer_set.layers[0]
94 material = layer_0.material
95 density = material.density
96 spec_heat_capacity = material.spec_heat_capacity
97 print(f"Density is: {density}")
98 print(f"Specific heat capacity is {spec_heat_capacity}")
99 # let's also get the final teaser project which can be manipulated further
100 teaser_prj = project.playground.state['teaser_prj']
101 return project
104if __name__ == '__main__':
105 run_example_simple_building_teaser()