Changeset 483 for trunk

Show
Ignore:
Timestamp:
10/06/2009 06:27:25 PM (3 years ago)
Author:
powell
Message:

Binary iteration preceding secant iteration for better edge effectiveness.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/matml/src/ternary/spinodal.c

    r482 r483  
    1212 
    1313/*++++++++++++++++++++++++++++++++++++++ 
    14   This function uses secant iteration to estimate the root of the spinodal 
    15   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. 
    1616 
    1717  inline double interpolate Returns the fraction B whose weighted average with 
     
    4646 double T, double P, energy_params *eparams, int efunc, int iters) 
    4747{ 
    48   int i; 
     48  int i, binaries=10; 
    4949  energy_point X; 
    5050  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    } 
    5176 
    5277  for (i=0; i<iters; i++) 
     
    5479      X.C2 = (AS*B2 - BS*A2) / (AS - BS); 
    5580      X.C3 = (AS*B3 - BS*A3) / (AS - BS); 
    56  
    5781      X.efunc = -1; 
    5882      free_energies (&X, 1, T,P, eparams,efunc, WITH_DERIVATIVES_NO_INFINITY); 
    5983      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); 
    6384 
    6485      if (AS * XS > 0)