|
61 | 61 | from libecalc.expression import Expression |
62 | 62 | from libecalc.expression.expression import InvalidExpressionError |
63 | 63 | from libecalc.infrastructure.neqsim_fluid_provider.neqsim_fluid_factory import NeqSimFluidFactory |
| 64 | +from libecalc.presentation.yaml.domain.ecalc_components import ProcessSystemComponent, SimplifiedProcessUnitComponent |
64 | 65 | from libecalc.presentation.yaml.domain.expression_time_series_flow_rate import ExpressionTimeSeriesFlowRate |
65 | 66 | from libecalc.presentation.yaml.domain.expression_time_series_fluid_density import ExpressionTimeSeriesFluidDensity |
66 | 67 | from libecalc.presentation.yaml.domain.expression_time_series_power import ExpressionTimeSeriesPower |
@@ -940,6 +941,7 @@ def __init__( |
940 | 941 | self._period_subsets = {} |
941 | 942 | self._time_adjusted_model = define_time_model_for_period(energy_usage_model, target_period=target_period) |
942 | 943 | self._mapping_context = mapping_context |
| 944 | + self._process_service = mapping_context._process_service |
943 | 945 | self._consumer_id = consumer_id |
944 | 946 | for period in self._time_adjusted_model: |
945 | 947 | start_index, end_index = period.get_period_indices(expression_evaluator.get_periods()) |
@@ -1105,10 +1107,11 @@ def _map_pump( |
1105 | 1107 | ) |
1106 | 1108 | # Register the pump model and its evaluation input in the mapping context |
1107 | 1109 | model_id = uuid4() |
1108 | | - self._mapping_context.register_simplified_process_unit(id=model_id, simplified_process_unit=pump_model) |
1109 | | - self._mapping_context.register_evaluation_input(id=model_id, evaluation_input=evaluation_input) |
1110 | | - # Ensure that the process system ID is associated with the correct consumer ID and period |
1111 | | - self._mapping_context.map_model_to_consumer(consumer_id=consumer_id, period=period, model_id=model_id) |
| 1110 | + component = SimplifiedProcessUnitComponent(id=model_id, name=model.energy_function, type=model.type) |
| 1111 | + self._process_service.register_simplified_process_unit( |
| 1112 | + ecalc_component=component, simplified_process_unit=pump_model, evaluation_input=evaluation_input |
| 1113 | + ) |
| 1114 | + self._process_service.map_model_to_consumer(consumer_id=consumer_id, period=period, ecalc_component=component) |
1112 | 1115 |
|
1113 | 1116 | return pump_model |
1114 | 1117 |
|
@@ -1195,11 +1198,11 @@ def _map_multiple_streams_compressor( |
1195 | 1198 | ) |
1196 | 1199 |
|
1197 | 1200 | # Register the compressor model and its evaluation input in the mapping context |
1198 | | - self._mapping_context.register_process_system(id=process_system_id, process_system=compressor_train_model) |
1199 | | - self._mapping_context.register_evaluation_input(id=process_system_id, evaluation_input=evaluation_input) |
1200 | | - |
1201 | | - # Ensure that the process system ID is associated with the correct consumer ID and period |
1202 | | - self._mapping_context.map_model_to_consumer(consumer_id=consumer_id, period=period, model_id=process_system_id) |
| 1201 | + component = ProcessSystemComponent(id=process_system_id, name=model.compressor_train_model, type=model.type) |
| 1202 | + self._process_service.register_process_system( |
| 1203 | + ecalc_component=component, process_system=compressor_train_model, evaluation_input=evaluation_input |
| 1204 | + ) |
| 1205 | + self._process_service.map_model_to_consumer(consumer_id=consumer_id, period=period, ecalc_component=component) |
1203 | 1206 |
|
1204 | 1207 | return compressor_train_model |
1205 | 1208 |
|
@@ -1286,27 +1289,36 @@ def _map_compressor( |
1286 | 1289 | ) |
1287 | 1290 |
|
1288 | 1291 | model_id = uuid4() |
1289 | | - # Register the compressor model and its evaluation input in the mapping context |
| 1292 | + # Register the compressor model and its evaluation input in the process service |
1290 | 1293 | # - If it is a sampled model, or a turbine model wrapping a sampled model, treat as non-process. |
1291 | 1294 | # - Otherwise, treat as a process model. |
1292 | 1295 | if isinstance(compressor_model, CompressorModelSampled): |
1293 | | - self._mapping_context.register_simplified_process_unit( |
1294 | | - id=model_id, simplified_process_unit=compressor_model |
| 1296 | + component = SimplifiedProcessUnitComponent(id=model_id, name=model.energy_function, type=model.type) |
| 1297 | + self._process_service.register_simplified_process_unit( |
| 1298 | + ecalc_component=component, simplified_process_unit=compressor_model, evaluation_input=evaluation_input |
1295 | 1299 | ) |
1296 | 1300 | elif isinstance(compressor_model, CompressorWithTurbineModel): |
1297 | 1301 | if isinstance(compressor_model.compressor_model, CompressorModelSampled): |
1298 | | - self._mapping_context.register_simplified_process_unit( |
1299 | | - id=model_id, simplified_process_unit=compressor_model |
| 1302 | + component = SimplifiedProcessUnitComponent(id=model_id, name=model.energy_function, type=model.type) |
| 1303 | + self._process_service.register_simplified_process_unit( |
| 1304 | + ecalc_component=component, |
| 1305 | + simplified_process_unit=compressor_model, |
| 1306 | + evaluation_input=evaluation_input, |
1300 | 1307 | ) |
1301 | 1308 | else: |
1302 | | - self._mapping_context.register_process_system(id=model_id, process_system=compressor_model) |
1303 | | - else: |
1304 | | - self._mapping_context.register_process_system(id=model_id, process_system=compressor_model) |
| 1309 | + component = ProcessSystemComponent(id=model_id, name=model.energy_function, type=model.type) |
| 1310 | + self._process_service.register_process_system( |
| 1311 | + ecalc_component=component, process_system=compressor_model, evaluation_input=evaluation_input |
| 1312 | + ) |
1305 | 1313 |
|
1306 | | - self._mapping_context.register_evaluation_input(id=model_id, evaluation_input=evaluation_input) |
| 1314 | + else: |
| 1315 | + component = ProcessSystemComponent(id=model_id, name=model.energy_function, type=model.type) |
| 1316 | + self._process_service.register_process_system( |
| 1317 | + ecalc_component=component, process_system=compressor_model, evaluation_input=evaluation_input |
| 1318 | + ) |
1307 | 1319 |
|
1308 | 1320 | # Ensure that the process system ID is associated with the correct consumer ID and period |
1309 | | - self._mapping_context.map_model_to_consumer(consumer_id=consumer_id, period=period, model_id=model_id) |
| 1321 | + self._process_service.map_model_to_consumer(consumer_id=consumer_id, period=period, ecalc_component=component) |
1310 | 1322 |
|
1311 | 1323 | return compressor_model |
1312 | 1324 |
|
|
0 commit comments