Coverage for backend/idaes_factory/adapters/dynamic_adapter.py: 100%
12 statements
« prev ^ index » next coverage.py v7.10.7, created at 2025-11-06 23:27 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2025-11-06 23:27 +0000
1from .property_info_adapter import ValueAdapter
2from ..idaes_factory_context import IdaesFactoryContext
3from ..queryset_lookup import get_property, get_value_object
4from common.models.idaes import PropertySchema, PropertiesSchema, PropertyValueSchema
5from flowsheetInternals.unitops.models import SimulationObject
8class DynamicAdapter(ValueAdapter):
9 """
10 Returns True if the unit model has dynamics enabled, otherwise False.
11 """
13 def serialise(self, ctx:IdaesFactoryContext, model: SimulationObject) -> bool:
14 # If the flowsheet is not dynamic, return False
15 if not ctx.is_dynamic():
16 return False
17 # get the property from the unit model
18 property_set = model.properties
19 prop = get_property(property_set, "dynamics")
20 # serialise the property
21 return prop.values.first().value == True