Coverage for backend/idaes_service/solver/arc_manager.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2025-11-06 23:27 +0000

1from pyomo.network import Arc 

2from .flowsheet_manager_type import FlowsheetManager 

3from common.models.idaes import PortId 

4 

5 

6class ArcManager: 

7 

8 def __init__(self, flowsheet_manager: FlowsheetManager): 

9 """ 

10 Initializes the arc manager 

11 """ 

12 self._flowsheet_manager = flowsheet_manager 

13 

14 def load(self): 

15 """ 

16 Loads arcs from the schema and adds them to the flowsheet 

17 """ 

18 schema = self._flowsheet_manager.schema 

19 

20 for arc_schema in schema.arcs: 

21 self.add_arc(arc_schema.source, arc_schema.destination) 

22 

23 def add_arc(self, from_port_id: PortId, to_port_id: PortId): 

24 """ 

25 Adds an arc between two ports 

26 """ 

27 port_manager = self._flowsheet_manager.ports 

28 from_port = port_manager.get_port(from_port_id) 

29 to_port = port_manager.get_port(to_port_id) 

30 arc = Arc(source=from_port, destination=to_port) 

31 self._flowsheet_manager.model.fs.add_component( 

32 f"arc_{from_port_id}_{to_port_id}", arc 

33 )