Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
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
.
Solved! Go to Solution.
@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.
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
This is what I'm talking about:
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
thanks..
I am not sure what happened. it was working
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.
Hi again -
I am having trouble updating the value of Ai based on the ratio of z/L I am not it is updating at all. Ai should increase by the ratio each time step. The sheet is messy
thanks
Not sure what you are trying to achieve.
Initial value of Ai is 11.08 ft^2, but this value isn't used anywhere.
Starting with z=1 the last value of Ai gets multiplied by z/L, making it smaller an smaller.
At least thats what you have programmed.
If you let the program return Ai1 instead of Twnew you can see the values of Ai calculated:
Could it be that you had Ai+Ai*z/L=Ai*(1+z/L) in mind instead of Ai*z/L ?
Here the modified program. I streamlined it by omitting the unnecessary variable T1 ( = dt) and its also not necessary to create that many vectors A, B , etc. if the only vector you are interested in is Twnew:
You will notice the two gaps in the plot. These stem from the root function returning non-real solutions with a very tiny imaginary part - presumable because of numerical inaccuracies.
You may cope with this by taking the absolute value or by using just the real part of the solution
P9 worksheet attached
thanks for that,. Ai, as you can tell, an area. Basically, what it represents is a column filled with sand that is being drained at 1" per second. So, at time=0 Ai is small, and at the end of the time it is Ai*1.. So, as z approaches L it should get closer to 1, right? that is what I was trying to program. Thanks again for the help.
But you define Ai to be 11.08 square feet right from the start! at time 0?
So what area should it be when z=L ?
In case the definition Ai=11.08 ft^2 is meant to be the end value at z=L, the following may be what you are looking for?
I also got rid of the external definition of dt:=0 and also the external creation of time vector T.
Remark: Using just the real part of the result of root seems not to be necessary now. There are no gaps in the plot when the "Re(..)" is removed.
thanks. That was my problem - the redifining of Ai.. that is why I was using Ai1 and then setting Ai = Ai1, but that must not be correct.
Using a variable Ai1 like you tried would do the job as well, of course:
Here the end value Ai is not touched in any way and its Ai1 which is increased step by step.
Your initial program, while a bit too elaborate, would work OK, too, if you delete the line Ai <-- Ai1[z and if you use Ai1[z in the calculations for A[z and B[z instead of Ai.
I am now trying to get the cooldown (below the else statement) to work, but for some reason it is not starting at the last value of Twall, but jumping to Tamb.
@AH_10527716 wrote:
I am now trying to get the cooldown (below the else statement) to work, but for some reason it is not starting at the last value of Twall, but jumping to Tamb.
'Last' value of Tamb? Tamb isn't changing, its constant 400 K.
I also see no reason why there should not be a discontinuity at l=700.
After all the else branch is using completely different calculations.
Only dt continues to increase the same way, but the functions you solve for l=699 and l=700 seem to be completely different. At least I can see no reason why the results should be the same.
You may try to write out both calculations, for l=699 and l=700 so you can see where and why there is a difference you don't expect.
BTW, not that it would make any difference, but I am a bit confused as of
Neither putting L in the nominator AND denominator, not that multiplication by Twnew seem to have and effect.
Here you see that values of the coefficients for l=699 and l=700 along with the results of the corresponding equations