diff --git a/src/libecalc/core/consumers/legacy_consumer/system/consumer_function.py b/src/libecalc/core/consumers/legacy_consumer/system/consumer_function.py index 5963bab35d..41f756099f 100644 --- a/src/libecalc/core/consumers/legacy_consumer/system/consumer_function.py +++ b/src/libecalc/core/consumers/legacy_consumer/system/consumer_function.py @@ -287,7 +287,7 @@ def calculate_operational_settings_after_cross_over( f" {type(energy_usage_model).__name__} has not been implemented." f" This should not happen. Please contact eCalc support." ) - transfer_rate = requested_rates[consumer_index] - consumer_maximum_rate + transfer_rate = rates_after_cross_over[consumer_index] - consumer_maximum_rate # Only transfer when max rate is exceeded transfer_rate = np.where(transfer_rate > 0, transfer_rate, 0) diff --git a/src/libecalc/presentation/yaml/yaml_types/components/legacy/energy_usage_model/yaml_energy_usage_model_consumer_system.py b/src/libecalc/presentation/yaml/yaml_types/components/legacy/energy_usage_model/yaml_energy_usage_model_consumer_system.py index 6503cfe98a..fd6338778f 100644 --- a/src/libecalc/presentation/yaml/yaml_types/components/legacy/energy_usage_model/yaml_energy_usage_model_consumer_system.py +++ b/src/libecalc/presentation/yaml/yaml_types/components/legacy/energy_usage_model/yaml_energy_usage_model_consumer_system.py @@ -1,6 +1,6 @@ from typing import Literal -from pydantic import Field +from pydantic import Field, model_validator from libecalc.presentation.yaml.yaml_types import YamlBase from libecalc.presentation.yaml.yaml_types.components.legacy.energy_usage_model.common import ( @@ -65,6 +65,24 @@ class YamlCompressorSystemOperationalSetting(YamlBase): description="Set suction pressure equal for all consumers in a consumer system operational setting. \n\n$ECALC_DOCS_KEYWORDS_URL/SUCTION_PRESSURE", ) + @model_validator(mode="after") + def ensure_increasing_cross_over(self): + if self.crossover is None: + return self + for index, crossover in enumerate(self.crossover): + if crossover >= max(self.crossover[: index + 1]) or crossover == 0: + pass + else: + raise ValueError( + f"Crossover: {self.crossover}\n" + "To avoid loops and to avoid passing rates to compressor trains that have already been " + "processed, the index of the crossovers should be either 0 or increasing in the list. " + "This can probably be fixed by changing the order of the compressor trains in " + "the compressor system. " + ) + + return self + class YamlPumpSystemOperationalSettings(YamlCompressorSystemOperationalSetting): fluid_densities: list[YamlExpressionType] = Field(