Changeset 373

Show
Ignore:
Timestamp:
05/23/08 05:59:49 (6 months ago)
Author:
powell
Message:

New phase boundary, doesn't quite build.

Location:
trunk/matml/src/ternary
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/matml/src/ternary/ChangeLog

    r366 r373  
    33  * Overhauled the free energy interface and functions, adding derivative 
    44    implementations. 
     5  * Added phase_boundary typedef struct. 
    56  * Changed hull calculation interface to permit (multiple) refinement between 
    67    original calculation and return. 
  • trunk/matml/src/ternary/qhull.c

    r369 r373  
    105105++++++++++++++++++++++++++++++++++++++*/ 
    106106 
    107 static inline void NewtonRefine 
     107static void NewtonRefine 
    108108(coordT *point, coordT *corners, energy_params *eparams, int nparams, 
    109109 double T, double P, int globaldims, int localdims, int side, 
     
    140140  else 
    141141    { 
    142       /*+ Slope for the binary case +*/ 
     142      /* Slope for the binary case */ 
    143143      if (side==0 || side==2) // C3=0 or C2+C3=1 sides: dG/dC2 
    144144        slope2 = (corners[5]-corners[2])/(corners[3]-corners[0]); 
     
    176176 
    177177/*++++++++++++++++++++++++++++++++++++++ 
    178   This refines each of the facets in the hull, adding a new vertex at its 
    179   centroid if in a one-phase region, and using Newton-Raphson iteration to 
    180   refine down the vertices of multi-phase facets. 
     178  This refines each of the facets in the hull, using Newton-Raphson iteration 
     179  to refine down the vertices of multi-phase facets, and (optionally) adding a 
     180  new vertex at its centroid if in a one-phase region. 
    181181 
    182182  int hullRefine It returns zero or an error code. 
     
    197197  choose this parameter to indicate how close to consider them the "same" 
    198198  point. 
     199 
     200  int one_phase_refine Non-zero if the one-phase regions should be refined by 
     201  adding a new vertex at the centroid. 
    199202  ++++++++++++++++++++++++++++++++++++++*/ 
    200203 
    201204int hullRefine (energy_params *eparams, int nparams, double T, double P, 
    202                 double newton_tolerance, double vertex_tolerance) 
     205                double newton_tolerance, double vertex_tolerance, 
     206                int one_phase_refine) 
    203207{ 
    204208  facetT *facet; 
     
    214218  FORALLfacets 
    215219    { 
    216       coordT corners [6], centroid [2]; 
     220      double corners [6], energies [3], centroid [3], Gcenter; 
    217221      vertexT *vertex, **vertexp; 
     222      int j=0; 
    218223 
    219224      /*+ 
    220225        +latex+\item 
    221226        +html+ <li> 
    222         If the lowest free energy function at the centroid has lower energy 
    223         than the average energy of the vertices, add it as a new vertex. 
     227        Copy vertex information into local variables. 
    224228        +html+ </li> 
    225229        +*/ 
    226       if (centroid[0] < corners[0]) 
    227         ; 
    228  
    229       /*+ 
    230         +latex+\item 
    231         +html+ <li> 
    232         Otherwise, use Newton-Raphson iteration to refine each vertex. 
    233         +html+ </li> 
    234         +*/ 
    235       else 
     230      FOREACHvertex_(facet->vertices) 
    236231        { 
    237  
     232          int thepoint = (vertex->point-qh first_point)/3; 
     233 
     234          if (j<3) 
     235            { 
     236              (*facetverts) [3*i+j] = thepoint; 
     237              corners [2*j]   = vertex->point[0]; 
     238              corners [2*j+1] = vertex->point[1]; 
     239              energies [j]    = vertex->point[2]; 
     240            } 
     241          j++; 
     242        } 
     243 
     244      if (j<3) /* Ignore non-simplical facets */ 
     245        { 
    238246          /*+ 
    239247            +latex+\item 
    240248            +html+ <li> 
    241             Find the lowest free energy function at this vertex. 
     249            If the lowest free energy function at the centroid has lower energy 
     250            than the average energy of the vertices, add it as a new vertex. 
    242251            +html+ </li> 
    243252            +*/ 
     253          centroid[0] = (corners[0] + corners[2] + corners[4]) / 3.; 
     254          centroid[1] = (corners[1] + corners[3] + corners[5]) / 3.; 
     255          centroid[2] = (energies[0] + energies[1] + energies[2]) / 3.; 
     256          /*** CHECK ALL EPARAMS OF CORNERS ***/ 
     257          Gcenter = free_energy (centroid[0], centroid[1], T, P, eparams); 
     258 
     259          if (Gcenter < centroid[2] && one_phase_refine) 
     260              ; 
    244261 
    245262          /*+ 
    246263            +latex+\item 
    247264            +html+ <li> 
    248             If the vertex is on a side of the phase diagram (one or more 
    249             composition variables is zero or they sum to one), refine along 
    250             each side that it's on, to avoid the "infinite slope at the edge" 
    251             problem.  If it's on more than one side, add a new candidate vertex 
    252             for each side it's on. 
     265            Otherwise, use Newton-Raphson iteration to refine each vertex. 
    253266            +html+ </li> 
    254267            +*/ 
     268          else 
     269            { 
     270              /*+ 
     271                +latex+\item 
     272                +html+ <li> 
     273                Find the lowest free energy function at this vertex. 
     274                +html+ </li> 
     275                +*/ 
     276 
     277              /*+ 
     278                +latex+\item 
     279                +html+ <li> 
     280                If the vertex is on a side of the phase diagram (one or more 
     281                composition variables is zero or they sum to one), refine along 
     282                each side that it's on, to avoid the "infinite slope at the 
     283                edge" problem.  If it's on more than one side, add a new 
     284                candidate vertex for each side it's on. 
     285                +html+ </li> 
     286                +*/ 
     287 
     288              /*+ 
     289                +latex+\item 
     290                +html+ <li> 
     291                Otherwise refine starting at this vertex. 
     292                +html+ </li> 
     293                +*/ 
     294            } 
    255295 
    256296          /*+ 
    257297            +latex+\item 
    258298            +html+ <li> 
    259             Otherwise refine starting at this vertex. 
     299            If any two new candidate vertices are in the same place (closer than 
     300            vertex_tolerance), eliminate one. 
    260301            +html+ </li> 
    261302            +*/ 
    262303        } 
    263  
    264       /*+ 
    265         +latex+\item 
    266         +html+ <li> 
    267         If any two new candidate vertices are in the same place (closer than 
    268         vertex_tolerance), eliminate one. 
    269         +html+ </li> 
    270         +*/ 
    271304    } 
    272305  /*+ 
  • trunk/matml/src/ternary/ternary.h

    r366 r373  
    8888} energy_params;   /*+ Free energy parameters structure +*/ 
    8989 
     90typedef struct { 
     91  int compos;   /*+ Number of components of the space +*/ 
     92  int *edges;   /*+ Edges with indices of ternary_points comprising a phase 
     93                  boundary; each edge has compos-n_phases+1 points +*/ 
     94  int n_edges;  /*+ Number of points comprising this boundary +*/ 
     95  int *phases;  /*+ Phases involved (energy_params indices) starting with the 
     96                  "current" phase +*/ 
     97  int n_phases; /*+ Number of phases involved +*/ 
     98  int ties;     /*+ Zero if this is one phase's boundary edges (the "current" 
     99                  phase), non-zero if this is a set of tie simplicies +*/ 
     100} phase_boundary; /*+ Phase boundary structure which can store either the 
     101                    boundary between a single phase and a multi-phase region, 
     102                    or the tie lines/simplices across a multi-phase region +*/ 
     103 
    90104/* From freenergy.c */ 
    91105double free_energy