Coverage for bim2sim/plugins/PluginAixLib/test/integration/test_aixlib.py: 0%

46 statements  

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

1import unittest 

2from collections import Counter 

3 

4from bim2sim import ConsoleDecisionHandler, run_project 

5from bim2sim.kernel.decision.decisionhandler import DebugDecisionHandler 

6from bim2sim.export.modelica import ModelicaElement 

7from bim2sim.elements.aggregation.hvac_aggregations import \ 

8 ConsumerHeatingDistributorModule 

9from bim2sim.utilities.test import IntegrationBase 

10from bim2sim.utilities.types import IFCDomain 

11 

12 

13class IntegrationBaseAixLib(IntegrationBase): 

14 def tearDown(self): 

15 ModelicaElement.lookup = {} 

16 super().tearDown() 

17 

18 def model_domain_path(self) -> str: 

19 return 'hydraulic' 

20 

21 

22class TestIntegrationAixLib(IntegrationBaseAixLib, unittest.TestCase): 

23 

24 def test_vereinshaus1_aixlib(self): 

25 """Run project with 

26 KM_DPM_Vereinshaus_Gruppe62_Heizung_with_pumps.ifc""" 

27 ifc_names = {IFCDomain.hydraulic: 

28 'KM_DPM_Vereinshaus_Gruppe62_Heizung_with_pumps.ifc'} 

29 project = self.create_project(ifc_names, 'aixlib') 

30 answers = ('HVAC-HeatPump', 'HVAC-Storage', 'HVAC-Storage', 

31 '2lU4kSSzH16v7KPrwcL7KZ', '0t2j$jKmf74PQpOI0ZmPCc', 

32 # 1x expansion tank and 17x dead end 

33 *(True,) * 18, 

34 # boiler efficiency 

35 0.9, 

36 # boiler flow temperature 

37 50, 

38 # boiler nominal consumption 

39 150, 

40 # boiler return temperature 

41 70, 

42 # volume of junctions 

43 *(0.1,) * 35, 

44 # 2x pumps: pressure difference, volume flow rate 

45 *(1e5, 120) * 2, 

46 # 11x space heater: flow temperature, rated_power, 

47 # return temperature 

48 *(70, 10, 50) * 11, 

49 # storage: diameter 

50 1, 

51 # storage: height 

52 2) 

53 handler = DebugDecisionHandler(answers) 

54 for decision, answer in handler.decision_answer_mapping(project.run()): 

55 decision.value = answer 

56 self.assertEqual(0, handler.return_value, 

57 "Project did not finish successfully.") 

58 

59 def test_run_b03_heating(self): 

60 """Run project with 2022_11_21_update_B03_Heating_ownCells""" 

61 ifc_names = {IFCDomain.hydraulic: 

62 '2022_11_21_update_B03_Heating_ownCells.ifc'} 

63 project = self.create_project(ifc_names, 'aixlib') 

64 project.sim_settings.aggregations = [ 

65 'UnderfloorHeating', 

66 'Consumer', 

67 'PipeStrand', 

68 'ParallelPump', 

69 'ConsumerHeatingDistributorModule', 

70 ] 

71 answers = (None, 'HVAC-PipeFitting', 'HVAC-Distributor', 

72 'HVAC-ThreeWayValve', 

73 # 7x dead ends 

74 *(True,) * 7, 

75 # boiler: efficiency 

76 0.9, 

77 # boiler: flow temperature 

78 50, 

79 # boiler: power consumption 

80 150, 

81 # boiler: return temperature 

82 70, 

83 # junction: volume 

84 0.1, 

85 # pump: rated pressure difference 

86 1e5, 

87 # pump: rated volume flow 

88 120, 

89 # 7x space heater: heat capacity 

90 *(10,) * 7, 

91 # three-way valve: nominal mass flow rate 

92 30, 

93 # three-way valve: nominal pressure difference 

94 250) 

95 # handler = ConsoleDecisionHandler() 

96 # run_project(project, handler) 

97 handler = DebugDecisionHandler(answers) 

98 for decision, answer in handler.decision_answer_mapping(project.run()): 

99 decision.value = answer 

100 graph = project.playground.state['graph'] 

101 aggregated = Counter((type(item) for item in graph.element_graph.nodes)) 

102 self.assertIn(ConsumerHeatingDistributorModule, aggregated) 

103 self.assertEqual(0, handler.return_value, 

104 "Project did not finish successfully.") 

105 

106 def test_run_b03_heating_with_all_aggregations(self): 

107 """Run project with 2022_11_21_update_B03_Heating_ownCells""" 

108 ifc_names = {IFCDomain.hydraulic: 

109 '2022_11_21_update_B03_Heating_ownCells.ifc'} 

110 project = self.create_project(ifc_names, 'aixlib') 

111 answers = (None, 'HVAC-PipeFitting', 'HVAC-Distributor', 

112 'HVAC-ThreeWayValve', 

113 # 6x dead ends 

114 *(True,) * 6, 

115 # boiler: efficiency 

116 0.9, 

117 # boiler: flow temperature 

118 50, 

119 # boiler: power consumption 

120 150, 

121 # boiler: return temperature 

122 70, 

123 # 7x space heater: heat capacity 

124 *(10,) * 7) 

125 handler = DebugDecisionHandler(answers) 

126 for decision, answer in handler.decision_answer_mapping(project.run()): 

127 decision.value = answer 

128 graph = project.playground.state['graph'] 

129 aggregated = Counter((type(item) for item in graph.element_graph.nodes)) 

130 # TODO check generator 

131 self.assertIn(ConsumerHeatingDistributorModule, aggregated) 

132 self.assertEqual(0, handler.return_value, 

133 "Project did not finish successfully.") 

134 

135 # def test_run_digitalhub_hvac(self): 

136 # """Run project with FM_HZG_DigitalHub.ifc""" 

137 # ifc_names = {IFCDomain.hydraulic:  

138 # 'FM_HZG_DigitalHub.ifc'} 

139 # project = self.create_project(ifc_names, 'aixlib') 

140 # answers = (('HVAC-ThreeWayValve')*3, ('HVAC-PipeFitting')*19, *(None,)*100,) 

141 # handler = DebugDecisionHandler(answers) 

142 # project.workflow.fuzzy_threshold = 0.5 

143 # for decision, answer in handler.decision_answer_mapping(project.run()): 

144 # decision.value = answer 

145 # print('test')