question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Evaluating properties based on an array of input parameters

See original GitHub issue

For example, if I have a large numpy array of temperature values (say a million-element long), other than calling thermo in a for loop, is there a vectorized way to extract properties from thermo?

Many thanks, Amin

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
CalebBellcommented, Dec 31, 2021

Hi,

I added an example of using multiprocessing to speed up multiple phase equilibria calculations: https://thermo.readthedocs.io/Examples/Performing Large Numbers of Calculations with Thermo in Parallel.html I hope this is helpful. I don’t have any plans to vectorize calculations further or add a convenience wrapper which allows numpy arrays as inputs. I don’t know what broadcasting rules would be best for that sort of an interface, and I don’t think using a loop is too onerous on users. The numba backend will hopefully continue to be developed for those who want to use numba’s parallelization features. I can try to answer specific questions about parallelism here if you have questions.

Sincerely, Caleb

1reaction
CalebBellcommented, Nov 19, 2019

Hi Amin,

My experience with CFD suggests tabular interpolation is the way to go. Calculating these properties will definitely be one of the slowest steps, and applying simplifications is normal - calling thermo directly would be too slow no matter what happened.

So you might make a lookup table of say T, P, and composition; and fill it out with values from thermo. Then during the simulation, interpolate with the nearest values. Some of numpy’s interpolation routines might be suitable but more likely would also be too slow.

Sincerely, Caleb

Read more comments on GitHub >

github_iconTop Results From Across the Web

Select a property from an array of objects based on a value
It will evaluate the method passed in foreach for each element of the array and check if the element.checked is true it will...
Read more >
Data Structures: Objects and Arrays - Eloquent JavaScript
When using square brackets, the expression between the brackets is evaluated to get the property name. Whereas value. x fetches the property of...
Read more >
Destructuring assignment - JavaScript - MDN Web Docs
The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from ...
Read more >
Set or skip an object property based on a condition · Issue #387
I'd like to be able to define all rules in one array and use bool parameters to control which rules to be included...
Read more >
Select statment from a Filter Array - Power Platform Community
Solved: Hi, im runing a flow which suppose to get a list of items from excel than im filtering it with Filter array....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found