Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
I'm setting up an equation to solve for a final temperature, and inserting the units makes Solver fail. From the way it's acting, it appears it's treating the symbol 'K" as a variable rather than Kelvin temperature. For example, if I write xK, it doesn't insert the tiny dot that means it's recognized the "K" as a Kelvin temperature. Typing x*K will insert a multiplication sign, but Solver still produces gibberish.
Take all the units out, and it works fine. But I'd much, much rather have MathCad track the units as an additional check. If possible. I can't find anything in the manual or online help that even comes close to addressing this.
File attached as MathCad 12 .mcd file, although I'm using MathCad 14.
Jeff Corkern
For example, if I write xK, it doesn't insert the tiny dot that means it's recognized the "K" as a Kelvin temperature.
Are you sure it doesn't think you've created a single variable called "xK"?
Also, when in doubt, use the Insert>Units menu.
You would be surprised what happens when Mathcad doesn't know you mean for "g" to be grams, not 9.8 m/sec^2.
There are several errors in your worksheet.
The heats of formation need to be cal/mol or similar.
The heat of reaction in the equation you are solving should have a negative sign to make the right hand side positive.
There is not a unit "grams", only "gm" or "kg".
Tried Insert Unit. Didn't work. My variable x went completely away, to be replaced by K.
I had a user-defined unit "gram" in the worksheet I cut this from. "gm" kept causing problems, so I re-defined a new unit.
Yeah, it should be cal/mol and the sign should be different.
But after doing all that, I still have the original problem.
Jeff,
Try using the symbolics>solve>variable and selecting x. That's what I did. If that doesn't work, please attach the modified worksheet.
Harvey
On my version, it's "Symbolics, Variable,Solve" and somehow it just won't take it. I tried "solve, x" and it's still not recognizing the degree units
File attached as MathCad 12 .cmd file.
Jeff Corkern
Here (x-298)K x is unitless
I think the correct solution ison this way:
What was my mistake?
I have tried that before and gotten gibberish.
I copied and pasted your entire page, put it in mine, and it worked.
The only difference I can see between the two is their alignment.
How was it aligned incorrectly?
Hmm, further examination shows you removed where I used the equals sign and forced it to calculate to a number for the delta-H of reaction. Forcing your worksheet to do the sames makes the Solve part crash on your worksheet.
Howsomever, removing the equals sign from my delta-H calculation still doesn't make it calculate correctly on my worksheet.
The major change was from (x-298)K to (x-298K) ; the solve function is calculating the 'x' in K so the constant needs to be dimensioned accordingly.
Regards
Andy
I have been experimenting with your worksheet.
The statement (x-298K) does not make sense as temperature doesn't work like that. It has to be (x-298)K
But if you make that change to your worksheet---Solver STILL works and gets the right answer.
Also if you remove the ",x"---Solver still works. At least it does using MathCad 14.
So the difference has to be something else.
Jeff Corkern
I got the SOB to work. Right units and everything.
The problem was the units have to match EXACTLY. I was using "mol" in some place and "mole" in others. MathCad shows both options so I assumed they were interchangeable. They were not.
And you can't mix assignment operators and equal signs. ":=", typing a calculation, then using "=" to get a numeric value screws MathCad up for some reason.
And it has to be (x-298K) in order for the calculation to come out in K. Putting the K outside the parentheses cancels out the K.
Thank you for your help.
Jeff Corkern
I have been experimenting further.
MathCad can't really handle units. At least, Solver can't.
What is happening is Solver is going through and canceling out units FIRST, and THEN solving for x.
Which is, of course, the completely backwards way to do it.(God, who wrote this program?)
It is still of value to write down the units as a check to make sure everything's correct, but I no longer expect the answer to have the right units. That just ain't gonna happen. The number will be right, but the units will be wrong.
Mathcad is primarily a numeric engine. The symbolic engine is there, but it has some draw-backs. If you're doing a symbolic solver one of the drawbacks is that the symbolic engine won't recognize units.
The numeric solver handles units very nicely, thank you.
You can still make it work.
If you've set the equation up properly, your answer in Solver will be unitless. You just have to remember the units of the answer are what's next to the variable x.
It still works as a check. It works sorta screwed up, but it works.
The symbolic solver does work with units, even with multiple definitions of the same quantity. I got the correct answer even with mol and mole and gm and grams mixed. The solver result just needs to be evaluated to get a numeric result. You can put another = (not Boolean) at the end of the symbolic solution, or you can define x:= using the symbolic result (copy and paste). Then x= gives the numeric answer.
The answer will have units if you have specified (x-298*K) in the problem because it can't cancel the K.
The answer will be unitless if you have specified (x-298)*K because the K will cancel.
Units are like variables to the solver. They will cancel if they can, however they will not convert during the solver solving step. So the gm and grams will still be present and mol and mole, and R and K if you wish. When you ask for the numeric result, the evaluation occurs and those multiple definitions are handled properly.