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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

using Solve in a loop

AH_10527716
3-Visitor

using Solve in a loop

I am having trouble understanding why I can't get a solution using the defined variables but am able to get one when I put in a value for the variable.  My issue arises because the values X, Y and Z depend on Twall.  I want to be able to loop this with an update to Twall at each dt.  Any help would be appreciated.

 

mathcad prime9

 

.

AH_10527716_0-1724695810465.png

 

 

 

 

9 REPLIES 9
LucMeekes
23-Emerald III
(To:AH_10527716)

Please attach the Prime worksheet (.mcdx file).

 

Other than that: I guess you're not interested in the complex answers for T, nor the negative one, so only the first answer is needed.

And you only need a numeric answer. In that case it's better to use the root() function, instead of solve. You can set it to not give you negative or complex answers by supplying two extra parameters that give limits of the range within which you expect your answer.

Look it up in the help information of the program.

 

Success!
Luc

Thanks Luc.  What I am doing is a transient heat transfer case.  Yes, I only need the positive root.  But, I need to use that root and resolve for all the variables after a time-step and resolve for Twall.  Repeat until Twall is equal to Thot.  I know how to do the programming, I just can't get the initial part to work.  My worksheet has some other stuff at the bottom that I was trying to get to work as well.

 

thanks

LucMeekes
23-Emerald III
(To:AH_10527716)

This is what I'm talking about:

LucMeekes_0-1724711393006.png

Now, I don't see you calculating new values of A,B,C,D,E,F,X,Y or Z based on this temperature value. You're using the same inputs over and again. Then there's no point in iterating.

 

Success,

Luc

 

ttokoro
20-Turquoise
(To:AH_10527716)

image.png

thanks.. 

I am not sure what happened.  it was working

AH_10527716_0-1724955357059.png

 

LucMeekes
23-Emerald III
(To:AH_10527716)

You should attach the prime worksheet file.

 

Success!
Luc

I figured it out.  I can't have the "=" after the X1 and Z1.  I was just checking units, but for some reason it didn't like it,

 

thanks


@AH_10527716 wrote:

I figured it out.  I can't have the "=" after the X1 and Z1.  I was just checking units, but for some reason it didn't like it,

 

thanks


This is because you cant numerically evaluate a function definition!

After all, which result would you expect from f(x):=x^2= ?

Even if you already had defined a value for a variable x before - the x in the function definition is a formal function argument and has nothing to do with that variable x.

 

Announcements

Top Tags