cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Solve Block - Now a function of solving variable, too many arguments

jroth
4-Participant

Solve Block - Now a function of solving variable, too many arguments

I am wondering then how to fix this new problem. I have fixed the error for the basic file, but now I want to express the heat transfer not knowing the wall temperature but rather knowing the ambient temperature. The equations are not too bad to solve, but I'm having issues with the solve block having too many arguments after I made the functions of the variable I wish to solve for. I would like to put my conditions in as a function and get the feedback for the correct outlet temperature (assuming the thermal gradient isn't too large that the wall temperature varies greatly in the z direction along the pipe axis).

The issue is I would like to express the properties of any given substance as a function of temperature (or average temperature in most cases).

The excel spreadsheet (minus updating the properties) gives a correct answer by iterating through. The user needs to press the buttons several times until all errors are zero.

I know I can do this problem in excel or a programing language, but the outputs look messy. For my project homework I'd like to use Mathcad to express the given solution, that way it is more readily checked.

Any insight would be much appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Werner_E
24-Ruby V
(To:jroth)

It is my impression that in Mathcad the while loop should repeat while the condition is true, and stop when it is false.

Thats the behaviour in any other programming language I know of, too.

The problem is again that you use the same name for different things as you did in your other sheet.

Chose different names for the higlighted variables.

The second time your loop is executed h_i is no function anymore because you redefined it as variable in the first run and therefore the error message. Its a shame that Prime is not more helpful in finding errors in programs.

temp.png

View solution in original post

16 REPLIES 16
Werner_E
24-Ruby V
(To:jroth)

The problem are function definitions like the following one you are using.

02.12.png

You use a similar construction for other functions as well.

Use the error tracing in the calculation ribbon to see where the error stems from,

jroth
4-Participant
(To:Werner_E)

How do I use the error tracing? It is 'grayed out' for me, i.e. I'm not able to press any buttons.

Werner_E
24-Ruby V
(To:jroth)

Open your sheet, chose ribbon Calculate, click in the expression which throws the error and type F9 for recalculate. Now you should be able to use the error tracing. When you press "First" the tracing buttons are greyed out again (which should not happen) and the cursor jumps to the region I showed in my previous post.

jroth
4-Participant
(To:Werner_E)

I would also like to ask, why this doesn't work, but the following version (my simplier trial of getting this to work) did.

Werner_E
24-Ruby V
(To:jroth)

It seems to work because this time you used different function names - h() for the function with 3 paraneters and h.i for the function with just one.

In the former sheet you used h.i for both.

jroth
4-Participant
(To:Werner_E)

Ok, let me take a 360 on this and use the programming features in mathcad. I have redone the function and now I have the "must be a function" error again.

It is my impression that in Mathcad the while loop should repeat while the condition is true, and stop when it is false. So I go through the system by feeding an initial condition of Tfo (fluid outlet temperature). I then solve backwards through my system until I find the resulting Ambient Temperature that makes this Tfo true (there is only one answer). I then compare this calculated Ambient Temperature to my known ambient temperature condition. Then I use an if statment to feed/calculate a new outlet fluid temperature and as well sending the solution to a convergence. I also update the while loop condition. The while loop should then check this new condition and if it is true, go through again, but with now the new Tfo, (which is should be an increment of 0.001K larger or smaller). Once the while loop is satisfied, it should end, and then return my required values.

Werner_E
24-Ruby V
(To:jroth)

It is my impression that in Mathcad the while loop should repeat while the condition is true, and stop when it is false.

Thats the behaviour in any other programming language I know of, too.

The problem is again that you use the same name for different things as you did in your other sheet.

Chose different names for the higlighted variables.

The second time your loop is executed h_i is no function anymore because you redefined it as variable in the first run and therefore the error message. Its a shame that Prime is not more helpful in finding errors in programs.

temp.png

jroth
4-Participant
(To:Werner_E)

Thank you! It works now! I just renamed h_i to h_int and h_o to h_ext and everything is working as it should. I appreciate your help on this. It has been bugging me to no end for the last week.

I would never have guessed that was the reason for the error. Coding wise, it seemed fine.

jroth
4-Participant
(To:Werner_E)

As a reference here are the completed files with respects to both programming and a solve block.

Once again, Thankyou for all of your prompt help on the forums. It has been a great aid to new users such as myself in learning to use Mathcad.

ELSID
4-Participant
(To:jroth)

Sorry to bring up an old thread.  I cannot open these (Prime 2.0 and Mathcad 15).  It would be appreciated if someone could PDF both files.

LucMeekes
23-Emerald III
(To:ELSID)

Here you go.

 

Note that you can install Prime 4.0 Express (for free ! ) next to your existing Prime 2.

You could even work with its full capabilities for 30 days, after which it falls down to Express capabilities. This should NOT destroy your existing installation of Prime 2. Don't de-install your Prime 2 !

It will allow you to open any Prime sheet, and you may be able to copy expressions from Prime 4 to a Prime 2 sheet (with both applications open).

 

Success!
Luc

 

Werner_E
24-Ruby V
(To:ELSID)

Here you are.

I had to modify both files as the OP used more than the page width (especially in the second file which is also the reason I changed the paper size to A3) and Prime does not offer a way to print more than the first page width.

But as Luc already said you could install Prime 4. I would not bet that it would leave your Prime 2 installation intact (incl. the ability to convert legacy real Mathcad sheets in Prime2 format), so i would suggest you make a backup before installing Prime 4 or even better you may try Prime 4 in a virtual machine (if prime allows to do so, not sure).

jroth
4-Participant
(To:Werner_E)

As a check, here is the completed excel file solving for the correct cooling outlet fliud temperature (as far as I know. I should have all mistakes fixed).

IRstuff
3-Visitor
(To:jroth)

A picture of the physical configuration might be useful.

TTFN

jroth
4-Participant
(To:IRstuff)

I don't have access to a scanner currently (I'll try to upload on later).

I have a flow inside of a pipe. I want to know the outlet temperature at the end of some run. However, the heat transfer depends on the average properties (more specifically local properties), so I am calculating the heat transfer from the fluid to the pipe, the transfer of energy across the pipe, and the transfer of energy from the pipe to the ambient outside air/fluid.

Essentially, the energy lost by the fluid is equal to the energy given off to the environment for a hot flow in a pipe.

But, as i mentioned, we don't know the inside wall temperature of the pipe, nor the outside wall temperature of the pipe. If we guess the Temperature final out, we should be able to solve for the inner wall temperature of the pipe, then the outter wall temperature of the pipe, and then the ambient air. But as we know the ambient air temperature, we continue to guess the outlet fluid temperature until we have a solution, and there can only be one solution.

This is why I figured the solve block would work well for it.

IRstuff
3-Visitor
(To:jroth)

Yes, it should. You probably have too many variables defined. Given set convection and conduction, there is only one unknown, which is the surface temperature. The continuity relationship ensures that energy is conserved, so the delta temperatures across each interface are strictly determined by the amount of heat transferred.

TTFN

To clarify, given the thermal conductivity between the fluid and the ambient, there can only be one value of heat that simultaneously satisfies all of the individual heat flows so that the sum of the delta Ts equals the delta between the fluid and the ambient. This would be the way I would solve the problem.

Top Tags