In the condition of constant pressure, "Common Tangent Method" is easy, quick and accurate method to obtain phase equilibrium of pure and binary solution.
Phase diagram is essential part of thermodynamics and can be obtained by solving equilibrium condition, which usually involves iteration of solution finding of nonlinear equation, which needs good initial value, which only can be found by manual trial and error.
But, geometrical side is simple.
Free energy is 4th order curve and equilibrium point of the system is the 2 points where common tangent line contacts. (Detailed information is in the source zip file's txt file.)
As a result, if we can obtain common tangent line, we can obtain equilibrium points. (Detailed information is in the txt file in source zip file.)
I coded a library which finds the 2 contanct points of common tangent line.
The Common Tangent method was coded in C and tested with Lattice-Fluid theory(Sanchez-Lacomb) and PHSC theory(Prausnitz et al).
Code quality is in (at most) alpha stage. Algorithm is not so well-designed.
So, Depending on the choice EOS, search increment size(d_break, d_delta) may need modification.
And, only UCST curve can be obtained.
(As temperature goes up, equilibrium points is assumed to be inner side of previous solutions.)
With adequate modification, LCST also can be obtained, but not now.
Without this code, parameters was fitted to experimental data by 'manual trial and error'.
After this code started to work, make 'automatic parameter fitting' possible,
if combined with nonlinear least squares library like Minpack-2,
which is freely available and can be converted to C by f2c. (I used only "lmdif1" function.)
In comparison with Fortran, C suffers lack of good mathematic library.
But, f2c converts fortran libraries to C automatically and GNU Scientific Library also shows some light.
Or you can use commercial IMSL library.
My code works for 2 polymer thermodynamic theory, one is based on lattice approach, the other based on statistic approach. I hope this code actually work for your EOS and help your parameter fitting job easier.
Useful Links
Netlib - Numerical library source code pool
f2c(Fortran to C conversion)
DJGPP - Free C, C++ And Fortran Compiler for DOS & MS-Windows
Cygwin - Free UNIX environment for MS-Windows
cfortran.h - Interfacing C or C++ and FORTRAN
Contact Information
Name: Un Ha Kim
Email: kuh74@daum.net