Changeset 379
- Timestamp:
- 06/26/08 16:42:58 (4 months ago)
- Files:
-
- trunk/matml/src/ternary/freenergy.c (modified) (1 diff)
- trunk/matml/src/ternary/qhull.c (modified) (2 diffs)
- trunk/matml/src/ternary/ternary.c (modified) (4 diffs)
- trunk/matml/src/ternary/ternary.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/matml/src/ternary/freenergy.c
r372 r379 318 318 319 319 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). 320 328 ++++++++++++++++++++++++++++++++++++++*/ 321 329 322 330 int 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 } 330 347 331 348 for (i=0; i<n; i++) 332 349 { 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 } 333 360 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 } 335 377 } 336 378 337 379 return 0; 338 380 } 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 where347 we calculate the free energy, and the free energy and derivative fields where348 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_derivatives360 (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 146 146 147 147 /*+ Calculate the energy derivatives +*/ 148 free_energ y_derivatives (¤t, 1, T, P, eparams);148 free_energies (¤t, 1, T, P, eparams, -1, 1); 149 149 150 150 /*+ Subtract the facet slopes from the energy derivatives +*/ … … 194 194 point. 195 195 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. 198 197 ++++++++++++++++++++++++++++++++++++++*/ 199 198 trunk/matml/src/ternary/ternary.c
r378 r379 35 35 /* eparams: R,T0, G1@T0,G2,G3, C1,C2,C3, M1,M2,M3, O12,O13,O23,O123 */ 36 36 energy_params /* Solid, liquid */ 37 eparams 1= {1.,1., 0.,-.1,-.2, -1.,-1.1,-1.2, 1.,2.,5., -.5,2.,.2, 0.},38 eparams 2= {1.,1., .3,.1,-.1, -2.2,-2.,-1.8, 1.,1.,1.5, -.3,-.4,-.1, -.5},39 allparams[2] = {eparams 1, 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}; 40 40 41 41 if (argc>1) … … 67 67 68 68 /* 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)) 70 70 { printf ("main: Error %d in free_energies\n", i); exit (i); } 71 71 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)) 73 73 { printf ("main: Error %d in free_energies\n", i); exit (i); } 74 74 … … 84 84 { printf ("main: Error %d in Geomview Display\n", i); exit (i); } 85 85 86 /* Calculate the lower convex hull */86 /* Calculate and refine the lower convex hull */ 87 87 printf ("qhull version: %s\n", hullQHullVersion()); 88 88 if (i=hullCalculate (3, (loop_max+1)*(loop_max+2), points)) 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 (allparams, 2, T, P, 1e-15, 1e-10, 0)) 91 // { printf ("main: error %d in hullRefine\n", i); exit (i); } 92 92 if (i=hullReturnFacets (&hullnumverts, &hullverts)) 93 93 { printf ("main: Error %d in hullReturnFacets\n", i); exit (i); } … … 113 113 /* Test whether hull facet is in one-phase region: free energy at 114 114 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) 117 117 { 118 118 for (j=i; j<hullnumverts-1; j++) trunk/matml/src/ternary/ternary.h
r378 r379 20 20 -latex-3 (0 -> 1-C2) 21 21 +*/ 22 int efunc; /*+ Index indicating which energy surface (phase) this point 23 is on +*/ 22 24 double G; /*+ Free energy +*/ 23 25 double G2; /*+ Free energy derivative … … 106 108 (double C2, double C3, double T, double P, energy_params *eparams); 107 109 int 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); 111 112 112 113 /* From geomview.c */