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