Coverage for backend/ahuora-builder-types/src/ahuora_builder_types/flowsheet_schema.py: 100%
36 statements
« prev ^ index » next coverage.py v7.10.7, created at 2026-05-13 02:47 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2026-05-13 02:47 +0000
1from typing import Optional, Any
2from pydantic import BaseModel, Field
3from ahuora_builder_types import UnitModelSchema, ArcSchema
4from ahuora_builder_types.unit_model_schema import SolvedPropertyValueSchema
5from ahuora_builder_types.scenario_schema import OptimizationSchema
6from .custom_package_schema import CustomCompoundPropertiesSchema, CustomPropertyPackagePropertiesSchema
8class PropertyPackageType(BaseModel):
9 id: int
10 type: Optional[str] = None
11 compounds: Optional[list[str]] = None
12 phases: list[str]
13 custom_compound_properties: Optional[list[CustomCompoundPropertiesSchema]] = None
14 custom_package_properties: Optional[CustomPropertyPackagePropertiesSchema] = None
15 custom_kappa_values: Optional[dict[str,dict[str,float]]] = None
18def default_time_set():
19 return list([0])
21class FlowsheetSchema(BaseModel):
22 """Represents the schema required on a JSON object to define a flowsheet in IDAES."""
23 group_id: int
24 name: str = Field(default="")
25 description: str = Field(default="")
26 dynamic: bool # If the flowsheet is dynamic or steady state
27 is_rating_mode: bool = False # If the flowsheet is in rating mode
28 time_set: Optional[list[float]] = Field(default_factory=lambda: default_time_set()) # Time set to use in idaes.
29 property_packages: list[PropertyPackageType] # Property packages are not required in return type
30 unit_models: list[UnitModelSchema]
31 arcs: list[ArcSchema]
32 machineLearningBlock: Optional[list[dict]] = None
33 expressions: Optional[list[dict]] = None
34 optimizations: Optional[list[OptimizationSchema]] = None # Convert to list[ScenarioSchema]
35 disable_initialization: bool = False # If the flowsheet should not be initialised
36 skip_initialization_for_units_with_initial_values: bool = False
37 solver_option: Optional[str] = "ipopt"
40class SolvedFlowsheetSchema(BaseModel):
41 group_id: int
42 properties: list[SolvedPropertyValueSchema]
43 initial_values: dict[str, dict]