Changeset 373
- Timestamp:
- 05/23/08 05:59:49 (6 months ago)
- Location:
- trunk/matml/src/ternary
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/matml/src/ternary/ChangeLog
r366 r373 3 3 * Overhauled the free energy interface and functions, adding derivative 4 4 implementations. 5 * Added phase_boundary typedef struct. 5 6 * Changed hull calculation interface to permit (multiple) refinement between 6 7 original calculation and return. -
trunk/matml/src/ternary/qhull.c
r369 r373 105 105 ++++++++++++++++++++++++++++++++++++++*/ 106 106 107 static inlinevoid NewtonRefine107 static void NewtonRefine 108 108 (coordT *point, coordT *corners, energy_params *eparams, int nparams, 109 109 double T, double P, int globaldims, int localdims, int side, … … 140 140 else 141 141 { 142 /* + Slope for the binary case +*/142 /* Slope for the binary case */ 143 143 if (side==0 || side==2) // C3=0 or C2+C3=1 sides: dG/dC2 144 144 slope2 = (corners[5]-corners[2])/(corners[3]-corners[0]); … … 176 176 177 177 /*++++++++++++++++++++++++++++++++++++++ 178 This refines each of the facets in the hull, adding a new vertex at its179 centroid if in a one-phase region, and using Newton-Raphson iteration to180 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. 181 181 182 182 int hullRefine It returns zero or an error code. … … 197 197 choose this parameter to indicate how close to consider them the "same" 198 198 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. 199 202 ++++++++++++++++++++++++++++++++++++++*/ 200 203 201 204 int 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) 203 207 { 204 208 facetT *facet; … … 214 218 FORALLfacets 215 219 { 216 coordT corners [6], centroid [2];220 double corners [6], energies [3], centroid [3], Gcenter; 217 221 vertexT *vertex, **vertexp; 222 int j=0; 218 223 219 224 /*+ 220 225 +latex+\item 221 226 +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. 224 228 +html+ </li> 225 229 +*/ 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) 236 231 { 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 { 238 246 /*+ 239 247 +latex+\item 240 248 +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. 242 251 +html+ </li> 243 252 +*/ 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 ; 244 261 245 262 /*+ 246 263 +latex+\item 247 264 +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. 253 266 +html+ </li> 254 267 +*/ 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 } 255 295 256 296 /*+ 257 297 +latex+\item 258 298 +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. 260 301 +html+ </li> 261 302 +*/ 262 303 } 263 264 /*+265 +latex+\item266 +html+ <li>267 If any two new candidate vertices are in the same place (closer than268 vertex_tolerance), eliminate one.269 +html+ </li>270 +*/271 304 } 272 305 /*+ -
trunk/matml/src/ternary/ternary.h
r366 r373 88 88 } energy_params; /*+ Free energy parameters structure +*/ 89 89 90 typedef 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 90 104 /* From freenergy.c */ 91 105 double free_energy