A little bit long Matlab code that I just developed to solve for four unknowns. There are three files. One with the name "water-CO2 coexistence _curve1.m" which contains the main code equations. The other one which is "literature_H2O-CO2.m" contains the initial 4 guesses and also the fsolve function. The third one is a "findDifference_H2O_CO2.m" which is to show the 4 equality equations that needs to be satisfied in order to solve for the four unknowns. The specified variables are T and P. On the other hand the unknowns are: 2 different rau and 2 different [url removed, login to view] four equations are as follows:
1) P_res = P (vapor phase as function of T and x_c at the vapor phase; P is specified)
2) P_res = P (liquid phase as function of T and x_c at the liquid phase; P is specified)
3) chempt_w (vapor phase) = chempt_w (liquid phase) (function of T and x_c at liquid and vapor phase)
4)chempt_c (vapor phase) = chempt_c (liquid phase) (function of T and x_c at liquid and vapor phase)
Initial guess: raul (rau at liquid phase), rauv (rau at vapor phase), x_c (x_c at liquid phase), y_c (x_c at vapor phase).
I know that it will be confusing just reading the above paragraph. But, please have a look at the code and then we can discuss things out to make it clearer. The code is ALREADY DONE, however, I am facing errors while solving, probably because I have some small programming mistakes here and there.
Ready for giving out a good award for submitting good quality work.