|
1 | 1 | """ |
2 | 2 | Dummy process implementation for testing purposes. |
3 | 3 | """ |
| 4 | +import uuid |
4 | 5 | from datetime import datetime |
5 | 6 |
|
| 7 | +from libecalc.domain.process.entities.process_units.compressor import Compressor |
6 | 8 | from libecalc.domain.process.entities.process_units.legacy_compressor.legacy_compressor import LegacyCompressor |
| 9 | +from libecalc.domain.process.process_simulation import ProcessSimulation, PressureControlConfig, AntiSurgeConfig, \ |
| 10 | + Constraint, IndividualStreamDistributionConfig, ProcessPipeline, create_process_simulation_id |
| 11 | +from libecalc.domain.process.process_solver.anti_surge import anti_surge_strategy |
7 | 12 | from libecalc.domain.process.process_system.serial_process_system import SerialProcessSystem |
8 | 13 | from libecalc.domain.process.value_objects.fluid_stream.fluid_stream import SimpleStream |
| 14 | +from libecalc.presentation.yaml.domain.time_series_expression import TimeSeriesExpression |
9 | 15 | from libecalc.presentation.yaml.mappers.fluid_mapper import MEDIUM_MW_19P4 |
10 | 16 |
|
11 | 17 | """ |
|
20 | 26 | from libecalc.domain.process.process_solver.boundary import Boundary |
21 | 27 | from libecalc.domain.process.process_system.compressor_stage_process_unit import CompressorStageProcessUnit |
22 | 28 | from libecalc.domain.process.process_system.process_error import OutsideCapacityError, RateTooHighError, RateTooLowError |
23 | | -from libecalc.domain.process.process_system.process_system import ProcessSystem, create_process_system_id |
| 29 | +from libecalc.domain.process.process_system.process_system import ProcessSystem, create_process_system_id, \ |
| 30 | + ProcessSystemId |
24 | 31 | from libecalc.domain.process.process_system.process_unit import ProcessUnitId, create_process_unit_id |
25 | 32 | from libecalc.domain.process.value_objects.chart import ChartCurve |
26 | 33 | from libecalc.domain.process.value_objects.chart.chart import ChartData |
@@ -78,93 +85,95 @@ def propagate_stream(self, inlet_stream: FluidStream) -> FluidStream: |
78 | 85 | raise OutsideCapacityError() |
79 | 86 | return result.outlet_stream |
80 | 87 |
|
81 | | - |
82 | | -def process_system_dummy() -> ProcessSystem: |
83 | | - def chart_data() -> ChartData: |
84 | | - # TODO: 2 compressors use this chart data - is it sharable in db; but in domain objs it is VO? |
85 | | - # Should we enforce this in YAML too? |
86 | | - return UserDefinedChartData( |
87 | | - curves=[ |
88 | | - ChartCurve( |
89 | | - rate_actual_m3_hour=[3000.0, 3500.0, 4000.0, 4500.0], |
90 | | - polytropic_head_joule_per_kg=[8500.0, 8000.0, 7500.0, 6500.0], |
91 | | - efficiency_fraction=[0.72, 0.75, 0.74, 0.70], |
92 | | - speed_rpm=7500.0, |
93 | | - ), |
94 | | - ChartCurve( |
95 | | - rate_actual_m3_hour=[4100.0, 4600.0, 5000.0, 5500.0, 6000.0, 6500.0], |
96 | | - polytropic_head_joule_per_kg=[16500.0, 16500.0, 15500.0, 14500.0, 13500.0, 12000.0], |
97 | | - efficiency_fraction=[0.72, 0.73, 0.74, 0.74, 0.72, 0.70], |
98 | | - speed_rpm=10500.0, |
99 | | - ), |
100 | | - ], |
101 | | - control_margin=0.0, |
| 88 | +dummy_process_pipeline_id = uuid.uuid4() |
| 89 | + |
| 90 | +def process_simulation_dummy() -> ProcessSimulation: |
| 91 | + return ProcessSimulation( |
| 92 | + id=create_process_simulation_id(), |
| 93 | + process_pipeline_id=dummy_process_pipeline_id, |
| 94 | + pressure_control_strategy=PressureControlConfig( |
| 95 | + type="DOWNSTREAM_CHOKE" |
| 96 | + ), |
| 97 | + anti_surge_strategy=AntiSurgeConfig( |
| 98 | + type="COMMON_ASV", |
| 99 | + ), |
| 100 | + constraint=Constraint( |
| 101 | + outlet_pressure=200.0 |
| 102 | + ), |
| 103 | + inlet_stream=process_system_dummy_stream() |
| 104 | + ) |
| 105 | + |
| 106 | +def shaft_dummy() -> Shaft: |
| 107 | + return VariableSpeedShaft( |
| 108 | + speed_rpm=10500.0 |
| 109 | + ) # TODO: Should not set speed here, but we may want to set min and max here ...(from data or explicit) |
| 110 | + |
| 111 | + |
| 112 | +def chart_data_dummy() -> ChartData: |
| 113 | + # TODO: 2 compressors use this chart data - is it sharable in db; but in domain objs it is VO? |
| 114 | + # Should we enforce this in YAML too? |
| 115 | + return UserDefinedChartData( |
| 116 | + curves=[ |
| 117 | + ChartCurve( |
| 118 | + rate_actual_m3_hour=[3000.0, 3500.0, 4000.0, 4500.0], |
| 119 | + polytropic_head_joule_per_kg=[8500.0, 8000.0, 7500.0, 6500.0], |
| 120 | + efficiency_fraction=[0.72, 0.75, 0.74, 0.70], |
| 121 | + speed_rpm=7500.0, |
| 122 | + ), |
| 123 | + ChartCurve( |
| 124 | + rate_actual_m3_hour=[4100.0, 4600.0, 5000.0, 5500.0, 6000.0, 6500.0], |
| 125 | + polytropic_head_joule_per_kg=[16500.0, 16500.0, 15500.0, 14500.0, 13500.0, 12000.0], |
| 126 | + efficiency_fraction=[0.72, 0.73, 0.74, 0.74, 0.72, 0.70], |
| 127 | + speed_rpm=10500.0, |
| 128 | + ), |
| 129 | + ], |
| 130 | + control_margin=0.0, |
| 131 | + ) |
| 132 | + |
| 133 | + |
| 134 | +def compressors_dummy() -> list[Compressor]: |
| 135 | + common_shaft = shaft_dummy() |
| 136 | + return [ |
| 137 | + Compressor( |
| 138 | + process_unit_id=create_process_unit_id(), |
| 139 | + compressor_chart=chart_data_dummy(), |
| 140 | + fluid_service=NeqSimFluidService.instance(), |
| 141 | + shaft=common_shaft, |
| 142 | + ), |
| 143 | + Compressor( |
| 144 | + process_unit_id=create_process_unit_id(), |
| 145 | + compressor_chart=chart_data_dummy(), |
| 146 | + fluid_service=NeqSimFluidService.instance(), |
| 147 | + shaft=common_shaft, |
102 | 148 | ) |
| 149 | + ] |
103 | 150 |
|
104 | | - def shaft() -> Shaft: |
105 | | - return VariableSpeedShaft( |
106 | | - speed_rpm=10500.0 |
107 | | - ) # TODO: Should not set speed here, but we may want to set min and max here ...(from data or explicit) |
108 | | - |
109 | | - ## e.g. loaded from db, after solving has taken place |
110 | | - def train() -> ProcessSystem: |
111 | | - common_shaft = shaft() |
112 | | - process_system = SerialProcessSystem( |
113 | | - process_system_id=create_process_system_id(), |
114 | | - propagators=[ |
115 | | - MyStageProcessUnit( |
116 | | - compressor_stage=CompressorTrainStage( |
117 | | - compressor=LegacyCompressor( |
118 | | - compressor_chart=chart_data(), |
119 | | - fluid_service=NeqSimFluidService.instance(), |
120 | | - shaft=common_shaft, |
121 | | - ), |
122 | | - temperature_setter=TemperatureSetter( |
123 | | - process_unit_id=create_process_unit_id(), |
124 | | - fluid_service=NeqSimFluidService.instance(), |
125 | | - required_temperature_kelvin=30 + 273.15, |
126 | | - ), |
127 | | - liquid_remover=None, |
128 | | - rate_modifier=RateModifier(compressor_chart=chart_data(), shaft=common_shaft), |
129 | | - fluid_service=NeqSimFluidService.instance(), |
130 | | - splitter=None, |
131 | | - mixer=None, |
132 | | - choke=None, |
133 | | - interstage_pressure_control=None, |
134 | | - ) |
135 | | - ), |
136 | | - MyStageProcessUnit( |
137 | | - compressor_stage=CompressorTrainStage( |
138 | | - compressor=LegacyCompressor( |
139 | | - compressor_chart=chart_data(), |
140 | | - fluid_service=NeqSimFluidService.instance(), |
141 | | - shaft=common_shaft, |
142 | | - ), |
143 | | - temperature_setter=TemperatureSetter( |
144 | | - process_unit_id=create_process_unit_id(), |
145 | | - fluid_service=NeqSimFluidService.instance(), |
146 | | - required_temperature_kelvin=30 + 273.15, |
147 | | - ), |
148 | | - liquid_remover=None, |
149 | | - rate_modifier=RateModifier(compressor_chart=chart_data(), shaft=common_shaft), |
150 | | - fluid_service=NeqSimFluidService.instance(), |
151 | | - splitter=None, |
152 | | - mixer=None, |
153 | | - choke=None, |
154 | | - interstage_pressure_control=None, |
155 | | - ) |
156 | | - ), |
157 | | - Choke( # DownStreamChoke - default PressureControlMechanism when not specified |
| 151 | +def process_pipeline_dummy() -> ProcessPipeline: |
| 152 | + # TODO: Process system ..? |
| 153 | + propagators = [*compressors_dummy(), |
| 154 | + Choke( # DownStreamChoke - default PressureControlMechanism when not specified |
158 | 155 | process_unit_id=create_process_unit_id(), |
159 | 156 | fluid_service=NeqSimFluidService.instance(), |
160 | 157 | pressure_change=0.0, # No need to choke...we meet outlet target pressure perfectly... |
161 | | - ), |
162 | | - ], |
163 | | - ) |
164 | | - |
165 | | - return process_system |
| 158 | + ), |
| 159 | + ] |
| 160 | + return ProcessPipeline( |
| 161 | + id=dummy_process_pipeline_id, |
| 162 | + stream_propagators=propagators |
| 163 | + ) |
| 164 | + |
| 165 | +def process_system_dummy_stream() -> SimpleStream: |
| 166 | + fluid_model = FluidModel(eos_model=EoSModel.SRK, composition=MEDIUM_MW_19P4) |
| 167 | + pressure = 20.0 |
| 168 | + temperature_kelvin = 273.15 + 30 |
| 169 | + standard_rate_m3_per_day = 4000000 |
166 | 170 |
|
167 | | - return train() |
| 171 | + return SimpleStream( |
| 172 | + fluid_model=fluid_model, |
| 173 | + pressure_bara=pressure, |
| 174 | + temperature_kelvin=temperature_kelvin, |
| 175 | + standard_rate_m3_per_day=standard_rate_m3_per_day, |
| 176 | + ) |
168 | 177 |
|
169 | 178 | def process_system_dummy_streams() -> dict[datetime, SimpleStream | FluidStream]: |
170 | 179 | fluid_model = FluidModel(eos_model=EoSModel.SRK, composition=MEDIUM_MW_19P4) |
|
0 commit comments