Changeset 350

Show
Ignore:
Timestamp:
03/27/08 15:47:10 (8 months ago)
Author:
powell
Message:

New "bookkeeping" file will take a lot of the busywork out of main().

Location:
trunk/matml/src/ternary
Files:
1 added
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/matml/src/ternary/Makefile.am

    r342 r350  
    1111bin_PROGRAMS    = ternary 
    1212noinst_HEADERS  = ternary.h 
    13 ternary_SOURCES = ternary.c geomview.c qhull.c freenergy.c 
     13ternary_SOURCES = ternary.c geomview.c qhull.c book.c freenergy.c 
    1414ternary_CFLAGS  = -DGEOMVIEW=\"@GEOMVIEW@\" # -DDEBUG 
    1515ternary_LDADD   = -lm -lqhull 
     
    2525                 $(top_srcdir)/geomview.c.tex \ 
    2626                 $(top_srcdir)/qhull.c.tex \ 
     27                 $(top_srcdir)/book.c.tex \ 
    2728                 $(top_srcdir)/freenergy.c.tex 
    2829 
  • trunk/matml/src/ternary/ternary.c

    r349 r350  
    77 
    88 
    9 #include "ternary.h" 
    10 #include <stdlib.h> 
    11 #include <math.h> 
     9#include "ternary.h" /*+ Ternary prototypes, typedefs, etc. +*/ 
     10#include <stdlib.h>  /*+ For calloc +*/ 
    1211 
    1312 
     
    3130  char gv_version[100], *qh_version; 
    3231  FILE *pfd = NULL; 
    33   double Gmin, Gmax; 
     32  double Gmin, Gmax, T=1.; 
    3433  ternary_point *points; 
    35   energy_params eparams={1.,1., 0.2,0.1,0., 1.,1.,1., 1.,2.,5., -.5,2.,.2, 0.}; 
     34  /* eparams: R,T0, G1@T0,G2,G3, C1,C2,C3, M1,M2,M3, O12,O13,O23,O123 */ 
     35  energy_params /* Solid, liquid */ 
     36    eparams1 = {1.,1., 0.,-.1,-.2, 1.,1.1,1.2, 1.,2.,5., -.5,2.,.2, 0.}, 
     37    eparams2 = {1.,1., .3,.1,-.1, 2.2,2.,1.8, 1.,1.,1.5, -.3,-.4,-.1, -.5}; 
    3638 
    3739  if (argc>1) 
     
    4749  /* Start Geomview process */ 
    4850  if (i=GeomviewBegin (&pfd, gv_version)) 
    49     { printf ("main: Error %d in Geomview Begin\n", i); exit (i); } 
     51    { printf ("main: Error %d in GeomviewBegin\n", i); exit (i); } 
    5052  printf("Geomview version: %s\n", gv_version); 
     53 
     54  /* Calculate free energies, including upper and lower bounds for coloring */ 
     55  if (i=init_triangle_array (loop_max, points)) 
     56    { printf ("main: Error %d in init_triangle_array\n", i); exit (i); } 
    5157 
    5258#define ROWSTART(row) ((row)*(loop_max+1) - ((row)*((row)-1))/2) 
    5359 
    54   /* Calculate free energies, including upper and lower bounds for coloring */ 
    55   Gmin = Gmax = free_energy (0., 0., 1., &eparams); 
     60  Gmin = Gmax = free_energy (0., 0., T, &eparams1); 
    5661  for (i=0; i<=loop_max; i++) 
    5762    for (j=0; j<=loop_max-i; j++) 
     
    5964        index = (ROWSTART (i) + j); 
    6065 
    61         points[index].C2 = (double)i/loop_max; 
    62         points[index].C3 = (double)j/loop_max; 
    63         points[index].G = free_energy (points[index].C2, points[index].C3, 1., &eparams); 
     66        points[index].G = 
     67          free_energy (points[index].C2, points[index].C3, T, &eparams1); 
    6468        Gmin = (points[index].G<Gmin) ? points[index].G : Gmin; 
    6569        Gmax = (points[index].G>Gmax) ? points[index].G : Gmax; 
     
    7882 
    7983        /* Switch y and z because geomview uses z as depth */ 
    80         points[index].x = points[index].C2 + 0.5 * points[index].C3; 
    8184        points[index].y = Grel(points[index].G); 
    82         points[index].z = (1. - points[index].C3) * sqrt(3)/2.; 
    8385 
    8486        points[index].red   = RED   (Grel (points[index].G));