Changeset 381
- Timestamp:
- 06/27/08 15:00:20 (4 months ago)
- Files:
-
- trunk/matml/src/ternary/qhull.c (modified) (9 diffs)
- trunk/matml/src/ternary/ternary.c (modified) (2 diffs)
- trunk/matml/src/ternary/ternary.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/matml/src/ternary/qhull.c
r379 r381 24 24 int dim Number of dimensions (should always be 3 for ternary). 25 25 26 ternary_point *points Point information. 27 26 28 int numpoints Number of points of which to calculate the convex hull. 27 28 ternary_point *points Point information.29 29 ++++++++++++++++++++++++++++++++++++++*/ 30 30 31 int hullCalculate (int dim, int numpoints, ternary_point *points)31 int hullCalculate (int dim, ternary_point *points, int numpoints) 32 32 { 33 33 int i, corner1, corner2, corner3; … … 78 78 79 79 /*++++++++++++++++++++++++++++++++++++++ 80 This uses Newton iteration to refine a single 80 This uses Newton iteration to refine a single point within a triangle. 81 81 82 82 coordT *point Composition coordinates of the starting point for refining; the … … 178 178 int hullRefine It returns zero or an error code. 179 179 180 ternary_point *points Point information. 181 182 int numpoints Number of points of which to calculate the convex hull. 183 180 184 energy_params *eparams Collection of energy parameter structures. 181 185 … … 197 201 ++++++++++++++++++++++++++++++++++++++*/ 198 202 199 int hullRefine (energy_params *eparams, int nparams, double T, double P, 200 double newton_tolerance, double vertex_tolerance, 201 int one_phase_refine) 203 int hullRefine 204 (ternary_point *points, int npoints, energy_params *eparams, int nparams, 205 double T,double P, double newton_tolerance, double vertex_tolerance, 206 int one_phase_refine) 202 207 { 203 208 facetT *facet; … … 215 220 double corners [9], centroid [3], Gcenter; 216 221 vertexT *vertex, **vertexp; 217 int j=0, eparam [3] = {0,0,0} ;222 int j=0, eparam [3] = {0,0,0}, thepoint [3]; 218 223 219 224 /*+ … … 226 231 FOREACHvertex_(facet->vertices) 227 232 { 228 int thepoint = (vertex->point-qh first_point)/3;229 230 233 if (j<3) 231 234 { 232 int i; 233 double emin; 235 thepoint [j] = (vertex->point-qh first_point)/3; 234 236 235 237 corners [3*j] = vertex->point[0]; … … 237 239 corners [3*j+2] = vertex->point[2]; 238 240 239 emin = fabs (corners [3*j+2] - free_energy 240 (corners [3*j], corners [3*j+1], T, P, eparams)); 241 242 for (i=1; i<nparams; i++) 243 if (fabs (corners [3*j+2] - free_energy 244 (corners [3*j], corners [3*j+1], T, P, eparams+i)) 245 < emin) 246 { 247 emin = fabs (corners [3*j+2] - free_energy 248 (corners [3*j], corners [3*j+1], T, P, eparams+i)); 249 eparam [j] = i; 250 } 251 if (emin > 1.e-10) // Sanity check; this should always be zero 252 printf ("Vertex at %g,%g: eparam=%d, emin=%g\n", 253 corners [3*j], corners [3*j+1], eparam [j], emin); 241 eparam [j] = points[thepoint[j]].efunc; 254 242 } 255 243 j++; 256 244 } 257 245 258 // Ignore non-simplical facets and top facet246 // Ignore non-simplical side facets and top facet 259 247 if (fabs((corners[3]-corners[0])*(corners[7]-corners[1]) - 260 248 (corners[6]-corners[0])*(corners[4]-corners[1])) < 0.999999 … … 268 256 corners[0], corners[1], corners[3], 269 257 corners[4], corners[6], corners[7]); 270 printf (" Curves: %d %d %d, Area: %g\n",258 printf (" Curves: %d %d %d, points %d %d %d, Area: %g\n", 271 259 eparam[0], eparam[1], eparam[2], 260 thepoint[0], thepoint[1], thepoint[2], 272 261 fabs((corners[3]-corners[0])*(corners[7]-corners[1]) - 273 262 (corners[6]-corners[0])*(corners[4]-corners[1]))); … … 287 276 Gcenter = free_energy (centroid[0], centroid[1], T, P, eparams); 288 277 for (j=1; j<nparams; j++) 289 if (Gcenter > free_energy (centroid[0],centroid[1], T,P, eparams ))278 if (Gcenter > free_energy (centroid[0],centroid[1], T,P, eparams+j)) 290 279 { 291 Gcenter = free_energy (centroid[0],centroid[1], T,P, eparams );280 Gcenter = free_energy (centroid[0],centroid[1], T,P, eparams+j); 292 281 eparamc = j; 293 282 } trunk/matml/src/ternary/ternary.c
r379 r381 78 78 { printf ("main: Error %d in scale_triangle_array\n", i); exit (i); } 79 79 80 /* Send points and triangle vertexdata to Geomview */80 /* Send free energy surface data to Geomview */ 81 81 if (i=GeomviewDisplayTriangleCOFF 82 82 (pfd, "Ternary Free Energy", "tfe", "shading smooth", … … 86 86 /* Calculate and refine the lower convex hull */ 87 87 printf ("qhull version: %s\n", hullQHullVersion()); 88 if (i=hullCalculate (3, (loop_max+1)*(loop_max+2), points))88 if (i=hullCalculate (3, points, (loop_max+1)*(loop_max+2))) 89 89 { printf ("main: Error %d in hullCalculate\n", i); exit (i); } 90 //if (i=hullRefine (allparams, 2, T, P, 1e-15, 1e-10, 0)) 91 // { printf ("main: error %d in hullRefine\n", i); exit (i); } 90 if (i=hullRefine (points, (loop_max+1)*(loop_max+2), allparams, 2, T, P, 91 1e-10, 1e-7, 0)) 92 { printf ("main: error %d in hullRefine\n", i); exit (i); } 92 93 if (i=hullReturnFacets (&hullnumverts, &hullverts)) 93 94 { printf ("main: Error %d in hullReturnFacets\n", i); exit (i); } trunk/matml/src/ternary/ternary.h
r379 r381 119 119 120 120 /* From qhull.c */ 121 int hullCalculate (int dim, int numpoints, ternary_point *points); 122 int hullRefine (energy_params *eparams, int nparams, double T, double P, 123 double newton_tolerance, double vertex_tolerance, 124 int one_phase_refine); 121 int hullCalculate (int dim, ternary_point *points, int numpoints); 122 int hullRefine 123 (ternary_point *points, int numpoints, energy_params *eparams, int nparams, 124 double T,double P, double newton_tolerance, double vertex_tolerance, 125 int one_phase_refine); 125 126 int hullReturnFacets (int *facets, int **verts); 126 127 char *hullQHullVersion ();