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

41 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2025-12-18 09:34 +0000

1from pathlib import Path 

2from teaser.project import Project 

3 

4from e5_serialize_teaser_prj import run_serialize_teaser_project_example 

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

6 

7def load_serialized_teaser_project(): 

8 """This function demonstrates different loading options of TEASER""" 

9 prj_export_path, prj_json_path = run_serialize_teaser_project_example() 

10 prj = Project() 

11 

12 prj.load_project(path=prj_json_path) 

13 export_vars = { 

14 "HeatingDemands": ["*multizone.PHeater*", "*multizone.PHeatAHU"], 

15 "CoolingDemands": ["*multizone.PCooler*", "*multizone.PCoolAHU"], 

16 "Temperatures": ["*multizone.TAir*", "*multizone.TRad*"] 

17 } 

18 

19 # Do some work on the model, e.g. increase total window area of each 

20 # thermal zone by 10 % 

21 window_increase_percentage = 0.1 

22 for bldg in prj.buildings: 

23 for tz in bldg.thermal_zones: 

24 ow_area_old = 0 

25 for ow in tz.outer_walls: 

26 ow_area_old += ow.area 

27 win_area_old = 0 

28 for win in tz.windows: 

29 win_area_old += win.area 

30 win_ratio = win_area_old / ow_area_old 

31 print(f"Current window to wall ratio of thermal zone " 

32 f"{tz.name} is {round(win_ratio*100,2 )} %. " 

33 f"Increasing total window " 

34 f"area by {window_increase_percentage*100} %.") 

35 # calculate the total new window area 

36 win_area_new = (1 + window_increase_percentage) * win_area_old 

37 win_area_increase = win_area_new-win_area_old 

38 ow_area_new = ow_area_old - win_area_increase 

39 ow_area_decrease = ow_area_old - ow_area_new 

40 # distribute the changes on the different windows and outer walls 

41 # based on their percentage ratio 

42 for win in tz.windows: 

43 win.area += win_area_increase * win.area/win_area_old 

44 for ow in tz.outer_walls: 

45 ow.area -= ow_area_decrease * ow.area/ow_area_old 

46 # check new areas 

47 ow_area_res = 0 

48 for ow in tz.outer_walls: 

49 ow_area_res += ow.area 

50 win_area_res = 0 

51 for win in tz.windows: 

52 win_area_res += win.area 

53 win_ratio_res = win_area_res/ow_area_res 

54 print(f"New window to wall ratio of thermal zone " 

55 f"{tz.name} is {round(win_ratio_res*100,2 )} %.") 

56 # calculate all buildings, this is needed as model_attr and library_attr 

57 # are not saved via json export. 

58 prj.calc_all_buildings() 

59 

60 # As calc_all_buildings() recalculates the heating loads and thus the max 

61 # ideal heater PI-control values, we might reset those as they can be too 

62 # low and lead to too low zone temperatures 

63 orig_heat_loads, orig_cool_loads = teaser_task.CreateTEASER.overwrite_heatloads( 

64 prj.buildings) 

65 

66 prj.export_aixlib( 

67 path=prj_export_path, 

68 use_postprocessing_calc=True, 

69 report=True, 

70 export_vars=export_vars 

71 ) 

72 

73 

74if __name__ == "__main__": 

75 load_serialized_teaser_project() 

76