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

Array Multiplication & Division in pc.re_pipe #321

Open
WPennock opened this issue Apr 16, 2022 · 1 comment
Open

Array Multiplication & Division in pc.re_pipe #321

WPennock opened this issue Apr 16, 2022 · 1 comment

Comments

@WPennock
Copy link
Collaborator

I have been inputting 8-element long arrays for diameter and flow rate into pc.re_pipe. When I do this, I get an (8, 8, 1) matrix. If I then switch from a single value of kinematic viscosity to 8, I get an (8, 8, 8) matrix. I can't figure out what's going wrong, since when I write out the operation that is written in the code for pc.re_pipe, I get a single (8,) array. This phenomenon throws off all dependent functions (e.g., fric_pipe).

I will show the error here:


D = [0.30, 0.20, 0.20, 0.20, 0.20, 0.20, 0.20, 0.25]*u.m 
Q_0 = [0.20, 0.10, 0.10, 0.05, 0.05, 0.10, 0.20, 0.25]*u.m**3/u.s
nu = 1E-6*u.m**2/u.s

print(np.shape((4 * Q_0) / (np.pi * D * nu)))

print(np.shape(ac.fric_pipe(Q_0,D,nu,eps)))

and this returns


(8,)
(8, 8, 1)

@HannahSi
Copy link
Member

HannahSi commented May 6, 2022

Hi @WPennock! Apologies for the late response to your issue. What you're seeing is the result of a function with the utility.list_handler() decorator above it (or, in the source code, @ut.list_handler()). This decorator was added to many functions in the aguaclara package to emulate NumPy functions that can either take in scalar inputs and produce scalar outputs or take in vector inputs and produce vector outputs (so giving a function a list of values is similar to calling the function on each value and storing the outputs in a list). When multiple inputs are lists, the result is a multidimensional array. There's a more thorough explanation in the documentation here.

The functionality isn't very well documented, and I don't blame you for being confused. What do you need to pass 8-element arrays into pc.re_pipe for? What kind of output do you need?

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

No branches or pull requests

2 participants