~ubuntu-branches/ubuntu/vivid/psicode/vivid

« back to all changes in this revision

Viewing changes to src/bin/ccenergy/new_d1diag.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck, Michael Banck, Daniel Leidert
  • Date: 2009-02-23 00:12:02 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090223001202-rutldoy3dimfpesc
Tags: 3.4.0-1
* New upstream release.

[ Michael Banck ]
* debian/patches/01_DESTDIR.dpatch: Refreshed.
* debian/patches/02_FHS.dpatch: Removed, applied upstream.
* debian/patches/03_debian_docdir: Likewise.
* debian/patches/04_man.dpatch: Likewise.
* debian/patches/06_466828_fix_gcc_43_ftbfs.dpatch: Likewise.
* debian/patches/07_464867_move_executables: Fixed and refreshed.
* debian/patches/00list: Adjusted.
* debian/control: Improved description.
* debian/patches-held: Removed.
* debian/rules (install/psi3): Do not ship the ruby bindings for now.

[ Daniel Leidert ]
* debian/rules: Fix txtdir via DEB_MAKE_INSTALL_TARGET.
* debian/patches/01_DESTDIR.dpatch: Refreshed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <stdio.h>
2
 
#include <stdlib.h>
3
 
#include <math.h>
4
 
#include <libciomr/libciomr.h>
5
 
#include <libdpd/dpd.h>
6
 
#include <libqt/qt.h>
7
 
#define EXTERN
8
 
#include "globals.h"
9
 
 
10
 
/* Computes a modified D1 diagnostic developed by T.J. Lee, but not yet
11
 
 * published.
12
 
 * */
13
 
 
14
 
double d1diag_t1_rhf(void);
15
 
 
16
 
static double new_d1diag_t1_rohf(void)
17
 
