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

[Feature Request] vectorized P & T input and/or soft-fail error handling. #42

Closed
k-a-mendoza opened this issue Feb 8, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@k-a-mendoza
Copy link

For use of a specific fluid property, I currently do the following:

def calc_density(P,T,water: Fluid): 
    try:
        water.update(Input.pressure(P * 1e9), Input.temperature(T-273.15))
     except:
        return np.nan
     return water.density

This allows me to both vectorize calculation of the property across a P-T grid, and fill the result with nan's should the query lie outside of the database bounds. However, for large (200x200) P-T grids, this operation can be quite slow, probably because of the try/except block. I can see two possible ways to improve code execution:

  • propagate nan's in a manner which simply return nan if any of the input is invalid.

  • allow implicit vectorization of numpy arrays P & T data over the internal coolprop calls.

I'm not sure how this would work behind the scenes, its possible it might break the OOP structure to implement these fixes.
Considering im currently getting runtimes of a few minutes to 30min or more, I figure id bring it up anyways.

@portyanikhin portyanikhin added the enhancement New feature or request label Feb 13, 2024
@portyanikhin portyanikhin self-assigned this Feb 13, 2024
@portyanikhin
Copy link
Owner

Hello, @k-a-mendoza!

However, for large (200x200) P-T grids, this operation can be quite slow, probably because of the try/except block.

I don't think it's related to the try-except block, it's not that expensive. To identify the cause for sure, you should use a profiler. Before adopting a strategy to solve the problem, you should make sure that this is the reason.

  • propagate nan's in a manner which simply return nan if any of the input is invalid.

It's always impossible to return nan for sure, this will break the code for PyFluids users. This is only necessary in your particular case, most simply don't need it.

  • allow implicit vectorization of numpy arrays P & T data over the internal coolprop calls.

I don't think this is within the PyFluids' area of responsibility (I can't even imagine how this can be implemented yet).

@portyanikhin portyanikhin closed this as not planned Won't fix, can't repro, duplicate, stale Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants