| 105 | | int globaldims, int localdims, int side, double newton_tolerance) |
| 106 | | { |
| 107 | | double distance = 0.; |
| | 109 | double T, double P, int globaldims, int localdims, int side, |
| | 110 | double newton_tolerance) |
| | 111 | { |
| | 112 | int i, minfunc=0; |
| | 113 | double distance = 1., G, slope2, slope3; |
| | 114 | ternary_point current; |
| | 115 | |
| | 116 | if (globaldims != 3) |
| | 117 | { printf ("qhullCalcHull: Non-ternaries not yet supported\n"); return; } |
| | 118 | current.C2 = point[0]; |
| | 119 | current.C3 = point[1]; |
| | 122 | G = free_energy (current.C2, current.C3, T, P, eparams); |
| | 123 | for (i=1; i<nparams; i++) |
| | 124 | if (slope2 = free_energy (current.C2, current.C3, T, P, eparams+i) < G) |
| | 125 | { |
| | 126 | G = slope2; |
| | 127 | minfunc = i; |
| | 128 | } |
| | 129 | |
| | 130 | /*+ Determine the slope(s) of the facet +*/ |
| | 131 | if (localdims==3) |
| | 132 | { |
| | 133 | double x2=corners[3]-corners[0], y2=corners[6]-corners[0], |
| | 134 | x3=corners[4]-corners[1], y3=corners[7]-corners[1], |
| | 135 | xG=corners[5]-corners[2], yG=corners[8]-corners[2]; |
| | 136 | double vG=x2*y3-x3*y2; |
| | 137 | slope2 = (x3*yG-xG*y3)/vG; |
| | 138 | slope3 = (xG*y2-x2*yG)/vG; |
| | 139 | } |
| | 140 | else |
| | 141 | { |
| | 142 | /*+ Slope for the binary case +*/ |
| | 143 | if (side==0 || side==2) // C3=0 or C2+C3=1 sides: dG/dC2 |
| | 144 | slope2 = (corners[5]-corners[2])/(corners[3]-corners[0]); |
| | 145 | else if (side==1) // C2=0 side: dG/dC3 |
| | 146 | slope2 = (corners[5]-corners[2])/(corners[4]-corners[1]); |
| | 147 | } |
| 116 | | |
| 117 | | /*+ Solve the linear system to estimate the distance to the minimum +*/ |
| 118 | | |
| 119 | | /*+ Add that distance to the point +*/ |
| 120 | | } |
| | 157 | current.G2 -= slope2; |
| | 158 | current.G3 -= slope3; |
| | 159 | |
| | 160 | /*+ Solve the linear system to estimate the vector to the minimum +*/ |
| | 161 | dC3 = current.G22*current.G33 - current.G23*current.G23; |
| | 162 | dC2 = (current.G3*current.G23 - current.G2*current.G33) / dC3; |
| | 163 | dC3 = (current.G2*current.G23 - current.G3*current.G22) / dC3; |
| | 164 | |
| | 165 | /*+ Add that vector to the point +*/ |
| | 166 | current.C2 += dC2; |
| | 167 | current.C3 += dC3; |
| | 168 | distance = dC2*dC2 + dC3*dC3; |
| | 169 | } |
| | 170 | |
| | 171 | /* Return the current point */ |
| | 172 | point[0] = current.C2; |
| | 173 | point[1] = current.C3; |