{
18
 
  int h, nirreps, i, j;
19
 
  int nclsd, nuocc, nopen;
20
 
  double **T1_hp, **T1_hx, **T1_xp, **T1_sq;
21
 
  double *E, **C;
22
 
  double max_hp=0.0, max_xp=0.0, max_hx=0.0, max;
23
 
  dpdfile2 T1_a, T1_b;
24
 
 
25
 
  nirreps = moinfo.nirreps;
26
 
 
27
 
  dpd_file2_init(&T1_a, CC_OEI, 0, 0, 1, "tIA");
28
 
  dpd_file2_mat_init(&T1_a);
29
 
  dpd_file2_mat_rd(&T1_a);
30
 
      
31
 
  dpd_file2_init(&T1_b, CC_OEI, 0, 0, 1, "tia");
32
 
  dpd_file2_mat_init(&T1_b);
33
 
  dpd_file2_mat_rd(&T1_b);
34
 
 
35
 
  for(h=0; h < nirreps; h++) {
36
 
    nclsd = moinfo.clsdpi[h];
37
 
    nuocc = moinfo.uoccpi[h];
38
 
    nopen = moinfo.openpi[h];
39
 
 
40
 
    if(nclsd && nuocc) {
41
 
      T1_hp = block_matrix(nclsd, nuocc);
42
 
      for (i=0; i < nclsd; i++)
43
 
        for (j=0; j < nuocc; j++)
44
 
          T1_hp[i][j] = (T1_a.matrix[h][i][j] + T1_b.matrix[h][i][j])/2.;
45
 
 
46
 
      T1_sq = block_matrix(nclsd, nclsd);
47
 
      C_DGEMM('n','t',nclsd,nclsd,nuocc,1.0,&(T1_hp[0][0]),nuocc, 
48
 
             &(T1_hp[0][0]),nuocc,0.0,&(T1_sq[0][0]),nclsd);
49
 
 
50
 
      E = init_array(nclsd);
51
 
      C = block_matrix(nclsd, nclsd);
52
 
      sq_rsp(nclsd, nclsd, T1_sq, E, 0, C, 1e-12);
53
 
      for(i=0; i < nclsd; i++) if(E[i] > max_hp) max_hp = E[i];
54
 
      free(E);
55
 
      free_block(C);
56
 
      free_block(T1_sq);
57
 
      free_block(T1_hp);
58
 
    }
59
 
 
60
 
    if(nclsd && nopen) {
61
 
      T1_hx = block_matrix(nclsd, nopen);
62
 
      for (i=0; i < nclsd; i++)
63
 
        for (j=0; j < nopen; j++)
64
 
          T1_hx[i][j] = T1_b.matrix[h][i][nuocc+j]/sqrt(2.);
65
 
 
66
 
      T1_sq = block_matrix(nclsd, nclsd);
67
 
      C_DGEMM('n','t',nclsd,nclsd,nopen,1.0,&(T1_hx[0][0]),nopen, 
68
 
             &(T1_hx[0][0]),nopen,0.0,&(T1_sq[0][0]),nclsd);
69
 
 
70
 
      E = init_array(nclsd);
71
 
      C = block_matrix(nclsd, nclsd);
72
 
      sq_rsp(nclsd, nclsd, T1_sq, E, 0, C, 1e-12);
73
 
      for(i=0; i < nclsd; i++) if(E[i] > max_hx) max_hx = E[i];
74
 
      free(E);
75
 
      free_block(C);
76
 
      free_block(T1_sq);
77
 
      free_block(T1_hx);
78
 
    }
79
 
 
80
 
    if(nopen && nuocc) {
81
 
      T1_xp = block_matrix(nopen, nuocc);
82
 
      for (i=0; i < nopen; i++)
83
 
        for (j=0; j < nuocc; j++)
84
 
          T1_xp[i][j] = T1_a.matrix[h][nclsd+i][j]/sqrt(2.);
85
 
 
86
 
      T1_sq = block_matrix(nopen, nopen);
87
 
      C_DGEMM('n','t',nopen,nopen,nuocc,1.0,&(T1_xp[0][0]),nuocc, 
88
 
             &(T1_xp[0][0]),nuocc,0.0,&(T1_sq[0][0]),nopen);
89
 
 
90
 
      E = init_array(nopen);
91
 
      C = block_matrix(nopen, nopen);
92
 
      sq_rsp(nopen, nopen, T1_sq, E, 0, C, 1e-12);
93
 
      for(i=0; i < nopen; i++) if(E[i] > max_xp) max_xp = E[i];
94
 
      free(E);
95
 
      free_block(C);
96
 
      free_block(T1_sq);
97
 
      free_block(T1_xp);
98
 
    }
99
 
  }
100
 
 
101
 
  dpd_file2_mat_close(&T1_a);
102
 
  dpd_file2_close(&T1_a);
103
 
 
104
 
  dpd_file2_mat_close(&T1_b);
105
 
  dpd_file2_close(&T1_b);
106
 
 
107
 
  max_hp = sqrt(max_hp);
108
 
  max_hx = sqrt(max_hx);
109
 
  max_xp = sqrt(max_xp);
110
 
 
111
 
  /*
112
 
  fprintf(outfile, "ND1: hp=%8.6f hx=%8.6f xp=%8.6f\n", max_hp, max_hx, max_xp);
113
 
  */
114
 
 
115
 
  max = max_hp;
116
 
  if (max_hx > max) max = max_hx;
117
 
  if (max_xp > max) max = max_xp;
118
 
 
119
 
  return max;
120
 
}
121
 
 
122
 
double new_d1diag(void)
123
 
{
124
 
  double norm = 0.0;
125
 
 
126
 
  if(params.ref == 0) { /** RHF **/
127
 
    norm = d1diag_t1_rhf();
128
 
  }
129
 
  else if (params.ref == 1) { /** ROHF **/
130
 
    norm = new_d1diag_t1_rohf();
131
 
  }
132
 
  return norm;
133
 
}