I am trying to program an equation of state for a mixture and want to make mathcad loop from an initial guess of the concentration to the solution (by updating the guess each time). I have a file which has a the calculations working if I manually update the initial guess (this section is right at the bottom highlighted by the red comment at the start) to get to a solution. Above this section I have tried to create a while loop to automate the process for me, but MathCAD doesn't like the polyroots part where the euqation of state is solved for the three roots. For the example I have two roots are imaginary numbers but this will not always be the case depending on the conditions therefore this needs to be part of the loop. What is the method one is supposed to use for this type of problem? Any help would be much appreciated. File is attached.
Solved! Go to Solution.
Perfect, I had made a few other mistakes in the loop mixing up my y[0 with y.0 which I corrected but you put me on the right path; it works fine now. Thanks very much for your help, much appreciated.