Skip to content

Commit

Permalink
feat: allow cross overs both in and out of the same compressor train …
Browse files Browse the repository at this point in the history
…in a compressor system

This can be done if it is made sure that the compressor trains in the compressor system
are processed in the right order. You can only pass rates to a compressor train that
has not been processed yet. Hence, the indexes in the list specifying the cross overs
must be increasing (or zero, meaning no cross over).
  • Loading branch information
olelod committed Nov 22, 2024
1 parent 09929cb commit cf7be3f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit cf7be3f

Please sign in to comment.