| | 58 | |
| | 59 | |
| | 60 | /*++++++++++++++++++++++++++++++++++++++ |
| | 61 | This local function calculates the derivative of free energy with respect to |
| | 62 | +latex+$C_2$: $\partial G/\partial C_2$ |
| | 63 | +html+ <i>C</i><sub>2</sub>: <i>dG</i>/<i>DC</i><sub>2</sub> |
| | 64 | as a function of composition, temperature, pressure, and the specified |
| | 65 | parameters. |
| | 66 | |
| | 67 | inline double _G2 It returns the free energy derivative. |
| | 68 | |
| | 69 | double C2 Concentration of species 2. |
| | 70 | |
| | 71 | double C3 Concentration of species 3. |
| | 72 | |
| | 73 | double T Temperature. |
| | 74 | |
| | 75 | double P Pressure (ignored for now). |
| | 76 | |
| | 77 | energy_params *eparams Free energy function parameters. |
| | 78 | ++++++++++++++++++++++++++++++++++++++*/ |
| | 79 | |
| | 80 | static inline double _G2 |
| | 81 | (double C2, double C3, double T, double P, energy_params *eparams) |
| | 82 | { |
| | 83 | return 0.; |
| | 84 | } |
| | 85 | |
| | 86 | |
| | 87 | /*++++++++++++++++++++++++++++++++++++++ |
| | 88 | This local function calculates the derivative of free energy with respect to |
| | 89 | +latex+$C_3$: $\partial G/\partial C_3$ |
| | 90 | +html+ <i>C</i><sub>3</sub>: <i>dG</i>/<i>DC</i><sub>3</sub> |
| | 91 | as a function of composition, temperature, pressure, and the specified |
| | 92 | parameters. |
| | 93 | |
| | 94 | inline double _G3 It returns the free energy derivative. |
| | 95 | |
| | 96 | double C2 Concentration of species 2. |
| | 97 | |
| | 98 | double C3 Concentration of species 3. |
| | 99 | |
| | 100 | double T Temperature. |
| | 101 | |
| | 102 | double P Pressure (ignored for now). |
| | 103 | |
| | 104 | energy_params *eparams Free energy function parameters. |
| | 105 | ++++++++++++++++++++++++++++++++++++++*/ |
| | 106 | |
| | 107 | static inline double _G3 |
| | 108 | (double C2, double C3, double T, double P, energy_params *eparams) |
| | 109 | { |
| | 110 | return 0.; |
| | 111 | } |
| | 112 | |
| | 113 | |
| | 114 | /*++++++++++++++++++++++++++++++++++++++ |
| | 115 | This local function calculates the second derivative of free energy with |
| | 116 | respect to |
| | 117 | +latex+$C_2$: $\partial^2G/\partial C_2^2$ |
| | 118 | +html+ <i>C</i><sub>2</sub>: |
| | 119 | +html+ <i>d</i><sup>2</sup><i>G</i>/<i>DC</i><sub>2</sub><sup>2</sup> |
| | 120 | as a function of composition, temperature, pressure, and the specified |
| | 121 | parameters. |
| | 122 | |
| | 123 | inline double _G22 It returns the free energy derivative. |
| | 124 | |
| | 125 | double C2 Concentration of species 2. |
| | 126 | |
| | 127 | double C3 Concentration of species 3. |
| | 128 | |
| | 129 | double T Temperature. |
| | 130 | |
| | 131 | double P Pressure (ignored for now). |
| | 132 | |
| | 133 | energy_params *eparams Free energy function parameters. |
| | 134 | ++++++++++++++++++++++++++++++++++++++*/ |
| | 135 | |
| | 136 | static inline double _G22 |
| | 137 | (double C2, double C3, double T, double P, energy_params *eparams) |
| | 138 | { |
| | 139 | return 0.; |
| | 140 | } |
| | 141 | |
| | 142 | |
| | 143 | /*++++++++++++++++++++++++++++++++++++++ |
| | 144 | This local function calculates the second derivative of free energy with |
| | 145 | respect to |
| | 146 | +latex+$C_3$: $\partial^2G/\partial C_3^2$ |
| | 147 | +html+ <i>C</i><sub>3</sub>: |
| | 148 | +html+ <i>d</i><sup>2</sup><i>G</i>/<i>DC</i><sub>3</sub><sup>2</sup> |
| | 149 | as a function of composition, temperature, pressure, and the specified |
| | 150 | parameters. |
| | 151 | |
| | 152 | inline double _G33 It returns the free energy derivative. |
| | 153 | |
| | 154 | double C2 Concentration of species 2. |
| | 155 | |
| | 156 | double C3 Concentration of species 3. |
| | 157 | |
| | 158 | double T Temperature. |
| | 159 | |
| | 160 | double P Pressure (ignored for now). |
| | 161 | |
| | 162 | energy_params *eparams Free energy function parameters. |
| | 163 | ++++++++++++++++++++++++++++++++++++++*/ |
| | 164 | |
| | 165 | static inline double _G33 |
| | 166 | (double C2, double C3, double T, double P, energy_params *eparams) |
| | 167 | { |
| | 168 | return 0.; |
| | 169 | } |
| | 170 | |
| | 171 | |
| | 172 | /*++++++++++++++++++++++++++++++++++++++ |
| | 173 | This local function calculates the mixed second derivative of free energy |
| | 174 | with respect to |
| | 175 | +latex+$C_2$ and $C_3$: $\partial^2G/\partial C_2\partial C_3$ |
| | 176 | +html+ <i>C</i><sub>2</sub> and <i>C</i><sub>3</sub>: |
| | 177 | +html+ <i>d</i><sup>2</sup><i>G</i>/<i>DC</i><sub>2</sub><i>DC</i><sub>3</sub> |
| | 178 | as a function of composition, temperature, pressure, and the specified |
| | 179 | parameters. |
| | 180 | |
| | 181 | inline double _G23 It returns the free energy derivative. |
| | 182 | |
| | 183 | double C2 Concentration of species 2. |
| | 184 | |
| | 185 | double C3 Concentration of species 3. |
| | 186 | |
| | 187 | double T Temperature. |
| | 188 | |
| | 189 | double P Pressure (ignored for now). |
| | 190 | |
| | 191 | energy_params *eparams Free energy function parameters. |
| | 192 | ++++++++++++++++++++++++++++++++++++++*/ |
| | 193 | |
| | 194 | static inline double _G23 |
| | 195 | (double C2, double C3, double T, double P, energy_params *eparams) |
| | 196 | { |
| | 197 | return 0.; |
| | 198 | } |
| | 199 | |
| | 200 | |
| | 201 | /*++++++++++++++++++++++++++++++++++++++ |
| | 202 | This returns the free energy at a single composition. |
| | 203 | |
| | 204 | double free_energy It returns the free energy. |
| | 205 | |
| | 206 | double C2 Concentration of species 2. |
| | 207 | |
| | 208 | double C3 Concentration of species 3. |
| | 209 | |
| | 210 | double T Temperature. |
| | 211 | |
| | 212 | double P Pressure (ignored for now). |
| | 213 | |
| | 214 | energy_params *eparams Free energy function parameters. |
| | 215 | ++++++++++++++++++++++++++++++++++++++*/ |
| | 216 | |
| | 217 | double free_energy |
| | 218 | (double C2, double C3, double T, double P, energy_params *eparams) |
| | 219 | { |
| | 220 | return _G (C2, C3, T, P, eparams); |
| | 221 | } |
| | 222 | |
| | 223 | |
| | 224 | /*++++++++++++++++++++++++++++++++++++++ |
| | 225 | This calculates free energy at a bunch of compositions. |
| | 226 | |
| | 227 | int free_energies It returns zero or an error code. |
| | 228 | |
| | 229 | ternary_point *points Ternary point structures holding the compositions where |
| | 230 | we calculate the free energy, and the free energy field where we put the |
| | 231 | return values. |
| | 232 | |
| | 233 | int n Number of points to calculate. |
| | 234 | |
| | 235 | double T Temperature. |
| | 236 | |
| | 237 | double P Pressure (ignored for now). |
| | 238 | |
| | 239 | energy_params *eparams Free energy function parameters. |
| | 240 | ++++++++++++++++++++++++++++++++++++++*/ |
| | 241 | |
| | 242 | int free_energies |
| | 243 | (ternary_point *points, int n, double T, double P, energy_params *eparams) |
| | 244 | { |
| | 245 | int i; |
| | 246 | |
| | 247 | for (i=0; i<n; i++) |
| | 248 | points[i].G = _G (points[i].C2, points[i].C3, T, P, eparams); |
| | 249 | |
| | 250 | return 0; |
| | 251 | } |
| | 252 | |
| | 253 | |
| | 254 | /*++++++++++++++++++++++++++++++++++++++ |
| | 255 | This calculates free energy and its derivatives at a bunch of compositions. |
| | 256 | |
| | 257 | int free_energy_derivatives It returns zero or an error code. |
| | 258 | |
| | 259 | ternary_point *points Ternary point structures holding the compositions where |
| | 260 | we calculate the free energy, and the free energy and derivative fields where |
| | 261 | we put the return values. |
| | 262 | |
| | 263 | int n Number of points to calculate. |
| | 264 | |
| | 265 | double T Temperature. |
| | 266 | |
| | 267 | double P Pressure (ignored for now). |
| | 268 | |
| | 269 | energy_params *eparams Free energy function parameters. |
| | 270 | ++++++++++++++++++++++++++++++++++++++*/ |
| | 271 | |
| | 272 | int free_energy_derivatives |
| | 273 | (ternary_point *points, int n, double T, double P, energy_params *eparams) |
| | 274 | { |
| | 275 | int i; |
| | 276 | |
| | 277 | for (i=0; i<n; i++) |
| | 278 | { |
| | 279 | points[i].G = _G (points[i].C2, points[i].C3, T, P, eparams); |
| | 280 | points[i].G2 = _G2 (points[i].C2, points[i].C3, T, P, eparams); |
| | 281 | points[i].G3 = _G3 (points[i].C2, points[i].C3, T, P, eparams); |
| | 282 | points[i].G22 = _G22 (points[i].C2, points[i].C3, T, P, eparams); |
| | 283 | points[i].G33 = _G33 (points[i].C2, points[i].C3, T, P, eparams); |
| | 284 | points[i].G23 = _G23 (points[i].C2, points[i].C3, T, P, eparams); |
| | 285 | } |
| | 286 | |
| | 287 | return 0; |
| | 288 | } |