Skip to content
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

chore: handle requested pressures for compressor systems #215

Merged

Conversation

frodehk
Copy link
Contributor

@frodehk frodehk commented Sep 28, 2023

Why is this pull request needed?

Extracting requested inlet- and outlet pressure does not work correctly for compressor systems:
When using SUCTION_PRESSURES or DISCHARGE_PRESSURES there are one pressure per component in the system. This list of pressures is not captured and the pressures are set to nan, and then nan to num (0).

What does this pull request change?

  • Update get_requested_compressor_pressures in graph_result, to select correct pressures for compressors in system
  • Ensure correct operational setting is used for the compressors in the system

Issues related to this change:

https://equinor-ecalc.atlassian.net/browse/ECALC-252?atlOrigin=eyJpIjoiYTJiZGUwNmY5MjlhNGMwMjg5YTc1Y2FiNTY0ZTkxNDQiLCJwIjoiaiJ9

@frodehk frodehk requested a review from a team as a code owner September 28, 2023 11:04
@frodehk frodehk self-assigned this Sep 28, 2023
@frodehk frodehk force-pushed the ECALC-252-handle-requested-pressures-for-compressor-systems branch from 709a82d to ddec1b9 Compare September 28, 2023 11:08
Copy link
Contributor

@jsolaas jsolaas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we drop this and say requested pressures are good enough until v2? Wouldn't this cause confusion? If I understand it correctly this is not necessarily correct?

@frodehk
Copy link
Contributor Author

frodehk commented Sep 28, 2023

Can we drop this and say requested pressures are good enough until v2? Wouldn't this cause confusion? If I understand it correctly this is not necessarily correct?

No problem for me. Maybe disable requested pressure plots for systems then. Right now e.g. requested_inlet_pressures show up as 0 if e.g. SUCTION_PRESSURES are given (one pressure per component).

@TeeeJay
Copy link
Collaborator

TeeeJay commented Sep 29, 2023

Did you discuss this today? Should we just drop it for now? It just turns out to be "full of holes" because of all the different edge cases?

@frodehk
Copy link
Contributor Author

frodehk commented Sep 29, 2023

@TeeeJay and @jsolaas : Discussed with @HeddaSvendsen, she reminded me of the operational_settings_used. The code is now updated, and it should extract the correct requested pressures now - taking into account the relevant operational setting used, and picking the correct compressor in the system (if different pressures are specified for individual system components within a temporal model).

Have checked the model (advanced model) that was used to flag the problem with zero requested inlet pressure, it now runs with expected output (for the requested pressures).

@frodehk frodehk force-pushed the ECALC-252-handle-requested-pressures-for-compressor-systems branch from 53a9339 to 367915a Compare September 29, 2023 12:45
@@ -215,50 +216,90 @@ def _parse_emissions(emissions: Dict[str, EmissionResult]) -> Dict[str, libecalc
for key in emissions
}

@staticmethod
def get_operational_setting_index(timestep: datetime, operational_settings_used: TimeSeriesInt):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def get_operational_setting_index(timestep: datetime, operational_settings_used: TimeSeriesInt):
def get_operational_setting_index(timestep: datetime, operational_settings_used: TimeSeriesInt) -> int:

def get_operational_setting_index(timestep: datetime, operational_settings_used: TimeSeriesInt):
timestep_index = operational_settings_used.timesteps.index(timestep)

operational_setting_index = operational_settings_used.values[timestep_index]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to use a different name. This is easily confused with the index in the list. How about operational_setting_used? Or perhaps you have sth better?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or Id?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like operational_setting_used, as it refers to one entry in the in the time series operational_settings_used, or?

@TeeeJay
Copy link
Collaborator

TeeeJay commented Oct 3, 2023

This is getting overly complicated. Not your fault, it is just very difficult to get this good and right. I am afraid that we do not have enough overview of edge cases, where this will work and not etc, and whether the user can always trust the results? If we are to merge this, we should make sure that the code is isolated (doesnt break anything else), and possibly give a warning about this being experimental (using Feature.experimental, in case it fails?) which also gives a warning....

Also, we do not have any other tests than the standard tests to test this.

What do you think?

@frodehk
Copy link
Contributor Author

frodehk commented Oct 3, 2023

I agree that it is complicated, and difficult to control edge cases - with few tests really checking. On the other hand, the code that is already merged in is trying to handle the requested pressures for systems in a wrong way - and this will not make it worse I think. Is it an idea to create some targeted tests for this, especially for operational settings in compressor systems - and checking for different pressures for different compressors in the system etc.?

@TeeeJay
Copy link
Collaborator

TeeeJay commented Oct 3, 2023

I agree that it is complicated, and difficult to control edge cases - with few tests really checking. On the other hand, the code that is already merged in is trying to handle the requested pressures for systems in a wrong way - and this will not make it worse I think. Is it an idea to create some targeted tests for this, especially for operational settings in compressor systems - and checking for different pressures for different compressors in the system etc.?

I would say it is better to wrap with Feature.experimental(), for information + handle gracefully in case of error. If we get any more complications with this, we might want to remove it. It will be handled better in the future in any case.

@TeeeJay
Copy link
Collaborator

TeeeJay commented Oct 3, 2023

So, also, we need to patch it then...

@frodehk frodehk force-pushed the ECALC-252-handle-requested-pressures-for-compressor-systems branch from 2ebc77b to c34e728 Compare October 3, 2023 12:12
Copy link
Contributor

@jsolaas jsolaas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@frodehk frodehk merged commit 6b05439 into main Oct 4, 2023
6 checks passed
@frodehk frodehk deleted the ECALC-252-handle-requested-pressures-for-compressor-systems branch October 4, 2023 09:09
frodehk added a commit that referenced this pull request Oct 4, 2023
* chore: handle requested pressures for compressor systems

(cherry picked from commit 6b05439)
frodehk added a commit that referenced this pull request Oct 4, 2023
* chore: handle requested pressures for compressor systems (#215)

(cherry picked from commit 6b05439)

* chore: move feature experimental to main method for requested pressures (#230)

(cherry picked from commit 00ad854)
equinor-schen pushed a commit that referenced this pull request Nov 22, 2023
* chore: handle requested pressures for compressor systems
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants