00001
00005 #include <stdio.h>
00006 #include <math.h>
00007 #include <libdpd/dpd.h>
00008 #include <libchkpt/chkpt.h>
00009 #include <libqt/qt.h>
00010 #include "globals.h"
00011
00012 double **Build_R(void);
00013 double **Build_U(void);
00014
00015 void analyze(char *pert, char *cart, int irrep, double omega)
00016 {
00017 int nirreps, h, i, j, a, b, ij, ab, u, v;
00018 int position, num_div, tot1, tot2, nvir, nso, nocc;
00019 double width, max, min, value, value2;
00020 double *amp_array;
00021 double **tmp, **T2trans, **T1trans;
00022 FILE *efile;
00023 dpdbuf4 I, T2, D;
00024 dpdfile2 T1;
00025 char lbl[32];
00026
00027 nirreps = moinfo.nirreps;
00028 num_div = 500;
00029 max = 9;
00030 min = 0;
00031 width = (max-min) / (num_div);
00032
00033
00034 sprintf(lbl, "X_%s_%1s_%5.3f", pert, cart, omega);
00035 ffile(&efile, lbl, 1);
00036 amp_array = init_array(num_div);
00037
00038 nvir = moinfo.virtpi[0];
00039 nocc = moinfo.occpi[0];
00040 nso = moinfo.nso;
00041
00042 sprintf(lbl, "X_%s_%1s_IjAb (%5.3f)", pert, cart, omega);
00043 dpd_buf4_init(&T2, CC_LR, 0, 0, 5, 0, 5, 0, lbl);
00044 dpd_buf4_mat_irrep_init(&T2, 0);
00045 dpd_buf4_mat_irrep_rd(&T2, 0);
00046 T2trans = block_matrix(nocc*nocc, nso*nso);
00047 tmp = block_matrix(nvir, nso);
00048 tot1 = 0;
00049 tot2 = 0;
00050 for(ij=0; ij<T2.params->rowtot[0]; ij++) {
00051
00052 C_DGEMM('n', 't', nvir, nso, nvir, 1.0, &(T2.matrix[0][ij][0]), nvir,
00053 &(moinfo.C[0][0][0]), nvir, 0.0, &(tmp[0][0]), nso);
00054 C_DGEMM('n', 'n', nso, nso, nvir, 1.0, &(moinfo.C[0][0][0]), nvir,
00055 tmp[0], nso, 0.0, T2trans[ij], nso);
00056
00057 for(ab=0; ab<nso*nso; ab++) {
00058 value = fabs(log10(fabs(T2trans[ij][ab])));
00059 tot2++;
00060 if ((value >= max) && (value <= (max+width))) {
00061 amp_array[num_div-1]++;
00062 tot1++;
00063 }
00064 else if ((value <= min) && (value >= (min-width))) {
00065 amp_array[0]++;
00066 tot1++;
00067 }
00068 else if ((value < max) && (value > min)) {
00069 position = floor((value-min)/width);
00070 amp_array[position]++;
00071 tot1++;
00072 }
00073 }
00074 }
00075 dpd_buf4_mat_irrep_close(&T2, 0);
00076 dpd_buf4_close(&T2);
00077 free_block(tmp);
00078 free_block(T2trans);
00079
00080 value2 = 0;
00081 for (i = num_div-1; i >= 0; i--) {
00082 value = amp_array[i] / tot1;
00083 value2 += value;
00084 fprintf(efile, "%10.5lf %lf\n", -((i)*width)-min, value);
00085 }
00086 free(amp_array);
00087 fprintf(outfile, "Total number of converged T2 amplitudes = %d\n", tot2);
00088 fprintf(outfile, "Number of T2 amplitudes in analysis= %d\n", tot1);
00089 fclose(efile);
00090
00091 num_div = 40;
00092 max = 2;
00093 min = -5;
00094 width = (max-min) / (num_div);
00095
00096 sprintf(lbl, "X1_%s_%1s_%5.3f", pert, cart, omega);
00097 ffile(&efile, lbl, 1);
00098 amp_array = init_array(num_div);
00099
00100 sprintf(lbl, "X_%s_%1s_IA (%5.3f)", pert, cart, omega);
00101 dpd_file2_init(&T1, CC_OEI, 0, 0, 1, lbl);
00102 dpd_file2_print(&T1, outfile);
00103 dpd_file2_mat_init(&T1);
00104 dpd_file2_mat_rd(&T1);
00105
00106
00107
00108
00109
00110
00111
00112
00113 tot1 = tot2 = 0;
00114 for(i=0; i < nocc; i++) {
00115 for(a=0; a < nso; a++) {
00116
00117 value = log10(fabs(T1.matrix[0][i][a]));
00118 tot2++;
00119 if ((value >= max) && (value <= (max+width))) {
00120 amp_array[num_div-1]++;
00121 tot1++;
00122 }
00123 else if ((value <= min) && (value >= (min-width))) {
00124 amp_array[0]++;
00125 tot1++;
00126 }
00127 else if ((value < max) && (value > min)) {
00128 position = floor((value-min)/width);
00129 amp_array[position]++;
00130 tot1++;
00131 }
00132 }
00133 }
00134
00135
00136 dpd_file2_mat_close(&T1);
00137 dpd_file2_close(&T1);
00138
00139 value2 = 0;
00140 for (i = num_div-1; i >= 0; i--) {
00141 value = amp_array[i] / tot1;
00142 value2 += value;
00143 fprintf(efile, "%10.5lf %lf\n", ((i)*width)-min, value);
00144 }
00145
00146 free(amp_array);
00147 fclose(efile);
00148
00149 }
00150