Coverage for backend/idaes_factory/adapters/generic_adapters.py: 100%

10 statements  

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

1""" 

2Generic adapters that may be useful across a few different unit model types. 

3""" 

4from core.auxiliary.enums import ConType 

5from flowsheetInternals.unitops.models import SimulationObject 

6from .property_info_adapter import ValueAdapter 

7from ..queryset_lookup import get_all_ports 

8 

9 

10class NumInletsAdapter(ValueAdapter): 

11 """ 

12 Can be used when the number of inlets has to be set as an argument on a unit model. 

13 E.g a mixer https://idaes-pse.readthedocs.io/en/stable/reference_guides/model_libraries/generic/unit_models/mixer.html?highlight=num_inlets#idaes.models.unit_models.mixer.Mixer 

14 """ 

15 def serialise(self, ctx, unit_model: SimulationObject): 

16 return len(get_all_ports(unit_model, "inlet")) 

17 

18 

19class NumOutletsAdapter(ValueAdapter): 

20 """ 

21 Can be used when the number of outlets has to be set as an argument on a unit model. 

22 E.g a splitter https://idaes-pse.readthedocs.io/en/stable/reference_guides/model_libraries/generic/unit_models/splitter.html?highlight=num_outlets#idaes.models.unit_models.splitter.Splitter 

23 """ 

24 def serialise(self, ctx, unit_model: SimulationObject): 

25 return len(get_all_ports(unit_model, "outlet"))