Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
Hi everyone,
I am new to the Mathad world when it comes to the nonlinear solvers for system of equations. I would appreciate any help that I can get
I am trying to find partial pressures for an equilibrium equation of state model. I am running into trouble as to how I can get each of the partial pressures as a function of my temperature. I am attaching the Mathcad file so that you can see what I mean. I have doubled check my stuff but I am unsure of how to proceed. It keeps saying that "initial guess must consist of numbers and matrices".
Anybody care to get me out of my mess I have created?
Thanks,
Addison
Solved! Go to Solution.
You can't take the derivative w.r.t. T because it's not a function of T. To make it a function of T also requires some changes earlier in the worksheet. See the highlighted regions.
As an aside, if you have to multiply by m^3 to be able t take the log, that might indicate a problem. It depends on where the formula comes from. If it is an empirical formula, this can happen. If it is a formula derived from the physics, it will never happen. If it's derived from the physics and the log of the quantity has any physical meaning then the quantity must be dimensionless to begin with.
The attached might help a little, but doesn't solve all your problems!
Alan
You need to turn the solve block into a function.
I appreciate the help in correcting the mess I created. I wish there is was a way I could get all the partial pressures to calculate out of the entire temp range instead of limiting it to the first couple.
Thanks again for all your help.
Addison
Dear Addison!
May be this Mathcad WebSheet (The Ionization Constant of H2O) will be interesting to you:
If a valid solution exists for those temperatures then you will be able to find it by changing the guess values so that they are closer to the solution.
Instead of using the Find(Partial Pressures), I ended up using the minerr function which punched the expected number out in no time.
Thanks again.
Minerr will give you an answer, but that answer may not satisfy your equations. Minerr will just minimize the error in the equations, and the minimized error could still be very large.
Richard Jackson wrote:
Minerr will give you an answer, but that answer may not satisfy your equations. Minerr will just minimize the error in the equations, and the minimized error could still be very large.
That's for sure! see the attached.
Alan
Ok guys I am running into something else here that is bugging me. This is something that is probably going to make me feel ignorant when I find out a solution. I am trying to take the derivative to figure out my energy but it keeps saying that the value must be a scalar. I am attaching the sheet.
You can't take the derivative w.r.t. T because it's not a function of T. To make it a function of T also requires some changes earlier in the worksheet. See the highlighted regions.
As an aside, if you have to multiply by m^3 to be able t take the log, that might indicate a problem. It depends on where the formula comes from. If it is an empirical formula, this can happen. If it is a formula derived from the physics, it will never happen. If it's derived from the physics and the log of the quantity has any physical meaning then the quantity must be dimensionless to begin with.
Thanks. I knew it had to be something really simple. And yes it was a vectorized result.
Ok. I promise this is the last thing I am going to ask regarding this Mathcad sheet. Probably another case of not having a function defined in T.
Ok. I promise this is the last thing I am going to ask regarding this Mathcad sheet.
You should be careful about making promises you may regret
Probably another case of not having a function defined in T.
Yes. The problem is in the definition of h(T). You have defined it in such a way that it will return a vector of temperatures even with a scalar argument (and will fail completely if you give it a vector of temperatures that is of different length to the original vector). That is because cH2O, cH2, etc are vectors. They need to be functions of T. The derivative operator doesn't know what to do with a function that takes a scalar and returns a vector (what's the gradient when you have multiple h for each T?).
You are running into these problems because you are carrying your results through the worksheet as a series of vectors. What you really need to do, although it's a lot of work. is to change everything that depends on T to a function of T. Then create a vector (with a different name of course) when needed.