|
| 1 | +import enum |
1 | 2 | from typing import Annotated, Literal, TypeVar |
2 | 3 |
|
3 | 4 | from pydantic import Field |
|
10 | 11 | from libecalc.presentation.yaml.yaml_types.yaml_data_or_file import DataOrFile |
11 | 12 |
|
12 | 13 | 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 | + ] |
13 | 51 |
|
14 | 52 |
|
15 | 53 | class YamlControlMargin(YamlBase): |
@@ -73,6 +111,17 @@ class YamlCompressorStageProcessSystem(YamlBase): |
73 | 111 | ), |
74 | 112 | ] = 0.0 |
75 | 113 | 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 |
76 | 125 |
|
77 | 126 |
|
78 | 127 | TTarget = TypeVar("TTarget") |
@@ -131,6 +180,17 @@ class YamlProcessSimulation(YamlBase): |
131 | 180 | Field(title="TARGETS"), |
132 | 181 | ] |
133 | 182 | 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 |
134 | 194 | pressure_control: Annotated[ |
135 | 195 | dict[ |
136 | 196 | ProcessSystemReference, |
|
0 commit comments