Coverage for bim2sim/plugins/PluginTEASER/bim2sim_teaser/examples/e6_load_serialized_teaser_prj.py: 0%
41 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-12 17:09 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-12 17:09 +0000
1from pathlib import Path
2from teaser.project import Project
4from bim2sim_teaser.task import CreateTEASER
5from e5_serialize_teaser_prj import run_serialize_teaser_project_example
8def load_serialized_teaser_project():
9 """This function demonstrates different loading options of TEASER"""
10 prj_export_path, prj_json_path = run_serialize_teaser_project_example()
11 prj = Project()
13 prj.load_project(path=prj_json_path)
14 export_vars = {
15 "HeatingDemands": ["*multizone.PHeater*", "*multizone.PHeatAHU"],
16 "CoolingDemands": ["*multizone.PCooler*", "*multizone.PCoolAHU"],
17 "Temperatures": ["*multizone.TAir*", "*multizone.TRad*"]
18 }
20 # Do some work on the model, e.g. increase total window area of each
21 # thermal zone by 10 %
22 window_increase_percentage = 0.1
23 for bldg in prj.buildings:
24 for tz in bldg.thermal_zones:
25 ow_area_old = 0
26 for ow in tz.outer_walls:
27 ow_area_old += ow.area
28 win_area_old = 0
29 for win in tz.windows:
30 win_area_old += win.area
31 win_ratio = win_area_old / ow_area_old
32 print(f"Current window to wall ratio of thermal zone "
33 f"{tz.name} is {round(win_ratio*100,2 )} %. "
34 f"Increasing total window "
35 f"area by {window_increase_percentage*100} %.")
36 # calculate the total new window area
37 win_area_new = (1 + window_increase_percentage) * win_area_old
38 win_area_increase = win_area_new-win_area_old
39 ow_area_new = ow_area_old - win_area_increase
40 ow_area_decrease = ow_area_old - ow_area_new
41 # distribute the changes on the different windows and outer walls
42 # based on their percentage ratio
43 for win in tz.windows:
44 win.area += win_area_increase * win.area/win_area_old
45 for ow in tz.outer_walls:
46 ow.area -= ow_area_decrease * ow.area/ow_area_old
47 # check new areas
48 ow_area_res = 0
49 for ow in tz.outer_walls:
50 ow_area_res += ow.area
51 win_area_res = 0
52 for win in tz.windows:
53 win_area_res += win.area
54 win_ratio_res = win_area_res/ow_area_res
55 print(f"New window to wall ratio of thermal zone "
56 f"{tz.name} is {round(win_ratio_res*100,2 )} %.")
57 # calculate all buildings, this is needed as model_attr and library_attr
58 # are not saved via json export.
59 prj.calc_all_buildings()
61 # As calc_all_buildings() recalculates the heating loads and thus the max
62 # ideal heater PI-control values, we might reset those as they can be too
63 # low and lead to too low zone temperatures
64 orig_heat_loads, orig_cool_loads = CreateTEASER.overwrite_heatloads(
65 prj.buildings)
67 prj.export_aixlib(
68 path=prj_export_path,
69 use_postprocessing_calc=True,
70 report=True,
71 export_vars=export_vars
72 )
75if __name__ == "__main__":
76 load_serialized_teaser_project()