Skip to content

Commit 7e75098

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

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
from typing import Annotated, Literal, TypeAlias
2+
3+
from pydantic import AfterValidator, 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.model_reference_validation import check_field_model_reference
8+
from libecalc.presentation.yaml.yaml_types.models.yaml_compressor_chart import UnitsField, YamlCurve, YamlUnits
9+
from libecalc.presentation.yaml.yaml_types.models.yaml_compressor_stages import YamlControlMarginUnits
10+
from libecalc.presentation.yaml.yaml_types.yaml_data_or_file import DataOrFile
11+
from libecalc.presentation.yaml.yaml_validation_context import ModelName
12+
13+
StreamRef = str
14+
15+
16+
class YamlControlMargin(YamlBase):
17+
unit: YamlControlMarginUnits
18+
value: float
19+
20+
21+
class YamlCompressorChart(YamlBase):
22+
name: ModelName = Field(
23+
...,
24+
description="Name of the model. See documentation for more information.",
25+
title="NAME",
26+
)
27+
type: Literal["COMPRESSOR_CHART@v2"] = Field(
28+
...,
29+
description="Defines the type of model. See documentation for more information.",
30+
title="TYPE",
31+
)
32+
curves: DataOrFile[list[YamlCurve]] = Field(
33+
..., description="Compressor chart curves, one per speed.", title="CURVES"
34+
)
35+
units: YamlUnits = UnitsField()
36+
control_margin: YamlControlMargin
37+
38+
39+
CompressorChartReference = Annotated[
40+
ModelName,
41+
AfterValidator(
42+
check_field_model_reference(
43+
allowed_types=[
44+
"COMPRESSOR_CHART@v2",
45+
]
46+
)
47+
),
48+
]
49+
50+
CompressorStageReference = str # TODO: validate correct reference
51+
52+
ProcessSystemReference: TypeAlias = str # TODO: validate correct reference
53+
ProcessSystemDefinition: TypeAlias = "YamlCompressorStageProcessSystem" | "YamlSerialParallelProcessSystem"
54+
ProcessSystemReferenceOrDefinition = ProcessSystemReference | ProcessSystemDefinition
55+
56+
57+
class YamlCompressorStageProcessSystem(YamlBase):
58+
type: Literal["COMPRESSOR_STAGE"]
59+
name: ProcessSystemReferenceOrDefinition
60+
inlet_temperature: float = Field(
61+
...,
62+
description="Inlet temperature in Celsius for stage",
63+
title="INLET_TEMPERATURE",
64+
)
65+
pressure_drop_ahead_of_stage: float = Field(
66+
0.0,
67+
description="Pressure drop before compression stage [in bar]",
68+
title="PRESSURE_DROP_AHEAD_OF_STAGE",
69+
)
70+
compressor_chart: CompressorChartReference
71+
72+
73+
class YamlItem(YamlBase):
74+
target: ProcessSystemReferenceOrDefinition
75+
76+
77+
class YamlSerialParallelProcessSystem(YamlBase):
78+
type: Literal["SERIAL", "PARALLEL"]
79+
name: ProcessSystemReferenceOrDefinition
80+
items: list[YamlItem]
81+
82+
83+
class YamlOverflow(YamlBase):
84+
FROM: CompressorStageReference
85+
TO: CompressorStageReference
86+
87+
88+
class YamlCommonStreamSetting(YamlBase):
89+
rate_fractions: list[YamlExpressionType]
90+
overflow: list[YamlOverflow]
91+
92+
93+
class YamlCommonStreamDistribution(YamlBase):
94+
method: Literal["COMMON_STREAM"]
95+
inlet_stream: StreamRef
96+
settings: list[YamlCommonStreamSetting]
97+
98+
99+
class YamlIndividualStreamDistribution(YamlBase):
100+
method: Literal["INDIVIDUAL_STREAMS"]
101+
inlet_streams: list[StreamRef]
102+
103+
104+
YamlStreamDistribution = Annotated[
105+
YamlCommonStreamDistribution | YamlIndividualStreamDistribution, Field(discriminator="method")
106+
]
107+
108+
109+
class YamlProcessSimulation(YamlBase):
110+
name: str
111+
target: ProcessSystemReferenceOrDefinition
112+
stream_distribution: YamlStreamDistribution

0 commit comments

Comments
 (0)