CalebBell / fluids

Fluid dynamics component of Chemical Engineering Design Library (ChEDL)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request: Use np.sqrt() instead of math.sqrt()

Idontknowwhatimdoing1234 opened this issue · comments

It would be nice if the usage of math.sqrt would be replaced by the use of np.sqrt().

If one is to evaluate Arrays of Data the math.sqrt() Function will raise:
TypeError: cannot convert the series to <class 'float'>
even though a series with the type of float is given.

It would make using the fluid module more convenient.
image
image

Solution: (Sorry i forgot to append)
image

Sorry again i forgot to mention i discoverd the error while trying to calculate the Froude number!

Hi Idontknowwhatimdoing1234,

Thank you for reaching out and your interest in fluids. Support for numpy arrays is provided in fluids according to the following documentation: https://fluids.readthedocs.io/fluids.vectorized.html
If you are on a platform that supports numba as well, you can accelerate the fluids library with it as shown here: https://fluids.readthedocs.io/fluids.numba.html#numpy-support-fluids-numba-vectorized
You can see another discussion of this issue here: #13 and another about obtaining maximum speed here: CalebBell/chemicals#27
The TL;DR is that I am happy with these options instead of using numpy, and while numpy can be quite convenient, for scalar calls it slows things down unacceptably so I chose not to use it.
I wish that weren't the case, but it is the case today.

Sincerely,
Caleb

Hello Caleb,

thank you for your response. That one is completly on me... i didnt see that there was the possibility to vectorize it! Userneame checks out i would say :D

Thank you and keep up the great work!