- Timestamp:
- 10/06/2009 06:27:25 PM (3 years ago)
- Files:
-
- 1 modified
-
trunk/matml/src/ternary/spinodal.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/matml/src/ternary/spinodal.c
r482 r483 12 12 13 13 /*++++++++++++++++++++++++++++++++++++++ 14 This function uses secant iteration to estimate the root of the spinodal15 function on a line in ternary space between points A and B.14 This function uses dissection and secant iteration to estimate the root of 15 the spinodal function on a line in ternary space between points A and B. 16 16 17 17 inline double interpolate Returns the fraction B whose weighted average with … … 46 46 double T, double P, energy_params *eparams, int efunc, int iters) 47 47 { 48 int i ;48 int i, binaries=10; 49 49 energy_point X; 50 50 double interp=0., intfrac=1., XS; 51 52 for (i=0; i<binaries; i++) 53 { 54 X.C2 = 0.5 * (A2+B2); 55 X.C3 = 0.5 * (A3+B3); 56 X.efunc = -1; 57 free_energies (&X, 1, T,P, eparams,efunc, WITH_DERIVATIVES_NO_INFINITY); 58 XS = X.G22 * X.G33 - X.G23 * X.G23; 59 60 if (AS * XS > 0) 61 { 62 interp += intfrac * 0.5; 63 intfrac *= 0.5; 64 A2 = X.C2; 65 A3 = X.C3; 66 AS = XS; 67 } 68 else 69 { 70 intfrac *= 0.5; 71 B2 = X.C2; 72 B3 = X.C3; 73 BS = XS; 74 } 75 } 51 76 52 77 for (i=0; i<iters; i++) … … 54 79 X.C2 = (AS*B2 - BS*A2) / (AS - BS); 55 80 X.C3 = (AS*B3 - BS*A3) / (AS - BS); 56 57 81 X.efunc = -1; 58 82 free_energies (&X, 1, T,P, eparams,efunc, WITH_DERIVATIVES_NO_INFINITY); 59 83 XS = X.G22 * X.G33 - X.G23 * X.G23; 60 61 printf ("A=%g,%g->%g B=%g,%g->%g, X=%g,%g->%g\n", A2,A3,AS, B2,B3,BS,62 X.C2,X.C3,XS);63 84 64 85 if (AS * XS > 0)