Skip to content

Commit ad3b774

Browse files
committed
chore: init parallel system yaml
1 parent eff2476 commit ad3b774

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
from typing import Annotated, Generic, Literal, TypeAlias, TypeVar
2+
3+
from pydantic import Field
4+
5+
from libecalc.presentation.yaml.yaml_types import YamlBase
6+
from libecalc.presentation.yaml.yaml_types.components.yaml_expression_type import YamlExpressionType
7+
from libecalc.presentation.yaml.yaml_types.models.yaml_compressor_chart import UnitsField, YamlCurve, YamlUnits
8+
from libecalc.presentation.yaml.yaml_types.models.yaml_compressor_stages import YamlControlMarginUnits
9+
from libecalc.presentation.yaml.yaml_types.yaml_data_or_file import DataOrFile
10+
11+
StreamRef = str
12+
13+
14+
class YamlControlMargin(YamlBase):
15+
unit: YamlControlMarginUnits
16+
value: float
17+
18+
19+
class YamlCompressorChart(YamlBase):
20+
curves: DataOrFile[list[YamlCurve]] = Field(
21+
..., description="Compressor chart curves, one per speed.", title="CURVES"
22+
)
23+
units: YamlUnits = UnitsField()
24+
25+
26+
class YamlCompressorModelChart(YamlBase):
27+
type: Literal["COMPRESSOR_CHART"]
28+
chart: YamlCompressorChart
29+
control_margin: YamlControlMargin
30+
31+
32+
YamlCompressorModel = YamlCompressorModelChart # Could add compressor_sampled as a model if needed
33+
34+
35+
ProcessUnitReference = str
36+
37+
38+
class YamlCompressor(YamlBase):
39+
"""
40+
A Compressor process unit
41+
"""
42+
43+
type: Literal["COMPRESSOR"]
44+
name: ProcessUnitReference = Field(
45+
...,
46+
description="Name of the model. See documentation for more information.",
47+
title="NAME",
48+
)
49+
compressor_model: YamlCompressorModel
50+
51+
52+
ProcessSystemReference: TypeAlias = str # TODO: validate correct reference
53+
54+
CompressorReference = ProcessUnitReference # TODO: validate correct process unit type
55+
56+
57+
class YamlCompressorStageProcessSystem(YamlBase):
58+
type: Literal["COMPRESSOR_STAGE"]
59+
name: ProcessSystemReference
60+
inlet_temperature: YamlExpressionType = Field(
61+
...,
62+
description="Inlet temperature in Celsius for stage",
63+
title="INLET_TEMPERATURE",
64+
)
65+
pressure_drop_ahead_of_stage: YamlExpressionType = Field(
66+
0.0,
67+
description="Pressure drop before compression stage [in bar]",
68+
title="PRESSURE_DROP_AHEAD_OF_STAGE",
69+
)
70+
compressor: CompressorReference
71+
72+
73+
TTarget = TypeVar("TTarget")
74+
75+
76+
class YamlItem(YamlBase, Generic[TTarget]):
77+
target: TTarget | ProcessSystemReference
78+
79+
80+
class YamlSerialProcessSystem(YamlBase):
81+
type: Literal["SERIAL"]
82+
name: ProcessSystemReference
83+
items: list[YamlItem[YamlCompressorStageProcessSystem]]
84+
85+
86+
class YamlParallelProcessSystem(YamlBase):
87+
type: Literal["PARALLEL"]
88+
name: ProcessSystemReference
89+
items: list[YamlItem[YamlSerialProcessSystem]]
90+
91+
92+
class YamlOverflow(YamlBase):
93+
from_reference: ProcessSystemReference
94+
to_reference: ProcessSystemReference
95+
96+
97+
class YamlCommonStreamSetting(YamlBase):
98+
rate_fractions: list[YamlExpressionType]
99+
overflow: list[YamlOverflow]
100+
101+
102+
class YamlCommonStreamDistribution(YamlBase):
103+
method: Literal["COMMON_STREAM"]
104+
inlet_stream: StreamRef
105+
settings: list[YamlCommonStreamSetting]
106+
107+
108+
class YamlIndividualStreamDistribution(YamlBase):
109+
method: Literal["INDIVIDUAL_STREAMS"]
110+
inlet_streams: list[StreamRef]
111+
112+
113+
YamlStreamDistribution = Annotated[
114+
YamlCommonStreamDistribution | YamlIndividualStreamDistribution, Field(discriminator="method")
115+
]
116+
117+
118+
class YamlProcessSimulation(YamlBase):
119+
name: str
120+
target: YamlParallelProcessSystem | YamlSerialProcessSystem | ProcessSystemReference
121+
stream_distribution: YamlStreamDistribution

0 commit comments

Comments
 (0)