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

Equation of state

SOLVED
Highlighted
Newbie

Equation of state

Hi,

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.

Andrew

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Equation of state

Does the attached help? (You also had an infinite loop! Make sure the parameter you are testing changes within the loop.)

Alan

View solution in original post

2 REPLIES 2

Re: Equation of state

Does the attached help? (You also had an infinite loop! Make sure the parameter you are testing changes within the loop.)

Alan

View solution in original post

Re: Equation of state

Alan,

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.

Andrew

Announcements