Coverage for bim2sim/plugins/PluginHKESim/test/integration/test_hkesim.py: 0%
45 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
1import unittest
2from collections import Counter
4from bim2sim.kernel.decision.decisionhandler import DebugDecisionHandler
5from bim2sim.export.modelica import ModelicaElement
6from bim2sim.elements.aggregation.hvac_aggregations \
7 import ConsumerHeatingDistributorModule
8from bim2sim.utilities.test import IntegrationBase
9from bim2sim.utilities.types import IFCDomain
12class IntegrationBaseHKESIM(IntegrationBase):
13 def tearDown(self):
14 ModelicaElement.lookup = {}
15 super().tearDown()
17 def model_domain_path(self) -> str:
18 return 'hydraulic'
21class TestIntegrationHKESIM(IntegrationBaseHKESIM, unittest.TestCase):
23 def test_run_vereinshaus1(self):
24 """
25 Run project with KM_DPM_Vereinshaus_Gruppe62_Heizung_with_pumps.ifc
26 """
27 ifc_names = {IFCDomain.hydraulic:
28 'KM_DPM_Vereinshaus_Gruppe62_Heizung_with_pumps.ifc'}
29 project = self.create_project(ifc_names, 'hkesim')
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 power,
37 150,
38 # boiler return temperature
39 70,
40 # volume of junctions
41 *(0.1,) * 35,
42 # 2x pumps: current, height, voltage, volume flow rate
43 *(4, 10, 400, 120,) * 2,
44 # 11x space heater: rated_power, return_temperature
45 *(10, 50) * 11,
46 # diameter of storage
47 1,
48 # height of storage
49 2,
50 # rated_power of heat pump
51 200)
52 handler = DebugDecisionHandler(answers)
53 for decision, answer in handler.decision_answer_mapping(project.run()):
54 decision.value = answer
55 self.assertEqual(0, handler.return_value,
56 "Project did not finish successfully.")
58 def test_run_b03_heating(self):
59 """Run project with 2022_11_21_update_B03_Heating_ownCells.ifc"""
60 ifc_names = {IFCDomain.hydraulic:
61 '2022_11_21_update_B03_Heating_ownCells.ifc'}
62 project = self.create_project(ifc_names, 'hkesim')
63 project.sim_settings.aggregations = [
64 'UnderfloorHeating',
65 'Consumer',
66 'PipeStrand',
67 'ParallelPump',
68 'ConsumerHeatingDistributorModule',
69 ]
70 answers = (None, 'HVAC-PipeFitting', 'HVAC-Distributor',
71 'HVAC-ThreeWayValve',
72 # 7x dead ends
73 *(True,) * 7,
74 # boiler: efficiency
75 0.9,
76 # boiler: nominal power consumption
77 150,
78 # boiler: nominal output temperature
79 70,
80 # junction: volume
81 1,
82 # pump: rated current
83 4,
84 # pump: rated height
85 10,
86 # pump: rated voltage
87 400,
88 # pump: rated volume flow
89 120)
90 handler = DebugDecisionHandler(answers)
91 for decision, answer in handler.decision_answer_mapping(project.run()):
92 decision.value = answer
93 graph = project.playground.state['graph']
94 aggregated = Counter((type(item) for item in graph.element_graph.nodes))
95 self.assertIn(ConsumerHeatingDistributorModule, aggregated)
96 self.assertEqual(0, handler.return_value,
97 "Project did not finish successfully.")
99 def test_run_b03_heating_with_all_aggregations(self):
100 """Run project with 2022_11_21_update_B03_Heating_ownCells.ifc"""
101 ifc_names = {IFCDomain.hydraulic:
102 '2022_11_21_update_B03_Heating_ownCells.ifc'}
103 project = self.create_project(ifc_names, 'hkesim')
104 answers = (None, 'HVAC-PipeFitting', 'HVAC-Distributor',
105 'HVAC-ThreeWayValve',
106 # 6x dead ends
107 *(True,) * 6,
108 # boiler: nominal flow temperature
109 70,
110 # boiler: rated power consumption
111 150,
112 # boiler: nominal return temperature
113 50)
114 handler = DebugDecisionHandler(answers)
115 for decision, answer in handler.decision_answer_mapping(project.run()):
116 decision.value = answer
117 graph = project.playground.state['graph']
118 aggregated = Counter((type(item) for item in graph.element_graph.nodes))
119 self.assertIn(ConsumerHeatingDistributorModule, aggregated)
120 self.assertEqual(0, handler.return_value,
121 "Project did not finish successfully.")