Changeset 379

Show
Ignore:
Timestamp:
06/26/08 16:42:58 (4 months ago)
Author:
powell
Message:

Another interface change.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/matml/src/ternary/freenergy.c

    r372 r379  
    318318 
    319319  energy_params *eparams Free energy function parameters. 
     320 
     321  int efunc Index indicating which set of energy parameters to use, -1 to use 
     322  values already stored in 
     323  +latex+{\tt points}. 
     324  +html+ <tt>points</tt>. 
     325 
     326  int derivs Flag indicating whether to also calculate and store free energy 
     327  derivatives (if non-zero). 
    320328  ++++++++++++++++++++++++++++++++++++++*/ 
    321329 
    322330int free_energies 
    323 (ternary_point *points, int n, double T, double P, energy_params *eparams) 
    324 
    325   int i; 
    326   double C1, 
    327     G1 = eparams->G1_T0 + eparams->G1_C*(T-eparams->T0), 
    328     G2 = eparams->G2_T0 + eparams->G2_C*(T-eparams->T0), 
    329     G3 = eparams->G3_T0 + eparams->G3_C*(T-eparams->T0); 
     331(ternary_point *points, int n, double T, double P, energy_params *eparams, 
     332 int efunc, int derivs) 
     333
     334  int i, thefunc; 
     335  double C1, G1, G2, G3; 
     336 
     337  if (efunc >= 0) 
     338    { 
     339      thefunc = efunc; 
     340      G1 = (eparams+thefunc)->G1_T0 + 
     341        (eparams+thefunc)->G1_C*(T-(eparams+thefunc)->T0); 
     342      G2 = (eparams+thefunc)->G2_T0 + 
     343        (eparams+thefunc)->G2_C*(T-(eparams+thefunc)->T0); 
     344      G3 = (eparams+thefunc)->G3_T0 + 
     345        (eparams+thefunc)->G3_C*(T-(eparams+thefunc)->T0); 
     346    } 
    330347 
    331348  for (i=0; i<n; i++) 
    332349    { 
     350      if (efunc<0) 
     351        { 
     352          thefunc = points[i].efunc; 
     353          G1 = (eparams+thefunc)->G1_T0 + 
     354            (eparams+thefunc)->G1_C*(T-(eparams+thefunc)->T0); 
     355          G2 = (eparams+thefunc)->G2_T0 + 
     356            (eparams+thefunc)->G2_C*(T-(eparams+thefunc)->T0); 
     357          G3 = (eparams+thefunc)->G3_T0 + 
     358            (eparams+thefunc)->G3_C*(T-(eparams+thefunc)->T0); 
     359        } 
    333360      C1 = 1.-points[i].C2-points[i].C3; 
    334       points[i].G = _G (C1,points[i].C2,points[i].C3, G1,G2,G3, T, P, eparams); 
     361      points[i].G = _G (C1,points[i].C2,points[i].C3, G1,G2,G3, T, P, 
     362                        eparams+thefunc); 
     363 
     364      if (derivs) 
     365        { 
     366          points[i].G2 =_G2 (C1,points[i].C2,points[i].C3, G1,G2,G3, T,P, 
     367                             eparams+thefunc); 
     368          points[i].G3 =_G3 (C1,points[i].C2,points[i].C3, G1,G2,G3, T,P, 
     369                             eparams+thefunc); 
     370          points[i].G22=_G22(C1,points[i].C2,points[i].C3, G1,G2,G3, T,P, 
     371                             eparams+thefunc); 
     372          points[i].G33=_G33(C1,points[i].C2,points[i].C3, G1,G2,G3, T,P, 
     373                             eparams+thefunc); 
     374          points[i].G23=_G23(C1,points[i].C2,points[i].C3, G1,G2,G3, T,P, 
     375                             eparams+thefunc); 
     376        } 
    335377    } 
    336378 
    337379  return 0; 
    338380} 
    339  
    340  
    341 /*++++++++++++++++++++++++++++++++++++++ 
    342   This calculates free energy and its derivatives at a bunch of compositions. 
    343  
    344   int free_energy_derivatives It returns zero or an error code. 
    345  
    346 ternary_point *points Ternary point structures holding the compositions where 
    347   we calculate the free energy, and the free energy and derivative fields where 
    348   we put the return values. 
    349  
    350   int n Number of points to calculate. 
    351  
    352   double T Temperature. 
    353  
    354   double P Pressure (ignored for now). 
    355  
    356   energy_params *eparams Free energy function parameters. 
    357   ++++++++++++++++++++++++++++++++++++++*/ 
    358  
    359 int free_energy_derivatives 
    360 (ternary_point *points, int n, double T, double P, energy_params *eparams) 
    361 { 
    362   int i; 
    363   double C1, 
    364     G1 = eparams->G1_T0 + eparams->G1_C*(T-eparams->T0), 
    365     G2 = eparams->G2_T0 + eparams->G2_C*(T-eparams->T0), 
    366     G3 = eparams->G3_T0 + eparams->G3_C*(T-eparams->T0); 
    367  
    368   for (i=0; i<n; i++) 
    369     { 
    370       C1 = 1.-points[i].C2-points[i].C3; 
    371       points[i].G  =_G  (C1,points[i].C2,points[i].C3, G1,G2,G3, T,P, eparams); 
    372       points[i].G2 =_G2 (C1,points[i].C2,points[i].C3, G1,G2,G3, T,P, eparams); 
    373       points[i].G3 =_G3 (C1,points[i].C2,points[i].C3, G1,G2,G3, T,P, eparams); 
    374       points[i].G22=_G22(C1,points[i].C2,points[i].C3, G1,G2,G3, T,P, eparams); 
    375       points[i].G33=_G33(C1,points[i].C2,points[i].C3, G1,G2,G3, T,P, eparams); 
    376       points[i].G23=_G23(C1,points[i].C2,points[i].C3, G1,G2,G3, T,P, eparams); 
    377     } 
    378  
    379   return 0; 
    380 } 
  • trunk/matml/src/ternary/qhull.c

    r378 r379  
    146146 
    147147      /*+ Calculate the energy derivatives +*/ 
    148       free_energy_derivatives (&current, 1, T, P, eparams); 
     148      free_energies (&current, 1, T, P, eparams, -1, 1); 
    149149 
    150150      /*+ Subtract the facet slopes from the energy derivatives +*/ 
     
    194194  point. 
    195195 
    196   int one_phase_refine Non-zero if the one-phase regions should be refined by 
    197   adding a new vertex at the centroid. 
     196  int one_phase_refine Non-zero if the one-phase regions should be refined. 
    198197  ++++++++++++++++++++++++++++++++++++++*/ 
    199198 
  • trunk/matml/src/ternary/ternary.c

    r378 r379  
    3535  /* eparams: R,T0, G1@T0,G2,G3, C1,C2,C3, M1,M2,M3, O12,O13,O23,O123 */ 
    3636  energy_params /* Solid, liquid */ 
    37     eparams1 = {1.,1., 0.,-.1,-.2, -1.,-1.1,-1.2, 1.,2.,5., -.5,2.,.2, 0.}, 
    38     eparams2 = {1.,1., .3,.1,-.1, -2.2,-2.,-1.8, 1.,1.,1.5, -.3,-.4,-.1, -.5}, 
    39       allparams[2] = {eparams1, eparams2}; 
     37    eparams0 = {1.,1., 0.,-.1,-.2, -1.,-1.1,-1.2, 1.,2.,5., -.5,2.,.2, 0.}, 
     38    eparams1 = {1.,1., .3,.1,-.1, -2.2,-2.,-1.8, 1.,1.,1.5, -.3,-.4,-.1, -.5}, 
     39      allparams[2] = {eparams0, eparams1}; 
    4040 
    4141  if (argc>1) 
     
    6767 
    6868  /* Calculate free energies */ 
    69   if (i=free_energies (points, (loop_max+1)*(loop_max+2)/2, T, P, &eparams1)) 
     69  if (i=free_energies (points, (loop_max+1)*(loop_max+2)/2, T,P, allparams,0,0)) 
    7070    { printf ("main: Error %d in free_energies\n", i); exit (i); } 
    7171  if (i=free_energies (points+(loop_max+1)*(loop_max+2)/2, 
    72                        (loop_max+1)*(loop_max+2)/2, T, P, &eparams2)) 
     72                       (loop_max+1)*(loop_max+2)/2, T,P, allparams,1,0)) 
    7373    { printf ("main: Error %d in free_energies\n", i); exit (i); } 
    7474 
     
    8484    { printf ("main: Error %d in Geomview Display\n", i); exit (i); } 
    8585 
    86   /* Calculate the lower convex hull */ 
     86  /* Calculate and refine the lower convex hull */ 
    8787  printf ("qhull version: %s\n", hullQHullVersion()); 
    8888  if (i=hullCalculate (3, (loop_max+1)*(loop_max+2), points)) 
    8989    { 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 (allparams, 2, T, P, 1e-15, 1e-10, 0)) 
     91  //  { printf ("main: error %d in hullRefine\n", i); exit (i); } 
    9292  if (i=hullReturnFacets (&hullnumverts, &hullverts)) 
    9393    { printf ("main: Error %d in hullReturnFacets\n", i); exit (i); } 
     
    113113      /* Test whether hull facet is in one-phase region: free energy at 
    114114         centroid is below facet; if so, remove it */ 
    115       if (fmin (free_energy (C2av, C3av, T, P, &eparams1), 
    116                 free_energy (C2av, C3av, T, P, &eparams2)) < Gav) 
     115      if (fmin (free_energy (C2av, C3av, T, P, allparams), 
     116                free_energy (C2av, C3av, T, P, allparams+1)) < Gav) 
    117117        { 
    118118          for (j=i; j<hullnumverts-1; j++) 
  • trunk/matml/src/ternary/ternary.h

    r378 r379  
    2020                   -latex-3 (0 -> 1-C2) 
    2121                   +*/ 
     22  int efunc;     /*+ Index indicating which energy surface (phase) this point 
     23                   is on +*/ 
    2224  double G;      /*+ Free energy +*/ 
    2325  double G2;     /*+ Free energy derivative 
     
    106108(double C2, double C3, double T, double P, energy_params *eparams); 
    107109int free_energies 
    108 (ternary_point *points, int n, double T, double P, energy_params *eparams); 
    109 int free_energy_derivatives 
    110 (ternary_point *points, int n, double T, double P, energy_params *eparams); 
     110(ternary_point *points, int n, double T, double P, energy_params *eparams, 
     111 int efunc, int derivs); 
    111112 
    112113/* From geomview.c */ 




About | Terms of Use | Contact | Privacy Policy