Changeset 438 for trunk/matml
- Timestamp:
- 03/16/2009 03:46:32 PM (3 years ago)
- Files:
-
- 1 modified
-
trunk/matml/src/ternary/qhull.c (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/matml/src/ternary/qhull.c
r437 r438 726 726 *n_bounds = 0; 727 727 728 #ifdef DEBUG 728 729 printf ("Starting ReturnPhaseBoundaries with %d facets, %d points\n", 729 730 n_facets, n_points); 730 731 printf ("Last facet %d vertices %d, %d, %d\n", n_facets-1, 732 facets[n_facets-1].vertex[0], facets[n_facets-1].vertex[1], 733 facets[n_facets-1].vertex[2]); 731 #endif 734 732 735 733 for (f=0; f<n_facets; f++) … … 738 736 v2 = facets[f].vertex[2]; 739 737 738 #ifdef DEBUG 740 739 printf ("Facet %d: type %d, vertices %d ",f, facets [f].type, v0); 741 740 printf ("(%d), %d (%d), %d(%d)\n", … … 743 742 points[v1].efunc, v2, points[v2].efunc); 744 743 fflush (stdout); 744 #endif 745 745 746 746 switch (facets [f].type) … … 774 774 // No boundary with these three phases, make a new one 775 775 bound = *n_bounds; 776 #ifdef DEBUG 776 777 printf ("Making new three-phase boundary %d\n", *n_bounds); 778 #endif 777 779 if (!(*boundaries = realloc 778 780 (*boundaries, (*n_bounds+1) * sizeof (phase_boundary)))) … … 794 796 (*boundaries) [bound].edges [2] = MAX3 (v0, v1, v2); 795 797 (*n_bounds) ++; 798 #ifdef DEBUG 796 799 printf (" Corners for bound %d edge 0: %d, %d, %d\n", bound, 797 800 (*boundaries) [bound].edges [0], 798 801 (*boundaries) [bound].edges [1], 799 802 (*boundaries) [bound].edges [2]); 803 #endif 800 804 } 801 805 else … … 804 808 // that we need not worry about the realloc overhead 805 809 int e = (*boundaries) [bound].n_edges; 810 #ifdef DEBUG 806 811 printf ("Ternary boundary %d adding edge %d\n",bound,e); 812 #endif 807 813 // All of these reallocs are pretty expensive... 808 814 // Later use compos to store size of array, sort out later … … 814 820 (*boundaries) [bound].edges [3*e+2] = MAX3 (v0, v1, v2); 815 821 (*boundaries) [bound].n_edges += 1; 822 #ifdef DEBUG 816 823 printf (" Corners for bound %d edge %d: %d, %d, %d\n", bound,e, 817 824 (*boundaries) [bound].edges [3*e], 818 825 (*boundaries) [bound].edges [3*e+1], 819 826 (*boundaries) [bound].edges [3*e+2]); 827 #endif 820 828 } 821 829 … … 852 860 G2 = points [v2].G; 853 861 862 #ifdef DEBUG 854 863 printf ("Misc gap: "); 864 #endif 855 865 nphases=1; 856 866 … … 858 868 (G0+G1)/2) 859 869 { 870 #ifdef DEBUG 860 871 printf ("v2 alone, Gav=%g, Gmid=%g\n", 861 872 (G0+G1)/2, free_energy ((C02+C12)/2,(C03+C13)/2,T,P,eparams+phase0)); 873 #endif 862 874 p0 = MIN (v0, v1); 863 875 p1 = MAX (v0, v1); … … 867 879 (G0+G2)/2) 868 880 { 881 #ifdef DEBUG 869 882 printf ("v1 alone, Gav=%g, Gmid=%g\n", 870 883 (G0+G2)/2, free_energy ((C02+C22)/2,(C03+C23)/2,T,P,eparams+phase0)); 884 #endif 871 885 p0 = MIN (v0, v2); 872 886 p1 = MAX (v0, v2); … … 875 889 else 876 890 { 891 #ifdef DEBUG 877 892 printf ("v0 alone, Gav=%g, Gmid=%g\n", 878 893 (G1+G2)/2, free_energy ((C22+C12)/2,(C23+C13)/2,T,P,eparams+phase0)); 894 #endif 879 895 p0 = MIN (v1, v2); 880 896 p1 = MAX (v1, v2); … … 908 924 bound = *n_bounds; 909 925 // No boundary with these two phases, make a new one 926 #ifdef DEBUG 910 927 printf ("Making new tie-line boundary %d\n", *n_bounds); 928 #endif 911 929 if (!(*boundaries = realloc 912 930 (*boundaries, (*n_bounds+1) * sizeof (phase_boundary)))) … … 940 958 (*boundaries) [bound].edges [2*e+2] = MIN (p1, p2); 941 959 (*boundaries) [bound].edges [2*e+3] = MAX (p1, p2); 960 #ifdef DEBUG 942 961 printf (" Corners for bound %d edges %d,%d: %d,%d, %d,%d\n", 943 962 bound, e, e+1, (*boundaries) [bound].edges [2*e], … … 945 964 (*boundaries) [bound].edges [2*e+2], 946 965 (*boundaries) [bound].edges [2*e+3]); 966 #endif 947 967 948 968 // Check for a boundary with an edge on the "majority" phase … … 958 978 // No boundary with these two phases, make a new one 959 979 bound = *n_bounds; 980 #ifdef DEBUG 960 981 printf ("Making new phase edge boundary %d\n", *n_bounds); 982 #endif 961 983 if (!(*boundaries = realloc 962 984 (*boundaries, (bound+1) * sizeof (phase_boundary)))) … … 986 1008 (*boundaries) [bound].edges [2*e+1] = MAX (p0, p1); 987 1009 (*boundaries) [bound].n_edges += 1; 1010 #ifdef DEBUG 988 1011 printf (" Corners for bound %d edge %d: %d,%d\n", 989 1012 bound, e, (*boundaries) [bound].edges [2*e], 990 1013 (*boundaries) [bound].edges [2*e+1]); 1014 #endif 991 1015 992 1016 break; … … 995 1019 case CRITICAL_POINT: 996 1020 { 1021 #ifdef DEBUG 997 1022 printf ("Critical point case\n"); 1023 #endif 998 1024 int b=0, bound=-1, p0, p1, p2, e=0, phase = points [v0].efunc; 999 1025 double C02 = points [v0].C2, C03 = points [v0].C3, … … 1006 1032 (G0+G1)/2) 1007 1033 { 1034 #ifdef DEBUG 1008 1035 printf ("v2 alone, Gav=%g, Gmid=%g\n", 1009 1036 (G0+G1)/2, free_energy ((C02+C12)/2,(C03+C13)/2,T,P,eparams+phase)); 1037 #endif 1010 1038 p0 = MIN (v0, v1); 1011 1039 p1 = MAX (v0, v1); … … 1015 1043 (G0+G2)/2) 1016 1044 { 1045 #ifdef DEBUG 1017 1046 printf ("v1 alone, Gav=%g, Gmid=%g\n", 1018 1047 (G0+G2)/2, free_energy ((C02+C22)/2,(C03+C23)/2,T,P,eparams+phase)); 1048 #endif 1019 1049 p0 = MIN (v0, v2); 1020 1050 p1 = MAX (v0, v2); … … 1023 1053 else 1024 1054 { 1055 #ifdef DEBUG 1025 1056 printf ("v0 alone, Gav=%g, Gmid=%g\n", 1026 1057 (G1+G2)/2, free_energy ((C22+C12)/2,(C23+C13)/2,T,P,eparams+phase)); 1058 #endif 1027 1059 p0 = MIN (v1, v2); 1028 1060 p1 = MAX (v1, v2); … … 1041 1073 bound = *n_bounds; 1042 1074 // No tie-line boundary in this phase, make a new one 1075 #ifdef DEBUG 1043 1076 printf ("Making new tie-line boundary %d\n", *n_bounds); 1077 #endif 1044 1078 if (!(*boundaries = realloc 1045 1079 (*boundaries, (*n_bounds+1) * sizeof (phase_boundary)))) … … 1069 1103 (*boundaries) [bound].edges [2*e] = MIN (p0, p1); 1070 1104 (*boundaries) [bound].edges [2*e+1] = MAX (p0, p1); 1105 #ifdef DEBUG 1071 1106 printf (" Corners for bound %d edges %d,%d: %d,%d\n", 1072 1107 bound, e, e+1, (*boundaries) [bound].edges [2*e], 1073 1108 (*boundaries) [bound].edges [2*e+1]); 1109 #endif 1074 1110 1075 1111 // Check for a boundary with an edge on this miscibility gap … … 1084 1120 // No edge boundary with this miscibility gap, make a new one 1085 1121 bound = *n_bounds; 1122 #ifdef DEBUG 1086 1123 printf ("Making new phase edge boundary %d\n", *n_bounds); 1124 #endif 1087 1125 if (!(*boundaries = realloc 1088 1126 (*boundaries, (bound+1) * sizeof (phase_boundary)))) … … 1112 1150 (*boundaries) [bound].edges [2*e+3] = MAX (p1, p2); 1113 1151 (*boundaries) [bound].n_edges += 2; 1152 #ifdef DEBUG 1114 1153 printf (" Corners for bound %d edge %d: %d,%d, %d,%d\n", 1115 1154 bound, e, (*boundaries) [bound].edges [2*e], … … 1117 1156 (*boundaries) [bound].edges [2*e+2], 1118 1157 (*boundaries) [bound].edges [2*e+3]); 1158 #endif 1119 1159 1120 1160 break;