Skip to content

Commit 6c1988a

Browse files
committed
feat: add PORTS and STREAM_CONNECTIONS to process system schema
Refs: equinor/ecalc-internal#1809
1 parent 77e5d7e commit 6c1988a

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

src/libecalc/presentation/yaml/yaml_types/components/yaml_process_system.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import enum
12
from typing import Annotated, Literal, TypeVar
23

34
from pydantic import Field
@@ -10,6 +11,43 @@
1011
from libecalc.presentation.yaml.yaml_types.yaml_data_or_file import DataOrFile
1112

1213
StreamRef = str
14+
PortName = str
15+
PortReference = str # hierarchical: "target.stage.port" or "stage.port" (single-target case)
16+
17+
18+
class YamlPortType(enum.StrEnum):
19+
INLET = "INLET"
20+
OUTLET = "OUTLET"
21+
22+
23+
class YamlPort(YamlBase):
24+
type: Annotated[
25+
YamlPortType,
26+
Field(
27+
title="TYPE",
28+
description="Port direction: INLET (stream enters the stage) or OUTLET (stream leaves the stage).",
29+
),
30+
]
31+
32+
33+
class YamlStreamConnection(YamlBase):
34+
port: Annotated[
35+
PortReference,
36+
Field(
37+
title="PORT",
38+
description=(
39+
"Hierarchical reference to a port declared on a stage: 'target.stage.port'. "
40+
"The 'target.' prefix may be omitted when the simulation has a single target."
41+
),
42+
),
43+
]
44+
stream: Annotated[
45+
StreamRef,
46+
Field(
47+
title="STREAM",
48+
description="Reference to a stream declared in INLET_STREAMS.",
49+
),
50+
]
1351

1452

1553
class YamlControlMargin(YamlBase):
@@ -73,6 +111,17 @@ class YamlCompressorStageProcessSystem(YamlBase):
73111
),
74112
] = 0.0
75113
compressor: CompressorReference | YamlCompressor
114+
ports: Annotated[
115+
dict[PortName, YamlPort] | None,
116+
Field(
117+
title="PORTS",
118+
description=(
119+
"Optional mapping of port name → port specification. Declares physical interstage "
120+
"connection points where fluid streams can be added (INLET) or extracted (OUTLET). "
121+
"Wired to streams via STREAM_CONNECTIONS on the PROCESS_SIMULATION."
122+
),
123+
),
124+
] = None
76125

77126

78127
TTarget = TypeVar("TTarget")
@@ -131,6 +180,17 @@ class YamlProcessSimulation(YamlBase):
131180
Field(title="TARGETS"),
132181
]
133182
stream_distribution: YamlStreamDistribution
183+
stream_connections: Annotated[
184+
list[YamlStreamConnection] | None,
185+
Field(
186+
title="STREAM_CONNECTIONS",
187+
description=(
188+
"Optional list of port-to-stream mappings. Each entry connects a port "
189+
"(declared on a stage via PORTS) to a stream (declared in INLET_STREAMS). "
190+
"INLET ports receive a stream into the train; OUTLET ports extract a stream."
191+
),
192+
),
193+
] = None
134194
pressure_control: Annotated[
135195
dict[
136196
ProcessSystemReference,

0 commit comments

Comments
 (0)