HP Forums

Full Version: SOLVE for Function Vectors
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I made a program that returns VECTOR(x) expressed as [a(x),b(x),c(x)]
given that b(x) is a known value, what would be the sintaxis for solving VECTOR(x) for x with a(x), b(x) or c(x) known?

On the specifics side this is the curve for a pump, where a(x) is the head, b(x) the efficiency and c(x) the shaft power.

At any given time and generally the easiest to know would be the head. So based on the head only known I would like to know how to use the solve function in the case of a vector.

I currently have the functions as separate, but I would like to see if I can simplify this.

Thanks in advance.
Hi NomadVehr,

Welcome! I hope you find this forum both helpful and challenging (in a good way!) I'm at something of a "freshman skill level" with the Prime CAS myself, so I'm not likely to contribute directly to the answer to your question. However, your question does fall into the "show your work" category of problems posted here.

You mention head/efficiency/shaft power. Could you explain the problem you are trying to solve in terms suitable for a general audience, i.e. a water pumping station design problem? Next, could you show the equations you are working with that are used to solve the design problem? Lastly, you mention a program you wrote that addresses your design problem. The program code, if not too large, might help show how you went about trying to solve the design problem you have.

No need to do all at once! Start by describing the problem itself and your own goals. This should attract the attention of those in the forum with a similar background to your own (there are a number of Civil and Mechanical engineers posting here regularly) After that, hopefully the mathematical details will follow, and eventually advice on solving the problem itself.

As I said, I probably can't help you with the problem itself, but it does sound interesting to hear more about!

Hi Mark,

Thanks for the welcome. After a 20 year hiatus from programmable calculators spent mostly on Excel sheets I'm back into programming.

I´m a Chemical Engineer working in an Oil refinery in the Middle East.

It all started with Pump Curves. Since the statistics and curve adjustment is super friendly, plus the polynomial coefficients have more significant digits, hence more accuracy. I basically simulated the pump curve parameters for a series of pumps.

It all started with the need of having pump curves in the palm of my hand. Head, Efficiency, Power and NPSH all as a function of the flow Q. So I made separate programs for each variable of each Pump. The functions are described below.
H(Q)= Head as a function of flow Q. 4th Degree polynomial.
Eff(Q)= Efficiency as a function of flow Q. 3rd degree Polynomial.
SP(Q)=Shaft power as a function of flow Q. Linear.
NPSH(Q)= Net Positive Suction Head as a function of flow Q. Exponential.

All well here, then I ask myself, what if I just make a program to return all these functions at once by just entering the flow?
Then I faced my first road block: You cant use RETURN multiple times in the program, it will only return the function on the first return line.
Then I bump into this tutorial blog by Eddie Shore:
The Solution: A Vector!
So you basically would type:

Of course not these expressions as is, but the respective actual Polynomials or Functions.
Now I have a program that returns all the information at once by entering the flow.

The thing is that now my calculator is cluttered with the vector program and the individual functions.
So end up with programs like
And the Vector expression which groups them all.
Here´s my conundrum...I have more than 20 pumps to look after.I have done this for only 4 so far so it would take 100 programs to scroll through to solve the function.

Generally, on the field, the easiest of these functions to solve for Q is the head. Power is also relatively easy to estimate.

So when I want to check the flow against the flow meter I would determine the head, lets call it h, and use use for example

SOLVE(PUMP1H(Q)=h,Q); h i an actual number in this case.
Then the Prime will return the flow Q.

What I want to accomplish is just to keep the vector program to declutter the scrolling list then solve using the only known value is h.

Something like:
SOLVE(PUMP1HEPN(Q)=[h,unknown,unknown, unknown]);

In this part I have not succeded so far and where I am looking for someone to give me a clue on how to proceed.

Greetings from the desert,
Greetings from a fellow chemical engineer,

Have you considered returning a list instead of a vector? An example of code returning a list:

 LOCAL temp;
 return {temp,2*temp,3*temp,4*temp};

If that is your program, then:

fsolve(((PUMP1NPSH(x))(1)) = 500,x = 3)

will return 4.91058632644

Thanks a lot Road!

Tried it out and works like a charm.
Here´s the code
I used X since I copied the equations from the 2 variable statistics app.

return {"h(m)",h,"Eff(%)",Eff,"SHP(kW)",PWR};
One thing I would like to know is if there is a way to present the ouput as a vertical list


Whereas I would like it to display something more like

h(m) 169
Eff(%) 50
SHP(kW) 170
Will something like this work:

 LOCAL h,a;
Thanks Roadrunner,

I finally found the workaround thanks to the print command.
While the solution you posted didn't work as expected, it helped me get to work around.

I also made an enhancement to the program where it prompts warning messages when flow is below minimum or above end of curve:

LOCAL h,a;
IF X<80 THEN RETURN {" Warning: Flow below minimum",a};END;
IF X>340 THEN RETURN {"Warning: Flow above end of curve",a};END;

Thanks again for helping me get started,

Seems I may be in exam mode or something, now when I try the solve function for the program all I get is "[]".
It worked fine until a few hours ago.
Please help.

Exam mode would not have this effect. Do you see the orange header on the top of your calc? If no, then you are not in exam mode...

Most likely, the calculator can not find a solution to the problem (this is what the [] result means)...

Have you subtely changed your program in a way that might cause this?

Try saving/exporting what you are trying to solve to a string and look at it, it might help you notice the issue.

Thanks Cyrille,

I already reset my calculator to factory settings version 2018-02. I will start the programs with earlier working versions. Let´s see how it goes...

It might be one of the IF statements causing the unexpected result. REM those out and then try your program to eliminate that possibility. If fsolve suddenly sees a list instead of a number it will stop and return empty brackets.

Well guys,

I know some of you will facepalm like me and others will just laugh their heads off...
Here´s the solution: Make copies of the 2 variable statistics app with the data for each pump.

I feel a mix of sense of accomplishment and embarrasment.

Thanks to all of you who stepped in to help!

Another thing you may not be aware of - the location you are putting your "list" variables allows equations as well. So you can do things "like LOG(C1)+C2" or similar. You might not need to even be calculating things outside of it if you build equations correctly.
Thanks Tim and Roadrunner!

I´ll still try your suggestions with the program to see where it leads.

Here's the Pump1 app. Works for me perfectly since I can just use the solve function on the curve regressions rather easily, plus it allows me to see the pump curve plot.
I hope you find it helpful.

(06-06-2018 03:58 AM)Tim Wessman Wrote: [ -> ]Another thing you may not be aware of - the location you are putting your "list" variables allows equations as well. So you can do things "like LOG(C1)+C2" or similar. You might not need to even be calculating things outside of it if you build equations correctly.

Wow!!!! that helps me with the conversion of power to motor Amps. Big facepalm moment!!!
Thanks Time
Hi Tim,

I´m trying to insert the formula in the columna á la Excel, but it´s not working. Any tips?

Add '=' before your formula: =PWRkw*1000/(400*1.73)
Select the column name 'Amps' when you enter the formula to apply it to all cells of the column.
Thanks Didier,

Still stuck even with the '='

Will keep trying.
If you enter the formula for the whole column use: =PWRkw*1000/(400*1.73)
But if you enter the formula in a single cell, for ex row 1, then add the row number after the colum name: =PWRkw1*1000/(400*1.73)
Pages: 1 2
Reference URL's