00001
00005 #include <stdio.h>
00006 #include <libqt/qt.h>
00007 #include <psifiles.h>
00008 #define EXTERN
00009 #include "globals.h"
00010 #include <math.h>
00011
00021 void ael(struct RHO_Params *rho_params)
00022 {
00023 int dim,i,j,k;
00024 double **rho_g, *evals, **evects, **tmat, **rho_x, ael, **rho_diff, trace;
00025
00026 dim = moinfo.nmo - moinfo.nfzv;
00027 rho_g = block_matrix(dim,dim);
00028 rho_x = block_matrix(dim,dim);
00029 rho_diff = block_matrix(dim,dim);
00030 evals = init_array(dim);
00031 evects = block_matrix(dim,dim);
00032 tmat = block_matrix(dim,dim);
00033
00034
00035 psio_open(PSIF_MO_OPDM, PSIO_OPEN_OLD);
00036 psio_read_entry(PSIF_MO_OPDM, rho_params[0].opdm_lbl, (char *) &(rho_g[0][0]), sizeof(double)*dim*dim);
00037 psio_close(PSIF_MO_OPDM, 1);
00038
00039 sq_rsp(dim, dim, rho_g, evals, 3, evects, 1.0E-14);
00040 C_DGEMM('t', 'n', dim, dim, dim, 1.0, &(evects[0][0]), dim, &(rho_g[0][0]), dim, 0.0, &(tmat[0][0]), dim);
00041 C_DGEMM('n', 'n', dim, dim, dim, 1.0, &(tmat[0][0]), dim, &(evects[0][0]), dim, 0.0, &(rho_g[0][0]), dim);
00042
00043 for (i=1; i<params.nstates; ++i) {
00044
00045 psio_open(PSIF_MO_OPDM, PSIO_OPEN_OLD);
00046 psio_read_entry(PSIF_MO_OPDM, rho_params[i].opdm_lbl, (char *) &(rho_x[0][0]),
00047 sizeof(double)*dim*dim);
00048 psio_close(PSIF_MO_OPDM, 1);
00049
00050
00051 C_DGEMM('t', 'n', dim, dim, dim, 1.0, &(evects[0][0]), dim, &(rho_x[0][0]), dim, 0.0, &(tmat[0][0]), dim);
00052 C_DGEMM('n', 'n', dim, dim, dim, 1.0, &(tmat[0][0]), dim, &(evects[0][0]), dim, 0.0, &(rho_x[0][0]), dim);
00053
00054
00055 ael = 0.0;
00056 for (j=0; j<dim; ++j) {
00057 ael += 0.5 * fabs( rho_x[j][k] - rho_g[j][k] );
00058 }
00059 fprintf(outfile, "\tAEL %d: %10.7lf\n", i, ael);
00060 }
00061
00062 free(evals);
00063 free_block(evects);
00064 free_block(tmat);
00065 free_block(rho_g);
00066 free_block(rho_x);
00067 free_block(rho_diff);
00068 return;
00069 }
00070