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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Multiple Outputs from Solveblock - Intermediate Variables as Output included

jroth
4-Participant

Multiple Outputs from Solveblock - Intermediate Variables as Output included

Hello,

Looking to get multiple outputs from a solve block where some of the outputs are intermediate stages in the calculations. I'm getting an error when I try the normal things one might think of such as entering Tso(Tfo) and Tsi(Tfo). Looking to use the solve block becuase it is faster, but I can stick with the programmed version if that is necessary.

I like the Solve block version more, becuase the accuracy should be greater regarding the equations due to where I inserted the radiation componenet, though I think they should be fairly close for the majority of items.

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

Not sure what the problem is - both sheets don't show any errors?

I am confused as of the many function definitions IN the solve block. They should not be inside the block IMHO and the parameters you pass should be also arguments of those functions.

And the Excel sheets seems to have nothing to do with the question.

jroth
4-Participant
(To:Werner_E)

Werner,

I have altered the sheet to include the parameters I wanted output as well. I'm looking for a similar output in Temp Solve 3 as I have in my Temp Solve 4 where I programmed in the solving loop.

The excel sheet is a sanity check that the calculations I am getting back in MathCad are accurate.

If I shouldn't define the functions inside the solve block, how should I define them outside the solve block so that the system still solves. Instead of defining my constraint as Qcon + Qrad = Qtrans, should I rather define the constraint in as few variables as possible? I thought that the Constraint of the heat balance would be easiest to read.

Werner_E
24-Ruby V
(To:jroth)

You have only one equation to solve in your solve block, so you solve for just one variable, Tfo.

You want to see the function result of T.si(T.fo) where T.fo is the found value? Then simply assign the result of Temos(...) to a variable and put that variable as argument of the function T.si() and evaluate. For this to work T.si() must be defined outside the solve block, otherwise its not known on the worksheet level (thats different to MC15).

See attached the problem partly solved.

Its annoying to have to type so many arguments in so many functions, but as you want the result being made dependend on that many parameters you have no choice.

Of course you may consider turning some functions into bigger programming routines where you can use local functions with fewer arguments (like you did in the solve block). But everything you make local is not availabel outside, as you could see with T.si.

Of course you could leave all as it is and redefine T.si outside a second time, but thats in no way recommended.

At the end your solve block would consist just of three lines: the guess value for Tfo, the one equation to solve and the line with Find().

Werner_E
24-Ruby V
(To:jroth)

Hmm, here is a version where you don't have to change much and still get the values you are searching for. Nevertheless I still don't like the idea of those functions local to the block with less arguments than they depend on, but that may be a matter of taste.

I also dislike the approach of a letting Find() solve for three variables when in reality there is only one.

Anyway, here we simply add two new variables, add guess values for them and add two equations, making Find() solve for three variables in three equations.

jroth
4-Participant
(To:Werner_E)

Werner,

Thank you. It is an ingenious way to think of it, and the solution as far as I know should be unique. I'll keep looking into this abit more and post back what I find out.

Werner_E
24-Ruby V
(To:jroth)

and the solution as far as I know should be unique. I'll keep looking into this abit more and post back what I find out.

???

You mean because the solve block sheets yield different result than your "Solve Block 4" programmed routine?

This was the case from the very beginning (your first post). Those two sheets definitely are not calculating the same thing.

jroth
4-Participant
(To:Werner_E)

Werner,

The sheets and the excel sheet are to an accuracy of eachother by about 1 to 2 deg C, which is plenty close enough considering that the value of h is realistically on the order of plus or minus 30% (though it should average out in the long run). I was wanting some more accuracy if possible in the actual calcualtions incase my programming was incorrect. My assmption was that a solve block would provide a more stable or accurate answer, and it also calculates quite abit faster than the looping code.

I assume the difference is comming from the TOL factor in Mathcad and if there is a looping limit, while the accuracy in the programmed MathCad version comes from the error allowance set up in the equations.

Werner_E
24-Ruby V
(To:jroth)

I never looked at the excel sheet. Iwas just comparing the output of the solve block with your program in tghe second Mathcad sheet. It seemed to me the differences were significant and more than just 1 or 2 degree. Maybe I was wrong. After all I didn't see that the constraint in the solve block and the objective function in your program are the same, but I didn't spend much time on the comparison and concentrated to get the solve block running which it should be now. And anyway, if you are happy, we shouldn't worry 😉

And yes, I would also guess that the Levenberg-Marquardt algorithm, which is usually used for Find(), sure is more sophistcated and accurate than an algorithm which just adds a small amount until a calculated value is within a given tolerance.

Top Tags