Changeset 353
- Timestamp:
- 03/27/08 16:54:31 (8 months ago)
- Location:
- trunk/matml/src/ternary
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/matml/src/ternary/ChangeLog
r349 r353 4 4 * Check for qhull library in configure.in. 5 5 * Parameterized free energy function with temperature support. 6 * Moved many O(N) functions from main() out to new book.c file. 6 7 * TODO: better single-phase check in ternary.c, 7 8 multiple free energy functions; later refine qhull concave facets. -
trunk/matml/src/ternary/Makefile.am
r350 r353 12 12 noinst_HEADERS = ternary.h 13 13 ternary_SOURCES = ternary.c geomview.c qhull.c book.c freenergy.c 14 ternary_CFLAGS = - DGEOMVIEW=\"@GEOMVIEW@\" # -DDEBUG14 ternary_CFLAGS = -std=c99 -DGEOMVIEW=\"@GEOMVIEW@\" # -DDEBUG 15 15 ternary_LDADD = -lm -lqhull 16 16 -
trunk/matml/src/ternary/book.c
r351 r353 9 9 10 10 #include "ternary.h" /*+ Ternary prototypes, typedefs, etc. +*/ 11 #include <math.h> /*+ For sqrt() +*/11 #include <math.h> /*+ For sqrt(), fmin()/fmax() +*/ 12 12 13 13 … … 74 74 75 75 /*++++++++++++++++++++++++++++++++++++++ 76 This function fills an array with vertex indices. 77 78 int init_triangle_vertices It returns zero or an error code. 79 80 int resolution Resolution of the discretization (number of points on a side). 81 82 int *vertex_array Array of triangle indices of size 83 +latex+$N^2$, where $N$ is the resolution. 84 +html+ <i>N</i><sup>2</sup>, where <i>N</i> is the resolution. 85 ++++++++++++++++++++++++++++++++++++++*/ 86 87 int init_triangle_vertices (int resolution, int *vertex_array) 88 { 89 int i,j, index; 90 91 for (i=0, index=0; i<resolution-1; i++) 92 { 93 for (j=0; j<resolution-i-1; j++) 94 { 95 vertex_array [3*index] = ROWSTART(i)+j; 96 vertex_array [3*index+1] = ROWSTART(i)+j+1; 97 vertex_array [3*index+2] = ROWSTART(i+1)+j; 98 index++; 99 100 vertex_array [3*index] = ROWSTART(i)+j+1; 101 vertex_array [3*index+1] = ROWSTART(i+1)+j+1; 102 vertex_array [3*index+2] = ROWSTART(i+1)+j; 103 index++; 104 } 105 vertex_array [3*index] = ROWSTART(i)+resolution-i-1; 106 vertex_array [3*index+1] = ROWSTART(i)+resolution-i; 107 vertex_array [3*index+2] = ROWSTART(i+1)+resolution-i-1; 108 index++; 109 } 110 vertex_array [3*index] = ROWSTART(resolution-1); 111 vertex_array [3*index+1] = ROWSTART(resolution-1)+1; 112 vertex_array [3*index+2] = ROWSTART(resolution); 113 114 return 0; 115 } 116 117 118 /*++++++++++++++++++++++++++++++++++++++ 76 119 This scales the free energy of an array of ternary points to the 77 120 +latex+$y$-coordinate … … 79 122 and colors the points according to free energy as well. 80 123 81 int scale_ triangle_array It returns zero or an error code.124 int scale_energy_array It returns zero or an error code. 82 125 83 126 int num_points Number of points in the array … … 110 153 ++++++++++++++++++++++++++++++++++++++*/ 111 154 112 int scale_ triangle_array (int num_points, ternary_point *points,155 int scale_energy_array (int num_points, ternary_point *points, 113 156 double y0, double G0, double y1, double G1, 114 157 double *Gmin, double *Gmax) -
trunk/matml/src/ternary/ternary.c
r351 r353 52 52 printf("Geomview version: %s\n", gv_version); 53 53 54 /* Calculate free energies, including upper and lower bounds for coloring*/54 /* Initialize coordinates of triangle array */ 55 55 if (i=init_triangle_array (loop_max, points)) 56 56 { printf ("main: Error %d in init_triangle_array\n", i); exit (i); } 57 57 58 #define ROWSTART(row) ((row)*(loop_max+1) - ((row)*((row)-1))/2) 58 /* Calculate triangle vertex indices */ 59 if (i=init_triangle_vertices (loop_max, verts)) 60 { printf ("main: Error %d in init_triangle_vertices\n", i); exit (i); } 59 61 62 /* Calculate free energies */ 60 63 for (index=0; index<(loop_max+1)*(loop_max+2)/2; index++) 61 64 points[index].G = 62 65 free_energy (points[index].C2, points[index].C3, T, &eparams1); 63 66 64 if (i=scale_triangle_array ((loop_max+1)*(loop_max+2)/2, points, 67 /* Scale free energy values to (0->1) */ 68 if (i=scale_energy_array ((loop_max+1)*(loop_max+2)/2, points, 65 69 0., 0., 1., 0., NULL, NULL)) 66 70 { printf ("main: Error %d in scale_triangle_array\n", i); exit (i); } 67 68 /* Calculate triangle vertex indices */69 for (i=0, index=0; i<loop_max-1; i++)70 {71 for (j=0; j<loop_max-1-i; j++)72 {73 verts [3*index] = ROWSTART(i)+j;74 verts [3*index+1] = ROWSTART(i)+j+1;75 verts [3*index+2] = ROWSTART(i+1)+j;76 index++;77 78 verts [3*index] = ROWSTART(i)+j+1;79 verts [3*index+1] = ROWSTART(i+1)+j+1;80 verts [3*index+2] = ROWSTART(i+1)+j;81 index++;82 }83 verts [3*index] = ROWSTART(i)+j;84 verts [3*index+1] = ROWSTART(i)+j+1;85 verts [3*index+2] = ROWSTART(i+1)+j;86 index++;87 }88 verts [3*index] = ROWSTART(i);89 verts [3*index+1] = ROWSTART(i)+1;90 verts [3*index+2] = ROWSTART(i+1);91 71 92 72 /* Send points and triangle vertex data to Geomview */ -
trunk/matml/src/ternary/ternary.h
r351 r353 104 104 /* From book.c */ 105 105 int init_triangle_array (int resolution, ternary_point *points); 106 int scale_triangle_array (int num_points, ternary_point *points, 107 double y0, double G0, double y1, double G1, 108 double *Gmin, double *Gmax); 106 int init_triangle_vertices (int resolution, int *vertex_array); 107 int scale_energy_array (int num_points, ternary_point *points, 108 double y0, double G0, double y1, double G1, 109 double *Gmin, double *Gmax); 109 110 110 111 #endif /* TERNARY_H */