-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: allow cross overs both in and out of the same compressor train … #709
Open
olelod
wants to merge
2
commits into
main
Choose a base branch
from
feat/allow-cross-overs-both-in-and-out-of-a-compressor-train
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ( | ||
|
@@ -65,6 +65,36 @@ 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 compressor_train_index, crossover_to in enumerate(self.crossover): | ||
crossover_to_compressor_train_index = ( | ||
crossover_to - 1 | ||
) # compressor_train_index is 0-indexed, crossover_to is 1-indexed | ||
no_crossover = crossover_to == 0 | ||
if crossover_to_compressor_train_index > compressor_train_index or no_crossover: | ||
pass # passing excess rate to a comp. train not yet evaluated or no crossover defined for this comp. train | ||
else: | ||
raise ValueError( | ||
f"Crossover: {self.crossover}\n" | ||
"The compressor trains in the compressor system are not defined in the correct order, according to " | ||
"the way the crossovers are set up. eCalc can now try to pass excess rates to compressor trains in " | ||
"the system that has already been evaluated. \n\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 (no crossover) or larger than the index " | ||
"of the current compressor train (passing excess rate to a compressor train not yet evaluated). \n\n" | ||
"CROSSOVER: [2, 3, 0] is valid, but CROSSOVER: [2, 1, 0] is not. \n" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. v2 does the sorting for the user, just sayin' |
||
) | ||
|
||
return self | ||
|
||
def train_not_evaluated(self, index: int): | ||
if self.crossover is None: | ||
return False | ||
return self.crossover[index] == 0 | ||
|
||
|
||
class YamlPumpSystemOperationalSettings(YamlCompressorSystemOperationalSetting): | ||
fluid_densities: list[YamlExpressionType] = Field( | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct? Or should it be not evaluated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way it works now if you have crossover: [0, 1, 0], you first evaluate the first consumer (here it has no crossover). The next consumers can pass excess rate to the first one, potentially exceeding the maximum rate there, and the operational setting will be chosen even if it is invalid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sentence
eCalc can now try to pass excess rates to compressor trains the system that has already been evaluated
confused me. Is the intention to inform the user why the current crossover setting isn't allowed? SoIf we were to allow this crossover setup, eCalc™ could try to pass excess rates to compressor trains in the system that has already been evaluated
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Poorly phrased, I guess... Yes, that was happening in one model. The first train is within capacity, the second one outside capacity, so rate was passed to the first one (which then with the additional rate was outside capacity).