Changeset 449
- Timestamp:
- 03/18/2009 09:10:18 PM (3 years ago)
- Location:
- trunk/matml/src/ternary
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/matml/src/ternary/freenergy.c
r447 r449 48 48 double T, double P, energy_params *eparams) 49 49 { 50 /*+ This uses the Flory-Huggins free energy formula for a polymer solution, 51 which divides each species' entropy term by its molar volume and adds 52 binary interaction parameters. 50 /*+ This uses a free energy formula with a coefficient for each species' 51 entropy term, which allows one to use the Flory-Huggins model by setting 52 that coefficient equal to the reciprocal of the molar volume. To this it 53 adds binary interaction parameters. 53 54 +latex+The resulting regular solution expression for free energy is: 54 55 +latex+\begin{eqnarray} 55 56 +latex+ \label{eq:flory-huggins} 56 57 +latex+ G &=& G_1 + (G_2-G_1) C_2 + (G_3-G_1) C_3 \\\ \nonumber 57 +latex+ &+& RT \left( \frac{1}{m_1}C_1\log C_158 +latex+ + \frac{1}{m_2}C_2\log C_259 +latex+ + \frac{1}{m_3}C_3\log C_3\right) \\\ \nonumber58 +latex+ &+& RT \left(S_1C_1\log C_1 59 +latex+ + S_2C_2\log C_2 60 +latex+ + S_3C_3\log C_3\right) \\\ \nonumber 60 61 +latex+ &+& \Omega_{12}C_1C_2 + \Omega_{13}C_1C_3 61 62 +latex+ + \Omega_{23}C_2C_3 +\Omega_{123}C_1C_2C_3. 62 63 +latex+\end{eqnarray} 63 64 +*/ 64 return G1 + (G2-G1)*C2 + (G3-G1)*C3 65 int i; 66 double ret = G1 + (G2-G1)*C2 + (G3-G1)*C3 65 67 + eparams->R*T*( ((C1<=0.) ? 0. : eparams->S1*C1*log(C1)) 66 68 + ((C2<=0.) ? 0. : eparams->S2*C2*log(C2)) … … 70 72 + eparams->Omega12*C1*C2 + eparams->Omega13*C1*C3 + eparams->Omega23*C2*C3 71 73 + eparams->Omega123*C1*C2*C3; 74 75 for (i=0; i<eparams->n_gauss; i++) 76 ret += (eparams->gauss) [i].G * 77 exp (-((C2-(eparams->gauss) [i].C2)*(C2-(eparams->gauss) [i].C2) + 78 (C3-(eparams->gauss) [i].C3)*(C3-(eparams->gauss) [i].C3)) / 79 (eparams->gauss) [i].w / (eparams->gauss) [i].w); 80 81 return ret; 72 82 } 73 83 … … 115 125 +latex+\end{equation} 116 126 +*/ 117 return G2-G1 127 int i; 128 double ret = G2-G1 118 129 + eparams->R*T*(((eparams->S1==0.) ? 0. : 119 130 ((C1<=0.) ? LOCAL_INFINITY : eparams->S1*(-log(C1)-1))) … … 124 135 + eparams->Omega12*(C1-C2) - eparams->Omega13*C3 + eparams->Omega23*C3 125 136 + eparams->Omega123*(C1-C2)*C3; 137 138 for (i=0; i<eparams->n_gauss; i++) 139 ret -= 2. * (eparams->gauss) [i].G * (C2-(eparams->gauss) [i].C2) 140 / (eparams->gauss) [i].w / (eparams->gauss) [i].w 141 * exp (-((C2-(eparams->gauss) [i].C2)*(C2-(eparams->gauss) [i].C2) + 142 (C3-(eparams->gauss) [i].C3)*(C3-(eparams->gauss) [i].C3)) / 143 (eparams->gauss) [i].w / (eparams->gauss) [i].w); 144 145 return ret; 126 146 } 127 147 … … 162 182 double T, double P, energy_params *eparams, free_energy_flags flags) 163 183 { 164 return G3-G1 184 int i; 185 double ret = G3-G1 165 186 + eparams->R*T*(((eparams->S1==0.) ? 0. : 166 187 ((C2+C3>=1) ? LOCAL_INFINITY : eparams->S1*(-log(C1)-1))) … … 171 192 - eparams->Omega12*C2 + eparams->Omega13*(C1-C3) + eparams->Omega23*C2 172 193 + eparams->Omega123*(C1-C3)*C2; 194 195 for (i=0; i<eparams->n_gauss; i++) 196 ret -= 2. * (eparams->gauss) [i].G * (C3-(eparams->gauss) [i].C3) 197 / (eparams->gauss) [i].w / (eparams->gauss) [i].w 198 * exp (-((C2-(eparams->gauss) [i].C2)*(C2-(eparams->gauss) [i].C2) + 199 (C3-(eparams->gauss) [i].C3)*(C3-(eparams->gauss) [i].C3)) / 200 (eparams->gauss) [i].w / (eparams->gauss) [i].w); 201 202 return ret; 173 203 } 174 204 … … 211 241 double T, double P, energy_params *eparams, free_energy_flags flags) 212 242 { 213 return 243 int i; 244 double ret = 214 245 eparams->R*T*(((eparams->S1==0.) ? 0. : 215 246 ((C2+C3>=1) ? LOCAL_INFINITY : eparams->S1/C1)) … … 217 248 + ((C2>=1.) ? LOCAL_INFINITY : eparams->S4/(1.-C2))) 218 249 - eparams->Omega12*2 - eparams->Omega123*2*C3; 250 251 for (i=0; i<eparams->n_gauss; i++) 252 ret += 2. * (eparams->gauss) [i].G 253 / (eparams->gauss) [i].w / (eparams->gauss) [i].w 254 * (2. * (C2-(eparams->gauss) [i].C2) * (C2-(eparams->gauss) [i].C2) 255 / (eparams->gauss) [i].w / (eparams->gauss) [i].w - 1.) 256 * exp (-((C2-(eparams->gauss) [i].C2)*(C2-(eparams->gauss) [i].C2) + 257 (C3-(eparams->gauss) [i].C3)*(C3-(eparams->gauss) [i].C3)) / 258 (eparams->gauss) [i].w / (eparams->gauss) [i].w); 259 260 return ret; 219 261 } 220 262 … … 257 299 double T, double P, energy_params *eparams, free_energy_flags flags) 258 300 { 259 return 301 int i; 302 double ret = 260 303 eparams->R*T*(((eparams->S1==0.) ? 0. : 261 304 ((C2+C3>=1) ? LOCAL_INFINITY : eparams->S1/C1)) … … 263 306 + ((C3>=1.) ? LOCAL_INFINITY : eparams->S5/(1.-C3))) 264 307 - eparams->Omega13*2 - eparams->Omega123*2*C2; 308 309 for (i=0; i<eparams->n_gauss; i++) 310 ret += 2. * (eparams->gauss) [i].G 311 / (eparams->gauss) [i].w / (eparams->gauss) [i].w 312 * (2. * (C3-(eparams->gauss) [i].C3) * (C3-(eparams->gauss) [i].C3) 313 / (eparams->gauss) [i].w / (eparams->gauss) [i].w - 1.) 314 * exp (-((C2-(eparams->gauss) [i].C2)*(C2-(eparams->gauss) [i].C2) + 315 (C3-(eparams->gauss) [i].C3)*(C3-(eparams->gauss) [i].C3)) / 316 (eparams->gauss) [i].w / (eparams->gauss) [i].w); 317 318 return ret; 265 319 } 266 320 … … 303 357 double T, double P, energy_params *eparams, free_energy_flags flags) 304 358 { 305 return 359 int i; 360 double ret = 306 361 eparams->R*T*((eparams->S1==0.) ? 0. : 307 362 ((C2+C3>=1) ? LOCAL_INFINITY : eparams->S1/C1)) 308 363 - eparams->Omega12 - eparams->Omega13 + eparams->Omega23 309 364 + eparams->Omega123*(2*C1-1); 365 366 for (i=0; i<eparams->n_gauss; i++) 367 ret += 4. * (eparams->gauss) [i].G 368 * (C2-(eparams->gauss) [i].C2) * (C3-(eparams->gauss) [i].C3) 369 / (eparams->gauss) [i].w / (eparams->gauss) [i].w 370 / (eparams->gauss) [i].w / (eparams->gauss) [i].w 371 * exp (-((C2-(eparams->gauss) [i].C2)*(C2-(eparams->gauss) [i].C2) + 372 (C3-(eparams->gauss) [i].C3)*(C3-(eparams->gauss) [i].C3)) / 373 (eparams->gauss) [i].w / (eparams->gauss) [i].w); 374 375 return ret; 310 376 } 311 377 -
trunk/matml/src/ternary/square.c
r448 r449 37 37 /* eparams: R,T0, G1@T0,G2,G3, C1,C2,C3, M1,M2,M3, O12,O13,O23,O123 */ 38 38 energy_params /* Solid, liquid */ 39 eparams0 = {"Solid", 1.,1., 0.,-.1,-.2, -1.,-1.1,-1.2, 0.,1.,1.,1.,1., -.5,2.,.2, 0. },40 eparams1 = {"Liquid", 1.,1., .3,.1,-.1, -2.2,-2.,-1.8, 0.,1.,.67,1.,2., -.3,-.4,-.1, -.5 },39 eparams0 = {"Solid", 1.,1., 0.,-.1,-.2, -1.,-1.1,-1.2, 0.,1.,1.,1.,1., -.5,2.,.2, 0., NULL,0}, 40 eparams1 = {"Liquid", 1.,1., .3,.1,-.1, -2.2,-2.,-1.8, 0.,1.,.67,1.,2., -.3,-.4,-.1, -.5, NULL,0}, 41 41 allparams[2] = {eparams0, eparams1}; 42 42 -
trunk/matml/src/ternary/ternary.c
r440 r449 37 37 /* eparams: R,T0, G1@T0,G2,G3, C1,C2,C3, M1,M2,M3, O12,O13,O23,O123 */ 38 38 energy_params /* Solid, liquid */ 39 eparams0 = {"Solid", 1.,1., 0.,-.1,-.2, -1.,-1.1,-1.2, 1.,.5,.2,0.,0., -.5,2.,.2, 0. },40 eparams1 = {"Liquid", 1.,1., .3,.1,-.1, -2.2,-2.,-1.8, 1.,1.,.67,0.,0., -.3,-.4,-.1, -.5 },39 eparams0 = {"Solid", 1.,1., 0.,-.1,-.2, -1.,-1.1,-1.2, 1.,.5,.2,0.,0., -.5,2.,.2, 0., NULL,0}, 40 eparams1 = {"Liquid", 1.,1., .3,.1,-.1, -2.2,-2.,-1.8, 1.,1.,.67,0.,0., -.3,-.4,-.1, -.5, NULL,0}, 41 41 allparams[2] = {eparams0, eparams1}; 42 42 -
trunk/matml/src/ternary/ternary.h
r444 r449 76 76 +*/ 77 77 } ternary_point; /*+ Ternary "point" structure. +*/ 78 79 typedef struct { 80 double C2; /*+ Composition at center of this Gaussian term +*/ 81 double C3; /*+ Composition at center of this Gaussian term +*/ 82 double G; /*+ Free energy addition at the Gaussian center +*/ 83 double w; /*+ Width of the Gaussian distribution +*/ 84 double n; /*+ Exponent of the distribution, currently fixed at 2 +*/ 85 } energy_gaussian; 78 86 79 87 typedef struct { … … 96 104 double Omega23; /*+ Species 2-3 regular solution interaction parameter +*/ 97 105 double Omega123; /*+ Species 1-2-3 regular solution interaction parameter +*/ 106 energy_gaussian *gauss; /*+ Array of Gaussian energy parameter structs +*/ 107 int n_gauss; /*+ Number of Gaussian energy terms +*/ 98 108 } energy_params; /*+ Free energy parameters structure +*/ 99 109