Changeset 313
- Timestamp:
- 03/25/08 18:20:58 (8 months ago)
- Location:
- trunk/matml/src/ternary
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/matml/src/ternary/freenergy.c
r310 r313 6 6 7 7 8 #include <math.h>8 #include "ternary.h" 9 9 10 10 … … 12 12 This calculates the free energy. 13 13 14 doublefree_energy It returns the free energy.14 coordT free_energy It returns the free energy. 15 15 16 doubleC2 Concentration of species 2.16 coordT C2 Concentration of species 2. 17 17 18 doubleC3 Concentration of species 3.18 coordT C3 Concentration of species 3. 19 19 20 doubleT Temperature (ignored for now).20 coordT T Temperature (ignored for now). 21 21 ++++++++++++++++++++++++++++++++++++++*/ 22 22 23 double free_energy (double C2, double C3, doubleT)23 coordT free_energy (coordT C2, coordT C3, coordT T) 24 24 { 25 doubleC1 = (1.-C2-C3 < 0.) ? 0. : 1.-C2-C3;26 doublem1=1., m2=2., m3=5.; /* Flory-Huggins "Degree of polymerization" */27 doublechi12 = -.5, chi13 = 2., chi23 = .2; /* Interaction parameters */25 coordT C1 = (1.-C2-C3 < 0.) ? 0. : 1.-C2-C3; 26 coordT m1=1., m2=2., m3=5.; /* Flory-Huggins "Degree of polymerization" */ 27 coordT chi12 = -.5, chi13 = 2., chi23 = .2; /* Interaction parameters */ 28 28 29 29 return ((C1==0.)?0.:C1/m1*log(C1)) + ((C2==0.)?0.:C2/m2*log(C2)) + -
trunk/matml/src/ternary/ternary.c
r310 r313 7 7 8 8 9 #include <stdio.h>10 #include <math.h>11 #include <unistd.h>12 9 #include "ternary.h" 13 10 … … 18 15 FILE *pfd = NULL; 19 16 int i, j, loop_max=50, vertcolor=1; 20 doubleGmin=1.e+100, Gmax=-1.e+100, centerG;17 coordT Gmin=1.e+100, Gmax=-1.e+100, centerG; 21 18 22 19 pipe (gv_pipe); /* from geomview stdout */ … … 60 57 for (j=0; j<=loop_max-i; j++) 61 58 { 62 double C2=(double)i/loop_max, C3=(double)j/loop_max, G;59 coordT C2=(coordT)i/loop_max, C3=(coordT)j/loop_max, G; 63 60 G = free_energy (C2, C3, 0.); 64 61 Gmin = (G<Gmin) ? G : Gmin; … … 75 72 for (j=0; j<=loop_max-i; j++) 76 73 { 77 double C2=(double)i/loop_max, C3=(double)j/loop_max, G, x,y,z;74 coordT C2=(coordT)i/loop_max, C3=(coordT)j/loop_max, G, x,y,z; 78 75 79 76 G = free_energy (C2, C3, 0.); … … 96 93 for (j=0; j<loop_max-1-i; j++) 97 94 { 98 centerG = free_energy ((( double)i+0.333333)/loop_max,99 (( double)j+0.333333)/loop_max, 0.);95 centerG = free_energy (((coordT)i+0.333333)/loop_max, 96 ((coordT)j+0.333333)/loop_max, 0.); 100 97 fprintf (pfd, "3 %d %d %d", 101 98 ROWSTART(i)+j, ROWSTART(i)+j+1, ROWSTART(i+1)+j); … … 106 103 fprintf (pfd, "\n"); 107 104 108 centerG = free_energy ((( double)i+0.666667)/loop_max,109 (( double)j+0.666667)/loop_max, 0.);105 centerG = free_energy (((coordT)i+0.666667)/loop_max, 106 ((coordT)j+0.666667)/loop_max, 0.); 110 107 fprintf (pfd, "3 %d %d %d", 111 108 ROWSTART(i)+j+1, ROWSTART(i+1)+j, ROWSTART(i+1)+j+1); … … 116 113 fprintf (pfd, "\n"); 117 114 } 118 centerG = free_energy ((( double)i+0.333333)/loop_max,119 (( double)j+0.333333)/loop_max, 0.);115 centerG = free_energy (((coordT)i+0.333333)/loop_max, 116 ((coordT)j+0.333333)/loop_max, 0.); 120 117 fprintf (pfd, "3 %d %d %d", 121 118 ROWSTART(i)+j, ROWSTART(i)+j+1, ROWSTART(i+1)+j); … … 126 123 fprintf (pfd, "\n"); 127 124 } 128 centerG = free_energy (((double)i+0.333333)/loop_max, 0.333333/loop_max, 0.); 125 centerG = free_energy (((coordT)i+0.333333)/loop_max, 126 0.333333/loop_max, 0.); 129 127 fprintf (pfd, "3 %d %d %d", 130 128 ROWSTART(i), ROWSTART(i)+1, ROWSTART(i+1)); -
trunk/matml/src/ternary/ternary.h
r310 r313 9 9 #define TERNARY_H /*+ To stop multiple inclusions. +*/ 10 10 11 double free_energy (double C2, double C3, double T); 11 #include <stdio.h> 12 #include <math.h> 13 #include <unistd.h> 14 #include <qhull/qhull.h> 15 16 coordT free_energy (coordT C2, coordT C3, realT T); 12 17 13 18 #endif /* TERNARY_H */